From 1a13ad91e9a1884e41a7b8f090a621b22c0151ac Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 7 Feb 2017 17:22:56 +0300 Subject: [PATCH 1/5] add flipping text --- src/css/status_panel.scss | 72 +++++++++++++++++++++++++++++++++++++-- src/editor.html | 4 +++ src/module.html | 53 ++++++++++++++++------------ src/status_ctrl.js | 6 ++++ 4 files changed, 110 insertions(+), 25 deletions(-) diff --git a/src/css/status_panel.scss b/src/css/status_panel.scss index d7b82e3a..6cf83aca 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -4,28 +4,94 @@ width: 100%; & > div { - display: table-cell; - vertical-align: middle; - text-align: center; + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-size: 1.5rem } h1 { font-size: 1.5rem; } + + .ok-text, .warning-text, .fail-text, .gray-text{ + display: none; + font-size: 3.5rem; + } } .error-state { background-color: red; + .fail-text { + display: block; + } } .warn-state { background-color: orange; + .warning-text { + display: block; + } } .ok-state { background-color: green; + .ok-text { + display: block; + } } .gray-state { background-color: gray; + .gray-text { + display: block; + } +} + +.gray-state .st-card-back{ + display: none; +} + +.st-card { + position: relative; + text-align: center; +} + +.st-card-front, +.st-card-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.st-card-front, +.st-card-back { + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transition: -webkit-transform 0.5s; + transition: transform 0.5s; +} + +.st-card.effect-hover .st-card-back { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); +} + +.st-card.effect-hover:hover:not(.gray-state) .st-card-front { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } + +.st-card.effect-hover:hover:not(.gray-state) .st-card-back { + -webkit-transform: rotateY(0); + transform: rotateY(0); +} + +.st-card:not(.effect-hover):not(.gray-state) .st-card-front { + display: none; +} + + diff --git a/src/editor.html b/src/editor.html index d6a3386a..351b2249 100644 --- a/src/editor.html +++ b/src/editor.html @@ -22,6 +22,10 @@
{{ measurement.alias }}
+ diff --git a/src/module.html b/src/module.html index 16966592..de3550e9 100644 --- a/src/module.html +++ b/src/module.html @@ -1,32 +1,41 @@
-
- Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
+
ok
+
warning
+
critical
+
No data
+
+
+ Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
-
-

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

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

+

