From 1a13ad91e9a1884e41a7b8f090a621b22c0151ac Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Tue, 7 Feb 2017 17:22:56 +0300 Subject: [PATCH 1/7] 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/7] 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/7] 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/7] "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/7] 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 From eecf7814c7197ac638d2e156e4ad787967e43936 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Wed, 22 Mar 2017 18:41:44 +0300 Subject: [PATCH 6/7] merge --- dist/module.js.map | 2 +- dist/status_ctrl.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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.map b/dist/status_ctrl.js.map index e269551a..015a1f30 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","displayTypes","aggregations","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","panel","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","display","disabled","annotation","series","s","url","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","displayType","handleThresholdStatus","handleDisabledStatus","handleAnnotations","handle_css_display","parseUri","thresholds","parseThresholds","inverted","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","scope","elem","attrs","ctrl","metricOptions","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;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,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC,KAAhC,EAAuC,KAAvC,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,EA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,EAAU;AACxB,WAAKhC,MAAL,GAAcgC,SAASC,GAAT,CAAa,KAAKC,aAAL,CAAmBtE,IAAnB,CAAwB,IAAxB,CAAb,CAAd;;AAEA,WAAKuE,MAAL;AACA;;;mCAEa;AACb,WAAKxC,IAAL,GAAY,EAAZ;AACA,WAAKC,IAAL,GAAY,EAAZ;AACA;;;mCAEawC,U,EAAY;AACzB,UAAIpC,SAAS,IAAIlD,UAAJ,CAAe;AAC3BwD,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;;;;KAtMoC/B,gB;;;;AAoOtCI,oBAAiB4F,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\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\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","displayTypes","aggregations","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","panel","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","crit","warn","display","disabled","annotation","series","s","url","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","displayType","handleThresholdStatus","handleDisabledStatus","handleAnnotations","handle_css_display","parseUri","thresholds","parseThresholds","inverted","push","disabledValue","removeClass","addClass","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","scope","elem","attrs","ctrl","metricOptions","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EA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c/C,IAAzB;AACAjB,UAAIgB,IAAJ,GAAWgD,cAAchD,IAAzB;;AAEA,aAAOhB,GAAP;AACA;;;;KAtMoC/B,gB;;;;AAoOtCI,oBAAiB4F,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\r\nimport \"app/plugins/panel/graph/legend\";\r\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\r\nimport _ from \"lodash\";\r\nimport TimeSeries from \"app/core/time_series2\";\r\nimport coreModule from \"app/core/core_module\"\r\n\r\nimport './css/status_panel.css!';\r\n\r\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\r\n\t/** @ngInject */\r\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\r\n\t\tsuper($scope, $injector);\r\n\r\n\t\t//this.log = $log.debug;\r\n\t\tthis.filter = $filter;\r\n\r\n\t\tthis.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation'];\r\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\r\n\r\n\t\t/** Bind events to functions **/\r\n\t\tthis.events.on('render', this.onRender.bind(this));\r\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\r\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\r\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\r\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\r\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\r\n\t}\r\n\r\n\tpostRefresh() {\r\n\t\tif (this.panel.fixedSpan) {\r\n\t\t\tthis.panel.span = this.panel.fixedSpan;\r\n\t\t}\r\n\r\n\t\tthis.measurements = this.panel.targets;\r\n\r\n\t\t/** Duplicate alias validation **/\r\n\t\tthis.duplicates = false;\r\n\r\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\r\n\t\t\treturn !measurement.hide;\r\n\t\t});\r\n\r\n\t\t_.each(this.measurements, (m) => {\r\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\r\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\r\n\t\t\t});\r\n\r\n\t\t\tif (res.length > 1) {\r\n\t\t\t\tthis.duplicates = true;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tonInitEditMode() {\r\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\r\n\t}\r\n\r\n\tsetElementHeight() {\r\n\t\tthis.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\r\n\t}\r\n\r\n\tonRender() {\r\n\t\tthis.setElementHeight();\r\n\r\n\t\tif (this.panel.clusterName) {\r\n\t\t\tthis.panel.displayName =\r\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\r\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\r\n\t\t} else {\r\n\t\t\tthis.panel.displayName = \"\";\r\n\t\t}\r\n\r\n\r\n\r\n\t\tlet targets = this.panel.targets;\r\n\r\n\t\tthis.crit = [];\r\n\t\tthis.warn = [];\r\n\t\tthis.display = [];\r\n\t\tthis.disabled = [];\r\n\t\tthis.annotation = [];\r\n\r\n\t\t_.each(this.series, (s) => {\r\n\t\t\tlet target = _.find(targets, (target) => {\r\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\r\n\t\t\t});\r\n\r\n\t\t\tif (!target) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\ts.alias = target.alias;\r\n\t\t\ts.url = target.url;\r\n\r\n\t\t\tlet value;\r\n\t\t\tswitch (target.aggregation) {\r\n\t\t\t\tcase 'Max':\r\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\r\n\t\t\t\t\tvalue = s.stats.max;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Min':\r\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\r\n\t\t\t\t\tvalue = s.stats.min;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Sum':\r\n\t\t\t\t\tvalue = 0;\r\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\r\n\t\t\t\t\tvalue = s.stats.total;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'Avg':\r\n\t\t\t\t\tvalue = s.stats.avg;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'First':\r\n\t\t\t\t\tvalue = s.datapoints[0][0];\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\r\n\t\t\t}\r\n\r\n\t\t\ts.display_value = value;\r\n\r\n\t\t\tif (target.displayType == \"Threshold\") {\r\n\t\t\t\tthis.handleThresholdStatus(s, target);\r\n\t\t\t}\r\n\t\t\telse if (target.displayType == \"Disable Criteria\") {\r\n\t\t\t\tthis.handleDisabledStatus(s,target);\r\n\t\t\t}\r\n\t\t\telse if (target.displayType == \"Annotation\") {\r\n\t\t\t\tthis.handleAnnotations(s, target);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.handle_css_display();\r\n\t\tthis.parseUri();\r\n\t}\r\n\r\n\thandleThresholdStatus(series, target) {\r\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\r\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\r\n\t\tseries.display = target.display;\r\n\r\n\t\tif (!series.inverted) {\r\n\t\t\tif (series.display_value >= series.thresholds.crit) {\r\n\t\t\t\tthis.crit.push(series);\r\n\t\t\t} else if (series.display_value >= series.thresholds.warn) {\r\n\t\t\t\tthis.warn.push(series);\r\n\t\t\t} else if (series.display) {\r\n\t\t\t\tthis.display.push(series);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (series.display_value <= series.thresholds.crit) {\r\n\t\t\t\tthis.crit.push(series);\r\n\t\t\t} else if (series.display_value <= series.thresholds.warn) {\r\n\t\t\t\tthis.warn.push(series);\r\n\t\t\t} else if (series.display) {\r\n\t\t\t\tthis.display.push(series);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\thandleDisabledStatus(series, target) {\r\n\r\n\t\tseries.disabledValue = target.disabledValue;\r\n\r\n\t\tif (series.display_value == series.disabledValue) {\r\n\t\t\tthis.disabled.push(series);\r\n\t\t}\r\n\t}\r\n\r\n\thandleAnnotations(series, target) {\r\n\t\tthis.annotation.push(series);\r\n\t}\r\n\r\n\thandle_css_display() {\r\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\r\n\r\n\t\tif(this.duplicates) {\r\n\t\t\tthis.$panelContainer.addClass('error-state');\r\n\t\t} else if (this.disabled.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('disabled-state');\r\n\t\t} else if (this.crit.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('error-state');\r\n\t\t} else if (this.warn.length > 0) {\r\n\t\t\tthis.$panelContainer.addClass('warn-state');\r\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\r\n\t\t\tthis.$panelContainer.addClass('no-data-state');\r\n\t\t} else {\r\n\t\t\tthis.$panelContainer.addClass('ok-state');\r\n\t\t}\r\n\t}\r\n\r\n\tparseUri() {\r\n\t\tif (this.panel.links && this.panel.links.length > 0) {\r\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\r\n\t\t} else {\r\n\t\t\tthis.uri = undefined;\r\n\t\t}\r\n\t}\r\n\r\n\tstatic parseThresholds(metricOptions) {\r\n\t\tlet res = {};\r\n\r\n\t\tres.warn = metricOptions.warn;\r\n\t\tres.crit = metricOptions.crit;\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\tonDataReceived(dataList) {\r\n\t\tthis.series = dataList.map(this.seriesHandler.bind(this));\r\n\r\n\t\tthis.render();\r\n\t}\r\n\r\n\tonDataError() {\r\n\t\tthis.crit = [];\r\n\t\tthis.warn = [];\r\n\t}\r\n\r\n\tseriesHandler(seriesData) {\r\n\t\tvar series = new TimeSeries({\r\n\t\t\tdatapoints: seriesData.datapoints,\r\n\t\t\talias: seriesData.target\r\n\t\t});\r\n\r\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\r\n\r\n\t\treturn series;\r\n\t}\r\n\r\n\tlink(scope, elem, attrs, ctrl) {\r\n\t\tthis.$panelContainer = elem.find('.panel-container');\r\n\t\tthis.$panelContoller = ctrl;\r\n\t}\r\n}\r\n\r\nStatusPluginCtrl.templateUrl = 'module.html';\r\n"]} \ No newline at end of file From 4ac1c80872591f29af00224a258bec0cfeb2d7c6 Mon Sep 17 00:00:00 2001 From: Senkevich Alexsandr Date: Thu, 23 Mar 2017 13:19:48 +0300 Subject: [PATCH 7/7] Merge branch 'add-text-flipping' of https://github.com/LLIyRiK/Grafana_Status_panel into add-text-flipping # Conflicts: # dist/css/status_panel.css # dist/css/status_panel.css.map # dist/editor.html # dist/module.html # dist/status_ctrl.js # dist/status_ctrl.js.map # src/css/status_panel.scss # src/editor.html # src/module.html # src/status_ctrl.js --- dist/css/status_panel.css | 11 +- dist/css/status_panel.css.map | 2 +- dist/editor.html | 118 ++++-- dist/module.html | 68 ++-- dist/status_ctrl.js | 650 ++++++++++++++++++---------------- dist/status_ctrl.js.map | 2 +- src/css/status_panel.scss | 64 ++-- src/module.html | 1 + src/status_ctrl.js | 66 ++-- 9 files changed, 557 insertions(+), 425 deletions(-) diff --git a/dist/css/status_panel.css b/dist/css/status_panel.css index 071e8e87..c3a26f32 100644 --- a/dist/css/status_panel.css +++ b/dist/css/status_panel.css @@ -10,6 +10,12 @@ font-size: 1.5rem; } .status-panel h1 { font-size: 1.5rem; } + .status-panel .status-panel-annotation_row { + position: absolute; + top: 0; + 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 { display: none; font-size: 3.5rem; } @@ -71,7 +77,10 @@ .st-card:not(.effect-hover):not(.gray-state) .st-card-front { display: none; } -.gray-state { +.no-data-state { + background-color: gray; } + +.disabled-state { background-color: gray; } /*# sourceMappingURL=status_panel.css.map */ diff --git a/dist/css/status_panel.css.map b/dist/css/status_panel.css.map index 22ccd1db..d0825526 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,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,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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;;AAIf,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 cb38708d..0b8b2d30 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -1,9 +1,9 @@
- Note: Every measurement 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 measurements with the same alias. Please give each measurement a unique name. + Error: There are multiple metrics with the same alias. Please give each metric a unique name.
@@ -32,21 +32,28 @@
{{ measurement.alias }}
-
-
{{ measurement.alias }} Thresholds
-
-
Thresholds for measurement: {{ measurement.refId }}
-
Please enter an alias for this measurement bellow
-
+ +
{{ measurement.alias }}
+
+
Metric: {{ measurement.refId }}
+
Please enter an alias for this measurement bellow
+
+ +
+
Display Settings
+ +
Alias @@ -54,53 +61,106 @@
Thresholds for measurement: {{ measurement.refId }}<
+
- Warning + Aggregation + + What to do if the query returns multiple data points. + - +
+ +
+
- Critical + 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
+
- Aggregation + Status Type - What to do if the query returns multiple data points. + 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
+ + +
- Measurement URL - - Make the name of the measurement clickable, and send the user to a link (with explanations what to do when this error occurs) - + 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 de3550e9..84508cef 100644 --- a/dist/module.html +++ b/dist/module.html @@ -10,32 +10,48 @@ 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 }} - -

