diff --git a/README.md b/README.md index 7d0bcfd5..54ddad18 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,11 @@ Lets say that you want to monitor a bunch of servers, and you want to keep track This plugin will make it easier to do. You just add all the metrics you want to track, and choose how you want their values to be treated: 1. Component severity marker - Set the threshold for each and you get an overview that will report to you if there is anything wrong with any metrics. That means that if all the metrics are in the OK zone, the panel will be green. If evan one of the metrics is in the WARNING zone, it will be yellow, and red if any of them is CRITICAL. 2. Component disable marker - Set the exact value that represent if the component is disabled, the panel will be grey. -3. Annotation - show extra information about the component in the top left side of the panel. +3. Display as text - show extra information about the component in the panel + +Severity and text values can be shown in 2 options: +1. Regular - under the panel title +2. Annotation - In the top left side of the panel **Note:** The disable markers are prioritized over the severity ones. @@ -29,11 +33,11 @@ You can also repeat the panel on a template if you have multiple instances that 2. Choose the name of the panel to be displayed in the `Panel Title` field. **Note:** this field supports Grafana templates, so if you repeat the panel the correct name will show 3. Go the the Options tab, and choose the how to treat each metric. - 1. For severity disply, select the `Threshold` option type under `Status Type`. Enter the `Warning` and `Critical` thresholds for each of your queries. - * If you want the result to always be displayed with it's value (regardless to the thresholds), check the box titled `Show Value` + 1. For severity display, select the `Threshold` option type under `Handler Type`. Enter the `Warning` and `Critical` thresholds for each of your queries. + * If you want the result to always be displayed with it's value (regardless to the thresholds), check the box titled `Show Always` * The plugin automatically detects if higher values are good, or lower values are good by checking which threshold is higher/lower. i.e. if in your metric higher values are better, put a lower value in the "critical" threshold than the "warning" threshold. - 2. For disable display, select the `Disable Criteria` option type under "Status Type". Enter the `Disable Value` for each of your queries. - 3. For annotation, select the "Annotation" option type under "Status Type". The alias + the value of the metric will be shown on the top left. + 2. For disable display, select the `Disable Criteria` option type under `Handler Type`. Enter the `Disable Value` for each of your queries. + 3. For display the text without any condition, select the `Text Only` option type under `Handler Type`. The alias + the value of the metric will be shown on the panel by the `Display Type` value. 4. If the query returns multiple values, choose the type of aggregation you want to be used (`None` will just use the most first result) ## Other Features @@ -51,6 +55,10 @@ If there is not data from any of the metrics, you can show the panel as disabled ## Supported Data Sources Currently the plugin was tested with **influxDB** and **Graphite**. Support for other data sources could be added by demand +## Release Notes +### Version 1.0.3 +* Version (1.0.3) can have some conflicts with older versions. + # Screenshots ### Panel States ![ok](https://github.com/Vonage/Grafana_Status_panel/blob/develop/src/img/ok.png?raw=true) diff --git a/dist/README.md b/dist/README.md index 7d0bcfd5..54ddad18 100644 --- a/dist/README.md +++ b/dist/README.md @@ -13,7 +13,11 @@ Lets say that you want to monitor a bunch of servers, and you want to keep track This plugin will make it easier to do. You just add all the metrics you want to track, and choose how you want their values to be treated: 1. Component severity marker - Set the threshold for each and you get an overview that will report to you if there is anything wrong with any metrics. That means that if all the metrics are in the OK zone, the panel will be green. If evan one of the metrics is in the WARNING zone, it will be yellow, and red if any of them is CRITICAL. 2. Component disable marker - Set the exact value that represent if the component is disabled, the panel will be grey. -3. Annotation - show extra information about the component in the top left side of the panel. +3. Display as text - show extra information about the component in the panel + +Severity and text values can be shown in 2 options: +1. Regular - under the panel title +2. Annotation - In the top left side of the panel **Note:** The disable markers are prioritized over the severity ones. @@ -29,11 +33,11 @@ You can also repeat the panel on a template if you have multiple instances that 2. Choose the name of the panel to be displayed in the `Panel Title` field. **Note:** this field supports Grafana templates, so if you repeat the panel the correct name will show 3. Go the the Options tab, and choose the how to treat each metric. - 1. For severity disply, select the `Threshold` option type under `Status Type`. Enter the `Warning` and `Critical` thresholds for each of your queries. - * If you want the result to always be displayed with it's value (regardless to the thresholds), check the box titled `Show Value` + 1. For severity display, select the `Threshold` option type under `Handler Type`. Enter the `Warning` and `Critical` thresholds for each of your queries. + * If you want the result to always be displayed with it's value (regardless to the thresholds), check the box titled `Show Always` * The plugin automatically detects if higher values are good, or lower values are good by checking which threshold is higher/lower. i.e. if in your metric higher values are better, put a lower value in the "critical" threshold than the "warning" threshold. - 2. For disable display, select the `Disable Criteria` option type under "Status Type". Enter the `Disable Value` for each of your queries. - 3. For annotation, select the "Annotation" option type under "Status Type". The alias + the value of the metric will be shown on the top left. + 2. For disable display, select the `Disable Criteria` option type under `Handler Type`. Enter the `Disable Value` for each of your queries. + 3. For display the text without any condition, select the `Text Only` option type under `Handler Type`. The alias + the value of the metric will be shown on the panel by the `Display Type` value. 4. If the query returns multiple values, choose the type of aggregation you want to be used (`None` will just use the most first result) ## Other Features @@ -51,6 +55,10 @@ If there is not data from any of the metrics, you can show the panel as disabled ## Supported Data Sources Currently the plugin was tested with **influxDB** and **Graphite**. Support for other data sources could be added by demand +## Release Notes +### Version 1.0.3 +* Version (1.0.3) can have some conflicts with older versions. + # Screenshots ### Panel States ![ok](https://github.com/Vonage/Grafana_Status_panel/blob/develop/src/img/ok.png?raw=true) diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index c3a26f32..493db07a 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -1,28 +1,46 @@ .status-panel { - display: table; position: relative; - width: 100%; } - .status-panel > div { - display: flex; - flex-flow: column nowrap; - justify-content: center; - align-items: center; - font-size: 1.5rem; } + width: 100%; + height: 100%; + text-align: center; } .status-panel h1 { font-size: 1.5rem; } - .status-panel .status-panel-annotation_row { + .status-panel .st-card-front { position: absolute; - top: 0; width: 100%; + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-content: center; } + .status-panel .st-card-back .top_section .status-panel-annotation_row { 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; } + font-size: 0.85rem; + padding-bottom: 10px; } + .status-panel .st-card-back .top_section .status-panel-annotation_row .row-overflow { + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } + .status-panel .st-card-back .bottom_section { + display: flex; + flex-direction: column; + justify-content: center; + align-content: center; } + .status-panel .st-card-back .bottom_section .status_alerts_row { + min-height: 1px; } + .status-panel .st-card-front, + .status-panel .st-card-back { + backface-visibility: hidden; + transition: transform 0.5s; } -.error-state { - background-color: red; } - .error-state .fail-text { +.st-card-front .ok-text, .st-card-front .warning-text, .st-card-front .fail-text, .st-card-front .no-data-text, .st-card-front .disabled-text { + display: none; + font-size: 2.0rem; } + +.ok-state { + background-color: green; } + .ok-state .ok-text { display: block; } .warn-state { @@ -30,57 +48,34 @@ .warn-state .warning-text { display: block; } -.ok-state { - background-color: green; } - .ok-state .ok-text { +.error-state { + background-color: red; } + .error-state .fail-text { display: block; } -.gray-state { +.no-data-state { background-color: gray; } - .gray-state .gray-text { + .no-data-state .no-data-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; } +.disabled-state { + background-color: gray; } + .disabled-state .disabled-text { + display: block; } .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 { +.st-card.effect-hover:hover:not(.no-data-state) .st-card-front, .st-card.effect-hover.flipped:not(.no-data-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 { +.st-card.effect-hover:hover:not(.no-data-state) .st-card-back, .st-card.effect-hover.flipped:not(.no-data-state) .st-card-back { -webkit-transform: rotateY(0); transform: rotateY(0); } -.st-card:not(.effect-hover):not(.gray-state) .st-card-front { +.st-card:not(.effect-hover):not(.no-data-state) .st-card-front { display: none; } -.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 d0825526..eda53cc5 100644 --- a/dist/css/status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O,EAAE,KAAK;;AAIhB,YAAa;EACZ,gBAAgB,EAAE,GAAG;EACrB,uBAAW;IACV,OAAO,EAAE,KAAK;;AAIhB,cAAe;EACd,gBAAgB,EAAE,IAAI;EAEtB,4BAAc;IACb,OAAO,EAAE,KAAK;;AAIhB,eAAgB;EACf,gBAAgB,EAAE,IAAI;EACtB,8BAAe;IACd,OAAO,EAAE,KAAK;;AAIhB,mCAAoC;EACnC,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG5B,gIAAiI;EAChI,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG5B,8HAA+H;EAC9H,iBAAiB,EAAE,UAAU;EAC7B,SAAS,EAAE,UAAU;;AAGtB,8DAA+D;EAC9D,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 0b8b2d30..b62a17c2 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -1,166 +1,192 @@
- Note: Every metric 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 metrics with the same alias. Please give each metric a unique name. + Error: There are multiple metrics with the same alias. Please give each metric a unique name.
-
-
{{ measurement.alias }}
-
- Panel Title - -
-
- - Remove Prefix - - A prefix to remove from the name (helps when repeating panel over a template) - - - -
- -
- Flip interval - -
- -
+
+
{{ measurement.alias }}
+
+ Panel Title + +
+
+ + Remove Prefix + + A prefix to remove from the name (helps when repeating panel over a template) + + + +
+ +
+ Flip interval + +
+ +
-
- - -
{{ measurement.alias }}
-
-
Metric: {{ measurement.refId }}
-
Please enter an alias for this measurement bellow
-
- - -
-
Display Settings
- - -
- - Alias - - -
- - -
- - Aggregation - - What to do if the query returns multiple data points. - - -
- -
-
- - -
- - 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
- - -
- - Status Type - - 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
- - -
- - Warning - - -
- - -
- - Critical - - -
- - - -
- - -
-
Disable Criteria
- - -
- - Disable Value - - The exact value which will make this panel to be displayed as disabled
-
-
- -
-
-
-
+
+ + +
{{ measurement.alias }}
+
+
Metric: {{ measurement.refId }}
+
Please enter an alias for this measurement bellow
+
+ + +
+
Display Settings
+ + +
+ + Alias + + +
+ + +
+ + Aggregation + + What to do if the query returns multiple data points. + + +
+ +
+
+ + +
+ + 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
+ + +
+ + Handler Type + + 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 to grey if disabled.
+ Text Only - Show the alias + the value on the panel without any condition. +
+
+
+ +
+
+ + +
+ + Display Type + + The location the value will be displayed
+ Regular - The alias + the value will be display in the center, under the panel title
+ Annotation - The alias + the value will be displayed on top left. If the value answers a threshold condition, it will displayed as regular state
+
+
+
+ +
+
+
+ +
+ +
+
Threshold + + The Warning and Critical fields get numbers or strings.
+ In case both of them are numbers, the thresholds will be used as ranges, and metric value will be checked if it is in the warning/critical ranges.
+ In case one of them is string, the thresholds will check equality to the value. +
+
+ + +
+ + 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 84508cef..7e0d59ca 100644 --- a/dist/module.html +++ b/dist/module.html @@ -1,57 +1,67 @@
-
-
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 }} -
+
+ 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 }} - -