-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} -
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} +
+ {{ display.alias }} + {{ display.alias }} + - {{ display.display_value | number }} +
+
+ {{ crit.alias }} + {{ crit.alias }} + - {{ crit.display_value | number }} +
+
+ {{ warn.alias }} + {{ warn.alias }} + - {{ warn.display_value | number }} +
+
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 0fa860e2..3f3e1f3a 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -66,6 +66,11 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.panel.displayName = ""; } + if(this.panel.flipCard){ + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } let targets = this.panel.targets; @@ -185,6 +190,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { link(scope, elem, attrs, ctrl) { this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); this.$panelContoller = ctrl; } } From d3e3754309c0983886e61aa29481059137d0fcd8 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Fri, 10 Feb 2017 17:33:26 +0300 Subject: [PATCH 2/5] add flip interval for critical and warning state --- src/css/status_panel.scss | 4 ++-- src/editor.html | 6 +++++- src/status_ctrl.js | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/css/status_panel.scss b/src/css/status_panel.scss index 6cf83aca..50fc4403 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -80,12 +80,12 @@ transform: rotateY(-180deg); } -.st-card.effect-hover:hover:not(.gray-state) .st-card-front { +.st-card.effect-hover:hover:not(.gray-state) .st-card-front, .st-card.effect-hover.flipped:not(.gray-state) .st-card-front { -webkit-transform: rotateY(-180deg); transform: rotateY(-180deg); } -.st-card.effect-hover:hover:not(.gray-state) .st-card-back { +.st-card.effect-hover:hover:not(.gray-state) .st-card-back, .st-card.effect-hover.flipped:not(.gray-state) .st-card-back { -webkit-transform: rotateY(0); transform: rotateY(0); } diff --git a/src/editor.html b/src/editor.html index 351b2249..38072b09 100644 --- a/src/editor.html +++ b/src/editor.html @@ -25,7 +25,11 @@
{{ measurement.alias }}
+ on-change="ctrl.onRender()"> +
+ Flip interval + +
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 3f3e1f3a..86d87f55 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -17,6 +17,8 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.aggregations = ['None', 'Max', 'Min', 'Sum']; + this.panel.flipTime = this.panel.flipTime || 5; + /** Bind events to functions **/ this.events.on('render', this.onRender.bind(this)); this.events.on('refresh', this.postRefresh.bind(this)); @@ -140,12 +142,12 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } else if (this.warn.length > 0) { this.$panelContainer.addClass('warn-state'); } else if(this.display.length == 0) { - //this.$panelContainer.css('background-color', "gray"); this.$panelContainer.addClass('gray-state'); } else { this.$panelContainer.addClass('ok-state'); } + this.autoFlip(); this.parseUri(); } @@ -188,6 +190,19 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { return series; } + $onDestroy() { + if(this.timeoutId) clearInterval(this.timeoutId); + } + + autoFlip() { + if(this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(() => { + this.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } + link(scope, elem, attrs, ctrl) { this.$panelContainer = elem.find('.panel-container'); this.$panelContainer.addClass("st-card"); From 193fae056737cf301c43c0e13e49a9dfade39f73 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Fri, 10 Feb 2017 18:24:02 +0300 Subject: [PATCH 3/5] fix showing gray state if unchecked show value --- src/status_ctrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 86d87f55..9a244ac4 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -141,7 +141,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) { + } else if(this.series.length == 0) { this.$panelContainer.addClass('gray-state'); } else { this.$panelContainer.addClass('ok-state'); From 8681f887d81ffce57c41cffebf5ed9c873f56dad Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 14 Feb 2017 16:59:07 +0300 Subject: [PATCH 4/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 38072b09..593a1ba0 100644 --- a/src/editor.html +++ b/src/editor.html @@ -30,6 +30,10 @@
{{ measurement.alias }}
Flip interval + diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 9a244ac4..9de96953 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -141,7 +141,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 0bee93b776ba5bda30ee4ccddc7f7a9fff4cc961 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Thu, 2 Mar 2017 17:20:28 +0300 Subject: [PATCH 5/5] add dist folder --- dist/README.md | 5 +++ dist/css/status_panel.css | 59 +++++++++++++++++++++++++++++++++-- dist/css/status_panel.css.map | 2 +- dist/editor.html | 12 +++++++ dist/module.html | 53 ++++++++++++++++++------------- dist/module.js.map | 2 +- dist/status_ctrl.js | 31 +++++++++++++++++- dist/status_ctrl.js.map | 2 +- 8 files changed, 137 insertions(+), 29 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..b0af7fa4 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -3,19 +3,72 @@ position: relative; width: 100%; } .status-panel > div { - display: table-cell; - vertical-align: middle; - text-align: center; } + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-size: 1.5rem; } .status-panel h1 { font-size: 1.5rem; } + .status-panel .ok-text, .status-panel .warning-text, .status-panel .fail-text, .status-panel .gray-text { + display: none; + font-size: 3.5rem; } .error-state { background-color: red; } + .error-state .fail-text { + display: block; } .warn-state { background-color: orange; } + .warn-state .warning-text { + display: block; } .ok-state { background-color: green; } + .ok-state .ok-text { + display: block; } + +.gray-state { + background-color: gray; } + .gray-state .gray-text { + display: block; } + +.gray-state .st-card-back { + display: none; } + +.st-card { + position: relative; + text-align: center; } + +.st-card-front, +.st-card-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; } + +.st-card-front, +.st-card-back { + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transition: -webkit-transform 0.5s; + transition: transform 0.5s; } + +.st-card.effect-hover .st-card-back { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } + +.st-card.effect-hover:hover:not(.gray-state) .st-card-front, .st-card.effect-hover.flipped:not(.gray-state) .st-card-front { + -webkit-transform: rotateY(-180deg); + transform: rotateY(-180deg); } + +.st-card.effect-hover:hover:not(.gray-state) .st-card-back, .st-card.effect-hover.flipped:not(.gray-state) .st-card-back { + -webkit-transform: rotateY(0); + transform: rotateY(0); } + +.st-card:not(.effect-hover):not(.gray-state) .st-card-front { + display: none; } /*# sourceMappingURL=status_panel.css.map */ diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index aefc7fa7..22ccd1db 100644 --- a/dist/css/status_panel.css.map +++ b/dist/css/status_panel.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,aAAc;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,IAAI;IACb,SAAS,EAAE,aAAa;IACxB,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,MAAM;EAGnB,gBAAG;IACD,SAAS,EAAE,MAAM;EAGnB,uGAA+C;IAC7C,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,MAAM;;AAIrB,YAAa;EACX,gBAAgB,EAAE,GAAG;EACrB,uBAAW;IACT,OAAO,EAAE,KAAK;;AAIlB,WAAY;EACV,gBAAgB,EAAE,MAAM;EACxB,yBAAc;IACZ,OAAO,EAAE,KAAK;;AAIlB,SAAU;EACR,gBAAgB,EAAE,KAAK;EACvB,kBAAS;IACP,OAAO,EAAE,KAAK;;AAIlB,WAAY;EACV,gBAAgB,EAAE,IAAI;EACtB,sBAAW;IACT,OAAO,EAAE,KAAK;;AAIlB,yBAAyB;EACvB,OAAO,EAAE,IAAI;;AAGf,QAAS;EACP,QAAQ,EAAE,QAAQ;EAClB,UAAU,EAAE,MAAM;;AAGpB;aACc;EACZ,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;;AAGd;aACc;EACZ,2BAA2B,EAAE,MAAM;EACnC,mBAAmB,EAAE,MAAM;EAC3B,kBAAkB,EAAE,sBAAsB;EAC1C,UAAU,EAAE,cAAc;;AAG5B,mCAAoC;EAClC,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG7B,0HAA2H;EACzH,iBAAiB,EAAE,gBAAgB;EACnC,SAAS,EAAE,gBAAgB;;AAG7B,wHAAyH;EACvH,iBAAiB,EAAE,UAAU;EAC7B,SAAS,EAAE,UAAU;;AAGvB,2DAA4D;EAC1D,OAAO,EAAE,IAAI", "sources": ["../../src/css/status_panel.scss"], "names": [], "file": "status_panel.css" diff --git a/dist/editor.html b/dist/editor.html index d6a3386a..593a1ba0 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -22,6 +22,18 @@
{{ measurement.alias }}
+ +
+ Flip interval + +
+ diff --git a/dist/module.html b/dist/module.html index 16966592..de3550e9 100644 --- a/dist/module.html +++ b/dist/module.html @@ -1,32 +1,41 @@
-
- Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
+
ok
+
warning
+
critical
+
No data
+
+
+ Error: There are multiple measurements with the same alias. Please give each measurement a unique name. +
-
-

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

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

