"use strict"; /** * Value object for sla. * * @constructor */ function SLAVO() { // simple fields this.parentId = ''; this.title = ''; this.goal = ''; this.startTime = ''; this.endTime = ''; this.measurementStatus = ''; this.metMissedAmount = ''; this.overallStopTime = ''; this.downStartTime = ''; this.upStartTime = ''; this.downElapsedTime = ''; this.upElapsedTime = ''; this.warningDate = ''; this.slaType = ''; // derived fields this.iconClass = ''; this.position = ''; this.slaStatusClass = ''; this.statusColor; var COLOR; (function (COLOR) { COLOR[COLOR["GREEN"] = 1] = "GREEN"; COLOR[COLOR["ORANGE"] = 2] = "ORANGE"; COLOR[COLOR["RED"] = 3] = "RED"; })(COLOR || (COLOR = {})); // methods this.processIconClass = function () { switch (this.measurementStatus) { case SLAVO.MEASUREMENT_STATUS_IN_PROGRESS: case SLAVO.MEASUREMENT_STATUS_WARNING: this.iconClass = 'circle_o'; var currentDate = Date.now(); if (this.warningDate > currentDate) { this.slaStatusClass = 'sla-icon_color-green'; this.statusColor = COLOR.GREEN; } else { this.slaStatusClass = 'sla-icon_color-orange'; this.statusColor = COLOR.ORANGE; } break; case SLAVO.MEASUREMENT_STATUS_PENDING: this.iconClass = 'circle_o'; if (this.downStartTime > this.endTime) { this.slaStatusClass = 'sla-icon_color-red'; this.statusColor = COLOR.RED; } else if (this.warningDate) { this.slaStatusClass = this.downStartTime > this.warningDate ? 'sla-icon_color-orange' : 'sla-icon_color-green'; this.statusColor = this.downStartTime > this.warningDate ? COLOR.ORANGE : COLOR.GREEN; } else { this.slaStatusClass = 'sla-icon_color-green'; this.statusColor = COLOR.GREEN; } break; case SLAVO.MEASUREMENT_STATUS_MET: this.iconClass = 'check_circle_o'; this.slaStatusClass = 'sla-icon_color-green'; this.statusColor = COLOR.GREEN; break; case SLAVO.MEASUREMENT_STATUS_MISSED: case SLAVO.MEASUREMENT_STATUS_MISSED_GOAL: this.iconClass = 'cross_circle_o'; this.slaStatusClass = 'sla-icon_color-red'; this.statusColor = COLOR.RED; break; default: this.iconClass = 'circle_o'; this.statusColor = COLOR.GREEN; break; } }; } // inherit BaseVO SLAVO.prototype = new BaseVO(); // correct the constructor pointer SLAVO.prototype.constructor = SLAVO; SLAVO.MEASUREMENT_STATUS_IN_PROGRESS = '1'; SLAVO.MEASUREMENT_STATUS_PENDING = '2'; SLAVO.MEASUREMENT_STATUS_MET = '4'; SLAVO.MEASUREMENT_STATUS_MISSED = '5'; SLAVO.MEASUREMENT_STATUS_MISSED_GOAL = '7'; SLAVO.MEASUREMENT_STATUS_WARNING = '9'; /** * @override * @return {Array} */ SLAVO.prototype.getProps = function () { return BaseVO.prototype.getProps().concat('parentId', 'title', 'goal', 'startTime', 'endTime', 'measurementStatus', 'metMissedAmount', 'overallStopTime', 'downStartTime', 'upStartTime', 'downElapsedTime', 'upElapsedTime', 'warningDate', 'slaType', 'warningDate', 'warningPercentage'); }; /** * @override */ SLAVO.prototype.postBuild = function () { this.processIconClass(); };