diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index 071e8e87..c3a26f32 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -10,6 +10,12 @@ font-size: 1.5rem; } .status-panel h1 { font-size: 1.5rem; } + .status-panel .status-panel-annotation_row { + position: absolute; + top: 0; + width: 100%; + text-align: left; + font-size: 0.85rem; } .status-panel .ok-text, .status-panel .warning-text, .status-panel .fail-text, .status-panel .gray-text { display: none; font-size: 3.5rem; } @@ -71,7 +77,10 @@ .st-card:not(.effect-hover):not(.gray-state) .st-card-front { display: none; } -.gray-state { +.no-data-state { + background-color: gray; } + +.disabled-state { background-color: gray; } /*# sourceMappingURL=status_panel.css.map */ diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index 22ccd1db..d0825526 100644 --- a/dist/css/status_panel.css.map +++ b/dist/css/status_panel.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,aAAc;EACZ,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,IAAI;EAEX,mBAAQ;IACN,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,aAAa;IACxB,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,MAAM;EAGnB,gBAAG;IACD,SAAS,EAAE,MAAM;EAGnB,uGAA+C;IAC7C,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,MAAM;;AAIrB,YAAa;EACX,gBAAgB,EAAE,GAAG;EACrB,uBAAW;IACT,OAAO,EAAE,KAAK;;AAIlB,WAAY;EACV,gBAAgB,EAAE,MAAM;EACxB,yBAAc;IACZ,OAAO,EAAE,KAAK;;AAIlB,SAAU;EACR,gBAAgB,EAAE,KAAK;EACvB,kBAAS;IACP,OAAO,EAAE,KAAK;;AAIlB,WAAY;EACV,gBAAgB,EAAE,IAAI;EACtB,sBAAW;IACT,OAAO,EAAE,KAAK;;AAIlB,yBAAyB;EACvB,OAAO,EAAE,IA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kBAAS;IACP,OAAO,EAAE,KAAK;;AAIlB,WAAY;EACV,gBAAgB,EAAE,IAAI;EACtB,sBAAW;IACT,OAAO,EAAE,KAAK;;AAIlB,yBAAyB;EACvB,OAAO,EAAE,IAAI;;AAGf,QAAS;EACP,QAAQ,EAAE,QAAQ;EAClB,UAAU,EAAE,MAAM;;AAGpB;aACc;EACZ,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;;AAGd;aACc;EACZ,2BAA2B,EAAE,MAAM;EACnC,mBAAmB,EAAE,MAAM;EAC3B,kBAAkB,EAAE,sBAAsB;EAC1C,UAAU,EAAE,cAAc;;AAG5B,mCAAoC;EAClC,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG7B,0HAA2H;EACzH,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG7B,wHAAyH;EACvH,iBAAiB,EAAE,UAAU;EAC7B,SAAS,EAAE,UAAU;;AAGvB,2DAA4D;EAC1D,OAAO,EAAE,IAAI;;AAIf,cAAe;EACd,gBAAgB,EAAE,IAAI;;AAGvB,eAAgB;EACf,gBAAgB,EAAE,IAAI", "sources": ["../../src/css/status_panel.scss"], "names": [], "file": "status_panel.css" diff --git a/dist/editor.html b/dist/editor.html index cb38708d..0b8b2d30 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -1,9 +1,9 @@
- Note: Every measurement has to have a unique Alias to be used + Note: Every metric has to have a unique Alias to be used
- Error: There are multiple measurements with the same alias. Please give each measurement a unique name. + Error: There are multiple metrics with the same alias. Please give each metric a unique name.
@@ -32,21 +32,28 @@
{{ measurement.alias }}
-
-
{{ measurement.alias }} Thresholds
-
-
Thresholds for measurement: {{ measurement.refId }}
-
Please enter an alias for this measurement bellow
-
+ +
{{ measurement.alias }}
+
+
Metric: {{ measurement.refId }}
+
Please enter an alias for this measurement bellow
+
+ +
+
Display Settings
+ +
Alias @@ -54,53 +61,106 @@
Thresholds for measurement: {{ measurement.refId }}<
+
- Warning + Aggregation + + What to do if the query returns multiple data points. + - +
+ +
+
- Critical + Metric URL + + Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs) + - +
+
+ +
+
Metric display type
+
- Aggregation + Status Type - What to do if the query returns multiple data points. + The type of data to show to the panel
+ Note: 'Threshold' will select the first value.

