diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index 96b51ea6..071e8e87 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -1,34 +1,77 @@ .status-panel { display: table; position: relative; - width: 100%; - text-align: center; } - .status-panel .status-panel-annotation_row { - display: table-row; - height: 25%; - text-align: left; - font-size: 0.85rem; } - .status-panel .status_name_row { - display: table-row; - height: 10%; } - .status-panel .status_alerts_row { - display: table-row; } + width: 100%; } + .status-panel > div { + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-size: 1.5rem; } .status-panel h1 { font-size: 1.5rem; } + .status-panel .ok-text, .status-panel .warning-text, .status-panel .fail-text, .status-panel .gray-text { + display: none; + font-size: 3.5rem; } .error-state { background-color: red; } + .error-state .fail-text { + display: block; } .warn-state { background-color: orange; } + .warn-state .warning-text { + display: block; } .ok-state { background-color: green; } + .ok-state .ok-text { + display: block; } -.no-data-state { +.gray-state { background-color: gray; } + .gray-state .gray-text { + display: block; } + +.gray-state .st-card-back { + display: none; } + +.st-card { + position: relative; + text-align: center; } + +.st-card-front, +.st-card-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; } + +.st-card-front, +.st-card-back { + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transition: -webkit-transform 0.5s; + transition: transform 0.5s; } + +.st-card.effect-hover .st-card-back { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } + +.st-card.effect-hover:hover:not(.gray-state) .st-card-front, .st-card.effect-hover.flipped:not(.gray-state) .st-card-front { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } + +.st-card.effect-hover:hover:not(.gray-state) .st-card-back, .st-card.effect-hover.flipped:not(.gray-state) .st-card-back { + -webkit-transform: rotateY(0); + transform: rotateY(0); } + +.st-card:not(.effect-hover):not(.gray-state) .st-card-front { + display: none; } -.disabled-state { +.gray-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 fc22541e..22ccd1db 100644 --- a/dist/css/status_panel.css.map +++ b/dist/css/status_panel.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,aAAc;EACb,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAElB,0CAA6B;IAC5B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,GAAG;IACX,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,OAAO;EAGnB,8BAAiB;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,GAAG;EAGZ,gCAAmB;IAClB,OAAO,EAAE,SAAS;EAGnB,gBAAG;IACF,SAAS,EAAE,MAAM;;AAInB,YAAa;EACZ,gBAAgB,EAAE,GAAG;;AAGtB,WAAY;EACX,gBAAgB,EAAE,MAAM;;AAGzB,SAAU;EACT,gBAAgB,EAAE,KAAK;;AAGxB,cAAe;EACd,gBAAgB,EAAE,IAAI;;AAGvB,eAAgB;EACf,gBAAgB,EAAE,IAAI", +"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,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", "sources": ["../../src/css/status_panel.scss"], "names": [], "file": "status_panel.css" diff --git a/dist/editor.html b/dist/editor.html index 3f961162..cb38708d 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -1,9 +1,9 @@
- Note: Every metric has to have a unique Alias to be used + Note: Every measurement has to have a unique Alias to be used
- Error: There are multiple metrics with the same alias. Please give each metric a unique name. + Error: There are multiple measurements with the same alias. Please give each measurement a unique name.
@@ -24,26 +24,29 @@
{{ measurement.alias }}
+
+ Flip interval + +
+
- - -
{{ measurement.alias }}
-
-
Metric: {{ measurement.refId }}
-
Please enter an alias for this measurement bellow
-
- -
-
Display Settings
+
{{ measurement.alias }} Thresholds
+ +
+
Thresholds for measurement: {{ measurement.refId }}
+
Please enter an alias for this measurement bellow
+
-
Alias @@ -51,106 +54,53 @@
Display Settings
-
- Aggregation - - What to do if the query returns multiple data points. - + Warning -
- -
+
-
- 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) - + Critical - +
-
-
-
Metric display type
- -
- Status Type + Aggregation - 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. + What to do if the query returns multiple data points.
-
- -
- -
-
Threshold
- - -
- - Warning - - -
- -
+
- Critical + 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) + - -
- - - +
- -
-
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 b082cd9c..de3550e9 100644 --- a/dist/module.html +++ b/dist/module.html @@ -1,49 +1,41 @@
-
- Error: There are multiple measurements with the same alias. Please give each measurement a unique name. -
+
+
ok
+
warning
+
critical
+
No data
+
+
+
+ Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
-
-
- {{ annoation.alias }} - {{ annoation.alias }} - - {{ annoation.display_value }} -
-
+
+

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

-
-