+

-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} -
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} +
+ {{ display.alias }} + {{ display.alias }} + - {{ display.display_value | number }} +
+
+ {{ crit.alias }} + {{ crit.alias }} + - {{ crit.display_value | number }} +
+
+ {{ warn.alias }} + {{ warn.alias }} + - {{ warn.display_value | number }} +
+
diff --git a/dist/module.js.map b/dist/module.js.map index 962a6d1c..b8a3058f 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';\n\nexport {\n StatusPluginCtrl as PanelCtrl\n};\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';\r\n\r\nexport {\r\n StatusPluginCtrl as PanelCtrl\r\n};\r\n"]} \ No newline at end of file diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 7e03fc2c..12deaeda 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -78,6 +78,8 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi _this.aggregations = ['None', 'Max', 'Min', 'Sum']; + _this.panel.flipTime = _this.panel.flipTime || 5; + /** Bind events to functions **/ _this.events.on('render', _this.onRender.bind(_this)); _this.events.on('refresh', _this.postRefresh.bind(_this)); @@ -135,6 +137,12 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi this.panel.displayName = ""; } + if (this.panel.flipCard) { + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } + var targets = this.panel.targets; this.crit = []; @@ -201,16 +209,19 @@ 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'); } + this.autoFlip(); this.parseUri(); } }, { @@ -247,10 +258,28 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi return series; } + }, { + key: "$onDestroy", + value: function $onDestroy() { + if (this.timeoutId) clearInterval(this.timeoutId); + } + }, { + key: "autoFlip", + value: function autoFlip() { + var _this4 = this; + + if (this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(function () { + _this4.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } }, { key: "link", value: function link(scope, elem, attrs, ctrl) { this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); this.$panelContoller = ctrl; } }], [{ diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 16e385ea..b2495217 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","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,IAAjB,OAA7B;AACA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OC,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","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","display","series","s","thresholds","parseThresholds","inverted","url","value","aggregation","max","datapoints","point","min","display_value","push","isGrayColor","autoFlip","parseUri","links","uri","dashUri","params","undefined","dataList","map","seriesHandler","render","seriesData","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,sB,kBAAAA,gB;;AAGDC,O;;AACAC,gB;;AACAC,gB;;;;;;;;;;;;;;;;;;;;;kCAIMC,gB;;;AACX;AACA,kCAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;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,WAArB,CAAiC,SAAjC;AACD,eAFgB,EAEd,KAAKrE,KAAL,CAAWC,QAAX,GAAsB,IAFR,CAAjB;AAGD;AACF;;;+BAEIqE,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC7B,iBAAKnD,eAAL,GAAuBiD,KAAKhD,IAAL,CAAU,kBAAV,CAAvB;AACA,iBAAKD,eAAL,CAAqBY,QAArB,CAA8B,SAA9B;AACA,iBAAKT,eAAL,GAAuBgD,IAAvB;AACD;;;0CAhDsB5D,W,EAAa;AAClC,gBAAII,MAAM,EAAV;;AAEAA,gBAAIoB,IAAJ,GAAWxB,YAAYwB,IAAvB;AACApB,gBAAImB,IAAJ,GAAWvB,YAAYuB,IAAvB;;AAEA,mBAAOnB,GAAP;AACD;;;;QA/JmC7B,gB;;;;AA2MtCI,uBAAiBkF,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\r\nimport \"app/plugins/panel/graph/legend\";\r\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\r\nimport _ from \"lodash\";\r\nimport TimeSeries from \"app/core/time_series2\";\r\nimport coreModule from \"app/core/core_module\"\r\n\r\nimport './css/status_panel.css!';\r\n\r\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\r\n /** @ngInject */\r\n constructor($scope, $injector, $log, $filter, annotationsSrv) {\r\n super($scope, $injector);\r\n\r\n //this.log = $log.debug;\r\n this.filter = $filter;\r\n\r\n this.aggregations = ['None', 'Max', 'Min', 'Sum'];\r\n\r\n this.panel.flipTime = this.panel.flipTime || 5;\r\n\r\n /** Bind events to functions **/\r\n this.events.on('render', this.onRender.bind(this));\r\n this.events.on('refresh', this.postRefresh.bind(this));\r\n this.events.on('data-error', this.onDataError.bind(this));\r\n this.events.on('data-received', this.onDataReceived.bind(this));\r\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\r\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\r\n }\r\n\r\n postRefresh() {\r\n this.measurements = this.panel.targets;\r\n\r\n /** Duplicate alias validation **/\r\n this.duplicates = false;\r\n\r\n this.measurements = _.filter(this.measurements, (measurement) => {\r\n return !measurement.hide;\r\n });\r\n\r\n _.each(this.measurements, (m) => {\r\n let res = _.filter(this.measurements, (measurement) => {\r\n return (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\r\n });\r\n\r\n if (res.length > 1) {\r\n this.duplicates = true;\r\n }\r\n });\r\n }\r\n\r\n onInitEditMode() {\r\n this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\r\n }\r\n\r\n setElementHeight() {\r\n this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\r\n }\r\n\r\n onRender() {\r\n this.setElementHeight();\r\n\r\n if (this.panel.clusterName) {\r\n this.panel.displayName =\r\n this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\r\n .replace(new RegExp(this.panel.namePrefix, 'i'), '');\r\n } else {\r\n this.panel.displayName = \"\";\r\n }\r\n\r\n if(this.panel.flipCard){\r\n this.$panelContainer.addClass(\"effect-hover\");\r\n } else {\r\n this.$panelContainer.removeClass(\"effect-hover\");\r\n }\r\n\r\n\r\n let targets = this.panel.targets;\r\n\r\n this.crit = [];\r\n this.warn = [];\r\n this.display = [];\r\n\r\n _.each(this.series, (s) => {\r\n let target = _.find(targets, (target) => {\r\n return target.alias == s.alias || target.target == s.alias;\r\n });\r\n\r\n if (!target) {\r\n return;\r\n }\r\n\r\n s.thresholds = StatusPluginCtrl.parseThresholds(target);\r\n s.inverted = s.thresholds.crit < s.thresholds.warn;\r\n s.display = target.display;\r\n s.alias = target.alias;\r\n s.url = target.url;\r\n\r\n let value;\r\n\r\n switch (target.aggregation) {\r\n case 'Max':\r\n value = _.max(s.datapoints, (point) => { return point[0]; })[0];\r\n break;\r\n case 'Min':\r\n value = _.min(s.datapoints, (point) => { return point[0]; })[0];\r\n break;\r\n case 'Sum':\r\n value = 0;\r\n _.each(s.datapoints, (point) => { value += point[0] });\r\n break;\r\n default:\r\n value = s.datapoints[0][0];\r\n }\r\n\r\n s.display_value = value;\r\n\r\n if (!s.inverted) {\r\n if (value >= s.thresholds.crit) {\r\n this.crit.push(s);\r\n } else if (value >= s.thresholds.warn) {\r\n this.warn.push(s);\r\n } else if (s.display) {\r\n this.display.push(s);\r\n }\r\n } else {\r\n if (value <= s.thresholds.crit) {\r\n this.crit.push(s);\r\n } else if (value <= s.thresholds.warn) {\r\n this.warn.push(s);\r\n } else if (s.display) {\r\n s.display_value = value;\r\n this.display.push(s);\r\n }\r\n }\r\n });\r\n\r\n this.$panelContainer.removeClass('error-state warn-state ok-state gray-state');\r\n\r\n if (this.crit.length > 0 || this.duplicates) {\r\n this.$panelContainer.addClass('error-state');\r\n } else if (this.warn.length > 0) {\r\n this.$panelContainer.addClass('warn-state');\r\n } else if(this.series.length == 0 && this.panel.isGrayColor) {\r\n this.$panelContainer.addClass('gray-state');\r\n } else {\r\n this.$panelContainer.addClass('ok-state');\r\n }\r\n\r\n this.autoFlip();\r\n this.parseUri();\r\n }\r\n\r\n parseUri() {\r\n if (this.panel.links && this.panel.links.length > 0) {\r\n this.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\r\n } else {\r\n this.uri = undefined;\r\n }\r\n }\r\n\r\n static parseThresholds(measurement) {\r\n let res = {};\r\n\r\n res.warn = measurement.warn;\r\n res.crit = measurement.crit;\r\n\r\n return res;\r\n }\r\n\r\n onDataReceived(dataList) {\r\n this.series = dataList.map(this.seriesHandler.bind(this));\r\n\r\n this.render();\r\n }\r\n\r\n onDataError() {\r\n this.crit = [];\r\n this.warn = [];\r\n }\r\n\r\n seriesHandler(seriesData) {\r\n var series = new TimeSeries({\r\n datapoints: seriesData.datapoints,\r\n alias: seriesData.target\r\n });\r\n\r\n //series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\r\n\r\n return series;\r\n }\r\n\r\n $onDestroy() {\r\n if(this.timeoutId) clearInterval(this.timeoutId);\r\n }\r\n\r\n autoFlip() {\r\n if(this.timeoutId) clearInterval(this.timeoutId);\r\n if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) {\r\n this.timeoutId = setInterval(() => {\r\n this.$panelContainer.toggleClass(\"flipped\");\r\n }, this.panel.flipTime * 1000);\r\n }\r\n }\r\n\r\n link(scope, elem, attrs, ctrl) {\r\n this.$panelContainer = elem.find('.panel-container');\r\n this.$panelContainer.addClass(\"st-card\");\r\n this.$panelContoller = ctrl;\r\n }\r\n}\r\n\r\nStatusPluginCtrl.templateUrl = 'module.html';\r\n"]} \ No newline at end of file