UNPKG

fabric8-analytics-dependency-editor-jyas

Version:
138 lines 5.09 kB
import { Component, Input, Output, EventEmitter } from '@angular/core'; import * as _ from 'lodash'; import { DependencyEditorService } from '../shared/dependency-editor.service'; var InsightComponent = /** @class */ (function () { function InsightComponent(service) { this.service = service; this.companionAdded = new EventEmitter(); this.hasIssue = false; this.objToEmit = []; this.added = []; this.noOfTags = 0; } InsightComponent.prototype.ngOnChanges = function (changes) { var _this = this; if (changes) { if (changes['companions']) { if (changes['companions']['currentValue']) { this.usableCompanions = _.cloneDeep(this.companions.filter(function (c) { return _this.filterOut(c); })); this.error = null; } } } }; InsightComponent.prototype.ngOnInit = function () { }; InsightComponent.prototype.filterOut = function (companion) { if (companion) { var cache = this.service.cacheHiddenDependency; var len = cache.length; for (var i = 0; i < len; ++i) { if (cache[i].name === companion.name) { return false; } } return true; } return false; }; InsightComponent.prototype.addTag = function (eventData) { for (var i = 0; i < this.companions.length + this.alternate.length; i++) { if (this.added.length > 0 && this.added[i] && this.added[i].name === eventData[0].name) { if (this.added[i].type === true && eventData[0].type === true) { continue; } else if (this.added[i].type === true && eventData[0].type === false) { this.added[i].type = false; this.noOfTags--; i++; break; } else { if (eventData[0].type === true) { this.added[i].type = true; this.noOfTags++; break; } else if (eventData[0].type === false) { this.added[i].type = false; this.noOfTags--; break; } } } else if (i === this.added.length) { this.added.push(eventData[0]); this.noOfTags++; break; } } }; InsightComponent.prototype.companionWasAdded = function (eventData) { for (var i = 0; i < this.added.length; i++) { if (this.added[i].type === true) { this.objToEmit[i] = { depFull: this.added[i].name, depSnapshot: null, action: 'add' }; } } }; InsightComponent.prototype.releaseCompanion = function (eventData) { for (var i = 0; i < this.added.length; i++) { if (this.added[i].type !== true) { this.objToEmit[i] = { depFull: null, depSnapshot: null, action: '' }; } } }; InsightComponent.prototype.addCompanion = function () { for (var i = 0; i < this.added.length; i++) { if (this.added[i].type === true) { this.companionAdded.emit(this.objToEmit[i]); } } this.noOfTags = 0; this.added = []; this.objToEmit = []; }; InsightComponent.prototype.removeDependency = function (dependency) { for (var i = 0; i < this.added.length; i++) { this.objToEmit[i] = { depFull: dependency, depSnapshot: null, action: 'remove' }; } }; InsightComponent.prototype.removeCompanion = function (dependency) { this.service.cacheHiddenDependency.push(dependency); _.remove(this.usableCompanions, function (companion) { return companion.name === dependency.name; }); }; InsightComponent.decorators = [ { type: Component, args: [{ selector: 'app-insights', styles: [require('./insights.component.css').toString()], template: require('./insights.component.html') },] }, ]; /** @nocollapse */ InsightComponent.ctorParameters = function () { return [ { type: DependencyEditorService, }, ]; }; InsightComponent.propDecorators = { 'boosterInfo': [{ type: Input },], 'companions': [{ type: Input },], 'alternate': [{ type: Input },], 'error': [{ type: Input },], 'companionAdded': [{ type: Output },], }; return InsightComponent; }()); export { InsightComponent }; //# sourceMappingURL=insights.component.js.map