- - {{ 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 }} +
+
+
-
-
- {{ 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 d8a463c8..d9bb63e5 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -1,328 +1,305 @@ "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.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; - _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - - /** 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 = ""; - } - - 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.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: "link", - value: function link(scope, elem, attrs, ctrl) { - this.$panelContainer = elem.find('.panel-container'); - 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'; - } - }; + "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'; + } + }; }); //# sourceMappingURL=status_ctrl.js.map diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 015a1f30..b2495217 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","displayTypes","aggregations","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","panel","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","crit","warn","display","disabled","annotation","series","s","url","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","displayType","handleThresholdStatus","handleDisabledStatus","handleAnnotations","handle_css_display","parseUri","thresholds","parseThresholds","inverted","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","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;A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AAOhB,GAAP;AACA;;;;KAtMoC/B,gB;;;;AAoOtCI,oBAAiB4F,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\t/** @ngInject */\r\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\r\n\t\tsuper($scope, $injector);\r\n\r\n\t\t//this.log = $log.debug;\r\n\t\tthis.filter = $filter;\r\n\r\n\t\tthis.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation'];\r\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\r\n\r\n\t\t/** Bind events to functions **/\r\n\t\tthis.events.on('render', this.onRender.bind(this));\r\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\r\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\r\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\r\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\r\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\r\n\t}\r\n\r\n\tpostRefresh() {\r\n\t\tif (this.panel.fixedSpan) {\r\n\t\t\tthis.panel.span = this.panel.fixedSpan;\r\n\t\t}\r\n\r\n\t\tthis.measurements = this.panel.targets;\r\n\r\n\t\t/** Duplicate alias validation **/\r\n\t\tthis.duplicates = false;\r\n\r\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\r\n\t\t\treturn !measurement.hide;\r\n\t\t});\r\n\r\n\t\t_.each(this.measurements, (m) => {\r\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\r\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\r\n\t\t\t});\r\n\r\n\t\t\tif (res.length > 1) {\r\n\t\t\t\tthis.duplicates = true;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tonInitEditMode() {\r\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\r\n\t}\r\n\r\n\tsetElementHeight() {\r\n\t\tthis.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\r\n\t}\r\n\r\n\tonRender() {\r\n\t\tthis.setElementHeight();\r\n\r\n\t\tif (this.panel.clusterName) {\r\n\t\t\tthis.panel.displayName =\r\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\r\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\r\n\t\t} else {\r\n\t\t\tthis.panel.displayName = \"\";\r\n\t\t}\r\n\r\n\r\n\r\n\t\tlet targets = this.panel.targets;\r\n\r\n\t\tthis.crit = [];\r\n\t\tthis.warn = [];\r\n\t\tthis.display = [];\r\n\t\tthis.disabled = [];\r\n\t\tthis.annotation = [];\r\n\r\n\t\t_.each(this.series, (s) => {\r\n\t\t\tlet target = _.find(targets, (target) => {\r\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\r\n\t\t\t});\r\n\r\n\t\t\tif (!target) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\ts.alias = target.alias;\r\n\t\t\ts.url = target.url;\r\n\r\n\t\t\tlet value;\r\n\t\t\tswitch (target.aggregation) {\r\n\t\t\t\tcase 'Max':\r\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\r\n\t\t\t\t\tvalue = s.stats.max;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Min':\r\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\r\n\t\t\t\t\tvalue = s.stats.min;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Sum':\r\n\t\t\t\t\tvalue = 0;\r\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\r\n\t\t\t\t\tvalue = s.stats.total;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Avg':\r\n\t\t\t\t\tvalue = s.stats.avg;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'First':\r\n\t\t\t\t\tvalue = s.datapoints[0][0];\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\r\n\t\t\t}\r\n\r\n\t\t\ts.display_value = value;\r\n\r\n\t\t\tif (target.displayType == \"Threshold\") {\r\n\t\t\t\tthis.handleThresholdStatus(s, target);\r\n\t\t\t}\r\n\t\t\telse if (target.displayType == \"Disable Criteria\") {\r\n\t\t\t\tthis.handleDisabledStatus(s,target);\r\n\t\t\t}\r\n\t\t\telse if (target.displayType == \"Annotation\") {\r\n\t\t\t\tthis.handleAnnotations(s, target);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.handle_css_display();\r\n\t\tthis.parseUri();\r\n\t}\r\n\r\n\thandleThresholdStatus(series, target) {\r\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\r\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\r\n\t\tseries.display = target.display;\r\n\r\n\t\tif (!series.inverted) {\r\n\t\t\tif (series.display_value >= series.thresholds.crit) {\r\n\t\t\t\tthis.crit.push(series);\r\n\t\t\t} else if (series.display_value >= series.thresholds.warn) {\r\n\t\t\t\tthis.warn.push(series);\r\n\t\t\t} else if (series.display) {\r\n\t\t\t\tthis.display.push(series);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (series.display_value <= series.thresholds.crit) {\r\n\t\t\t\tthis.crit.push(series);\r\n\t\t\t} else if (series.display_value <= series.thresholds.warn) {\r\n\t\t\t\tthis.warn.push(series);\r\n\t\t\t} else if (series.display) {\r\n\t\t\t\tthis.display.push(series);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\thandleDisabledStatus(series, target) {\r\n\r\n\t\tseries.disabledValue = target.disabledValue;\r\n\r\n\t\tif (series.display_value == series.disabledValue) {\r\n\t\t\tthis.disabled.push(series);\r\n\t\t}\r\n\t}\r\n\r\n\thandleAnnotations(series, target) {\r\n\t\tthis.annotation.push(series);\r\n\t}\r\n\r\n\thandle_css_display() {\r\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\r\n\r\n\t\tif(this.duplicates) {\r\n\t\t\tthis.$panelContainer.addClass('error-state');\r\n\t\t} else if (this.disabled.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('disabled-state');\r\n\t\t} else if (this.crit.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('error-state');\r\n\t\t} else if (this.warn.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('warn-state');\r\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\r\n\t\t\tthis.$panelContainer.addClass('no-data-state');\r\n\t\t} else {\r\n\t\t\tthis.$panelContainer.addClass('ok-state');\r\n\t\t}\r\n\t}\r\n\r\n\tparseUri() {\r\n\t\tif (this.panel.links && this.panel.links.length > 0) {\r\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\r\n\t\t} else {\r\n\t\t\tthis.uri = undefined;\r\n\t\t}\r\n\t}\r\n\r\n\tstatic parseThresholds(metricOptions) {\r\n\t\tlet res = {};\r\n\r\n\t\tres.warn = metricOptions.warn;\r\n\t\tres.crit = metricOptions.crit;\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\tonDataReceived(dataList) {\r\n\t\tthis.series = dataList.map(this.seriesHandler.bind(this));\r\n\r\n\t\tthis.render();\r\n\t}\r\n\r\n\tonDataError() {\r\n\t\tthis.crit = [];\r\n\t\tthis.warn = [];\r\n\t}\r\n\r\n\tseriesHandler(seriesData) {\r\n\t\tvar series = new TimeSeries({\r\n\t\t\tdatapoints: seriesData.datapoints,\r\n\t\t\talias: seriesData.target\r\n\t\t});\r\n\r\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\r\n\r\n\t\treturn series;\r\n\t}\r\n\r\n\tlink(scope, elem, attrs, ctrl) {\r\n\t\tthis.$panelContainer = elem.find('.panel-container');\r\n\t\tthis.$panelContoller = ctrl;\r\n\t}\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","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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AAKhD,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 diff --git a/src/css/status_panel.scss b/src/css/status_panel.scss index e3261af8..ed26dafc 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -1,42 +1,114 @@ .status-panel { - display: table; - position: relative; - width: 100%; - text-align: center; + display: table; + position: relative; + width: 100%; - .status-panel-annotation_row { - display: table-row; - height: 25%; - text-align: left; - font-size: 0.85rem; - } + .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_name_row { + display: table-row; + height: 10%; + } - .status_alerts_row { - display: table-row; - } + .status_alerts_row { + display: table-row; + } - h1 { - font-size: 1.5rem; - } + & > 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; + } } .error-state { - background-color: red; + background-color: red; + .fail-text { + display: block; + } } .warn-state { - background-color: orange; + background-color: orange; + .warning-text { + display: block; + } } .ok-state { - background-color: green; + background-color: green; + .ok-text { + display: block; + } +} + +.gray-state { + background-color: gray; + .gray-text { + display: block; + } +} + +.gray-state .st-card-back{ + display: none; } +.st-card { + position: relative; + text-align: center; +} + +.st-card-front, +.st-card-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.st-card-front, +.st-card-back { + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transition: -webkit-transform 0.5s; + transition: transform 0.5s; +} + +.st-card.effect-hover .st-card-back { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); +} + +.st-card.effect-hover:hover:not(.gray-state) .st-card-front, .st-card.effect-hover.flipped:not(.gray-state) .st-card-front { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); +} + +.st-card.effect-hover:hover:not(.gray-state) .st-card-back, .st-card.effect-hover.flipped:not(.gray-state) .st-card-back { + -webkit-transform: rotateY(0); + transform: rotateY(0); +} + +.st-card:not(.effect-hover):not(.gray-state) .st-card-front { + display: none; +} + + .no-data-state { background-color: gray; } diff --git a/src/editor.html b/src/editor.html index 3f961162..0b8b2d30 100644 --- a/src/editor.html +++ b/src/editor.html @@ -24,6 +24,16 @@
{{ measurement.alias }}
+
+ Flip interval + +
+ diff --git a/src/module.html b/src/module.html index b082cd9c..b8e50129 100644 --- a/src/module.html +++ b/src/module.html @@ -1,7 +1,14 @@
-
- Error: There are multiple measurements with the same alias. Please give each measurement a unique name. -
+
+
ok
+
warning
+
critical
+
No data
+
+
+
+ Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 745eeb73..87abbe83 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -18,14 +18,16 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - /** 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)); - } + 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)); + } postRefresh() { if (this.panel.fixedSpan) { @@ -71,6 +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"); + } let targets = this.panel.targets; @@ -229,10 +236,24 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { return series; } - link(scope, elem, attrs, ctrl) { - this.$panelContainer = elem.find('.panel-container'); - 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';