From 88a40625bdbaf599893813c9095fc5b5ef4f00bd Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Wed, 15 Mar 2017 19:21:39 +0200 Subject: [PATCH 1/7] * Version 1.0.3: - Separate the display type of each metrics - Change the 'Annotation' value handler to 'text only' - Add option to show thresholds as annotations - Add option to put string as threshold check (it check if it is equal to the value, and not a range, in this scenario) --- README.md | 16 ++- dist/editor.html | 310 +++++++++++++++++++++------------------- dist/module.html | 14 +- dist/plugin.json | 2 +- dist/status_ctrl.js | 130 +++++++++++++---- dist/status_ctrl.js.map | 2 +- src/editor.html | 310 +++++++++++++++++++++------------------- src/module.html | 14 +- src/plugin.json | 2 +- src/status_ctrl.js | 113 ++++++++++++--- 10 files changed, 550 insertions(+), 363 deletions(-) diff --git a/README.md b/README.md index 7d0bcfd5..b81170be 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +**Note:** The new version (1.0.3) can have some conflicts with older versions. + # Grafana Status Panel This is a plugin meant to be used as a centralized view for the status of component in a glance. @@ -13,7 +15,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 +35,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 diff --git a/dist/editor.html b/dist/editor.html index 3f961162..12f4e614 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -1,156 +1,176 @@
- 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) - - - -
- -
+
+
{{ measurement.alias }}
+
+ Panel Title + +
+
+ + Remove Prefix + + A prefix to remove from the name (helps when repeating panel over a template) + + + +
+ +
-
- - -
{{ 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
+ + +
+ + 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 f72a691e..a122b637 100644 --- a/dist/module.html +++ b/dist/module.html @@ -4,10 +4,10 @@
-
- {{ annoation.alias }} - {{ annoation.alias }} - - {{ annoation.display_value }} +
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText }}
@@ -26,19 +26,19 @@

