@aca-1/a2-composer
Version:
Angular 2 Interface for composer
81 lines • 2.7 kB
JavaScript
import { Directive, EventEmitter, Input, Output } from '@angular/core';
import { SystemsService } from '../services';
var Debug = (function () {
function Debug(serv) {
this.enabled = true;
this.outputChange = new EventEmitter();
this.msgs = [];
this.change = false;
this.months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
this.service = serv;
this.msgs = [];
}
Debug.prototype.ngOnChanges = function (changes) {
this.change = true;
if (this.sys !== this.system && (typeof this.system !== 'object' || this.sys !== this.system.id)) {
this.getSystem();
this.getModule();
}
if (this.mod !== this.module && (typeof this.module !== 'object' || this.mod !== this.module.id)) {
this.getModule();
}
if (this.msgs !== this.output) {
this.msgs = this.output;
}
if (this.numLines && this.msgs.length > this.numLines) {
this.msgs.splice(this.numLines, this.msgs.length - this.numLines);
}
this.change = false;
};
Debug.prototype.time = function () {
return this.module.now;
};
Debug.prototype.addMessage = function (msg) {
if (!this.msgs) {
this.msgs = [];
}
this.msgs.splice(0, 0, this.time() + ' - ' + msg);
if (this.numLines && this.msgs.length > this.numLines) {
this.msgs.splice(this.numLines, this.msgs.length - this.numLines);
}
this.outputChange.emit(this.msgs);
};
Debug.prototype.getSystem = function () {
if (typeof this.sys === 'string') {
this.system = this.service.get(this.sys);
}
else {
this.system = this.sys;
}
};
Debug.prototype.getModule = function () {
if (typeof this.mod === 'string') {
this.module = this.system.get(this.mod, this.index ? this.index : 1);
}
else {
this.module = this.mod;
}
this.module.setDebug(this);
};
return Debug;
}());
export { Debug };
Debug.decorators = [
{ type: Directive, args: [{
selector: '[debug]',
providers: [],
},] },
];
Debug.ctorParameters = function () { return [
{ type: SystemsService, },
]; };
Debug.propDecorators = {
'sys': [{ type: Input },],
'mod': [{ type: Input },],
'index': [{ type: Input },],
'enabled': [{ type: Input },],
'output': [{ type: Input },],
'numLines': [{ type: Input },],
'outputChange': [{ type: Output },],
};
//# sourceMappingURL=debug.directive.js.map