From 561511309c71dbfde37d2e1c30fe779ab0390f59 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 7 Feb 2017 16:03:44 +0300 Subject: [PATCH 1/5] add last and avg aggregation --- src/status_ctrl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 62ea01ce..99c2c4ff 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -15,7 +15,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { //this.log = $log.debug; this.filter = $filter; - this.aggregations = ['None', 'Max', 'Min', 'Sum']; + this.aggregations = ['None', 'Max', 'Min', 'Sum', 'Avg', 'Last']; /** Bind events to functions **/ this.events.on('render', this.onRender.bind(this)); @@ -102,6 +102,12 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { value = 0; _.each(s.datapoints, (point) => { value += point[0] }); break; + case 'Avg': + value = s.stats.avg; + break; + case 'Last': + value = s.datapoints[s.datapoints.length - 1][0]; + break; default: value = s.datapoints[0][0]; } @@ -175,7 +181,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { alias: seriesData.target }); - //series.flotpairs = series.getFlotPairs(this.panel.nullPointMode); + series.flotpairs = series.getFlotPairs("connected"); return series; } From 342b92d43fba4f7bd5dc5f800463a757cf2ca574 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Fri, 10 Feb 2017 18:34:05 +0300 Subject: [PATCH 2/5] fix showing gray state if unchecked show value --- src/status_ctrl.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 0fa860e2..6978f320 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -134,8 +134,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.$panelContainer.addClass('error-state'); } else if (this.warn.length > 0) { this.$panelContainer.addClass('warn-state'); - } else if(this.display.length == 0) { - //this.$panelContainer.css('background-color', "gray"); + } else if(this.series.length == 0) { this.$panelContainer.addClass('gray-state'); } else { this.$panelContainer.addClass('ok-state'); From 05c7ce1490ba4e2b357762182782e8f4d6a76ea9 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 14 Feb 2017 12:46:19 +0300 Subject: [PATCH 3/5] "Gray panel" as an optional feature --- src/editor.html | 4 ++++ src/status_ctrl.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/editor.html b/src/editor.html index d6a3386a..48e8d977 100644 --- a/src/editor.html +++ b/src/editor.html @@ -22,6 +22,10 @@
{{ measurement.alias }}
+ diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 6978f320..4bbfa8fb 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -134,7 +134,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.$panelContainer.addClass('error-state'); } else if (this.warn.length > 0) { this.$panelContainer.addClass('warn-state'); - } else if(this.series.length == 0) { + } else if(this.series.length == 0 && this.panel.isGrayColor) { this.$panelContainer.addClass('gray-state'); } else { this.$panelContainer.addClass('ok-state'); From d64c73d6ff18cfc3f9f97f0aef835dbc215bb594 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 14 Feb 2017 15:23:16 +0300 Subject: [PATCH 4/5] Refactor aggregation code --- src/editor.html | 3 +-- src/status_ctrl.js | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/editor.html b/src/editor.html index d6a3386a..e6fca223 100644 --- a/src/editor.html +++ b/src/editor.html @@ -60,8 +60,7 @@
Thresholds for measurement: {{ measurement.refId }}< Aggregation - What to do if the query returns multiple data points.
- Note: 'None' will select the first value. + What to do if the query returns multiple data points.
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 99c2c4ff..9eab06ae 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -15,7 +15,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { //this.log = $log.debug; this.filter = $filter; - this.aggregations = ['None', 'Max', 'Min', 'Sum', 'Avg', 'Last']; + this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; /** Bind events to functions **/ this.events.on('render', this.onRender.bind(this)); @@ -93,23 +93,22 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { switch (target.aggregation) { case 'Max': - value = _.max(s.datapoints, (point) => { return point[0]; })[0]; + value = s.stats.max; break; case 'Min': - value = _.min(s.datapoints, (point) => { return point[0]; })[0]; + value = s.stats.min; break; case 'Sum': - value = 0; - _.each(s.datapoints, (point) => { value += point[0] }); + value = s.stats.total; break; case 'Avg': value = s.stats.avg; break; - case 'Last': - value = s.datapoints[s.datapoints.length - 1][0]; - break; - default: + case 'First': value = s.datapoints[0][0]; + break; + default: + value = s.datapoints[s.datapoints.length - 1][0]; } s.display_value = value; From 3cd336176b3eb30ed2be5997e000ee620dff7a6c Mon Sep 17 00:00:00 2001 From: Tomer Amir Date: Thu, 2 Mar 2017 13:16:02 +0200 Subject: [PATCH 5/5] Updated the dist folder --- dist/README.md | 5 +++++ dist/css/status_panel.css | 3 +++ dist/css/status_panel.css.map | 2 +- dist/editor.html | 7 +++++-- dist/status_ctrl.js | 29 +++++++++++++++-------------- dist/status_ctrl.js.map | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/dist/README.md b/dist/README.md index 156333cd..976560f9 100644 --- a/dist/README.md +++ b/dist/README.md @@ -8,6 +8,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 measurements that you want to track, set the threshold for each (you could also repeat the panel on a template if you have multiple instances that you want to watch) and you get an overview that will report to you if there is anything wrong with any measurements. That means that if all the measurements are is the OK zone, the panel will be green. if evan one of the measurements is in the WARNING zone, it will be yellow, and red if any of them is CRITICAL. +## How to install (for debugging purposes only) +1. Copy the contents of "Grafana_Status_panel" to the "/var/lib/grafana/plugins" folder +2. restart grafana by using "service grafana-server restart" +3. Now this panel should be installed. + ## How to use 1. Add the queries you want to the panel and give each of them a unique alias 2. Choose the name of the panel to be displayed in the `Panel Title` field. diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index a6c40ea5..6fabedea 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -18,4 +18,7 @@ .ok-state { background-color: green; } +.gray-state { + background-color: gray; } + /*# sourceMappingURL=status_panel.css.map */ diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index aefc7fa7..9e4757c9 100644 --- a/dist/css/status_panel.css.map +++ b/dist/css/status_panel.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,aAAc;EACZ,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,IAAI;EAEX,mBAAQ;IACN,OAAO,EAAE,UAAU;IACnB,cAAc,EAAE,MAAM;IACtB,UAAU,EAAE,MAAM;EAGpB,gBAAG;IACD,SAAS,EAAE,MAAM;;AAIrB,YAAa;EACX,gBAAgB,EAAE,GAAG;;AAGvB,WAAY;EACV,gBAAgB,EAAE,MAAM;;AAG1B,SAAU;EACR,gBAAgB,EAAE,KAAK", +"mappings": "AAAA,aAAc;EACZ,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,IAAI;EAEX,mBAAQ;IACN,OAAO,EAAE,UAAU;IACnB,cAAc,EAAE,MAAM;IACtB,UAAU,EAAE,MAAM;EAGpB,gBAAG;IACD,SAAS,EAAE,MAAM;;AAIrB,YAAa;EACX,gBAAgB,EAAE,GAAG;;AAGvB,WAAY;EACV,gBAAgB,EAAE,MAAM;;AAG1B,SAAU;EACR,gBAAgB,EAAE,KAAK;;AAGzB,WAAY;EACV,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 d6a3386a..ecd0f3ce 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -22,6 +22,10 @@
{{ measurement.alias }}
+ @@ -60,8 +64,7 @@
Thresholds for measurement: {{ measurement.refId }}< Aggregation - What to do if the query returns multiple data points.
- Note: 'None' will select the first value. + What to do if the query returns multiple data points.
diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 7e03fc2c..ce3a57c7 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -76,7 +76,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi //this.log = $log.debug; _this.filter = $filter; - _this.aggregations = ['None', 'Max', 'Min', 'Sum']; + _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; /** Bind events to functions **/ _this.events.on('render', _this.onRender.bind(_this)); @@ -160,23 +160,22 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi switch (target.aggregation) { case 'Max': - value = _.max(s.datapoints, function (point) { - return point[0]; - })[0]; + value = s.stats.max; break; case 'Min': - value = _.min(s.datapoints, function (point) { - return point[0]; - })[0]; + value = s.stats.min; break; case 'Sum': - value = 0; - _.each(s.datapoints, function (point) { - value += point[0]; - }); + value = s.stats.total; break; - default: + case 'Avg': + value = s.stats.avg; + break; + case 'First': value = s.datapoints[0][0]; + break; + default: + value = s.datapoints[s.datapoints.length - 1][0]; } s.display_value = value; @@ -201,12 +200,14 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi } }); - this.$panelContainer.removeClass('error-state warn-state ok-state'); + this.$panelContainer.removeClass('error-state warn-state ok-state gray-state'); if (this.crit.length > 0 || this.duplicates) { this.$panelContainer.addClass('error-state'); } else if (this.warn.length > 0) { this.$panelContainer.addClass('warn-state'); + } else if (this.series.length == 0 && this.panel.isGrayColor) { + this.$panelContainer.addClass('gray-state'); } else { this.$panelContainer.addClass('ok-state'); } @@ -243,7 +244,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi alias: seriesData.target }); - //series.flotpairs = series.getFlotPairs(this.panel.nullPointMode); + series.flotpairs = series.getFlotPairs("connected"); return series; } diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 16e385ea..ebad2c27 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","aggregations","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","series","s","thresholds","parseThresholds","inverted","url","value","aggregation","max","datapoints","point","min","display_value","push","removeClass","addClass","parseUri","links","uri","dashUri","params","undefined","dataList","map","seriesHandler","render","seriesData","scope","elem","attrs","ctrl","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,sB,kBAAAA,gB;;AAGDC,O;;AACAC,gB;;AACAC,gB;;;;;;;;;;;;;;;;;;;;;kCAIMC,gB;;;AACX;AACA,kCAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,0IACtDJ,MADsD,EAC9CC,SAD8C;;AAG5D;AACA,gBAAKI,MAAL,GAAcF,OAAd;;AAEA,gBAAKG,YAAL,GAAoB,CAAC,MAAD,EAAS,KAAT,EAAgB,KAAhB,EAAuB,KAAvB,CAApB;;AAEA;AACA,gBAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,gBAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF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;;;+BAEI2B,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC7B,iBAAK5C,eAAL,GAAuB0C,KAAKzC,IAAL,CAAU,kBAAV,CAAvB;AACA,iBAAKE,eAAL,GAAuByC,IAAvB;AACD;;;0CAlCsBrD,W,EAAa;AAClC,gBAAII,MAAM,EAAV;;AAEAA,gBAAIiB,IAAJ,GAAWrB,YAAYqB,IAAvB;AACAjB,gBAAIgB,IAAJ,GAAWpB,YAAYoB,IAAvB;;AAEA,mBAAOhB,GAAP;AACD;;;;QArJmC5B,gB;;;;AAmLtCI,uBAAiB0E,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 /** @ngInject */\n constructor($scope, $injector, $log, $filter, annotationsSrv) {\n super($scope, $injector);\n\n //this.log = $log.debug;\n this.filter = $filter;\n\n this.aggregations = ['None', 'Max', 'Min', 'Sum'];\n\n /** Bind events to functions **/\n this.events.on('render', this.onRender.bind(this));\n this.events.on('refresh', this.postRefresh.bind(this));\n this.events.on('data-error', this.onDataError.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n }\n\n postRefresh() {\n this.measurements = this.panel.targets;\n\n /** Duplicate alias validation **/\n this.duplicates = false;\n\n this.measurements = _.filter(this.measurements, (measurement) => {\n return !measurement.hide;\n });\n\n _.each(this.measurements, (m) => {\n let res = _.filter(this.measurements, (measurement) => {\n return (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n });\n\n if (res.length > 1) {\n this.duplicates = true;\n }\n });\n }\n\n onInitEditMode() {\n this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n }\n\n setElementHeight() {\n this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\n }\n\n onRender() {\n this.setElementHeight();\n\n if (this.panel.clusterName) {\n this.panel.displayName =\n this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n .replace(new RegExp(this.panel.namePrefix, 'i'), '');\n } else {\n this.panel.displayName = \"\";\n }\n\n\n\n let targets = this.panel.targets;\n\n this.crit = [];\n this.warn = [];\n this.display = [];\n\n _.each(this.series, (s) => {\n let target = _.find(targets, (target) => {\n return target.alias == s.alias || target.target == s.alias;\n });\n\n if (!target) {\n return;\n }\n\n s.thresholds = StatusPluginCtrl.parseThresholds(target);\n s.inverted = s.thresholds.crit < s.thresholds.warn;\n s.display = target.display;\n s.alias = target.alias;\n s.url = target.url;\n\n let value;\n\n switch (target.aggregation) {\n case 'Max':\n value = _.max(s.datapoints, (point) => { return point[0]; })[0];\n break;\n case 'Min':\n value = _.min(s.datapoints, (point) => { return point[0]; })[0];\n break;\n case 'Sum':\n value = 0;\n _.each(s.datapoints, (point) => { value += point[0] });\n break;\n default:\n value = s.datapoints[0][0];\n }\n\n s.display_value = value;\n\n if (!s.inverted) {\n if (value >= s.thresholds.crit) {\n this.crit.push(s);\n } else if (value >= s.thresholds.warn) {\n this.warn.push(s);\n } else if (s.display) {\n this.display.push(s);\n }\n } else {\n if (value <= s.thresholds.crit) {\n this.crit.push(s);\n } else if (value <= s.thresholds.warn) {\n this.warn.push(s);\n } else if (s.display) {\n s.display_value = value;\n this.display.push(s);\n }\n }\n });\n\n this.$panelContainer.removeClass('error-state warn-state ok-state');\n\n if (this.crit.length > 0 || this.duplicates) {\n this.$panelContainer.addClass('error-state');\n } else if (this.warn.length > 0) {\n this.$panelContainer.addClass('warn-state');\n } else {\n this.$panelContainer.addClass('ok-state');\n }\n\n this.parseUri();\n }\n\n parseUri() {\n if (this.panel.links && this.panel.links.length > 0) {\n this.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n } else {\n this.uri = undefined;\n }\n }\n\n static parseThresholds(measurement) {\n let res = {};\n\n res.warn = measurement.warn;\n res.crit = measurement.crit;\n\n return res;\n }\n\n onDataReceived(dataList) {\n this.series = dataList.map(this.seriesHandler.bind(this));\n\n this.render();\n }\n\n onDataError() {\n this.crit = [];\n this.warn = [];\n }\n\n seriesHandler(seriesData) {\n var series = new TimeSeries({\n datapoints: seriesData.datapoints,\n alias: seriesData.target\n });\n\n //series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\n\n return series;\n }\n\n link(scope, elem, attrs, ctrl) {\n this.$panelContainer = elem.find('.panel-container');\n this.$panelContoller = ctrl;\n }\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","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","series","s","thresholds","parseThresholds","inverted","url","value","aggregation","stats","max","min","total","avg","datapoints","display_value","push","removeClass","addClass","isGrayColor","parseUri","links","uri","dashUri","params","undefined","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","scope","elem","attrs","ctrl","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,sB,kBAAAA,gB;;AAGDC,O;;AACAC,gB;;AACAC,gB;;;;;;;;;;;;;;;;;;;;;kCAIMC,gB;;;AACX;AACA,kCAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AA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AAjB,EAAoBG,MAAnE;AACD,aAFD,MAEO;AACL,mBAAKF,GAAL,GAAWG,SAAX;AACD;AACF;;;yCAWcC,Q,EAAU;AACvB,iBAAKzB,MAAL,GAAcyB,SAASC,GAAT,CAAa,KAAKC,aAAL,CAAmB3D,IAAnB,CAAwB,IAAxB,CAAb,CAAd;;AAEA,iBAAK4D,MAAL;AACD;;;wCAEa;AACZ,iBAAK/B,IAAL,GAAY,EAAZ;AACA,iBAAKC,IAAL,GAAY,EAAZ;AACD;;;wCAEa+B,U,EAAY;AACxB,gBAAI7B,SAAS,IAAI7C,UAAJ,CAAe;AAC1B0D,0BAAYgB,WAAWhB,UADG;AAE1B/B,qBAAO+C,WAAW9C;AAFQ,aAAf,CAAb;;AAKAiB,mBAAO8B,SAAP,GAAmB9B,OAAO+B,YAAP,CAAoB,WAApB,CAAnB;;AAEA,mBAAO/B,MAAP;AACD;;;+BAEIgC,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC7B,iBAAKjD,eAAL,GAAuB+C,KAAK9C,IAAL,CAAU,kBAAV,CAAvB;AACA,iBAAKE,eAAL,GAAuB8C,IAAvB;AACD;;;0CAlCsB1D,W,EAAa;AAClC,gBAAII,MAAM,EAAV;;AAEAA,gBAAIiB,IAAJ,GAAWrB,YAAYqB,IAAvB;AACAjB,gBAAIgB,IAAJ,GAAWpB,YAAYoB,IAAvB;;AAEA,mBAAOhB,GAAP;AACD;;;;QA5JmC5B,gB;;;;AA0LtCI,uBAAiB+E,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 /** @ngInject */\n constructor($scope, $injector, $log, $filter, annotationsSrv) {\n super($scope, $injector);\n\n //this.log = $log.debug;\n this.filter = $filter;\n\n this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\n /** Bind events to functions **/\n this.events.on('render', this.onRender.bind(this));\n this.events.on('refresh', this.postRefresh.bind(this));\n this.events.on('data-error', this.onDataError.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n }\n\n postRefresh() {\n this.measurements = this.panel.targets;\n\n /** Duplicate alias validation **/\n this.duplicates = false;\n\n this.measurements = _.filter(this.measurements, (measurement) => {\n return !measurement.hide;\n });\n\n _.each(this.measurements, (m) => {\n let res = _.filter(this.measurements, (measurement) => {\n return (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n });\n\n if (res.length > 1) {\n this.duplicates = true;\n }\n });\n }\n\n onInitEditMode() {\n this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n }\n\n setElementHeight() {\n this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\n }\n\n onRender() {\n this.setElementHeight();\n\n if (this.panel.clusterName) {\n this.panel.displayName =\n this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n .replace(new RegExp(this.panel.namePrefix, 'i'), '');\n } else {\n this.panel.displayName = \"\";\n }\n\n\n\n let targets = this.panel.targets;\n\n this.crit = [];\n this.warn = [];\n this.display = [];\n\n _.each(this.series, (s) => {\n let target = _.find(targets, (target) => {\n return target.alias == s.alias || target.target == s.alias;\n });\n\n if (!target) {\n return;\n }\n\n s.thresholds = StatusPluginCtrl.parseThresholds(target);\n s.inverted = s.thresholds.crit < s.thresholds.warn;\n s.display = target.display;\n s.alias = target.alias;\n s.url = target.url;\n\n let value;\n\n switch (target.aggregation) {\n case 'Max':\n value = s.stats.max;\n break;\n case 'Min':\n value = s.stats.min;\n break;\n case 'Sum':\n value = s.stats.total;\n break;\n case 'Avg':\n value = s.stats.avg;\n break;\n case 'First':\n value = s.datapoints[0][0];\n break;\n default:\n value = s.datapoints[s.datapoints.length - 1][0];\n }\n\n s.display_value = value;\n\n if (!s.inverted) {\n if (value >= s.thresholds.crit) {\n this.crit.push(s);\n } else if (value >= s.thresholds.warn) {\n this.warn.push(s);\n } else if (s.display) {\n this.display.push(s);\n }\n } else {\n if (value <= s.thresholds.crit) {\n this.crit.push(s);\n } else if (value <= s.thresholds.warn) {\n this.warn.push(s);\n } else if (s.display) {\n s.display_value = value;\n this.display.push(s);\n }\n }\n });\n\n this.$panelContainer.removeClass('error-state warn-state ok-state gray-state');\n\n if (this.crit.length > 0 || this.duplicates) {\n this.$panelContainer.addClass('error-state');\n } else if (this.warn.length > 0) {\n this.$panelContainer.addClass('warn-state');\n } else if(this.series.length == 0 && this.panel.isGrayColor) {\n this.$panelContainer.addClass('gray-state');\n } else {\n this.$panelContainer.addClass('ok-state');\n }\n\n this.parseUri();\n }\n\n parseUri() {\n if (this.panel.links && this.panel.links.length > 0) {\n this.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n } else {\n this.uri = undefined;\n }\n }\n\n static parseThresholds(measurement) {\n let res = {};\n\n res.warn = measurement.warn;\n res.crit = measurement.crit;\n\n return res;\n }\n\n onDataReceived(dataList) {\n this.series = dataList.map(this.seriesHandler.bind(this));\n\n this.render();\n }\n\n onDataError() {\n this.crit = [];\n this.warn = [];\n }\n\n seriesHandler(seriesData) {\n var series = new TimeSeries({\n datapoints: seriesData.datapoints,\n alias: seriesData.target\n });\n\n series.flotpairs = series.getFlotPairs(\"connected\");\n\n return series;\n }\n\n link(scope, elem, attrs, ctrl) {\n this.$panelContainer = elem.find('.panel-container');\n this.$panelContoller = ctrl;\n }\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file