+ Threshold - Change background color of the panel if got warning / error + show the alias of the problematic metrics.
+ Disable Criteria - Change background color of the panel if disabled.
+ Annotation - Show extra info on the panel on top right.
+
-
+
+ +
+
Threshold
+ + +
- Measurement URL - - Make the name of the measurement clickable, and send the user to a link (with explanations what to do when this error occurs) - + Warning - + +
+ + +
+ + Critical + + +
+ + +
- + +
+
Disable Criteria
+ + +
+ + Disable Value + + The exact value which will make this panel to be displayed as disabled
+
+
+ +
+
diff --git a/dist/module.html b/dist/module.html index de3550e9..84508cef 100644 --- a/dist/module.html +++ b/dist/module.html @@ -10,32 +10,48 @@ Error: There are multiple measurements with the same alias. Please give each measurement a unique name.
-
-

- - {{ ctrl.panel.displayName | interpolateTemplateVars:this }} - - - {{ ctrl.panel.displayName | interpolateTemplateVars:this }} - -

+
+
+ {{ annoation.alias }} + {{ annoation.alias }} + - {{ annoation.display_value }} +
+
-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} -
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} -
-
-
+
+

+ + {{ ctrl.panel.displayName | interpolateTemplateVars:this }} + + + {{ ctrl.panel.displayName | interpolateTemplateVars:this }} + +