{{ display.alias }} {{ display.alias }} - - {{ display.display_value | number }} + - {{ display.display_value | numberOrText }}
{{ crit.alias }} {{ crit.alias }} - - {{ crit.display_value | number }} + - {{ crit.display_value | numberOrText }}
{{ warn.alias }} {{ warn.alias }} - - {{ warn.display_value | number }} + - {{ warn.display_value | numberOrText }}
diff --git a/dist/plugin.json b/dist/plugin.json index 0d94275e..b1f94643 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -23,7 +23,7 @@ {"name": "Warning State", "path": "img/warning.png"}, {"name": "Critical State", "path": "img/error.png"} ], - "version": "1.0.2", + "version": "1.0.3", "updated": "2017-3-14" }, diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index d660fc59..6e252962 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']; /** Bind events to functions **/ _this.events.on('render', _this.onRender.bind(_this)); @@ -86,13 +87,31 @@ 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 () { + return function (input) { + if (angular.isNumber(input)) { + return _this2.filter('number')(input); + } else { + return input; + // return this.filter('limitTo')(input, 20, 0); + } + }; + }); + } + }, { key: "postRefresh", value: function postRefresh() { - var _this2 = this; + var _this3 = this; this.measurements = this.panel.targets; @@ -104,12 +123,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; } }); } @@ -126,9 +145,11 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi }, { key: "onRender", value: function onRender() { - var _this3 = this; + var _this4 = this; + // this.addFilters(); this.setElementHeight(); + this.upgradeOldVersion(); if (this.panel.clusterName) { this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); @@ -140,8 +161,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) { @@ -155,6 +176,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) { @@ -189,18 +212,42 @@ 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.handle_css_display(); 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) { @@ -208,20 +255,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); } } @@ -229,7 +297,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) { @@ -237,9 +305,13 @@ 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", @@ -306,7 +378,9 @@ 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; } diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 96ce5de8..de1b42fc 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","measurements","panel","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;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,YAAL,GAAoB,CAAC,WAAD,EAAc,kBAAd,EAAkC,YAAlC,CAApB;AACA,WAAKC,YAAL,GAAoB,CAAC,MA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B,EAAoBE,OAApB,GAA8B,GAA9B,GAAoC,KAAK1D,KAAL,CAAWwD,KAAX,CAAiB,CAAjB,EAAoBG,MAAnE;AACA,OAFD,MAEO;AACN,YAAKF,GAAL,GAAWH,SAAX;AACA;AACD;;;oCAWcM,Q,EAAU;AACxB,WAAKhC,MAAL,GAAcgC,SAASC,GAAT,CAAa,KAAKC,aAAL,CAAmBpE,IAAnB,CAAwB,IAAxB,CAAb,CAAd;;AAEA,WAAKqE,MAAL;AACA;;;mCAEa;AACb,WAAKxC,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;mCAEawC,U,EAAY;AACzB,UAAIpC,SAAS,IAAIhD,UAAJ,CAAe;AAC3BsD,mBAAY8B,WAAW9B,UADI;AAE3B1B,cAAOwD,WAAWvD;AAFS,OAAf,CAAb;;AAKAmB,aAAOqC,SAAP,GAAmBrC,OAAOsC,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOtC,MAAP;AACA;;;0BAEIuC,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAK1D,eAAL,GAAuBwD,KAAKvD,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuBuD,IAAvB;AACA;;;qCAlCsBC,a,EAAe;AACrC,UAAIhE,MAAM,EAAV;;AAEAA,UAAIiB,IAAJ,GAAW+C,cAAc/C,IAAzB;AACAjB,UAAIgB,IAAJ,GAAWgD,cAAchD,IAAzB;;AAEA,aAAOhB,GAAP;AACA;;;;KAlMoC7B,gB;;;;AAgOtCI,oBAAiB0F,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\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\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\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.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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handle_css_display","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","scope","elem","attrs","ctrl","metricOptions","templateUrl"],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AAKtC,MAAL,GAAcsC,SAASC,GAAT,CAAa,KAAKC,aAAL,CAAmB/E,IAAnB,CAAwB,IAAxB,CAAb,CAAd;;AAEA,WAAKgF,MAAL;AACA;;;mCAEa;AACb,WAAK9C,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;mCAEa8C,U,EAAY;AACzB,UAAI1C,SAAS,IAAItD,UAAJ,CAAe;AAC3B6D,mBAAYmC,WAAWnC,UADI;AAE3B5B,cAAO+D,WAAW9D;AAFS,OAAf,CAAb;;AAKAoB,aAAO2C,SAAP,GAAmB3C,OAAO4C,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAO5C,MAAP;AACA;;;0BAEI6C,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKjE,eAAL,GAAuB+D,KAAK9D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuB8D,IAAvB;AACA;;;qCApCsBC,a,EAAe;AACrC,UAAIvE,MAAM,EAAV;;AAEAA,UAAIkB,IAAJ,GAAWqD,cAAcrD,IAAzB;AACAlB,UAAIgD,YAAJ,GAAmB1D,QAAQC,QAAR,CAAiBS,IAAIkB,IAArB,CAAnB;AACAlB,UAAIiB,IAAJ,GAAWsD,cAActD,IAAzB;AACAjB,UAAIiD,YAAJ,GAAmB3D,QAAQC,QAAR,CAAiBS,IAAIiB,IAArB,CAAnB;;AAEA,aAAOjB,GAAP;AACA;;;;KArQoClC,gB;;;;AAmStCI,oBAAiBsG,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', ()=> {\n\t\t\treturn (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\t// return this.filter('limitTo')(input, 20, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpostRefresh() {\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\t// this.addFilters();\n\t\tthis.setElementHeight();\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\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.handle_css_display();\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\tvar isCritical = false;\n\t\tvar 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\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.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(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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/editor.html b/src/editor.html index 3f961162..12f4e614 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1,156 +1,176 @@
- 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) - - - -
- -
+
+
{{ measurement.alias }}
+
+ Panel Title + +
+
+ + Remove Prefix + + A prefix to remove from the name (helps when repeating panel over a template) + + + +
+ +
-
- - -
{{ 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
+ + +
+ + 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 f72a691e..a122b637 100644 --- a/src/module.html +++ b/src/module.html @@ -4,10 +4,10 @@
-
- {{ annoation.alias }} - {{ annoation.alias }} - - {{ annoation.display_value }} +
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText }}
@@ -26,19 +26,19 @@

{{ display.alias }} {{ display.alias }} - - {{ display.display_value | number }} + - {{ display.display_value | numberOrText }}
{{ crit.alias }} {{ crit.alias }} - - {{ crit.display_value | number }} + - {{ crit.display_value | numberOrText }}
{{ warn.alias }} {{ warn.alias }} - - {{ warn.display_value | number }} + - {{ warn.display_value | numberOrText }}
diff --git a/src/plugin.json b/src/plugin.json index 0d94275e..b1f94643 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -23,7 +23,7 @@ {"name": "Warning State", "path": "img/warning.png"}, {"name": "Critical State", "path": "img/error.png"} ], - "version": "1.0.2", + "version": "1.0.3", "updated": "2017-3-14" }, diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 4c46c742..06580fad 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']; /** Bind events to functions **/ this.events.on('render', this.onRender.bind(this)); @@ -25,6 +26,22 @@ 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', ()=> { + return (input)=> { + if(angular.isNumber(input)) { + return this.filter('number')(input); + } else { + return input; + // return this.filter('limitTo')(input, 20, 0); + } + } + }); } postRefresh() { @@ -57,7 +74,9 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } onRender() { + // this.addFilters(); this.setElementHeight(); + this.upgradeOldVersion(); if (this.panel.clusterName) { this.panel.displayName = @@ -67,14 +86,12 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.panel.displayName = ""; } - - let targets = this.panel.targets; this.crit = []; this.warn = []; - this.display = []; this.disabled = []; + this.display = []; this.annotation = []; _.each(this.series, (s) => { @@ -88,6 +105,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) { @@ -116,47 +135,89 @@ 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.handle_css_display(); 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); + var isCritical = false; + var 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) { @@ -164,8 +225,12 @@ 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() { @@ -198,7 +263,9 @@ 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; } From ddc9ec7d31bfe852de56cd537fdc4c5aeec00b80 Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Wed, 15 Mar 2017 19:25:27 +0200 Subject: [PATCH 2/7] * Change readme file --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b81170be..54ddad18 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -**Note:** The new version (1.0.3) can have some conflicts with older versions. - # Grafana Status Panel This is a plugin meant to be used as a centralized view for the status of component in a glance. @@ -57,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) From beba6ad02251ec2667cb2e9c1f59ef6fbd8a179a Mon Sep 17 00:00:00 2001 From: Tomer Amir Date: Thu, 16 Mar 2017 17:06:42 +0200 Subject: [PATCH 3/7] Some small changes --- dist/README.md | 18 +++++++++++++----- dist/status_ctrl.js | 34 ++++++++++++++++------------------ dist/status_ctrl.js.map | 2 +- src/status_ctrl.js | 16 +++++++--------- 4 files changed, 37 insertions(+), 33 deletions(-) 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/status_ctrl.js b/dist/status_ctrl.js index 6e252962..4c4869a4 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -103,7 +103,6 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi return _this2.filter('number')(input); } else { return input; - // return this.filter('limitTo')(input, 20, 0); } }; }); @@ -147,7 +146,6 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi value: function onRender() { var _this4 = this; - // this.addFilters(); this.setElementHeight(); this.upgradeOldVersion(); @@ -227,7 +225,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi this.display = []; } - this.handle_css_display(); + this.handleCssDisplay(); this.parseUri(); } }, { @@ -314,8 +312,8 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi } } }, { - 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) { @@ -344,7 +342,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(); } @@ -354,18 +352,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: "link", value: function link(scope, elem, attrs, ctrl) { @@ -384,6 +370,18 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi 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 de1b42fc..eec9f1da 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","valueHandlers","aggregations","displayTypes","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handle_css_display","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","scope","elem","attrs","ctrl","metricOptions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U;AACxB,WAAKtC,MAAL,GAAcsC,SAASC,GAAT,CAAa,KAAKC,aAAL,CAAmB/E,IAAnB,CAAwB,IAAxB,CAAb,CAAd;;AAEA,WAAKgF,MAAL;AACA;;;mCAEa;AACb,WAAK9C,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;mCAEa8C,U,EAAY;AACzB,UAAI1C,SAAS,IAAItD,UAAJ,CAAe;AAC3B6D,mBAAYmC,WAAWnC,UADI;AAE3B5B,cAAO+D,WAAW9D;AAFS,OAAf,CAAb;;AAKAoB,aAAO2C,SAAP,GAAmB3C,OAAO4C,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAO5C,MAAP;AACA;;;0BAEI6C,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKjE,eAAL,GAAuB+D,KAAK9D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuB8D,IAAvB;AACA;;;qCApCsBC,a,EAAe;AACrC,UAAIvE,MAAM,EAAV;;AAEAA,UAAIkB,IAAJ,GAAWqD,cAAcrD,IAAzB;AACAlB,UAAIgD,YAAJ,GAAmB1D,QAAQC,QAAR,CAAiBS,IAAIkB,IAArB,CAAnB;AACAlB,UAAIiB,IAAJ,GAAWsD,cAActD,IAAzB;AACAjB,UAAIiD,YAAJ,GAAmB3D,QAAQC,QAAR,CAAiBS,IAAIiB,IAArB,CAAnB;;AAEA,aAAOjB,GAAP;AACA;;;;KArQoClC,gB;;;;AAmStCI,oBAAiBsG,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', ()=> {\n\t\t\treturn (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\t// return this.filter('limitTo')(input, 20, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpostRefresh() {\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\t// this.addFilters();\n\t\tthis.setElementHeight();\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\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.handle_css_display();\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\tvar isCritical = false;\n\t\tvar 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\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.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(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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","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;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CAAoBH,IAApB,OAAhC;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,oBAAf,EAAqC,MAAKK,cAAL,CAAoBH,IAApB,OAArC;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,gBAAf,EAAiC,MAAKM,cAAL,CAAoBJ,IAApB,OAAjC;;AAEA,WAAKK,UAAL;AAlB6D;AAmB7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AnE;AACA,OAFD,MAEO;AACN,YAAKF,GAAL,GAAWH,SAAX;AACA;AACD;;;oCAacM,Q,EAAU;AACxB,WAAKtC,MAAL,GAAcsC,SAASC,GAAT,CAAa3F,iBAAiB4F,aAAjB,CAA+B/E,IAA/B,CAAoC,IAApC,CAAb,CAAd;;AAEA,WAAKgF,MAAL;AACA;;;mCAEa;AACb,WAAK9C,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;0BAaI8C,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAK9D,eAAL,GAAuB4D,KAAK3D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuB2D,IAAvB;AACA;;;qCApCsBC,a,EAAe;AACrC,UAAIpE,MAAM,EAAV;;AAEAA,UAAIkB,IAAJ,GAAWkD,cAAclD,IAAzB;AACAlB,UAAIgD,YAAJ,GAAmB1D,QAAQC,QAAR,CAAiBS,IAAIkB,IAArB,CAAnB;AACAlB,UAAIiB,IAAJ,GAAWmD,cAAcnD,IAAzB;AACAjB,UAAIiD,YAAJ,GAAmB3D,QAAQC,QAAR,CAAiBS,IAAIiB,IAArB,CAAnB;;AAEA,aAAOjB,GAAP;AACA;;;mCAaoBqE,U,EAAY;AAChC,UAAI/C,SAAS,IAAItD,UAAJ,CAAe;AAC3B6D,mBAAYwC,WAAWxC,UADI;AAE3B5B,cAAOoE,WAAWnE;AAFS,OAAf,CAAb;;AAKAoB,aAAOgD,SAAP,GAAmBhD,OAAOiD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOjD,MAAP;AACA;;;;KAzRoCxD,gB;;;;AAiStCI,oBAAiBsG,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\treturn (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\t\t});\n\t}\n\n\tpostRefresh() {\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\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\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.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\tvar isCritical = false;\n\t\tvar 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\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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 06580fad..1fbfe424 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -32,13 +32,12 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { addFilters() { - coreModule.filter('numberOrText', ()=> { - return (input)=> { + coreModule.filter('numberOrText', () => { + return (input) => { if(angular.isNumber(input)) { return this.filter('number')(input); } else { return input; - // return this.filter('limitTo')(input, 20, 0); } } }); @@ -74,7 +73,6 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } onRender() { - // this.addFilters(); this.setElementHeight(); this.upgradeOldVersion(); @@ -152,7 +150,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.display = []; } - this.handle_css_display(); + this.handleCssDisplay(); this.parseUri(); } @@ -217,7 +215,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } handleDisabledStatus(series, target) { - series.displayType = this.displayTypes[0] + series.displayType = this.displayTypes[0]; series.disabledValue = target.disabledValue; if (series.display_value == series.disabledValue) { @@ -233,7 +231,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } } - handle_css_display() { + handleCssDisplay() { this.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state'); if(this.duplicates) { @@ -271,7 +269,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } onDataReceived(dataList) { - this.series = dataList.map(this.seriesHandler.bind(this)); + this.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this)); this.render(); } @@ -281,7 +279,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.warn = []; } - seriesHandler(seriesData) { + static seriesHandler(seriesData) { var series = new TimeSeries({ datapoints: seriesData.datapoints, alias: seriesData.target From de72004cca979796ca3d646eff0f1f2d04307d61 Mon Sep 17 00:00:00 2001 From: Tomer Amir Date: Thu, 16 Mar 2017 17:08:40 +0200 Subject: [PATCH 4/7] Some small changes --- dist/status_ctrl.js.map | 2 +- src/status_ctrl.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index eec9f1da..4f5b1cdc 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","valueHandlers","aggregations","displayTypes","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","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;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CAAoBH,IAApB,OAAhC;AACA,WAAKH,MAAL,CAAYC,EAAZ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,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\treturn (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\t\t});\n\t}\n\n\tpostRefresh() {\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\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\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.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\tvar isCritical = false;\n\t\tvar 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\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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","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;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CA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A;;;;KAzRoCxD,gB;;;;AAiStCI,oBAAiBsG,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\treturn (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\t\t});\n\t}\n\n\tpostRefresh() {\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\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\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.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\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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 1fbfe424..71e72669 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -174,8 +174,8 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { series.inverted = series.thresholds.crit < series.thresholds.warn; series.display = target.display; - var isCritical = false; - var isWarning = false; + let isCritical = false; + let isWarning = false; let isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber; if (isCheckRanges) { if (!series.inverted) { From 51f75f8ae6a73c6ac00238f5aab69fac13e51fbe Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Thu, 16 Mar 2017 18:38:59 +0200 Subject: [PATCH 5/7] * Add info popover about the data that can be passed in the threshold values * Truncate the annotation if it is too long, and add popover to it --- dist/README.md | 18 +++++++++++++----- dist/css/status_panel.css | 6 ++++++ dist/css/status_panel.css.map | 2 +- dist/editor.html | 8 +++++++- dist/module.html | 18 ++++++++++-------- dist/status_ctrl.js | 19 +++++++++++++++---- dist/status_ctrl.js.map | 2 +- src/css/status_panel.scss | 7 +++++++ src/editor.html | 8 +++++++- src/module.html | 18 ++++++++++-------- src/status_ctrl.js | 23 +++++++++++++++++------ 11 files changed, 94 insertions(+), 35 deletions(-) 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 96b51ea6..03e65975 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -16,6 +16,12 @@ .status-panel h1 { font-size: 1.5rem; } +.row-overflow { + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } + .error-state { background-color: red; } diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index fc22541e..a903fea3 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;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,aAAc;EACb,SAAS,EAAE,KAAK;EAChB,QAAQ,EAAE,MAAM;EAChB,aAAa,EAAE,QAAQ;EACvB,WAAW,EAAE,MAAM;;AAGpB,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", "sources": ["../../src/css/status_panel.scss"], "names": [], "file": "status_panel.css" diff --git a/dist/editor.html b/dist/editor.html index 12f4e614..53d6faba 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -130,7 +130,13 @@
Metric display type
-
Threshold
+
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. +
+
diff --git a/dist/module.html b/dist/module.html index a122b637..2038afe7 100644 --- a/dist/module.html +++ b/dist/module.html @@ -4,10 +4,12 @@
-
- {{ annoation.alias }} - {{ annotation.alias }} - - {{ annotation.display_value | numberOrText }} +
+
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText}} +
@@ -24,25 +26,25 @@

- {{ display.alias }} + {{ display.alias }} {{ display.alias }} - {{ display.display_value | numberOrText }}
- {{ crit.alias }} + {{ crit.alias }} {{ crit.alias }} - {{ crit.display_value | numberOrText }}
- {{ warn.alias }} + {{ warn.alias }} {{ warn.alias }} - {{ warn.display_value | numberOrText }}
- {{ disabled.alias }} + {{ disabled.alias }} {{ disabled.alias }}
diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 6e252962..f8978546 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -98,14 +98,16 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi var _this2 = this; coreModule.filter('numberOrText', function () { - return function (input) { + var myFilter = function myFilter(input) { if (angular.isNumber(input)) { return _this2.filter('number')(input); } else { return input; - // return this.filter('limitTo')(input, 20, 0); } }; + + myFilter.$stateful = true; + return myFilter; }); } }, { @@ -142,13 +144,23 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi value: function setElementHeight() { this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); } + }, { + 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.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px'); + this.param = panelWidth; + } }, { key: "onRender", value: function onRender() { var _this4 = this; - // this.addFilters(); this.setElementHeight(); + this.setTextMaxWidth(); this.upgradeOldVersion(); if (this.panel.clusterName) { @@ -345,7 +357,6 @@ 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.render(); } }, { diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index de1b42fc..23177739 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","valueHandlers","aggregations","displayTypes","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","input","angular","isNumber","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handle_css_display","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","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;AAAA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AAItD,UAAJ,CAAe;AAC3B6D,mBAAYmC,WAAWnC,UADI;AAE3B5B,cAAO+D,WAAW9D;AAFS,OAAf,CAAb;;AAKAoB,aAAO2C,SAAP,GAAmB3C,OAAO4C,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAO5C,MAAP;AACA;;;0BAEI6C,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKjE,eAAL,GAAuB+D,KAAK9D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuB8D,IAAvB;AACA;;;qCApCsBC,a,EAAe;AACrC,UAAIvE,MAAM,EAAV;;AAEAA,UAAIkB,IAAJ,GAAWqD,cAAcrD,IAAzB;AACAlB,UAAIgD,YAAJ,GAAmB1D,QAAQC,QAAR,CAAiBS,IAAIkB,IAArB,CAAnB;AACAlB,UAAIiB,IAAJ,GAAWsD,cAActD,IAAzB;AACAjB,UAAIiD,YAAJ,GAAmB3D,QAAQC,QAAR,CAAiBS,IAAIiB,IAArB,CAAnB;;AAEA,aAAOjB,GAAP;AACA;;;;KArQoClC,gB;;;;AAmStCI,oBAAiBsG,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\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\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', ()=> {\n\t\t\treturn (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\t// return this.filter('limitTo')(input, 20, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpostRefresh() {\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\t// this.addFilters();\n\t\tthis.setElementHeight();\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\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.handle_css_display();\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\tvar isCritical = false;\n\t\tvar 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\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.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(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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","myFilter","input","angular","isNumber","$stateful","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","tail","panelWidth","innerWidth","isNaN","parseInt","slice","param","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handle_css_display","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","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,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BgH,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\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 myFilter = (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\tmyFilter.$stateful = true;\n\t\t\treturn myFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\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\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\t// this.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px');\n\t\tthis.param = 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\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.handle_css_display();\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\tvar isCritical = false;\n\t\tvar 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\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.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(this.seriesHandler.bind(this));\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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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 e3261af8..ae61869b 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -25,6 +25,13 @@ } } +.row-overflow { + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + .error-state { background-color: red; } diff --git a/src/editor.html b/src/editor.html index 12f4e614..53d6faba 100644 --- a/src/editor.html +++ b/src/editor.html @@ -130,7 +130,13 @@

Metric display type
-
Threshold
+
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. +
+
diff --git a/src/module.html b/src/module.html index a122b637..2038afe7 100644 --- a/src/module.html +++ b/src/module.html @@ -4,10 +4,12 @@
-
- {{ annoation.alias }} - {{ annotation.alias }} - - {{ annotation.display_value | numberOrText }} +
+
+ {{ annoation.alias }} + {{ annotation.alias }} + - {{ annotation.display_value | numberOrText}} +
@@ -24,25 +26,25 @@

- {{ display.alias }} + {{ display.alias }} {{ display.alias }} - {{ display.display_value | numberOrText }}
- {{ crit.alias }} + {{ crit.alias }} {{ crit.alias }} - {{ crit.display_value | numberOrText }}
- {{ warn.alias }} + {{ warn.alias }} {{ warn.alias }} - {{ warn.display_value | numberOrText }}
- {{ disabled.alias }} + {{ disabled.alias }} {{ disabled.alias }}
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 06580fad..203ddac5 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -30,21 +30,23 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.addFilters() } - addFilters() { coreModule.filter('numberOrText', ()=> { - return (input)=> { + let myFilter = (input)=> { if(angular.isNumber(input)) { return this.filter('number')(input); } else { return input; - // return this.filter('limitTo')(input, 20, 0); } - } + }; + + myFilter.$stateful = true; + return myFilter; }); } postRefresh() { + this.measurements = this.panel.targets; /** Duplicate alias validation **/ @@ -73,9 +75,19 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); } + setTextMaxWidth() { + let tail = ' …'; + let panelWidth = this.$panelContainer.innerWidth(); + if (isNaN(panelWidth)) + panelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12; + panelWidth = panelWidth - 20; + // this.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px'); + this.param = panelWidth; + } + onRender() { - // this.addFilters(); this.setElementHeight(); + this.setTextMaxWidth(); this.upgradeOldVersion(); if (this.panel.clusterName) { @@ -272,7 +284,6 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { onDataReceived(dataList) { this.series = dataList.map(this.seriesHandler.bind(this)); - this.render(); } From 262843cd3c665fc26e391c7cc811fe832d16c0db Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Thu, 23 Mar 2017 18:35:56 +0200 Subject: [PATCH 6/7] * change the ctrl property from "param" to "panelWidth" --- dist/module.html | 2 +- dist/status_ctrl.js | 3 +-- dist/status_ctrl.js.map | 2 +- src/module.html | 2 +- src/status_ctrl.js | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dist/module.html b/dist/module.html index 2038afe7..881b87c8 100644 --- a/dist/module.html +++ b/dist/module.html @@ -5,7 +5,7 @@
-
+
{{ annoation.alias }} {{ annotation.alias }} - {{ annotation.display_value | numberOrText}} diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index ecf9fd37..9d57817e 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -151,8 +151,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi var panelWidth = this.$panelContainer.innerWidth(); if (isNaN(panelWidth)) panelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12; panelWidth = panelWidth - 20; - // this.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px'); - this.param = panelWidth; + this.maxWidth = panelWidth; } }, { key: "onRender", diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 1b11d4c6..b9a9e52c 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","valueHandlers","aggregations","displayTypes","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","tail","panelWidth","innerWidth","isNaN","parseInt","slice","param","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","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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,GAAT,CAAarG,iBAAiBsG,aAAjB,CAA+BzF,IAA/B,CAAoC,IAApC,CAAb,CAAd;AACA,WAAK0F,MAAL;AACA;;;mCAEa;AACb,WAAK9C,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;0BAaI8C,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKtE,eAAL,GAAuBoE,KAAKnE,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKE,eAAL,GAAuBmE,IAAvB;AACA;;;qCAnCsBC,a,EAAe;AACrC,UAAI5E,MAAM,EAAV;;AAEAA,UAAI0B,IAAJ,GAAWkD,cAAclD,IAAzB;AACA1B,UAAIwD,YAAJ,GAAmBnE,QAAQC,QAAR,CAAiBU,IAAI0B,IAArB,CAAnB;AACA1B,UAAIyB,IAAJ,GAAWmD,cAAcnD,IAAzB;AACAzB,UAAIyD,YAAJ,GAAmBpE,QAAQC,QAAR,CAAiBU,IAAIyB,IAArB,CAAnB;;AAEA,aAAOzB,GAAP;AACA;;;mCAYoB6E,U,EAAY;AAChC,UAAI/C,SAAS,IAAIhE,UAAJ,CAAe;AAC3BuE,mBAAYwC,WAAWxC,UADI;AAE3BpC,cAAO4E,WAAW3E;AAFS,OAAf,CAAb;;AAKA4B,aAAOgD,SAAP,GAAmBhD,OAAOiD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOjD,MAAP;AACA;;;;KAtSoClE,gB;;;;AA8StCI,oBAAiBgH,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\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\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\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\t// this.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px');\n\t\tthis.param = 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\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.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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\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","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","measurements","panel","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","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;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf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M,EAAV;;AAEAA,UAAI0B,IAAJ,GAAWkD,cAAclD,IAAzB;AACA1B,UAAIwD,YAAJ,GAAmBnE,QAAQC,QAAR,CAAiBU,IAAI0B,IAArB,CAAnB;AACA1B,UAAIyB,IAAJ,GAAWmD,cAAcnD,IAAzB;AACAzB,UAAIyD,YAAJ,GAAmBpE,QAAQC,QAAR,CAAiBU,IAAIyB,IAArB,CAAnB;;AAEA,aAAOzB,GAAP;AACA;;;mCAYoB6E,U,EAAY;AAChC,UAAI/C,SAAS,IAAIhE,UAAJ,CAAe;AAC3BuE,mBAAYwC,WAAWxC,UADI;AAE3BpC,cAAO4E,WAAW3E;AAFS,OAAf,CAAb;;AAKA4B,aAAOgD,SAAP,GAAmBhD,OAAOiD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOjD,MAAP;AACA;;;;KArSoClE,gB;;;;AA6StCI,oBAAiBgH,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\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\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\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\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.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\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/module.html b/src/module.html index 2038afe7..881b87c8 100644 --- a/src/module.html +++ b/src/module.html @@ -5,7 +5,7 @@
-
+
{{ annoation.alias }} {{ annotation.alias }} - {{ annotation.display_value | numberOrText}} diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 5e1b2018..07e89260 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -81,8 +81,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { if (isNaN(panelWidth)) panelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12; panelWidth = panelWidth - 20; - // this.$panelContainer.find('.row-overflow').css('max-width', panelWidth + 'px'); - this.param = panelWidth; + this.maxWidth = panelWidth; } onRender() { From aee49a396c3b6690216d8b0fa4d005f477ab5575 Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Wed, 29 Mar 2017 15:27:22 +0300 Subject: [PATCH 7/7] * fixed merge changes for flipped panel --- dist/css/status_panel.css | 25 +++++++++++++++++-------- dist/css/status_panel.css.map | 2 +- dist/module.html | 9 +++++---- dist/module.js.map | 2 +- src/css/status_panel.scss | 31 +++++++++++++++++++++---------- src/module.html | 9 +++++---- 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index c3a26f32..794def55 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -16,9 +16,13 @@ width: 100%; text-align: left; font-size: 0.85rem; } - .status-panel .ok-text, .status-panel .warning-text, .status-panel .fail-text, .status-panel .gray-text { + .status-panel .ok-text, .status-panel .warning-text, .status-panel .fail-text, .status-panel .no-data-text, .status-panel .disabled-text { display: none; - font-size: 3.5rem; } + font-size: 2.5rem; } + .status-panel .status_name_row { + display: table-row; + height: 10%; + padding-top: 10px; } .error-state { background-color: red; } @@ -35,12 +39,17 @@ .ok-state .ok-text { display: block; } -.gray-state { +.no-data-state { + background-color: gray; } + .no-data-state .no-data-text { + display: block; } + +.disabled-state { background-color: gray; } - .gray-state .gray-text { + .disabled-state .disabled-text { display: block; } -.gray-state .st-card-back { +.no-data-state .st-card-back, .disabled-state .st-card-back { display: none; } .st-card { @@ -66,15 +75,15 @@ -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):not(.disabled-state) .st-card-front, .st-card.effect-hover.flipped:not(.no-data-state):not(.disabled-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):not(.disabled-state) .st-card-front { display: none; } .no-data-state { diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index d0825526..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;AAIhB,2DAA2D;EACzD,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,0KAA2K;EACzK,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG7B,8HAA+H;EAC7H,iBAAiB,EAAE,UAAU;EAC7B,SAAS,EAAE,UAAU;;AAGvB,mFAAoF;EAClF,OAAO,EAAE,IAAI;;AAGf,cAAe;EACd,gBAAgB,EAAE,IAAI;;AAGvB,eAAgB;EACf,gBAAgB,EAAE,IAAI", "sources": ["../../src/css/status_panel.scss"], "names": [], "file": "status_panel.css" diff --git a/dist/module.html b/dist/module.html index 84508cef..0d7df055 100644 --- a/dist/module.html +++ b/dist/module.html @@ -1,9 +1,10 @@
-
ok
-
warning
-
critical
-
No data
+
OK
+
Warning
+
Critical
+
No data
+
Disabled
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/src/css/status_panel.scss b/src/css/status_panel.scss index 1fa4de8b..b57e2d73 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -16,7 +16,6 @@ font-size: 1.5rem; } - .status-panel-annotation_row { position: absolute; top: 0; @@ -25,9 +24,15 @@ font-size: 0.85rem; } - .ok-text, .warning-text, .fail-text, .gray-text{ + .ok-text, .warning-text, .fail-text, .no-data-text, .disabled-text{ display: none; - font-size: 3.5rem; + font-size: 2.5rem; + } + + .status_name_row { + display: table-row; + height: 10%; + padding-top: 10px; } } @@ -52,14 +57,21 @@ } } -.gray-state { +.no-data-state { background-color: gray; - .gray-text { + .no-data-text { display: block; } } -.gray-state .st-card-back{ +.disabled-state { + background-color: gray; + .disabled-text { + display: block; + } +} + +.no-data-state .st-card-back, .disabled-state .st-card-back{ display: none; } @@ -90,21 +102,20 @@ 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):not(.disabled-state) .st-card-front, .st-card.effect-hover.flipped:not(.no-data-state):not(.disabled-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):not(.disabled-state) .st-card-front { display: none; } - .no-data-state { background-color: gray; } diff --git a/src/module.html b/src/module.html index 84508cef..0d7df055 100644 --- a/src/module.html +++ b/src/module.html @@ -1,9 +1,10 @@
-
ok
-
warning
-
critical
-
No data
+
OK
+
Warning
+
Critical
+
No data
+
Disabled