+
+
OK
+
Warning
+
Critical
+
No data
+
Disabled
+
-
-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} +
+
+
+
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText}} +
+
+
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
+
+
+

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

-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} -
+
+ +
+
+ {{ display.alias }} + {{ display.alias }} + - {{ display.display_value | numberOrText }} +
-
- {{ disabled.alias }} - {{ disabled.alias }} +
+ {{ crit.alias }} + {{ crit.alias }} + - {{ crit.display_value | numberOrText }} +
+ +
+ {{ warn.alias }} + {{ warn.alias }} + - {{ warn.display_value | numberOrText }} +
+ +
+ {{ disabled.alias }} + {{ disabled.alias }} +
+
+
-
diff --git a/dist/module.js.map b/dist/module.js.map index b8a3058f..962a6d1c 100644 --- a/dist/module.js.map +++ b/dist/module.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/module.js"],"names":["StatusPluginCtrl"],"mappings":";;;;;;;;AAAQA,sB,gBAAAA,gB;;;2BAGNA,gB","file":"module.js","sourcesContent":["import {StatusPluginCtrl} from './status_ctrl';\r\n\r\nexport {\r\n StatusPluginCtrl as PanelCtrl\r\n};\r\n"]} \ No newline at end of file +{"version":3,"sources":["../src/module.js"],"names":["StatusPluginCtrl"],"mappings":";;;;;;;;AAAQA,sB,gBAAAA,gB;;;2BAGNA,gB","file":"module.js","sourcesContent":["import {StatusPluginCtrl} from './status_ctrl';\n\nexport {\n StatusPluginCtrl as PanelCtrl\n};\n"]} \ No newline at end of file diff --git a/dist/plugin.json b/dist/plugin.json index 0d94275e..f93ead75 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -23,8 +23,8 @@ {"name": "Warning State", "path": "img/warning.png"}, {"name": "Critical State", "path": "img/error.png"} ], - "version": "1.0.2", - "updated": "2017-3-14" + "version": "1.0.3", + "updated": "2017-3-23" }, "dependencies": { diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 6fbea6fa..1e4c0d81 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -76,8 +76,9 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi //this.log = $log.debug; _this.filter = $filter; - _this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; + _this.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only']; _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; + _this.displayTypes = ['Regular', 'Annotation']; _this.panel.flipTime = _this.panel.flipTime || 5; @@ -88,13 +89,33 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi _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.addFilters(); return _this; } _createClass(StatusPluginCtrl, [{ + key: "addFilters", + value: function addFilters() { + var _this2 = this; + + coreModule.filter('numberOrText', function () { + var numberOrTextFilter = function numberOrTextFilter(input) { + if (angular.isNumber(input)) { + return _this2.filter('number')(input); + } else { + return input; + } + }; + + numberOrTextFilter.$stateful = true; + return numberOrTextFilter; + }); + } + }, { key: "postRefresh", value: function postRefresh() { - var _this2 = this; + var _this3 = this; if (this.panel.fixedSpan) { this.panel.span = this.panel.fixedSpan; @@ -110,12 +131,12 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }); _.each(this.measurements, function (m) { - var res = _.filter(_this2.measurements, function (measurement) { + var res = _.filter(_this3.measurements, function (measurement) { return (m.alias == measurement.alias || m.target == measurement.target && m.target) && !m.hide; }); if (res.length > 1) { - _this2.duplicates = true; + _this3.duplicates = true; } }); } @@ -127,14 +148,26 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }, { key: "setElementHeight", value: function setElementHeight() { - this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); + this.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px'); + this.minHeight = this.$panelContoller.height - 10; + } + }, { + key: "setTextMaxWidth", + value: function setTextMaxWidth() { + var tail = ' …'; + var panelWidth = this.$panelContainer.innerWidth(); + if (isNaN(panelWidth)) panelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12; + panelWidth = panelWidth - 20; + this.maxWidth = panelWidth; } }, { key: "onRender", value: function onRender() { - var _this3 = this; + var _this4 = this; this.setElementHeight(); + this.setTextMaxWidth(); + this.upgradeOldVersion(); if (this.panel.clusterName) { this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); @@ -152,8 +185,8 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi this.crit = []; this.warn = []; - this.display = []; this.disabled = []; + this.display = []; this.annotation = []; _.each(this.series, function (s) { @@ -167,6 +200,8 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi s.alias = target.alias; s.url = target.url; + s.display = true; + s.displayType = target.displayType; var value = void 0; switch (target.aggregation) { @@ -201,19 +236,43 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi 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); + if (target.valueHandler == "Threshold") { + _this4.handleThresholdStatus(s, target); + } else if (target.valueHandler == "Disable Criteria") { + _this4.handleDisabledStatus(s, target); + } else if (target.valueHandler == "Text Only") { + _this4.handleTextOnly(s, target); } }); + if (this.disabled.length > 0) { + this.crit = []; + this.warn = []; + this.display = []; + } + this.autoFlip(); - this.handle_css_display(); + this.handleCssDisplay(); this.parseUri(); } + }, { + key: "upgradeOldVersion", + value: function upgradeOldVersion() { + var _this5 = this; + + var targets = this.panel.targets; + + //Handle legacy code + _.each(targets, function (target) { + if (target.valueHandler == null) { + target.valueHandler = target.displayType; + if (target.valueHandler == "Annotation") { + target.valueHandler = "Text Only"; + } + target.displayType = _this5.displayTypes[0]; + } + }); + } }, { key: "handleThresholdStatus", value: function handleThresholdStatus(series, target) { @@ -221,20 +280,41 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi 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); + var isCritical = false; + var isWarning = false; + var isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber; + if (isCheckRanges) { + if (!series.inverted) { + if (series.display_value >= series.thresholds.crit) { + isCritical = true; + } else if (series.display_value >= series.thresholds.warn) { + isWarning = true; + } + } else { + if (series.display_value <= series.thresholds.crit) { + isCritical = true; + } else if (series.display_value <= series.thresholds.warn) { + isWarning = true; + } } } 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) { + if (series.display_value == series.thresholds.crit) { + isCritical = true; + } else if (series.display_value == series.thresholds.warn) { + isWarning = true; + } + } + + if (isCritical) { + this.crit.push(series); + series.displayType = this.displayTypes[0]; + } else if (isWarning) { + this.warn.push(series); + series.displayType = this.displayTypes[0]; + } else if (series.display) { + if (series.displayType == "Annotation") { + this.annotation.push(series); + } else { this.display.push(series); } } @@ -242,7 +322,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }, { key: "handleDisabledStatus", value: function handleDisabledStatus(series, target) { - + series.displayType = this.displayTypes[0]; series.disabledValue = target.disabledValue; if (series.display_value == series.disabledValue) { @@ -250,13 +330,17 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi } } }, { - key: "handleAnnotations", - value: function handleAnnotations(series, target) { - this.annotation.push(series); + key: "handleTextOnly", + value: function handleTextOnly(series, target) { + if (series.displayType == "Annotation") { + this.annotation.push(series); + } else { + this.display.push(series); + } } }, { - key: "handle_css_display", - value: function handle_css_display() { + key: "handleCssDisplay", + value: function handleCssDisplay() { this.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state'); if (this.duplicates) { @@ -285,8 +369,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }, { key: "onDataReceived", value: function onDataReceived(dataList) { - this.series = dataList.map(this.seriesHandler.bind(this)); - + this.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this)); this.render(); } }, { @@ -295,18 +378,6 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi 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() { @@ -315,12 +386,12 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }, { key: "autoFlip", value: function autoFlip() { - var _this4 = this; + var _this6 = this; if (this.timeoutId) clearInterval(this.timeoutId); - if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) { this.timeoutId = setInterval(function () { - _this4.$panelContainer.toggleClass("flipped"); + _this6.$panelContainer.toggleClass("flipped"); }, this.panel.flipTime * 1000); } } @@ -337,10 +408,24 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi var res = {}; res.warn = metricOptions.warn; + res.warnIsNumber = angular.isNumber(res.warn); res.crit = metricOptions.crit; + res.critIsNumber = angular.isNumber(res.crit); return res; } + }, { + key: "seriesHandler", + value: function seriesHandler(seriesData) { + var series = new TimeSeries({ + datapoints: seriesData.datapoints, + alias: seriesData.target + }); + + series.flotpairs = series.getFlotPairs("connected"); + + return series; + } }]); return StatusPluginCtrl; diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index f2ce379a..925f718d 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","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,EAA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R,EAAmBC,cAAc,KAAKD,SAAnB;AACnB;;;gCAEU;AAAA;;AACV,UAAI,KAAKA,SAAT,EAAoBC,cAAc,KAAKD,SAAnB;AACpB,UAAI,KAAKjF,KAAL,CAAWmC,QAAX,KAAwB,KAAKG,IAAL,CAAUhB,MAAV,GAAmB,CAAnB,IAAwB,KAAKiB,IAAL,CAAUjB,MAAV,GAAmB,CAAnE,CAAJ,EAA2E;AAC1E,YAAK2D,SAAL,GAAiBE,YAAY,YAAM;AAClC,eAAK3D,eAAL,CAAqB4D,WAArB,CAAiC,SAAjC;AACA,QAFgB,EAEd,KAAKpF,KAAL,CAAWC,QAAX,GAAsB,IAFR,CAAjB;AAGA;AACD;;;0BAEIoF,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKhE,eAAL,GAAuB8D,KAAK7D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKD,eAAL,CAAqBY,QAArB,CAA8B,SAA9B;AACA,WAAKT,eAAL,GAAuB6D,IAAvB;AACA;;;qCAhDsBC,a,EAAe;AACrC,UAAItE,MAAM,EAAV;;AAEAA,UAAIoB,IAAJ,GAAWkD,cAAclD,IAAzB;AACApB,UAAImB,IAAJ,GAAWmD,cAAcnD,IAAzB;;AAEA,aAAOnB,GAAP;AACA;;;;KA7MoChC,gB;;;;AAyPtCI,oBAAiBmG,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 +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","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,aAAL,GAAqB,CAAC,WAAD,EAAc,kBAAd,EAAkC,WAAlC,CAArB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC,KAAhC,EAAuC,KAAvC,CAApB;AACA,WAAKC,YAAL,GAAoB,CAAC,SAAD,EAAY,YAAZ,CAApB;;AAEA,WAAKC,KAAL,CAAWC,QAAX,GAAsB,MAAKD,KAAL,CAAWC,QAAX,IAAuB,CAA7C;;AAEA;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf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AI8B,IAArB,CAAnB;AACA9B,UAAI6B,IAAJ,GAAWsD,cAActD,IAAzB;AACA7B,UAAI8D,YAAJ,GAAmB1E,QAAQC,QAAR,CAAiBW,IAAI6B,IAArB,CAAnB;;AAEA,aAAO7B,GAAP;AACA;;;mCAYoBoF,U,EAAY;AAChC,UAAIlD,SAAS,IAAIvE,UAAJ,CAAe;AAC3B8E,mBAAY2C,WAAW3C,UADI;AAE3BxC,cAAOmF,WAAWlF;AAFS,OAAf,CAAb;;AAKAgC,aAAOmD,SAAP,GAAmBnD,OAAOoD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOpD,MAAP;AACA;;;;KAlToCzE,gB;;;;AAwUtCI,oBAAiB0H,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.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\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\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\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('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\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.disabled = [];\n\t\tthis.display = [];\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\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\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.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\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\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\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\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\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.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(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 || this.disabled.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 1fa4de8b..9e1abb25 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -1,114 +1,121 @@ .status-panel { - display: table; position: relative; width: 100%; - - > div{ - display: flex; - flex-flow: column nowrap; - justify-content: center; - align-items: center; - font-size: 1.5rem - } - + height: 100%; + text-align: center; h1 { font-size: 1.5rem; } - - .status-panel-annotation_row { + .st-card-front { position: absolute; - top: 0; width: 100%; - text-align: left; - font-size: 0.85rem; + height: 100%; + + display: flex; + flex-direction: column; + justify-content: center; + align-content: center; } - .ok-text, .warning-text, .fail-text, .gray-text{ - display: none; - font-size: 3.5rem; + .st-card-back { + .top_section { + .status-panel-annotation_row { + text-align: left; + font-size: 0.85rem; + padding-bottom: 10px; + + .row-overflow { + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } + } + + .bottom_section { + display: flex; + flex-direction: column; + justify-content: center; + align-content: center; + + .status_name_row { + } + + .status_alerts_row { + min-height: 1px; + } + } } -} -.error-state { - background-color: red; - .fail-text { - display: block; - } + .st-card-front, + .st-card-back { + backface-visibility: hidden; + transition: transform 0.5s; + } } -.warn-state { - background-color: orange; - .warning-text { - display: block; - } +.st-card-front { + .ok-text, .warning-text, .fail-text, .no-data-text, .disabled-text { + display: none; + font-size: 2.0rem; + } } .ok-state { - background-color: green; - .ok-text { - display: block; - } -} + background-color: green; -.gray-state { - background-color: gray; - .gray-text { - display: block; - } -} - -.gray-state .st-card-back{ - display: none; + .ok-text { + display: block; + } } -.st-card { - position: relative; - text-align: center; +.warn-state { + background-color: orange; + .warning-text { + display: block; + } } -.st-card-front, -.st-card-back { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; +.error-state { + background-color: red; + .fail-text { + display: block; + } } -.st-card-front, -.st-card-back { - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - -webkit-transition: -webkit-transform 0.5s; - transition: transform 0.5s; -} +.no-data-state { + background-color: gray; -.st-card.effect-hover .st-card-back { - -webkit-transform: rotateY(-180deg); - transform: rotateY(-180deg); + .no-data-text { + display: block; + } } -.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); +.disabled-state { + background-color: gray; + .disabled-text { + display: block; + } } -.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.effect-hover .st-card-back { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } -.st-card:not(.effect-hover):not(.gray-state) .st-card-front { - display: none; +.st-card.effect-hover:hover:not(.no-data-state) .st-card-front, .st-card.effect-hover.flipped:not(.no-data-state) .st-card-front { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } - -.no-data-state { - background-color: gray; +.st-card.effect-hover:hover:not(.no-data-state) .st-card-back, .st-card.effect-hover.flipped:not(.no-data-state) .st-card-back { + -webkit-transform: rotateY(0); + transform: rotateY(0); } -.disabled-state { - background-color: gray; +.st-card:not(.effect-hover):not(.no-data-state) .st-card-front { + display: none; } diff --git a/src/editor.html b/src/editor.html index 0b8b2d30..b62a17c2 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1,166 +1,192 @@
- Note: Every metric 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 metrics with the same alias. Please give each metric a unique name. + Error: There are multiple metrics with the same alias. Please give each metric a unique name.
-
-
{{ measurement.alias }}
-
- Panel Title - -
-
- - Remove Prefix - - A prefix to remove from the name (helps when repeating panel over a template) - - - -
- -
- Flip interval - -
- -
+
+
{{ measurement.alias }}
+
+ Panel Title + +
+
+ + Remove Prefix + + A prefix to remove from the name (helps when repeating panel over a template) + + + +
+ +
+ Flip interval + +
+ +
-
- - -
{{ measurement.alias }}
-
-
Metric: {{ measurement.refId }}
-
Please enter an alias for this measurement bellow
-
- - -
-
Display Settings
- - -
- - Alias - - -
- - -
- - Aggregation - - What to do if the query returns multiple data points. - - -
- -
-
- - -
- - 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
- - -
- - Status Type - - 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
- - -
- - Warning - - -
- - -
- - Critical - - -
- - - -
- - -
-
Disable Criteria
- - -
- - Disable Value - - The exact value which will make this panel to be displayed as disabled
-
-
- -
-
-
-
+
+ + +
{{ measurement.alias }}
+
+
Metric: {{ measurement.refId }}
+
Please enter an alias for this measurement bellow
+
+ + +
+
Display Settings
+ + +
+ + Alias + + +
+ + +
+ + Aggregation + + What to do if the query returns multiple data points. + + +
+ +
+
+ + +
+ + 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
+ + +
+ + Handler Type + + 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 to grey if disabled.
+ Text Only - Show the alias + the value on the panel without any condition. +
+
+
+ +
+
+ + +
+ + Display Type + + The location the value will be displayed
+ Regular - The alias + the value will be display in the center, under the panel title
+ Annotation - The alias + the value will be displayed on top left. If the value answers a threshold condition, it will displayed as regular state
+
+
+
+ +
+
+
+ +
+ +
+
Threshold + + The Warning and Critical fields get numbers or strings.
+ In case both of them are numbers, the thresholds will be used as ranges, and metric value will be checked if it is in the warning/critical ranges.
+ In case one of them is string, the thresholds will check equality to the value. +
+
+ + +
+ + Warning + + +
+ + +
+ + Critical + + +
+ + + +
+ + +
+
Disable Criteria
+ + +
+ + Disable Value + + The exact value which will make this panel to be displayed as disabled
+
+
+ +
+
+
+
diff --git a/src/module.html b/src/module.html index 84508cef..7e0d59ca 100644 --- a/src/module.html +++ b/src/module.html @@ -1,57 +1,67 @@
-
-
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 }} -
+
+ 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 }} - -