+
+
+ {{ annoation.alias }} + {{ annoation.alias }} + - {{ annoation.display_value }} +
+
-
- {{ display.alias }} - {{ display.alias }} - - {{ display.display_value | number }} -
-
- {{ crit.alias }} - {{ crit.alias }} - - {{ crit.display_value | number }} -
-
- {{ warn.alias }} - {{ warn.alias }} - - {{ warn.display_value | number }} -
-
-
+
+

+ + {{ 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 }} +
+ +
+ {{ disabled.alias }} + {{ disabled.alias }} +
+
+ diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index d9bb63e5..6fbea6fa 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -1,305 +1,355 @@ "use strict"; System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugins/panel/graph/series_overrides_ctrl", "lodash", "app/core/time_series2", "app/core/core_module", "./css/status_panel.css!"], function (_export, _context) { - "use strict"; - - var MetricsPanelCtrl, _, TimeSeries, coreModule, _createClass, StatusPluginCtrl; - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - return { - setters: [function (_appPluginsSdk) { - MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; - }, function (_appPluginsPanelGraphLegend) {}, function (_appPluginsPanelGraphSeries_overrides_ctrl) {}, function (_lodash) { - _ = _lodash.default; - }, function (_appCoreTime_series) { - TimeSeries = _appCoreTime_series.default; - }, function (_appCoreCore_module) { - coreModule = _appCoreCore_module.default; - }, function (_cssStatus_panelCss) {}], - execute: function () { - _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; - }(); - - _export("StatusPluginCtrl", StatusPluginCtrl = function (_MetricsPanelCtrl) { - _inherits(StatusPluginCtrl, _MetricsPanelCtrl); - - /** @ngInject */ - function StatusPluginCtrl($scope, $injector, $log, $filter, annotationsSrv) { - _classCallCheck(this, StatusPluginCtrl); - - var _this = _possibleConstructorReturn(this, (StatusPluginCtrl.__proto__ || Object.getPrototypeOf(StatusPluginCtrl)).call(this, $scope, $injector)); - - //this.log = $log.debug; - _this.filter = $filter; - - _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - - _this.panel.flipTime = _this.panel.flipTime || 5; - - /** Bind events to functions **/ - _this.events.on('render', _this.onRender.bind(_this)); - _this.events.on('refresh', _this.postRefresh.bind(_this)); - _this.events.on('data-error', _this.onDataError.bind(_this)); - _this.events.on('data-received', _this.onDataReceived.bind(_this)); - _this.events.on('data-snapshot-load', _this.onDataReceived.bind(_this)); - _this.events.on('init-edit-mode', _this.onInitEditMode.bind(_this)); - return _this; - } - - _createClass(StatusPluginCtrl, [{ - key: "postRefresh", - value: function postRefresh() { - var _this2 = this; - - this.measurements = this.panel.targets; - - /** Duplicate alias validation **/ - this.duplicates = false; - - this.measurements = _.filter(this.measurements, function (measurement) { - return !measurement.hide; - }); - - _.each(this.measurements, function (m) { - var res = _.filter(_this2.measurements, function (measurement) { - return (m.alias == measurement.alias || m.target == measurement.target && m.target) && !m.hide; - }); - - if (res.length > 1) { - _this2.duplicates = true; - } - }); - } - }, { - key: "onInitEditMode", - value: function onInitEditMode() { - this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2); - } - }, { - key: "setElementHeight", - value: function setElementHeight() { - this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); - } - }, { - key: "onRender", - value: function onRender() { - var _this3 = this; - - this.setElementHeight(); - - if (this.panel.clusterName) { - this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); - } else { - this.panel.displayName = ""; - } - - if (this.panel.flipCard) { - this.$panelContainer.addClass("effect-hover"); - } else { - this.$panelContainer.removeClass("effect-hover"); - } - - var targets = this.panel.targets; - - this.crit = []; - this.warn = []; - this.display = []; - - _.each(this.series, function (s) { - var target = _.find(targets, function (target) { - return target.alias == s.alias || target.target == s.alias; - }); - - if (!target) { - return; - } - - s.thresholds = StatusPluginCtrl.parseThresholds(target); - s.inverted = s.thresholds.crit < s.thresholds.warn; - s.display = target.display; - s.alias = target.alias; - s.url = target.url; - - var value = void 0; - - switch (target.aggregation) { - case 'Max': - value = s.stats.max; - break; - case 'Min': - value = s.stats.min; - break; - case 'Sum': - value = s.stats.total; - break; - case 'Avg': - value = s.stats.avg; - break; - case 'First': - value = s.datapoints[0][0]; - break; - default: - value = s.datapoints[s.datapoints.length - 1][0]; - } - - s.display_value = value; - - if (!s.inverted) { - if (value >= s.thresholds.crit) { - _this3.crit.push(s); - } else if (value >= s.thresholds.warn) { - _this3.warn.push(s); - } else if (s.display) { - _this3.display.push(s); - } - } else { - if (value <= s.thresholds.crit) { - _this3.crit.push(s); - } else if (value <= s.thresholds.warn) { - _this3.warn.push(s); - } else if (s.display) { - s.display_value = value; - _this3.display.push(s); - } - } - }); - - this.$panelContainer.removeClass('error-state warn-state ok-state gray-state'); - - if (this.crit.length > 0 || this.duplicates) { - this.$panelContainer.addClass('error-state'); - } else if (this.warn.length > 0) { - this.$panelContainer.addClass('warn-state'); - } else if (this.series.length == 0 && this.panel.isGrayColor) { - this.$panelContainer.addClass('gray-state'); - } else { - this.$panelContainer.addClass('ok-state'); - } - - this.autoFlip(); - this.parseUri(); - } - }, { - key: "parseUri", - value: function parseUri() { - if (this.panel.links && this.panel.links.length > 0) { - this.uri = this.panel.links[0].dashUri + "?" + this.panel.links[0].params; - } else { - this.uri = undefined; - } - } - }, { - key: "onDataReceived", - value: function onDataReceived(dataList) { - this.series = dataList.map(this.seriesHandler.bind(this)); - - this.render(); - } - }, { - key: "onDataError", - value: function onDataError() { - this.crit = []; - this.warn = []; - } - }, { - key: "seriesHandler", - value: function seriesHandler(seriesData) { - var series = new TimeSeries({ - datapoints: seriesData.datapoints, - alias: seriesData.target - }); - - series.flotpairs = series.getFlotPairs("connected"); - - return series; - } - }, { - key: "$onDestroy", - value: function $onDestroy() { - if (this.timeoutId) clearInterval(this.timeoutId); - } - }, { - key: "autoFlip", - value: function autoFlip() { - var _this4 = this; - - if (this.timeoutId) clearInterval(this.timeoutId); - if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { - this.timeoutId = setInterval(function () { - _this4.$panelContainer.toggleClass("flipped"); - }, this.panel.flipTime * 1000); - } - } - }, { - key: "link", - value: function link(scope, elem, attrs, ctrl) { - this.$panelContainer = elem.find('.panel-container'); - this.$panelContainer.addClass("st-card"); - this.$panelContoller = ctrl; - } - }], [{ - key: "parseThresholds", - value: function parseThresholds(measurement) { - var res = {}; - - res.warn = measurement.warn; - res.crit = measurement.crit; - - return res; - } - }]); - - return StatusPluginCtrl; - }(MetricsPanelCtrl)); - - _export("StatusPluginCtrl", StatusPluginCtrl); - - StatusPluginCtrl.templateUrl = 'module.html'; - } - }; + "use strict"; + + var MetricsPanelCtrl, _, TimeSeries, coreModule, _createClass, StatusPluginCtrl; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + return { + setters: [function (_appPluginsSdk) { + MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; + }, function (_appPluginsPanelGraphLegend) {}, function (_appPluginsPanelGraphSeries_overrides_ctrl) {}, function (_lodash) { + _ = _lodash.default; + }, function (_appCoreTime_series) { + TimeSeries = _appCoreTime_series.default; + }, function (_appCoreCore_module) { + coreModule = _appCoreCore_module.default; + }, function (_cssStatus_panelCss) {}], + execute: function () { + _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + _export("StatusPluginCtrl", StatusPluginCtrl = function (_MetricsPanelCtrl) { + _inherits(StatusPluginCtrl, _MetricsPanelCtrl); + + /** @ngInject */ + function StatusPluginCtrl($scope, $injector, $log, $filter, annotationsSrv) { + _classCallCheck(this, StatusPluginCtrl); + + var _this = _possibleConstructorReturn(this, (StatusPluginCtrl.__proto__ || Object.getPrototypeOf(StatusPluginCtrl)).call(this, $scope, $injector)); + + //this.log = $log.debug; + _this.filter = $filter; + + _this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; + _this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; + + _this.panel.flipTime = _this.panel.flipTime || 5; + + /** Bind events to functions **/ + _this.events.on('render', _this.onRender.bind(_this)); + _this.events.on('refresh', _this.postRefresh.bind(_this)); + _this.events.on('data-error', _this.onDataError.bind(_this)); + _this.events.on('data-received', _this.onDataReceived.bind(_this)); + _this.events.on('data-snapshot-load', _this.onDataReceived.bind(_this)); + _this.events.on('init-edit-mode', _this.onInitEditMode.bind(_this)); + return _this; + } + + _createClass(StatusPluginCtrl, [{ + key: "postRefresh", + value: function postRefresh() { + var _this2 = this; + + if (this.panel.fixedSpan) { + this.panel.span = this.panel.fixedSpan; + } + + this.measurements = this.panel.targets; + + /** Duplicate alias validation **/ + this.duplicates = false; + + this.measurements = _.filter(this.measurements, function (measurement) { + return !measurement.hide; + }); + + _.each(this.measurements, function (m) { + var res = _.filter(_this2.measurements, function (measurement) { + return (m.alias == measurement.alias || m.target == measurement.target && m.target) && !m.hide; + }); + + if (res.length > 1) { + _this2.duplicates = true; + } + }); + } + }, { + key: "onInitEditMode", + value: function onInitEditMode() { + this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2); + } + }, { + key: "setElementHeight", + value: function setElementHeight() { + this.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px'); + } + }, { + key: "onRender", + value: function onRender() { + var _this3 = this; + + this.setElementHeight(); + + if (this.panel.clusterName) { + this.panel.displayName = this.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope).replace(new RegExp(this.panel.namePrefix, 'i'), ''); + } else { + this.panel.displayName = ""; + } + + if (this.panel.flipCard) { + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } + + var targets = this.panel.targets; + + this.crit = []; + this.warn = []; + this.display = []; + this.disabled = []; + this.annotation = []; + + _.each(this.series, function (s) { + var target = _.find(targets, function (target) { + return target.alias == s.alias || target.target == s.alias; + }); + + if (!target) { + return; + } + + s.alias = target.alias; + s.url = target.url; + + var value = void 0; + switch (target.aggregation) { + case 'Max': + value = _.max(s.datapoints, function (point) { + return point[0]; + })[0]; + value = s.stats.max; + break; + case 'Min': + value = _.min(s.datapoints, function (point) { + return point[0]; + })[0]; + value = s.stats.min; + break; + case 'Sum': + value = 0; + _.each(s.datapoints, function (point) { + value += point[0]; + }); + value = s.stats.total; + break; + case 'Avg': + value = s.stats.avg; + break; + case 'First': + value = s.datapoints[0][0]; + break; + default: + value = s.datapoints[s.datapoints.length - 1][0]; + } + + s.display_value = value; + + if (target.displayType == "Threshold") { + _this3.handleThresholdStatus(s, target); + } else if (target.displayType == "Disable Criteria") { + _this3.handleDisabledStatus(s, target); + } else if (target.displayType == "Annotation") { + _this3.handleAnnotations(s, target); + } + }); + + this.autoFlip(); + this.handle_css_display(); + this.parseUri(); + } + }, { + key: "handleThresholdStatus", + value: function handleThresholdStatus(series, target) { + series.thresholds = StatusPluginCtrl.parseThresholds(target); + series.inverted = series.thresholds.crit < series.thresholds.warn; + series.display = target.display; + + if (!series.inverted) { + if (series.display_value >= series.thresholds.crit) { + this.crit.push(series); + } else if (series.display_value >= series.thresholds.warn) { + this.warn.push(series); + } else if (series.display) { + this.display.push(series); + } + } else { + if (series.display_value <= series.thresholds.crit) { + this.crit.push(series); + } else if (series.display_value <= series.thresholds.warn) { + this.warn.push(series); + } else if (series.display) { + this.display.push(series); + } + } + } + }, { + key: "handleDisabledStatus", + value: function handleDisabledStatus(series, target) { + + series.disabledValue = target.disabledValue; + + if (series.display_value == series.disabledValue) { + this.disabled.push(series); + } + } + }, { + key: "handleAnnotations", + value: function handleAnnotations(series, target) { + this.annotation.push(series); + } + }, { + key: "handle_css_display", + value: function handle_css_display() { + this.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state'); + + if (this.duplicates) { + this.$panelContainer.addClass('error-state'); + } else if (this.disabled.length > 0) { + this.$panelContainer.addClass('disabled-state'); + } else if (this.crit.length > 0) { + this.$panelContainer.addClass('error-state'); + } else if (this.warn.length > 0) { + this.$panelContainer.addClass('warn-state'); + } else if ((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) { + this.$panelContainer.addClass('no-data-state'); + } else { + this.$panelContainer.addClass('ok-state'); + } + } + }, { + key: "parseUri", + value: function parseUri() { + if (this.panel.links && this.panel.links.length > 0) { + this.uri = this.panel.links[0].dashUri + "?" + this.panel.links[0].params; + } else { + this.uri = undefined; + } + } + }, { + key: "onDataReceived", + value: function onDataReceived(dataList) { + this.series = dataList.map(this.seriesHandler.bind(this)); + + this.render(); + } + }, { + key: "onDataError", + value: function onDataError() { + this.crit = []; + this.warn = []; + } + }, { + key: "seriesHandler", + value: function seriesHandler(seriesData) { + var series = new TimeSeries({ + datapoints: seriesData.datapoints, + alias: seriesData.target + }); + + series.flotpairs = series.getFlotPairs("connected"); + + return series; + } + }, { + key: "$onDestroy", + value: function $onDestroy() { + if (this.timeoutId) clearInterval(this.timeoutId); + } + }, { + key: "autoFlip", + value: function autoFlip() { + var _this4 = this; + + if (this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(function () { + _this4.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } + }, { + key: "link", + value: function link(scope, elem, attrs, ctrl) { + this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); + this.$panelContoller = ctrl; + } + }], [{ + key: "parseThresholds", + value: function parseThresholds(metricOptions) { + var res = {}; + + res.warn = metricOptions.warn; + res.crit = metricOptions.crit; + + return res; + } + }]); + + return StatusPluginCtrl; + }(MetricsPanelCtrl)); + + _export("StatusPluginCtrl", StatusPluginCtrl); + + StatusPluginCtrl.templateUrl = 'module.html'; + } + }; }); //# sourceMappingURL=status_ctrl.js.map diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index b2495217..f2ce379a 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","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;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GAAmB,CAAnE,CAAJ,EAA2E;AACzE,mBAAK8C,SAAL,GAAiBE,YAAY,YAAM;AACjC,uBAAK9C,eAAL,CAAqB+C,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 +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","displayTypes","aggregations","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","setElementHeight","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","display","disabled","annotation","series","s","url","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","displayType","handleThresholdStatus","handleDisabledStatus","handleAnnotations","autoFlip","handle_css_display","parseUri","thresholds","parseThresholds","inverted","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","seriesData","flotpairs","getFlotPairs","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB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AAOqC,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOrC,MAAP;AACA;;;kCAEY;AACZ,UAAG,KAAKsC,SAAR,EAAmBC,cAAc,KAAKD,SAAnB;AACnB;;;gCAEU;AAAA;;AACV,UAAI,KAAKA,SAAT,EAAoBC,cAAc,KAAKD,SAAnB;AACpB,UAAI,KAAKjF,KAAL,CAAWmC,QAAX,KAAwB,KAAKG,IAAL,CAAUhB,MAAV,GAAmB,CAAnB,IAAwB,KAAKiB,IAAL,CAAUjB,MAAV,GAAmB,CAAnE,CAAJ,EAA2E;AAC1E,YAAK2D,SAAL,GAAiBE,YAAY,YAAM;AAClC,eAAK3D,eAAL,CAAqB4D,WAArB,CAAiC,SAAjC;AACA,QAFgB,EAEd,KAAKpF,KAAL,CAAWC,QAAX,GAAsB,IAFR,CAAjB;AAGA;AACD;;;0BAEIoF,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAKhE,eAAL,GAAuB8D,KAAK7D,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKD,eAAL,CAAqBY,QAArB,CAA8B,SAA9B;AACA,WAAKT,eAAL,GAAuB6D,IAAvB;AACA;;;qCAhDsBC,a,EAAe;AACrC,UAAItE,MAAM,EAAV;;AAEAA,UAAIoB,IAAJ,GAAWkD,cAAclD,IAAzB;AACApB,UAAImB,IAAJ,GAAWmD,cAAcnD,IAAzB;;AAEA,aAAOnB,GAAP;AACA;;;;KA7MoChC,gB;;;;AAyPtCI,oBAAiBmG,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n \t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('height', this.$panelContoller.height + 'px');\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.display = [];\n\t\tthis.disabled = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.displayType == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.displayType == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.displayType == \"Annotation\") {\n\t\t\t\tthis.handleAnnotations(s, target);\n\t\t\t}\n\t\t});\n\n\t\tthis.autoFlip();\n\t\tthis.handle_css_display();\n\t\tthis.parseUri();\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tif (!series.inverted) {\n\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\tthis.crit.push(series);\n\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\tthis.warn.push(series);\n\t\t\t} else if (series.display) {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\tthis.crit.push(series);\n\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\tthis.warn.push(series);\n\t\t\t} else if (series.display) {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleAnnotations(series, target) {\n\t\tthis.annotation.push(series);\n\t}\n\n\thandle_css_display() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.crit = metricOptions.crit;\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(this.seriesHandler.bind(this));\n\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tseriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/css/status_panel.scss b/src/css/status_panel.scss index ed26dafc..1fa4de8b 100644 --- a/src/css/status_panel.scss +++ b/src/css/status_panel.scss @@ -1,38 +1,34 @@ .status-panel { - display: table; - position: relative; - width: 100%; - - .status-panel-annotation_row { - display: table-row; - height: 25%; - text-align: left; - font-size: 0.85rem; - } - - .status_name_row { - display: table-row; - height: 10%; - } - - .status_alerts_row { - display: table-row; - } - - & > div { - display: table-cell; - vertical-align: middle; - text-align: center; - } - - h1 { - font-size: 1.5rem; - } - - .ok-text, .warning-text, .fail-text, .gray-text{ - display: none; - font-size: 3.5rem; - } + display: table; + position: relative; + width: 100%; + + > div{ + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-size: 1.5rem + } + + + h1 { + font-size: 1.5rem; + } + + + .status-panel-annotation_row { + position: absolute; + top: 0; + width: 100%; + text-align: left; + font-size: 0.85rem; + } + + .ok-text, .warning-text, .fail-text, .gray-text{ + display: none; + font-size: 3.5rem; + } } .error-state { diff --git a/src/module.html b/src/module.html index b8e50129..84508cef 100644 --- a/src/module.html +++ b/src/module.html @@ -54,3 +54,4 @@

+ diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 87abbe83..c3ba9794 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -18,16 +18,16 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.displayTypes = ['Threshold', 'Disable Criteria', 'Annotation']; this.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg']; - this.panel.flipTime = this.panel.flipTime || 5; + this.panel.flipTime = this.panel.flipTime || 5; - /** Bind events to functions **/ - this.events.on('render', this.onRender.bind(this)); - this.events.on('refresh', this.postRefresh.bind(this)); - this.events.on('data-error', this.onDataError.bind(this)); - this.events.on('data-received', this.onDataReceived.bind(this)); - this.events.on('data-snapshot-load', this.onDataReceived.bind(this)); - this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); - } + /** Bind events to functions **/ + this.events.on('render', this.onRender.bind(this)); + this.events.on('refresh', this.postRefresh.bind(this)); + this.events.on('data-error', this.onDataError.bind(this)); + this.events.on('data-received', this.onDataReceived.bind(this)); + this.events.on('data-snapshot-load', this.onDataReceived.bind(this)); + this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); + } postRefresh() { if (this.panel.fixedSpan) { @@ -73,12 +73,11 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { this.panel.displayName = ""; } - if(this.panel.flipCard){ - this.$panelContainer.addClass("effect-hover"); - } else { - this.$panelContainer.removeClass("effect-hover"); - } - + if(this.panel.flipCard){ + this.$panelContainer.addClass("effect-hover"); + } else { + this.$panelContainer.removeClass("effect-hover"); + } let targets = this.panel.targets; @@ -138,6 +137,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } }); + this.autoFlip(); this.handle_css_display(); this.parseUri(); } @@ -236,24 +236,24 @@ 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"); - this.$panelContoller = ctrl; - } + $onDestroy() { + if(this.timeoutId) clearInterval(this.timeoutId); + } + + autoFlip() { + if (this.timeoutId) clearInterval(this.timeoutId); + if (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0)) { + this.timeoutId = setInterval(() => { + this.$panelContainer.toggleClass("flipped"); + }, this.panel.flipTime * 1000); + } + } + + link(scope, elem, attrs, ctrl) { + this.$panelContainer = elem.find('.panel-container'); + this.$panelContainer.addClass("st-card"); + this.$panelContoller = ctrl; + } } StatusPluginCtrl.templateUrl = 'module.html';