+
+ +
+
+ {{ display.alias }} + {{ display.alias }} + - {{ display.display_value | number }} +
+
+ {{ crit.alias }} + {{ crit.alias }} + - {{ crit.display_value | number }} +
+ +
+ {{ warn.alias }} + {{ warn.alias }} + - {{ warn.display_value | number }} +
+ +
+ {{ disabled.alias }} + {{ disabled.alias }} +
+
+ diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index d9bb63e5..6fbea6fa 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -1,305 +1,355 @@ "use strict"; System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugins/panel/graph/series_overrides_ctrl", "lodash", "app/core/time_series2", "app/core/core_module", "./css/status_panel.css!"], function (_export, _context) { - "use strict"; - - var MetricsPanelCtrl, _, TimeSeries, coreModule, _createClass, StatusPluginCtrl; - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - return { - setters: [function (_appPluginsSdk) { - MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; - }, function (_appPluginsPanelGraphLegend) {}, function (_appPluginsPanelGraphSeries_overrides_ctrl) {}, function (_lodash) { - _ = _lodash.default; - }, function (_appCoreTime_series) { - TimeSeries = _appCoreTime_series.default; - }, function (_appCoreCore_module) { - coreModule = _appCoreCore_module.default; - }, function (_cssStatus_panelCss) {}], - execute: function () { - _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; - }(); - - _export("StatusPluginCtrl", StatusPluginCtrl = function (_MetricsPanelCtrl) { - _inherits(StatusPluginCtrl, _MetricsPanelCtrl); - - /** @ngInject */ - function StatusPluginCtrl($scope, $injector, $log, $filter, annotationsSrv) { - _classCallCheck(this, StatusPluginCtrl); - - var _this = _possibleConstructorReturn(this, (StatusPluginCtrl.__proto__ || Object.getPrototypeOf(StatusPluginCtrl)).call(this, $scope, $injector)); - - //this.log = $log.debug; - _this.filter = $filter; - - _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - - _this.panel.flipTime = _this.panel.flipTime || 5; - - /** Bind events to functions **/ - _this.events.on('render', _this.onRender.bind(_this)); - _this.events.on('refresh', _this.postRefresh.bind(_this)); - _this.events.on('data-error', _this.onDataError.bind(_this)); - _this.events.on('data-received', _this.onDataReceived.bind(_this)); - _this.events.on('data-snapshot-load', _this.onDataReceived.bind(_this)); - _this.events.on('init-edit-mode', _this.onInitEditMode.bind(_this)); - return _this; - } - - _createClass(StatusPluginCtrl, [{ - key: "postRefresh", - value: function postRefresh() { - var _this2 = this; - - this.measurements = this.panel.targets; - - /** Duplicate alias validation **/ - this.duplicates = false; - - this.measurements = _.filter(this.measurements, function (measurement) { - return !measurement.hide; - }); - - _.each(this.measurements, function (m) { - var res = _.filter(_this2.measurements, function (measurement) { - return (m.alias == measurement.alias || m.target == measurement.target && m.target) && !m.hide; - }); - - if (res.length > 1) { - _this2.duplicates = true; - } - }); - } - }, { - key: "onInitEditMode", - value: function onInitEditMode() { - this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2); - } - }, { - key: "setElementHeight", - value: function setElementHeight() { - this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); - } - }, { - key: "onRender", - value: function onRender() { - var _this3 = this; - - this.setElementHeight(); - - if (this.panel.clusterName) { - this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); - } else { - this.panel.displayName = ""; - } - - if (this.panel.flipCard) { - this.$panelContainer.addClass("effect-hover"); - } else { - this.$panelContainer.removeClass("effect-hover"); - } - - var targets = this.panel.targets; - - this.crit = []; - this.warn = []; - this.display = []; - - _.each(this.series, function (s) { - var target = _.find(targets, function (target) { - return target.alias == s.alias || target.target == s.alias; - }); - - if (!target) { - return; - } - - s.thresholds = StatusPluginCtrl.parseThresholds(target); - s.inverted = s.thresholds.crit < s.thresholds.warn; - s.display = target.display; - s.alias = target.alias; - s.url = target.url; - - var value = void 0; - - switch (target.aggregation) { - case 'Max': - value = s.stats.max; - break; - case 'Min': - value = s.stats.min; - break; - case 'Sum': - value = s.stats.total; - break; - case 'Avg': - value = s.stats.avg; - break; - case 'First': - value = s.datapoints[0][0]; - break; - default: - value = s.datapoints[s.datapoints.length - 1][0]; - } - - s.display_value = value; - - if (!s.inverted) { - if (value >= s.thresholds.crit) { - _this3.crit.push(s); - } else if (value >= s.thresholds.warn) { - _this3.warn.push(s); - } else if (s.display) { - _this3.display.push(s); - } - } else { - if (value <= s.thresholds.crit) { - _this3.crit.push(s); - } else if (value <= s.thresholds.warn) { - _this3.warn.push(s); - } else if (s.display) { - s.display_value = value; - _this3.display.push(s); - } - } - }); - - this.$panelContainer.removeClass('error-state warn-state ok-state gray-state'); - - if (this.crit.length > 0 || this.duplicates) { - this.$panelContainer.addClass('error-state'); - } else if (this.warn.length > 0) { - this.$panelContainer.addClass('warn-state'); - } else if (this.series.length == 0 && this.panel.isGrayColor) { - this.$panelContainer.addClass('gray-state'); - } else { - this.$panelContainer.addClass('ok-state'); - } - - this.autoFlip(); - this.parseUri(); - } - }, { - key: "parseUri", - value: function parseUri() { - if (this.panel.links && this.panel.links.length > 0) { - this.uri = this.panel.links[0].dashUri + "?" + this.panel.links[0].params; - } else { - this.uri = undefined; - } - } - }, { - key: "onDataReceived", - value: function onDataReceived(dataList) { - this.series = dataList.map(this.seriesHandler.bind(this)); - - this.render(); - } - }, { - key: "onDataError", - value: function onDataError() { - this.crit = []; - this.warn = []; - } - }, { - key: "seriesHandler", - value: function seriesHandler(seriesData) { - var series = new TimeSeries({ - datapoints: seriesData.datapoints, - alias: seriesData.target - }); - - series.flotpairs = series.getFlotPairs("connected"); - - return series; - } - }, { - key: "$onDestroy", - value: function $onDestroy() { - if (this.timeoutId) clearInterval(this.timeoutId); - } - }, { - key: "autoFlip", - value: function autoFlip() { - var _this4 = this; - - if (this.timeoutId) clearInterval(this.timeoutId); - if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { - this.timeoutId = setInterval(function () { - _this4.$panelContainer.toggleClass("flipped"); - }, this.panel.flipTime * 1000); - } - } - }, { - key: "link", - value: function link(scope, elem, attrs, ctrl) { - this.$panelContainer = elem.find('.panel-container'); - this.$panelContainer.addClass("st-card"); - this.$panelContoller = ctrl; - } - }], [{ - key: "parseThresholds", - value: function parseThresholds(measurement) { - var res = {}; - - res.warn = measurement.warn; - res.crit = measurement.crit; - - return res; - } - }]); - - return StatusPluginCtrl; - }(MetricsPanelCtrl)); - - _export("StatusPluginCtrl", StatusPluginCtrl); - - StatusPluginCtrl.templateUrl = 'module.html'; - } - }; + "use strict"; + + var MetricsPanelCtrl, _, TimeSeries, coreModule, _createClass, StatusPluginCtrl; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + return { + setters: [function (_appPluginsSdk) { + MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; + }, function (_appPluginsPanelGraphLegend) {}, function (_appPluginsPanelGraphSeries_overrides_ctrl) {}, function (_lodash) { + _ = _lodash.default; + }, function (_appCoreTime_series) { + TimeSeries = _appCoreTime_series.default; + }, function (_appCoreCore_module) { + coreModule = _appCoreCore_module.default; + }, function (_cssStatus_panelCss) {}], + execute: function () { + _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + _export("StatusPluginCtrl", StatusPluginCtrl = function (_MetricsPanelCtrl) { + _inherits(StatusPluginCtrl, _MetricsPanelCtrl); + + /** @ngInject */ + function StatusPluginCtrl($scope, $injector, $log, $filter, annotationsSrv) { + _classCallCheck(this, StatusPluginCtrl); + + var _this = _possibleConstructorReturn(this, (StatusPluginCtrl.__proto__ || Object.getPrototypeOf(StatusPluginCtrl)).call(this, $scope, $injector)); + + //this.log = $log.debug; + _this.filter = $filter; + + _this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; + _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; + + _this.panel.flipTime = _this.panel.flipTime || 5; + + /** Bind events to functions **/ + _this.events.on('render', _this.onRender.bind(_this)); + _this.events.on('refresh', _this.postRefresh.bind(_this)); + _this.events.on('data-error', _this.onDataError.bind(_this)); + _this.events.on('data-received', _this.onDataReceived.bind(_this)); + _this.events.on('data-snapshot-load', _this.onDataReceived.bind(_this)); + _this.events.on('init-edit-mode', _this.onInitEditMode.bind(_this)); + return _this; + } + + _createClass(StatusPluginCtrl, [{ + key: "postRefresh", + value: function postRefresh() { + var _this2 = this; + + if (this.panel.fixedSpan) { + this.panel.span = this.panel.fixedSpan; + } + + this.measurements = this.panel.targets; + + /** Duplicate alias validation **/ + this.duplicates = false; + + this.measurements = _.filter(this.measurements, function (measurement) { + return !measurement.hide; + }); + + _.each(this.measurements, function (m) { + var res = _.filter(_this2.measurements, function (measurement) { + return (m.alias == measurement.alias || m.target == measurement.target && m.target) && !m.hide; + }); + + if (res.length > 1) { + _this2.duplicates = true; + } + }); + } + }, { + key: "onInitEditMode", + value: function onInitEditMode() { + this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2); + } + }, { + key: "setElementHeight", + value: function setElementHeight() { + this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); + } + }, { + key: "onRender", + value: function onRender() { + var _this3 = this; + + this.setElementHeight(); + + if (this.panel.clusterName) { + this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); + } else { + this.panel.displayName = ""; + } + + if (this.panel.flipCard) { + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } + + var targets = this.panel.targets; + + this.crit = []; + this.warn = []; + this.display = []; + this.disabled = []; + this.annotation = []; + + _.each(this.series, function (s) { + var target = _.find(targets, function (target) { + return target.alias == s.alias || target.target == s.alias; + }); + + if (!target) { + return; + } + + s.alias = target.alias; + s.url = target.url; + + var value = void 0; + switch (target.aggregation) { + case 'Max': + value = _.max(s.datapoints, function (point) { + return point[0]; + })[0]; + value = s.stats.max; + break; + case 'Min': + value = _.min(s.datapoints, function (point) { + return point[0]; + })[0]; + value = s.stats.min; + break; + case 'Sum': + value = 0; + _.each(s.datapoints, function (point) { + value += point[0]; + }); + value = s.stats.total; + break; + case 'Avg': + value = s.stats.avg; + break; + case 'First': + value = s.datapoints[0][0]; + break; + default: + value = s.datapoints[s.datapoints.length - 1][0]; + } + + s.display_value = value; + + if (target.displayType == "Threshold") { + _this3.handleThresholdStatus(s, target); + } else if (target.displayType == "Disable Criteria") { + _this3.handleDisabledStatus(s, target); + } else if (target.displayType == "Annotation") { + _this3.handleAnnotations(s, target); + } + }); + + this.autoFlip(); + this.handle_css_display(); + this.parseUri(); + } + }, { + key: "handleThresholdStatus", + value: function handleThresholdStatus(series, target) { + series.thresholds = StatusPluginCtrl.parseThresholds(target); + series.inverted = series.thresholds.crit < series.thresholds.warn; + series.display = target.display; + + if (!series.inverted) { + if (series.display_value >= series.thresholds.crit) { + this.crit.push(series); + } else if (series.display_value >= series.thresholds.warn) { + this.warn.push(series); + } else if (series.display) { + this.display.push(series); + } + } else { + if (series.display_value <= series.thresholds.crit) { + this.crit.push(series); + } else if (series.display_value <= series.thresholds.warn) { + this.warn.push(series); + } else if (series.display) { + this.display.push(series); + } + } + } + }, { + key: "handleDisabledStatus", + value: function handleDisabledStatus(series, target) { + + series.disabledValue = target.disabledValue; + + if (series.display_value == series.disabledValue) { + this.disabled.push(series); + } + } + }, { + key: "handleAnnotations", + value: function handleAnnotations(series, target) { + this.annotation.push(series); + } + }, { + key: "handle_css_display", + value: function handle_css_display() { + this.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state'); + + if (this.duplicates) { + this.$panelContainer.addClass('error-state'); + } else if (this.disabled.length > 0) { + this.$panelContainer.addClass('disabled-state'); + } else if (this.crit.length > 0) { + this.$panelContainer.addClass('error-state'); + } else if (this.warn.length > 0) { + this.$panelContainer.addClass('warn-state'); + } else if ((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) { + this.$panelContainer.addClass('no-data-state'); + } else { + this.$panelContainer.addClass('ok-state'); + } + } + }, { + key: "parseUri", + value: function parseUri() { + if (this.panel.links && this.panel.links.length > 0) { + this.uri = this.panel.links[0].dashUri + "?" + this.panel.links[0].params; + } else { + this.uri = undefined; + } + } + }, { + key: "onDataReceived", + value: function onDataReceived(dataList) { + this.series = dataList.map(this.seriesHandler.bind(this)); + + this.render(); + } + }, { + key: "onDataError", + value: function onDataError() { + this.crit = []; + this.warn = []; + } + }, { + key: "seriesHandler", + value: function seriesHandler(seriesData) { + var series = new TimeSeries({ + datapoints: seriesData.datapoints, + alias: seriesData.target + }); + + series.flotpairs = series.getFlotPairs("connected"); + + return series; + } + }, { + key: "$onDestroy", + value: function $onDestroy() { + if (this.timeoutId) clearInterval(this.timeoutId); + } + }, { + key: "autoFlip", + value: function autoFlip() { + var _this4 = this; + + if (this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(function () { + _this4.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } + }, { + key: "link", + value: function link(scope, elem, attrs, ctrl) { + this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); + this.$panelContoller = ctrl; + } + }], [{ + key: "parseThresholds", + value: function parseThresholds(metricOptions) { + var res = {}; + + res.warn = metricOptions.warn; + res.crit = metricOptions.crit; + + return res; + } + }]); + + return StatusPluginCtrl; + }(MetricsPanelCtrl)); + + _export("StatusPluginCtrl", StatusPluginCtrl); + + StatusPluginCtrl.templateUrl = 'module.html'; + } + }; }); //# sourceMappingURL=status_ctrl.js.map diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index b2495217..f2ce379a 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","aggregations","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","display","series","s","thresholds","parseThresholds","inverted","url","value","aggregation","max","datapoints","point","min","display_value","push","isGrayColor","autoFlip","parseUri","links","uri","dashUri","params","undefined","dataList","map","seriesHandler","render","seriesData","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,sB,kBAAAA,gB;;AAGDC,O;;AACAC,gB;;AACAC,gB;;;;;;;;;;;;;;;;;;;;;kCAIMC,gB;;;AACX;AACA,kCAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,0IACtDJ,MADsD,EAC9CC,SAD8C;;AAG5D;AACA,gBAAKI,MAAL,GAAcF,OAAd;;AAEA,gBAAKG,YAAL,GAAoB,CAAC,MAAD,EAAS,KAAT,EAAgB,KAAhB,EAAuB,KAAvB,CAApB;;AAEA,gBAAKC,KAAL,CAAWC,QAAX,GAAsB,MAAKD,KAAL,CAAWC,QAAX,IAAuB,CAA7C;;AAEA;AACA,gBAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CAAoBH,IAApB,OAAhC;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,oBAAf,EAAqC,MAAKK,cAAL,CAAoBH,IAApB,OAArC;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,gBAAf,EAAiC,MAAKM,cAAL,CAAoBJ,IAApB,OAAjC;AAhB4D;AAiB7D;;;;wCAEa;AAAA;;AACZ,i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KA;;AAEA,mBAAOoB,MAAP;AACD;;;uCAEY;AACX,gBAAG,KAAK2B,SAAR,EAAmBC,cAAc,KAAKD,SAAnB;AACpB;;;qCAEU;AAAA;;AACT,gBAAG,KAAKA,SAAR,EAAmBC,cAAc,KAAKD,SAAnB;AACnB,gBAAI,KAAKlE,KAAL,CAAWiC,QAAX,KAAwB,KAAKG,IAAL,CAAUhB,MAAV,GAAmB,CAAnB,IAAwB,KAAKiB,IAAL,CAAUjB,MAAV,GAAmB,CAAnE,CAAJ,EAA2E;AACzE,mBAAK8C,SAAL,GAAiBE,YAAY,YAAM;AACjC,uBAAK9C,eAAL,CAAqB+C,WAArB,CAAiC,SAAjC;AACD,eAFgB,EAEd,KAAKrE,KAAL,CAAWC,QAAX,GAAsB,IAFR,CAAjB;AAGD;AACF;;;+BAEIqE,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC7B,iBAAKnD,eAAL,GAAuBiD,KAAKhD,IAAL,CAAU,kBAAV,CAAvB;AACA,iBAAKD,eAAL,CAAqBY,QAArB,CAA8B,SAA9B;AACA,iBAAKT,eAAL,GAAuBgD,IAAvB;AACD;;;0CAhDsB5D,W,EAAa;AAClC,gBAAII,MAAM,EAAV;;AAEAA,gBAAIoB,IAAJ,GAAWxB,YAAYwB,IAAvB;AACApB,gBAAImB,IAAJ,GAAWvB,YAAYuB,IAAvB;;AAEA,mBAAOnB,GAAP;AACD;;;;QA/JmC7B,gB;;;;AA2MtCI,uBAAiBkF,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\r\nimport \"app/plugins/panel/graph/legend\";\r\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\r\nimport _ from \"lodash\";\r\nimport TimeSeries from \"app/core/time_series2\";\r\nimport coreModule from \"app/core/core_module\"\r\n\r\nimport './css/status_panel.css!';\r\n\r\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\r\n /** @ngInject */\r\n constructor($scope, $injector, $log, $filter, annotationsSrv) {\r\n super($scope, $injector);\r\n\r\n //this.log = $log.debug;\r\n this.filter = $filter;\r\n\r\n this.aggregations = ['None', 'Max', 'Min', 'Sum'];\r\n\r\n this.panel.flipTime = this.panel.flipTime || 5;\r\n\r\n /** Bind events to functions **/\r\n this.events.on('render', this.onRender.bind(this));\r\n this.events.on('refresh', this.postRefresh.bind(this));\r\n this.events.on('data-error', this.onDataError.bind(this));\r\n this.events.on('data-received', this.onDataReceived.bind(this));\r\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\r\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\r\n }\r\n\r\n postRefresh() {\r\n this.measurements = this.panel.targets;\r\n\r\n /** Duplicate alias validation **/\r\n this.duplicates = false;\r\n\r\n this.measurements = _.filter(this.measurements, (measurement) => {\r\n return !measurement.hide;\r\n });\r\n\r\n _.each(this.measurements, (m) => {\r\n let res = _.filter(this.measurements, (measurement) => {\r\n return (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\r\n });\r\n\r\n if (res.length > 1) {\r\n this.duplicates = true;\r\n }\r\n });\r\n }\r\n\r\n onInitEditMode() {\r\n this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\r\n }\r\n\r\n setElementHeight() {\r\n this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\r\n }\r\n\r\n onRender() {\r\n this.setElementHeight();\r\n\r\n if (this.panel.clusterName) {\r\n this.panel.displayName =\r\n this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\r\n .replace(new RegExp(this.panel.namePrefix, 'i'), '');\r\n } else {\r\n this.panel.displayName = \"\";\r\n }\r\n\r\n if(this.panel.flipCard){\r\n this.$panelContainer.addClass(\"effect-hover\");\r\n } else {\r\n this.$panelContainer.removeClass(\"effect-hover\");\r\n }\r\n\r\n\r\n let targets = this.panel.targets;\r\n\r\n this.crit = [];\r\n this.warn = [];\r\n this.display = [];\r\n\r\n _.each(this.series, (s) => {\r\n let target = _.find(targets, (target) => {\r\n return target.alias == s.alias || target.target == s.alias;\r\n });\r\n\r\n if (!target) {\r\n return;\r\n }\r\n\r\n s.thresholds = StatusPluginCtrl.parseThresholds(target);\r\n s.inverted = s.thresholds.crit < s.thresholds.warn;\r\n s.display = target.display;\r\n s.alias = target.alias;\r\n s.url = target.url;\r\n\r\n let value;\r\n\r\n switch (target.aggregation) {\r\n case 'Max':\r\n value = _.max(s.datapoints, (point) => { return point[0]; })[0];\r\n break;\r\n case 'Min':\r\n value = _.min(s.datapoints, (point) => { return point[0]; })[0];\r\n break;\r\n case 'Sum':\r\n value = 0;\r\n _.each(s.datapoints, (point) => { value += point[0] });\r\n break;\r\n default:\r\n value = s.datapoints[0][0];\r\n }\r\n\r\n s.display_value = value;\r\n\r\n if (!s.inverted) {\r\n if (value >= s.thresholds.crit) {\r\n this.crit.push(s);\r\n } else if (value >= s.thresholds.warn) {\r\n this.warn.push(s);\r\n } else if (s.display) {\r\n this.display.push(s);\r\n }\r\n } else {\r\n if (value <= s.thresholds.crit) {\r\n this.crit.push(s);\r\n } else if (value <= s.thresholds.warn) {\r\n this.warn.push(s);\r\n } else if (s.display) {\r\n s.display_value = value;\r\n this.display.push(s);\r\n }\r\n }\r\n });\r\n\r\n this.$panelContainer.removeClass('error-state warn-state ok-state gray-state');\r\n\r\n if (this.crit.length > 0 || this.duplicates) {\r\n this.$panelContainer.addClass('error-state');\r\n } else if (this.warn.length > 0) {\r\n this.$panelContainer.addClass('warn-state');\r\n } else if(this.series.length == 0 && this.panel.isGrayColor) {\r\n this.$panelContainer.addClass('gray-state');\r\n } else {\r\n this.$panelContainer.addClass('ok-state');\r\n }\r\n\r\n this.autoFlip();\r\n this.parseUri();\r\n }\r\n\r\n parseUri() {\r\n if (this.panel.links && this.panel.links.length > 0) {\r\n this.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\r\n } else {\r\n this.uri = undefined;\r\n }\r\n }\r\n\r\n static parseThresholds(measurement) {\r\n let res = {};\r\n\r\n res.warn = measurement.warn;\r\n res.crit = measurement.crit;\r\n\r\n return res;\r\n }\r\n\r\n onDataReceived(dataList) {\r\n this.series = dataList.map(this.seriesHandler.bind(this));\r\n\r\n this.render();\r\n }\r\n\r\n onDataError() {\r\n this.crit = [];\r\n this.warn = [];\r\n }\r\n\r\n seriesHandler(seriesData) {\r\n var series = new TimeSeries({\r\n datapoints: seriesData.datapoints,\r\n alias: seriesData.target\r\n });\r\n\r\n //series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\r\n\r\n return series;\r\n }\r\n\r\n $onDestroy() {\r\n if(this.timeoutId) clearInterval(this.timeoutId);\r\n }\r\n\r\n autoFlip() {\r\n if(this.timeoutId) clearInterval(this.timeoutId);\r\n if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) {\r\n this.timeoutId = setInterval(() => {\r\n this.$panelContainer.toggleClass(\"flipped\");\r\n }, this.panel.flipTime * 1000);\r\n }\r\n }\r\n\r\n link(scope, elem, attrs, ctrl) {\r\n this.$panelContainer = elem.find('.panel-container');\r\n this.$panelContainer.addClass(\"st-card\");\r\n this.$panelContoller = ctrl;\r\n }\r\n}\r\n\r\nStatusPluginCtrl.templateUrl = 'module.html';\r\n"]} \ No newline at end of file +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","displayTypes","aggregations","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","display","disabled","annotation","series","s","url","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","displayType","handleThresholdStatus","handleDisabledStatus","handleAnnotations","autoFlip","handle_css_display","parseUri","thresholds","parseThresholds","inverted","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,YAAL,GAAoB,CAAC,WAAD,EAAc,kBAAd,EAAkC,YAAlC,CAApB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC,KAAhC,EAAuC,KAAvC,CAApB;;AAEA,WAAKC,KAAL,CAAWC,QAAX,GAAsB,MAAKD,KAAL,CAAWC,QAAX,IAAuB,CAA7C;;AAEA;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CAAoBH,IAApB,OAAhC;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,oBAAf,EAAqC,MAAKK,cAAL,CAAoBH,IAApB,OAArC;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,g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G,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n \t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.display = [];\n\t\tthis.disabled = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.displayType == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.displayType == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.displayType == \"Annotation\") {\n\t\t\t\tthis.handleAnnotations(s, target);\n\t\t\t}\n\t\t});\n\n\t\tthis.autoFlip();\n\t\tthis.handle_css_display();\n\t\tthis.parseUri();\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tif (!series.inverted) {\n\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\tthis.crit.push(series);\n\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\tthis.warn.push(series);\n\t\t\t} else if (series.display) {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\tthis.crit.push(series);\n\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\tthis.warn.push(series);\n\t\t\t} else if (series.display) {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleAnnotations(series, target) {\n\t\tthis.annotation.push(series);\n\t}\n\n\thandle_css_display() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.crit = metricOptions.crit;\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(this.seriesHandler.bind(this));\n\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tseriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/css/status_panel.scss b/src/css/status_panel.scss index ed26dafc..1fa4de8b 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -1,38 +1,34 @@ .status-panel { - display: table; - position: relative; - width: 100%; - - .status-panel-annotation_row { - display: table-row; - height: 25%; - text-align: left; - font-size: 0.85rem; - } - - .status_name_row { - display: table-row; - height: 10%; - } - - .status_alerts_row { - display: table-row; - } - - & > div { - display: table-cell; - vertical-align: middle; - text-align: center; - } - - h1 { - font-size: 1.5rem; - } - - .ok-text, .warning-text, .fail-text, .gray-text{ - display: none; - font-size: 3.5rem; - } + display: table; + position: relative; + width: 100%; + + > div{ + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-size: 1.5rem + } + + + h1 { + font-size: 1.5rem; + } + + + .status-panel-annotation_row { + position: absolute; + top: 0; + width: 100%; + text-align: left; + font-size: 0.85rem; + } + + .ok-text, .warning-text, .fail-text, .gray-text{ + display: none; + font-size: 3.5rem; + } } .error-state { diff --git a/src/module.html b/src/module.html index b8e50129..84508cef 100644 --- a/src/module.html +++ b/src/module.html @@ -54,3 +54,4 @@

+ diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 87abbe83..c3ba9794 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -18,16 +18,16 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - this.panel.flipTime = this.panel.flipTime || 5; + this.panel.flipTime = this.panel.flipTime || 5; - /** Bind events to functions **/ - this.events.on('render', this.onRender.bind(this)); - this.events.on('refresh', this.postRefresh.bind(this)); - this.events.on('data-error', this.onDataError.bind(this)); - this.events.on('data-received', this.onDataReceived.bind(this)); - this.events.on('data-snapshot-load', this.onDataReceived.bind(this)); - this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); - } + /** Bind events to functions **/ + this.events.on('render', this.onRender.bind(this)); + this.events.on('refresh', this.postRefresh.bind(this)); + this.events.on('data-error', this.onDataError.bind(this)); + this.events.on('data-received', this.onDataReceived.bind(this)); + this.events.on('data-snapshot-load', this.onDataReceived.bind(this)); + this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); + } postRefresh() { if (this.panel.fixedSpan) { @@ -73,12 +73,11 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.panel.displayName = ""; } - if(this.panel.flipCard){ - this.$panelContainer.addClass("effect-hover"); - } else { - this.$panelContainer.removeClass("effect-hover"); - } - + if(this.panel.flipCard){ + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } let targets = this.panel.targets; @@ -138,6 +137,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } }); + this.autoFlip(); this.handle_css_display(); this.parseUri(); } @@ -236,24 +236,24 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { return series; } - $onDestroy() { - if(this.timeoutId) clearInterval(this.timeoutId); - } - - autoFlip() { - if(this.timeoutId) clearInterval(this.timeoutId); - if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { - this.timeoutId = setInterval(() => { - this.$panelContainer.toggleClass("flipped"); - }, this.panel.flipTime * 1000); - } - } - - link(scope, elem, attrs, ctrl) { - this.$panelContainer = elem.find('.panel-container'); - this.$panelContainer.addClass("st-card"); - this.$panelContoller = ctrl; - } + $onDestroy() { + if(this.timeoutId) clearInterval(this.timeoutId); + } + + autoFlip() { + if (this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(() => { + this.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } + + link(scope, elem, attrs, ctrl) { + this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); + this.$panelContoller = ctrl; + } } StatusPluginCtrl.templateUrl = 'module.html';