+
+
OK
+
Warning
+
Critical
+
No data
+
Disabled
+
-
-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} +
+
+
+
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText}} +
+
+
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
+
+
+

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

-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} -
+
+ +
+
+ {{ display.alias }} + {{ display.alias }} + - {{ display.display_value | numberOrText }} +
-
- {{ disabled.alias }} - {{ disabled.alias }} +
+ {{ crit.alias }} + {{ crit.alias }} + - {{ crit.display_value | numberOrText }} +
+ +
+ {{ warn.alias }} + {{ warn.alias }} + - {{ warn.display_value | numberOrText }} +
+ +
+ {{ disabled.alias }} + {{ disabled.alias }} +
+
+
-
diff --git a/src/plugin.json b/src/plugin.json index 0d94275e..f93ead75 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -23,8 +23,8 @@ {"name": "Warning State", "path": "img/warning.png"}, {"name": "Critical State", "path": "img/error.png"} ], - "version": "1.0.2", - "updated": "2017-3-14" + "version": "1.0.3", + "updated": "2017-3-23" }, "dependencies": { diff --git a/src/status_ctrl.js b/src/status_ctrl.js index c3ba9794..9d0b93d0 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -15,8 +15,9 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { //this.log = $log.debug; this.filter = $filter; - this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; + this.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only']; this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; + this.displayTypes = ['Regular', 'Annotation']; this.panel.flipTime = this.panel.flipTime || 5; @@ -27,7 +28,24 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { 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.addFilters() + } + + addFilters() { + coreModule.filter('numberOrText', () => { + let numberOrTextFilter = (input) => { + if(angular.isNumber(input)) { + return this.filter('number')(input); + } else { + return input; + } + }; + + numberOrTextFilter.$stateful = true; + return numberOrTextFilter; + }); + } postRefresh() { if (this.panel.fixedSpan) { @@ -59,11 +77,23 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } setElementHeight() { - this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); + this.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px'); + this.minHeight = this.$panelContoller.height-10; + } + + setTextMaxWidth() { + let tail = ' …'; + let panelWidth = this.$panelContainer.innerWidth(); + if (isNaN(panelWidth)) + panelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12; + panelWidth = panelWidth - 20; + this.maxWidth = panelWidth; } onRender() { this.setElementHeight(); + this.setTextMaxWidth(); + this.upgradeOldVersion(); if (this.panel.clusterName) { this.panel.displayName = @@ -83,8 +113,8 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.crit = []; this.warn = []; - this.display = []; this.disabled = []; + this.display = []; this.annotation = []; _.each(this.series, (s) => { @@ -98,6 +128,8 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { s.alias = target.alias; s.url = target.url; + s.display = true; + s.displayType = target.displayType; let value; switch (target.aggregation) { @@ -126,48 +158,90 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { s.display_value = value; - if (target.displayType == "Threshold") { + if (target.valueHandler == "Threshold") { this.handleThresholdStatus(s, target); } - else if (target.displayType == "Disable Criteria") { + else if (target.valueHandler == "Disable Criteria") { this.handleDisabledStatus(s,target); } - else if (target.displayType == "Annotation") { - this.handleAnnotations(s, target); + else if (target.valueHandler == "Text Only") { + this.handleTextOnly(s, target); } }); + if(this.disabled.length > 0) { + this.crit = []; + this.warn = []; + this.display = []; + } + this.autoFlip(); - this.handle_css_display(); + this.handleCssDisplay(); this.parseUri(); } + upgradeOldVersion() { + let targets = this.panel.targets; + + //Handle legacy code + _.each(targets, (target) => { + if(target.valueHandler == null) { + target.valueHandler = target.displayType; + if(target.valueHandler == "Annotation") { + target.valueHandler = "Text Only" + } + target.displayType = this.displayTypes[0]; + } + }); + } + 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); + let isCritical = false; + let isWarning = false; + let isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber; + if (isCheckRanges) { + if (!series.inverted) { + if (series.display_value >= series.thresholds.crit) { + isCritical = true + } else if (series.display_value >= series.thresholds.warn) { + isWarning = true + } + } else { + if (series.display_value <= series.thresholds.crit) { + isCritical = true + } else if (series.display_value <= series.thresholds.warn) { + isWarning = true + } } } 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) { + if (series.display_value == series.thresholds.crit) { + isCritical = true + } else if (series.display_value == series.thresholds.warn) { + isWarning = true + } + } + + if(isCritical) { + this.crit.push(series); + series.displayType = this.displayTypes[0] + } else if(isWarning) { + this.warn.push(series); + series.displayType = this.displayTypes[0] + } else if (series.display) { + if(series.displayType == "Annotation") { + this.annotation.push(series); + } else { this.display.push(series); } } } handleDisabledStatus(series, target) { - + series.displayType = this.displayTypes[0]; series.disabledValue = target.disabledValue; if (series.display_value == series.disabledValue) { @@ -175,11 +249,15 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } } - handleAnnotations(series, target) { - this.annotation.push(series); + handleTextOnly(series, target) { + if(series.displayType == "Annotation") { + this.annotation.push(series); + } else { + this.display.push(series); + } } - handle_css_display() { + handleCssDisplay() { this.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state'); if(this.duplicates) { @@ -209,14 +287,15 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { let res = {}; res.warn = metricOptions.warn; + res.warnIsNumber = angular.isNumber(res.warn); res.crit = metricOptions.crit; + res.critIsNumber = angular.isNumber(res.crit); return res; } onDataReceived(dataList) { - this.series = dataList.map(this.seriesHandler.bind(this)); - + this.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this)); this.render(); } @@ -225,7 +304,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.warn = []; } - seriesHandler(seriesData) { + static seriesHandler(seriesData) { var series = new TimeSeries({ datapoints: seriesData.datapoints, alias: seriesData.target @@ -242,7 +321,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { autoFlip() { if (this.timeoutId) clearInterval(this.timeoutId); - if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) { this.timeoutId = setInterval(() => { this.$panelContainer.toggleClass("flipped"); }, this.panel.flipTime * 1000);