From 4444737d377410e2de356d0ed0aca7252937e3ea Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Thu, 30 Mar 2017 03:11:02 +0300 Subject: [PATCH 1/4] * support showing part of the value in the panel using regex --- dist/editor.html | 12 ++++++++++++ dist/module.html | 8 ++++---- dist/status_ctrl.js | 25 +++++++++++++++++++++++++ dist/status_ctrl.js.map | 2 +- src/editor.html | 12 ++++++++++++ src/module.html | 8 ++++---- src/status_ctrl.js | 27 +++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 9 deletions(-) diff --git a/dist/editor.html b/dist/editor.html index b62a17c2..a5497367 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -89,6 +89,18 @@
Display Settings
+ + +
+ + Value Regex + + A regex which will decide the part of the value to be displayed.
+ In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed. +
+
+ +
diff --git a/dist/module.html b/dist/module.html index 7e0d59ca..c00901bb 100644 --- a/dist/module.html +++ b/dist/module.html @@ -18,7 +18,7 @@
{{ annoation.alias }} {{ annotation.alias }} - - {{ annotation.display_value | numberOrText}} + - {{ annotation.display_value | numberOrTextWithRegex : annotation.valueDisplayRegex}}
@@ -41,19 +41,19 @@

{{ display.alias }} {{ display.alias }} - - {{ display.display_value | numberOrText }} + - {{ display.display_value | numberOrTextWithRegex : display.valueDisplayRegex }}
{{ crit.alias }} {{ crit.alias }} - - {{ crit.display_value | numberOrText }} + - {{ crit.display_value | numberOrTextWithRegex : crit.valueDisplayRegex }}
{{ warn.alias }} {{ warn.alias }} - - {{ warn.display_value | numberOrText }} + - {{ warn.display_value | numberOrTextWithRegex : warn.valueDisplayRegex }}
diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 1e4c0d81..fca1cbee 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -111,6 +111,30 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi numberOrTextFilter.$stateful = true; return numberOrTextFilter; }); + + coreModule.filter('numberOrTextWithRegex', function () { + var numberOrTextFilter = function numberOrTextFilter(input, textRegex) { + if (angular.isNumber(input)) { + return _this2.filter('number')(input); + } else { + + if (textRegex == null || textRegex.length == 0) { + return input; + } else { + var regex = new RegExp(textRegex); + var matchResults = input.match(regex); + if (matchResults == null) { + return input; + } else { + return matchResults[0]; + } + } + } + }; + + numberOrTextFilter.$stateful = true; + return numberOrTextFilter; + }); } }, { key: "postRefresh", @@ -202,6 +226,7 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi s.url = target.url; s.display = true; s.displayType = target.displayType; + s.valueDisplayRegex = target.valueDisplayRegex; var value = void 0; switch (target.aggregation) { diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 925f718d..e04bc64a 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","length","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","RegExp","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval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_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","textRegex","length","regex","RegExp","matchResults","match","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","valueDisplayRegex","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,aAAL,GAAqB,CAAC,WAAD,EAAc,kBAAd,EAAkC,WAAlC,CAArB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC,KAAhC,EAAuC,KAAvC,CAApB;AACA,WAAKC,YAAL,GAAoB,CAAC,SAAD,EAAY,YAAZ,CAApB;;AAEA,WAAKC,KAAL,CAAWC,QAAX,GAAsB,MAAKD,KAAL,CAAWC,QAAX,IAAuB,CAA7C;;AAEA;AACA,WAAKC,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,MAAKC,QAAL,CAAcC,IAAd,OAAzB;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,SAAf,EAA0B,MAAKG,WAAL,CAAiBD,IAAjB,OAA1B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,YAAf,EAA6B,MAAKI,WAAL,CAAiBF,IAAjB,OAA7B;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,eAAf,EAAgC,MAAKK,cAAL,CAAoBH,IAApB,OAAhC;AACA,WAAKH,MAAL,CAAYC,EAAZ,CAAe,oBAAf,EAAqC,MAAKK,cAAL,CAAoBH,IAApB,OAArC;AACA,WAAKH,M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C,K,EAAOC,I,EAAM;AAC9B,WAAK7E,eAAL,GAAuB2E,KAAK1E,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKD,eAAL,CAAqBqB,QAArB,CAA8B,SAA9B;AACA,WAAKlB,eAAL,GAAuB0E,IAAvB;AACA;;;qCAjDsBC,a,EAAe;AACrC,UAAIlF,MAAM,EAAV;;AAEAA,UAAI4B,IAAJ,GAAWsD,cAActD,IAAzB;AACA5B,UAAI4D,YAAJ,GAAmB9E,QAAQC,QAAR,CAAiBiB,IAAI4B,IAArB,CAAnB;AACA5B,UAAI2B,IAAJ,GAAWuD,cAAcvD,IAAzB;AACA3B,UAAI6D,YAAJ,GAAmB/E,QAAQC,QAAR,CAAiBiB,IAAI2B,IAArB,CAAnB;;AAEA,aAAO3B,GAAP;AACA;;;mCAYoBmF,U,EAAY;AAChC,UAAInD,SAAS,IAAI3E,UAAJ,CAAe;AAC3BmF,mBAAY2C,WAAW3C,UADI;AAE3BvC,cAAOkF,WAAWjF;AAFS,OAAf,CAAb;;AAKA8B,aAAOoD,SAAP,GAAmBpD,OAAOqD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOrD,MAAP;AACA;;;;KA7UoC7E,gB;;;;AAmWtCI,oBAAiB+H,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\n\t\tcoreModule.filter('numberOrTextWithRegex', () => {\n\t\t\tlet numberOrTextFilter = (input, textRegex) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\n\t\t\t\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar regex = new RegExp(textRegex);\n\t\t\t\t\t\tvar matchResults = input.match(regex);\n\t\t\t\t\t\tif(matchResults == null) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn matchResults[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\t\t\ts.valueDisplayRegex = target.valueDisplayRegex;\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/editor.html b/src/editor.html index b62a17c2..a5497367 100644 --- a/src/editor.html +++ b/src/editor.html @@ -89,6 +89,18 @@
Display Settings
+ + +
+ + Value Regex + + A regex which will decide the part of the value to be displayed.
+ In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed. +
+
+ +
diff --git a/src/module.html b/src/module.html index 7e0d59ca..c00901bb 100644 --- a/src/module.html +++ b/src/module.html @@ -18,7 +18,7 @@
{{ annoation.alias }} {{ annotation.alias }} - - {{ annotation.display_value | numberOrText}} + - {{ annotation.display_value | numberOrTextWithRegex : annotation.valueDisplayRegex}}
@@ -41,19 +41,19 @@

{{ display.alias }} {{ display.alias }} - - {{ display.display_value | numberOrText }} + - {{ display.display_value | numberOrTextWithRegex : display.valueDisplayRegex }}
{{ crit.alias }} {{ crit.alias }} - - {{ crit.display_value | numberOrText }} + - {{ crit.display_value | numberOrTextWithRegex : crit.valueDisplayRegex }}
{{ warn.alias }} {{ warn.alias }} - - {{ warn.display_value | numberOrText }} + - {{ warn.display_value | numberOrTextWithRegex : warn.valueDisplayRegex }}
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 9d0b93d0..602c1898 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -45,6 +45,32 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { numberOrTextFilter.$stateful = true; return numberOrTextFilter; }); + + coreModule.filter('numberOrTextWithRegex', () => { + let numberOrTextFilter = (input, textRegex) => { + if(angular.isNumber(input)) { + return this.filter('number')(input); + } else { + + if(textRegex == null || textRegex.length == 0) { + return input; + } + else { + var regex = new RegExp(textRegex); + var matchResults = input.match(regex); + if(matchResults == null) { + return input; + } + else { + return matchResults[0]; + } + } + } + }; + + numberOrTextFilter.$stateful = true; + return numberOrTextFilter; + }); } postRefresh() { @@ -130,6 +156,7 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { s.url = target.url; s.display = true; s.displayType = target.displayType; + s.valueDisplayRegex = target.valueDisplayRegex; let value; switch (target.aggregation) { From f48be3a90dd430fd96a0f4522e61c27e6934703c Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Tue, 4 Apr 2017 11:27:54 +0300 Subject: [PATCH 2/4] * add RegExp exception handling --- dist/editor.html | 21 ++++++++++++--------- dist/status_ctrl.js | 35 ++++++++++++++++++++++++++++------- dist/status_ctrl.js.map | 2 +- src/editor.html | 21 ++++++++++++--------- src/status_ctrl.js | 39 +++++++++++++++++++++++++++++---------- 5 files changed, 82 insertions(+), 36 deletions(-) diff --git a/dist/editor.html b/dist/editor.html index a5497367..0a278097 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -79,27 +79,30 @@
Display Settings
- +
- Metric URL + Value Regex - Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs) + A regex which will decide the part of the value to be displayed.
+ In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed.
- + +
+ Invalid Regex +
- +
- Value Regex + Metric URL - A regex which will decide the part of the value to be displayed.
- In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed. + Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs)
- +
diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index fca1cbee..7d3ea956 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -117,16 +117,19 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi if (angular.isNumber(input)) { return _this2.filter('number')(input); } else { - if (textRegex == null || textRegex.length == 0) { return input; } else { - var regex = new RegExp(textRegex); - var matchResults = input.match(regex); - if (matchResults == null) { + try { + var regex = new RegExp(textRegex); + var matchResults = input.match(regex); + if (matchResults == null) { + return input; + } else { + return matchResults[0]; + } + } catch (e) { return input; - } else { - return matchResults[0]; } } } @@ -226,7 +229,12 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi s.url = target.url; s.display = true; s.displayType = target.displayType; - s.valueDisplayRegex = target.valueDisplayRegex; + target.valueDisplayRegexValidated = _this4.validateRegex(target.valueDisplayRegex); + if (target.valueDisplayRegexValidated) { + s.valueDisplayRegex = target.valueDisplayRegex; + } else { + s.valueDisplayRegex = ""; + } var value = void 0; switch (target.aggregation) { @@ -391,6 +399,19 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi this.uri = undefined; } } + }, { + key: "validateRegex", + value: function validateRegex(textRegex) { + if (textRegex == null || textRegex.length == 0) { + return true; + } + try { + var regex = new RegExp(textRegex); + return true; + } catch (e) { + return false; + } + } }, { key: "onDataReceived", value: function onDataReceived(dataList) { diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index e04bc64a..10738af0 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","textRegex","length","regex","RegExp","matchResults","match","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","valueDisplayRegex","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,aAAL,GAAqB,CAAC,WAAD,EAAc,kBAAd,EAAkC,WAAlC,CAArB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,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BvC,cAAOkF,WAAWjF;AAFS,OAAf,CAAb;;AAKA8B,aAAOoD,SAAP,GAAmBpD,OAAOqD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOrD,MAAP;AACA;;;;KA7UoC7E,gB;;;;AAmWtCI,oBAAiB+H,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\n\t\tcoreModule.filter('numberOrTextWithRegex', () => {\n\t\t\tlet numberOrTextFilter = (input, textRegex) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\n\t\t\t\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar regex = new RegExp(textRegex);\n\t\t\t\t\t\tvar matchResults = input.match(regex);\n\t\t\t\t\t\tif(matchResults == null) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn matchResults[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\t\t\ts.valueDisplayRegex = target.valueDisplayRegex;\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","textRegex","length","regex","RegExp","matchResults","match","e","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","valueDisplayRegexValidated","validateRegex","valueDisplayRegex","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SA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KAAK/G,KAAL,CAAWC,QAAX,GAAsB,IAFR,CAAjB;AAGA;AACD;;;0BAEI+G,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC9B,WAAK/E,eAAL,GAAuB6E,KAAK5E,IAAL,CAAU,kBAAV,CAAvB;AACA,WAAKD,eAAL,CAAqBqB,QAArB,CAA8B,SAA9B;AACA,WAAKlB,eAAL,GAAuB4E,IAAvB;AACA;;;qCAjDsBC,a,EAAe;AACrC,UAAIpF,MAAM,EAAV;;AAEAA,UAAI4B,IAAJ,GAAWwD,cAAcxD,IAAzB;AACA5B,UAAI8D,YAAJ,GAAmBjF,QAAQC,QAAR,CAAiBkB,IAAI4B,IAArB,CAAnB;AACA5B,UAAI2B,IAAJ,GAAWyD,cAAczD,IAAzB;AACA3B,UAAI+D,YAAJ,GAAmBlF,QAAQC,QAAR,CAAiBkB,IAAI2B,IAArB,CAAnB;;AAEA,aAAO3B,GAAP;AACA;;;mCAYoBqF,U,EAAY;AAChC,UAAIrD,SAAS,IAAI5E,UAAJ,CAAe;AAC3BsF,mBAAY2C,WAAW3C,UADI;AAE3BzC,cAAOoF,WAAWnF;AAFS,OAAf,CAAb;;AAKA8B,aAAOsD,SAAP,GAAmBtD,OAAOuD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOvD,MAAP;AACA;;;;KAhWoC9E,gB;;;;AAsXtCI,oBAAiBkI,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\n\t\tcoreModule.filter('numberOrTextWithRegex', () => {\n\t\t\tlet numberOrTextFilter = (input, textRegex) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet regex = new RegExp(textRegex);\n\t\t\t\t\t\t\tlet matchResults = input.match(regex);\n\t\t\t\t\t\t\tif (matchResults == null) {\n\t\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn matchResults[0];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\t\t\ttarget.valueDisplayRegexValidated = this.validateRegex(target.valueDisplayRegex);\n\t\t\tif(target.valueDisplayRegexValidated) {\n\t\t\t\ts.valueDisplayRegex = target.valueDisplayRegex;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ts.valueDisplayRegex = \"\";\n\t\t\t}\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tvalidateRegex(textRegex) {\n\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\treturn true\n\t\t}\n\t\ttry {\n\t\t\tlet regex = new RegExp(textRegex);\n\t\t\treturn true\n\t\t} catch(e) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/editor.html b/src/editor.html index a5497367..0a278097 100644 --- a/src/editor.html +++ b/src/editor.html @@ -79,27 +79,30 @@

Display Settings
- +
- Metric URL + Value Regex - Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs) + A regex which will decide the part of the value to be displayed.
+ In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed.
- + +
+ Invalid Regex +
- +
- Value Regex + Metric URL - A regex which will decide the part of the value to be displayed.
- In case the regex is empty or it doesn't match any part of the metrics value, all the metric value will be displayed. + Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs)
- +
diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 602c1898..63daf89f 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -51,19 +51,20 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { if(angular.isNumber(input)) { return this.filter('number')(input); } else { - if(textRegex == null || textRegex.length == 0) { return input; - } - else { - var regex = new RegExp(textRegex); - var matchResults = input.match(regex); - if(matchResults == null) { + } else { + try { + let regex = new RegExp(textRegex); + let matchResults = input.match(regex); + if (matchResults == null) { + return input; + } else { + return matchResults[0]; + } + } catch (e) { return input; } - else { - return matchResults[0]; - } } } }; @@ -156,7 +157,13 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { s.url = target.url; s.display = true; s.displayType = target.displayType; - s.valueDisplayRegex = target.valueDisplayRegex; + target.valueDisplayRegexValidated = this.validateRegex(target.valueDisplayRegex); + if(target.valueDisplayRegexValidated) { + s.valueDisplayRegex = target.valueDisplayRegex; + } + else { + s.valueDisplayRegex = ""; + } let value; switch (target.aggregation) { @@ -310,6 +317,18 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { } } + validateRegex(textRegex) { + if(textRegex == null || textRegex.length == 0) { + return true + } + try { + let regex = new RegExp(textRegex); + return true + } catch(e) { + return false + } + } + static parseThresholds(metricOptions) { let res = {}; From a1320342e111d1f1e25317307e132d8f624f0f41 Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Thu, 6 Apr 2017 19:21:24 +0300 Subject: [PATCH 3/4] * remove the valueDisplayRegexValidated" param * change input name for "url measurement" --- dist/editor.html | 4 ++-- dist/status_ctrl.js | 24 +++++++++++++----------- dist/status_ctrl.js.map | 2 +- src/editor.html | 4 ++-- src/status_ctrl.js | 25 +++++++++++++------------ 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/dist/editor.html b/dist/editor.html index 0a278097..ee2de978 100644 --- a/dist/editor.html +++ b/dist/editor.html @@ -89,7 +89,7 @@
Display Settings
-
+
Invalid Regex
@@ -102,7 +102,7 @@
Display Settings
Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs) - + diff --git a/dist/status_ctrl.js b/dist/status_ctrl.js index 7d3ea956..df46b0d8 100644 --- a/dist/status_ctrl.js +++ b/dist/status_ctrl.js @@ -120,17 +120,20 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi if (textRegex == null || textRegex.length == 0) { return input; } else { + var regex = void 0; + try { - var regex = new RegExp(textRegex); - var matchResults = input.match(regex); - if (matchResults == null) { - return input; - } else { - return matchResults[0]; - } + regex = new RegExp(textRegex); } catch (e) { return input; } + + var matchResults = input.match(regex); + if (matchResults == null) { + return input; + } else { + return matchResults[0]; + } } } }; @@ -229,11 +232,10 @@ System.register(["app/plugins/sdk", "app/plugins/panel/graph/legend", "app/plugi s.url = target.url; s.display = true; s.displayType = target.displayType; - target.valueDisplayRegexValidated = _this4.validateRegex(target.valueDisplayRegex); - if (target.valueDisplayRegexValidated) { + s.valueDisplayRegex = ""; + + if (_this4.validateRegex(target.valueDisplayRegex)) { s.valueDisplayRegex = target.valueDisplayRegex; - } else { - s.valueDisplayRegex = ""; } var value = void 0; diff --git a/dist/status_ctrl.js.map b/dist/status_ctrl.js.map index 10738af0..d8b82924 100644 --- a/dist/status_ctrl.js.map +++ b/dist/status_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","textRegex","length","regex","RegExp","matchResults","match","e","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","valueDisplayRegexValidated","validateRegex","valueDisplayRegex","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,aAAL,GAAqB,CAAC,WAAD,EAAc,kBAAd,EAAkC,WAAlC,CAArB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAy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eAAL,CAAqBqB,QAArB,CAA8B,SAA9B;AACA,WAAKlB,eAAL,GAAuB4E,IAAvB;AACA;;;qCAjDsBC,a,EAAe;AACrC,UAAIpF,MAAM,EAAV;;AAEAA,UAAI4B,IAAJ,GAAWwD,cAAcxD,IAAzB;AACA5B,UAAI8D,YAAJ,GAAmBjF,QAAQC,QAAR,CAAiBkB,IAAI4B,IAArB,CAAnB;AACA5B,UAAI2B,IAAJ,GAAWyD,cAAczD,IAAzB;AACA3B,UAAI+D,YAAJ,GAAmBlF,QAAQC,QAAR,CAAiBkB,IAAI2B,IAArB,CAAnB;;AAEA,aAAO3B,GAAP;AACA;;;mCAYoBqF,U,EAAY;AAChC,UAAIrD,SAAS,IAAI5E,UAAJ,CAAe;AAC3BsF,mBAAY2C,WAAW3C,UADI;AAE3BzC,cAAOoF,WAAWnF;AAFS,OAAf,CAAb;;AAKA8B,aAAOsD,SAAP,GAAmBtD,OAAOuD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOvD,MAAP;AACA;;;;KAhWoC9E,gB;;;;AAsXtCI,oBAAiBkI,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\n\t\tcoreModule.filter('numberOrTextWithRegex', () => {\n\t\t\tlet numberOrTextFilter = (input, textRegex) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet regex = new RegExp(textRegex);\n\t\t\t\t\t\t\tlet matchResults = input.match(regex);\n\t\t\t\t\t\t\tif (matchResults == null) {\n\t\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn matchResults[0];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\t\t\ttarget.valueDisplayRegexValidated = this.validateRegex(target.valueDisplayRegex);\n\t\t\tif(target.valueDisplayRegexValidated) {\n\t\t\t\ts.valueDisplayRegex = target.valueDisplayRegex;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ts.valueDisplayRegex = \"\";\n\t\t\t}\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tvalidateRegex(textRegex) {\n\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\treturn true\n\t\t}\n\t\ttry {\n\t\t\tlet regex = new RegExp(textRegex);\n\t\t\treturn true\n\t\t} catch(e) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../src/status_ctrl.js"],"names":["MetricsPanelCtrl","_","TimeSeries","coreModule","StatusPluginCtrl","$scope","$injector","$log","$filter","annotationsSrv","filter","valueHandlers","aggregations","displayTypes","panel","flipTime","events","on","onRender","bind","postRefresh","onDataError","onDataReceived","onInitEditMode","addFilters","numberOrTextFilter","input","angular","isNumber","$stateful","textRegex","length","regex","RegExp","e","matchResults","match","fixedSpan","span","measurements","targets","duplicates","measurement","hide","each","m","res","alias","target","addEditorTab","$panelContainer","find","css","$panelContoller","height","minHeight","tail","panelWidth","innerWidth","isNaN","parseInt","slice","maxWidth","setElementHeight","setTextMaxWidth","upgradeOldVersion","clusterName","displayName","replace","namePrefix","flipCard","addClass","removeClass","crit","warn","disabled","display","annotation","series","s","url","displayType","valueDisplayRegex","validateRegex","value","aggregation","max","datapoints","point","stats","min","total","avg","display_value","valueHandler","handleThresholdStatus","handleDisabledStatus","handleTextOnly","autoFlip","handleCssDisplay","parseUri","thresholds","parseThresholds","inverted","isCritical","isWarning","isCheckRanges","warnIsNumber","critIsNumber","push","disabledValue","undefined","isGrayOnNoData","links","uri","dashUri","params","dataList","map","seriesHandler","render","timeoutId","clearInterval","setInterval","toggleClass","scope","elem","attrs","ctrl","metricOptions","seriesData","flotpairs","getFlotPairs","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,gB;;AAGDC,I;;AACAC,a;;AACAC,a;;;;;;;;;;;;;;;;;;;;;+BAIMC,gB;;;AACZ;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,IAA/B,EAAqCC,OAArC,EAA8CC,cAA9C,EAA8D;AAAA;;AAAA,qIACvDJ,MADuD,EAC/CC,SAD+C;;AAG7D;AACA,WAAKI,MAAL,GAAcF,OAAd;;AAEA,WAAKG,aAAL,GAAqB,CAAC,WAAD,EAAc,kBAAd,EAAkC,WAAlC,CAArB;AACA,WAAKC,YAAL,GAAoB,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC,KAAhC,EAAuC,KAAvC,CAApB;AACA,WAAKC,YAAL,GAAoB,CAAC,SAAD,EAAY,YAAZ,CAApB;;AAEA,WAAKC,KAAL,CAAWC,QAAX,GAAsB,MAAKD,KAAL,CAAWC,Q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hF,QAAQC,QAAR,CAAiBkB,IAAI4B,IAArB,CAAnB;AACA5B,UAAI2B,IAAJ,GAAWwD,cAAcxD,IAAzB;AACA3B,UAAI8D,YAAJ,GAAmBjF,QAAQC,QAAR,CAAiBkB,IAAI2B,IAArB,CAAnB;;AAEA,aAAO3B,GAAP;AACA;;;mCAYoBoF,U,EAAY;AAChC,UAAIpD,SAAS,IAAI5E,UAAJ,CAAe;AAC3BqF,mBAAY2C,WAAW3C,UADI;AAE3BxC,cAAOmF,WAAWlF;AAFS,OAAf,CAAb;;AAKA8B,aAAOqD,SAAP,GAAmBrD,OAAOsD,YAAP,CAAoB,WAApB,CAAnB;;AAEA,aAAOtD,MAAP;AACA;;;;KAjWoC9E,gB;;;;AAuXtCI,oBAAiBiI,WAAjB,GAA+B,aAA/B","file":"status_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from \"app/plugins/sdk\";\nimport \"app/plugins/panel/graph/legend\";\nimport \"app/plugins/panel/graph/series_overrides_ctrl\";\nimport _ from \"lodash\";\nimport TimeSeries from \"app/core/time_series2\";\nimport coreModule from \"app/core/core_module\"\n\nimport './css/status_panel.css!';\n\nexport class StatusPluginCtrl extends MetricsPanelCtrl {\n\t/** @ngInject */\n\tconstructor($scope, $injector, $log, $filter, annotationsSrv) {\n\t\tsuper($scope, $injector);\n\n\t\t//this.log = $log.debug;\n\t\tthis.filter = $filter;\n\n\t\tthis.valueHandlers = ['Threshold', 'Disable Criteria', 'Text Only'];\n\t\tthis.aggregations = ['Last', 'First', 'Max', 'Min', 'Sum', 'Avg'];\n\t\tthis.displayTypes = ['Regular', 'Annotation'];\n\n\t\tthis.panel.flipTime = this.panel.flipTime || 5;\n\n\t\t/** Bind events to functions **/\n\t\tthis.events.on('render', this.onRender.bind(this));\n\t\tthis.events.on('refresh', this.postRefresh.bind(this));\n\t\tthis.events.on('data-error', this.onDataError.bind(this));\n\t\tthis.events.on('data-received', this.onDataReceived.bind(this));\n\t\tthis.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n\t\tthis.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n\t\tthis.addFilters()\n\t}\n\n\taddFilters() {\n\t\tcoreModule.filter('numberOrText', () => {\n\t\t\tlet numberOrTextFilter = (input) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\n\t\tcoreModule.filter('numberOrTextWithRegex', () => {\n\t\t\tlet numberOrTextFilter = (input, textRegex) => {\n\t\t\t\tif(angular.isNumber(input)) {\n\t\t\t\t\treturn this.filter('number')(input);\n\t\t\t\t} else {\n\t\t\t\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet regex;\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tregex = new RegExp(textRegex);\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet matchResults = input.match(regex);\n\t\t\t\t\t\tif (matchResults == null) {\n\t\t\t\t\t\t\treturn input;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn matchResults[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tnumberOrTextFilter.$stateful = true;\n\t\t\treturn numberOrTextFilter;\n\t\t});\n\t}\n\n\tpostRefresh() {\n\t\tif (this.panel.fixedSpan) {\n\t\t\tthis.panel.span = this.panel.fixedSpan;\n\t\t}\n\n\t\tthis.measurements = this.panel.targets;\n\n\t\t/** Duplicate alias validation **/\n\t\tthis.duplicates = false;\n\n\t\tthis.measurements = _.filter(this.measurements, (measurement) => {\n\t\t\treturn !measurement.hide;\n\t\t});\n\n\t\t_.each(this.measurements, (m) => {\n\t\t\tlet res = _.filter(this.measurements, (measurement) => {\n\t\t\t\treturn (m.alias == measurement.alias || (m.target == measurement.target && m.target)) && !m.hide;\n\t\t\t});\n\n\t\t\tif (res.length > 1) {\n\t\t\t\tthis.duplicates = true;\n\t\t\t}\n\t\t});\n\t}\n\n\tonInitEditMode() {\n\t\tthis.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);\n\t}\n\n\tsetElementHeight() {\n\t\tthis.$panelContainer.find('.status-panel').css('min-height', this.$panelContoller.height + 'px');\n\t\tthis.minHeight = this.$panelContoller.height-10;\n\t}\n\n\tsetTextMaxWidth() {\n\t\tlet tail = ' …';\n\t\tlet panelWidth = this.$panelContainer.innerWidth();\n\t\tif (isNaN(panelWidth))\n\t\t\tpanelWidth = parseInt(panelWidth.slice(0, -2), 10) / 12;\n\t\tpanelWidth = panelWidth - 20;\n\t\tthis.maxWidth = panelWidth;\n\t}\n\n\tonRender() {\n\t\tthis.setElementHeight();\n\t\tthis.setTextMaxWidth();\n\t\tthis.upgradeOldVersion();\n\n\t\tif (this.panel.clusterName) {\n\t\t\tthis.panel.displayName =\n\t\t\t\tthis.filter('interpolateTemplateVars')(this.panel.clusterName, this.$scope)\n\t\t\t\t\t.replace(new RegExp(this.panel.namePrefix, 'i'), '');\n\t\t} else {\n\t\t\tthis.panel.displayName = \"\";\n\t\t}\n\n\t\tif(this.panel.flipCard){\n\t\t this.$panelContainer.addClass(\"effect-hover\");\n\t\t} else {\n\t\t this.$panelContainer.removeClass(\"effect-hover\");\n\t\t}\n\n\t\tlet targets = this.panel.targets;\n\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t\tthis.disabled = [];\n\t\tthis.display = [];\n\t\tthis.annotation = [];\n\n\t\t_.each(this.series, (s) => {\n\t\t\tlet target = _.find(targets, (target) => {\n\t\t\t\treturn target.alias == s.alias || target.target == s.alias;\n\t\t\t});\n\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ts.alias = target.alias;\n\t\t\ts.url = target.url;\n\t\t\ts.display = true;\n\t\t\ts.displayType = target.displayType;\n\t\t\ts.valueDisplayRegex = \"\";\n\n\t\t\tif(this.validateRegex(target.valueDisplayRegex)) {\n\t\t\t\ts.valueDisplayRegex = target.valueDisplayRegex;\n\t\t\t}\n\n\t\t\tlet value;\n\t\t\tswitch (target.aggregation) {\n\t\t\t\tcase 'Max':\n\t\t\t\t\tvalue = _.max(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.max;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Min':\n\t\t\t\t\tvalue = _.min(s.datapoints, (point) => { return point[0]; })[0];\n\t\t\t\t\tvalue = s.stats.min;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Sum':\n\t\t\t\t\tvalue = 0;\n\t\t\t\t\t_.each(s.datapoints, (point) => { value += point[0] });\n\t\t\t\t\tvalue = s.stats.total;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Avg':\n\t\t\t\t\tvalue = s.stats.avg;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'First':\n\t\t\t\t\tvalue = s.datapoints[0][0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = s.datapoints[s.datapoints.length - 1][0];\n\t\t\t}\n\n\t\t\ts.display_value = value;\n\n\t\t\tif (target.valueHandler == \"Threshold\") {\n\t\t\t\tthis.handleThresholdStatus(s, target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Disable Criteria\") {\n\t\t\t\tthis.handleDisabledStatus(s,target);\n\t\t\t}\n\t\t\telse if (target.valueHandler == \"Text Only\") {\n\t\t\t\tthis.handleTextOnly(s, target);\n\t\t\t}\n\t\t});\n\n\t\tif(this.disabled.length > 0) {\n\t\t\tthis.crit = [];\n\t\t\tthis.warn = [];\n\t\t\tthis.display = [];\n\t\t}\n\n\t\tthis.autoFlip();\n\t\tthis.handleCssDisplay();\n\t\tthis.parseUri();\n\t}\n\n\tupgradeOldVersion() {\n\t\tlet targets = this.panel.targets;\n\n\t\t//Handle legacy code\n\t\t_.each(targets, (target) => {\n\t\t\tif(target.valueHandler == null) {\n\t\t\t\ttarget.valueHandler = target.displayType;\n\t\t\t\tif(target.valueHandler == \"Annotation\") {\n\t\t\t\t\ttarget.valueHandler = \"Text Only\"\n\t\t\t\t}\n\t\t\t\ttarget.displayType = this.displayTypes[0];\n\t\t\t}\n\t\t});\n\t}\n\n\thandleThresholdStatus(series, target) {\n\t\tseries.thresholds = StatusPluginCtrl.parseThresholds(target);\n\t\tseries.inverted = series.thresholds.crit < series.thresholds.warn;\n\t\tseries.display = target.display;\n\n\t\tlet isCritical = false;\n\t\tlet isWarning = false;\n\t\tlet isCheckRanges = series.thresholds.warnIsNumber && series.thresholds.critIsNumber;\n\t\tif (isCheckRanges) {\n\t\t\tif (!series.inverted) {\n\t\t\t\tif (series.display_value >= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value >= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (series.display_value <= series.thresholds.crit) {\n\t\t\t\t\tisCritical = true\n\t\t\t\t} else if (series.display_value <= series.thresholds.warn) {\n\t\t\t\t\tisWarning = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (series.display_value == series.thresholds.crit) {\n\t\t\t\tisCritical = true\n\t\t\t} else if (series.display_value == series.thresholds.warn) {\n\t\t\t\tisWarning = true\n\t\t\t}\n\t\t}\n\n\t\tif(isCritical) {\n\t\t\tthis.crit.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if(isWarning) {\n\t\t\tthis.warn.push(series);\n\t\t\tseries.displayType = this.displayTypes[0]\n\t\t} else if (series.display) {\n\t\t\tif(series.displayType == \"Annotation\") {\n\t\t\t\tthis.annotation.push(series);\n\t\t\t} else {\n\t\t\t\tthis.display.push(series);\n\t\t\t}\n\t\t}\n\t}\n\n\thandleDisabledStatus(series, target) {\n\t\tseries.displayType = this.displayTypes[0];\n\t\tseries.disabledValue = target.disabledValue;\n\n\t\tif (series.display_value == series.disabledValue) {\n\t\t\tthis.disabled.push(series);\n\t\t}\n\t}\n\n\thandleTextOnly(series, target) {\n\t\tif(series.displayType == \"Annotation\") {\n\t\t\tthis.annotation.push(series);\n\t\t} else {\n\t\t\tthis.display.push(series);\n\t\t}\n\t}\n\n\thandleCssDisplay() {\n\t\tthis.$panelContainer.removeClass('error-state warn-state disabled-state ok-state no-data-state');\n\n\t\tif(this.duplicates) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.disabled.length > 0) {\n\t\t\tthis.$panelContainer.addClass('disabled-state');\n\t\t} else if (this.crit.length > 0) {\n\t\t\tthis.$panelContainer.addClass('error-state');\n\t\t} else if (this.warn.length > 0) {\n\t\t\tthis.$panelContainer.addClass('warn-state');\n\t\t} else if((this.series == undefined || this.series.length == 0) && this.panel.isGrayOnNoData) {\n\t\t\tthis.$panelContainer.addClass('no-data-state');\n\t\t} else {\n\t\t\tthis.$panelContainer.addClass('ok-state');\n\t\t}\n\t}\n\n\tparseUri() {\n\t\tif (this.panel.links && this.panel.links.length > 0) {\n\t\t\tthis.uri = this.panel.links[0].dashUri + \"?\" + this.panel.links[0].params;\n\t\t} else {\n\t\t\tthis.uri = undefined;\n\t\t}\n\t}\n\n\tvalidateRegex(textRegex) {\n\t\tif(textRegex == null || textRegex.length == 0) {\n\t\t\treturn true\n\t\t}\n\t\ttry {\n\t\t\tlet regex = new RegExp(textRegex);\n\t\t\treturn true\n\t\t} catch(e) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tstatic parseThresholds(metricOptions) {\n\t\tlet res = {};\n\n\t\tres.warn = metricOptions.warn;\n\t\tres.warnIsNumber = angular.isNumber(res.warn);\n\t\tres.crit = metricOptions.crit;\n\t\tres.critIsNumber = angular.isNumber(res.crit);\n\n\t\treturn res;\n\t}\n\n\tonDataReceived(dataList) {\n\t\tthis.series = dataList.map(StatusPluginCtrl.seriesHandler.bind(this));\n\t\tthis.render();\n\t}\n\n\tonDataError() {\n\t\tthis.crit = [];\n\t\tthis.warn = [];\n\t}\n\n\tstatic seriesHandler(seriesData) {\n\t\tvar series = new TimeSeries({\n\t\t\tdatapoints: seriesData.datapoints,\n\t\t\talias: seriesData.target\n\t\t});\n\n\t\tseries.flotpairs = series.getFlotPairs(\"connected\");\n\n\t\treturn series;\n\t}\n\n\t$onDestroy() {\n\t\tif(this.timeoutId) clearInterval(this.timeoutId);\n\t}\n\n\tautoFlip() {\n\t\tif (this.timeoutId) clearInterval(this.timeoutId);\n\t\tif (this.panel.flipCard && (this.crit.length > 0 || this.warn.length > 0 || this.disabled.length > 0)) {\n\t\t\tthis.timeoutId = setInterval(() => {\n\t\t\t\tthis.$panelContainer.toggleClass(\"flipped\");\n\t\t\t}, this.panel.flipTime * 1000);\n\t\t}\n\t}\n\n\tlink(scope, elem, attrs, ctrl) {\n\t\tthis.$panelContainer = elem.find('.panel-container');\n\t\tthis.$panelContainer.addClass(\"st-card\");\n\t\tthis.$panelContoller = ctrl;\n\t}\n}\n\nStatusPluginCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/src/editor.html b/src/editor.html index 0a278097..ee2de978 100644 --- a/src/editor.html +++ b/src/editor.html @@ -89,7 +89,7 @@
Display Settings
-
+
Invalid Regex
@@ -102,7 +102,7 @@
Display Settings
Make the name of the metric clickable, and send the user to a link (with explanations what to do when this error occurs) - + diff --git a/src/status_ctrl.js b/src/status_ctrl.js index 63daf89f..ea5df941 100644 --- a/src/status_ctrl.js +++ b/src/status_ctrl.js @@ -54,17 +54,20 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { if(textRegex == null || textRegex.length == 0) { return input; } else { + let regex; + try { - let regex = new RegExp(textRegex); - let matchResults = input.match(regex); - if (matchResults == null) { - return input; - } else { - return matchResults[0]; - } + regex = new RegExp(textRegex); } catch (e) { return input; } + + let matchResults = input.match(regex); + if (matchResults == null) { + return input; + } else { + return matchResults[0]; + } } } }; @@ -157,13 +160,11 @@ export class StatusPluginCtrl extends MetricsPanelCtrl { s.url = target.url; s.display = true; s.displayType = target.displayType; - target.valueDisplayRegexValidated = this.validateRegex(target.valueDisplayRegex); - if(target.valueDisplayRegexValidated) { + s.valueDisplayRegex = ""; + + if(this.validateRegex(target.valueDisplayRegex)) { s.valueDisplayRegex = target.valueDisplayRegex; } - else { - s.valueDisplayRegex = ""; - } let value; switch (target.aggregation) { From 353d4eb1f1eaafb950bd12b601622c820591c866 Mon Sep 17 00:00:00 2001 From: Yochpaz Yehonatan Date: Sun, 9 Apr 2017 11:39:47 +0300 Subject: [PATCH 4/4] * Update ReadMe + version date --- README.md | 8 ++++++-- dist/plugin.json | 2 +- src/plugin.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 54ddad18..708b07f7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This plugin will make it easier to do. You just add all the metrics you want to 2. Component disable marker - Set the exact value that represent if the component is disabled, the panel will be grey. 3. Display as text - show extra information about the component in the panel -Severity and text values can be shown in 2 options: +Severity and text values can be shown in 2 modes: 1. Regular - under the panel title 2. Annotation - In the top left side of the panel @@ -35,7 +35,8 @@ You can also repeat the panel on a template if you have multiple instances that 3. Go the the Options tab, and choose the how to treat each metric. 1. For severity display, select the `Threshold` option type under `Handler Type`. Enter the `Warning` and `Critical` thresholds for each of your queries. * If you want the result to always be displayed with it's value (regardless to the thresholds), check the box titled `Show Always` - * The plugin automatically detects if higher values are good, or lower values are good by checking which threshold is higher/lower. i.e. if in your metric higher values are better, put a lower value in the "critical" threshold than the "warning" threshold. + * In case one of the fields (`Warning`/`Critical`) is a text, there will be equality check with the values. + * In case both fields are numbers there will be range check with the values. The plugin automatically detects if higher values are good, or lower values are good by checking which threshold is higher/lower. i.e. if in your metric higher values are better, put a lower value in the `critical` threshold than the `warning` threshold. 2. For disable display, select the `Disable Criteria` option type under `Handler Type`. Enter the `Disable Value` for each of your queries. 3. For display the text without any condition, select the `Text Only` option type under `Handler Type`. The alias + the value of the metric will be shown on the panel by the `Display Type` value. 4. If the query returns multiple values, choose the type of aggregation you want to be used (`None` will just use the most first result) @@ -47,6 +48,9 @@ The plugins has a 'Remove Prefix' field in the configuration. This field is is m i.e. you recognize your servers by domain, and they are all name in the following way `www.general-prefix.server.com`, and you would like to remove the prefix from the display, then you enter `www.general-prefix.` and all the panels will only display the `server.com` part. +### Display Value by Regex +When you want to display just part of the value for a specific metric in the screen, you can pass a regex in the `Value Regex` field, and if there is match, Only the first match will be displayed. Otherwise, the original value will be displayed. + ### Measurement URL Lets say that you want your user to be able to get instructions on what to do when a certain metric is at Warning or Critical levels. Just put a link in this field and the name will become clickable, and send your user to any URL you desire (like an internal wiki). diff --git a/dist/plugin.json b/dist/plugin.json index f93ead75..bee5310d 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -24,7 +24,7 @@ {"name": "Critical State", "path": "img/error.png"} ], "version": "1.0.3", - "updated": "2017-3-23" + "updated": "2017-4-9" }, "dependencies": { diff --git a/src/plugin.json b/src/plugin.json index f93ead75..bee5310d 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -24,7 +24,7 @@ {"name": "Critical State", "path": "img/error.png"} ], "version": "1.0.3", - "updated": "2017-3-23" + "updated": "2017-4-9" }, "dependencies": {