From 80aa2e94ad24497c61f161d765c79833cc966263 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 7 May 2020 17:51:24 +0300 Subject: [PATCH] Move problem query options to the datasource --- src/datasource-zabbix/datasource.ts | 4 +- .../partials/query.editor.html | 173 +++++++++++++----- src/datasource-zabbix/query.controller.js | 32 +++- 3 files changed, 158 insertions(+), 51 deletions(-) diff --git a/src/datasource-zabbix/datasource.ts b/src/datasource-zabbix/datasource.ts index 178c290..ec1a224 100644 --- a/src/datasource-zabbix/datasource.ts +++ b/src/datasource-zabbix/datasource.ts @@ -398,9 +398,9 @@ export class ZabbixDatasource { let showAckButton = true; // const showEvents = this.panel.showEvents.value; - const showEvents = target.showEvents?.value || 1; + const showEvents = target.options.showEvents?.value || 1; // const showProxy = this.panel.hostProxy; - const showProxy = target.hostProxy; + const showProxy = target.options.hostProxy; const getProxiesPromise = showProxy ? this.zabbix.getProxies() : () => []; showAckButton = !this.disableReadOnlyUsersAck || userIsEditor; diff --git a/src/datasource-zabbix/partials/query.editor.html b/src/datasource-zabbix/partials/query.editor.html index 14487b6..ff6d4c6 100644 --- a/src/datasource-zabbix/partials/query.editor.html +++ b/src/datasource-zabbix/partials/query.editor.html @@ -12,7 +12,7 @@
- +
@@ -71,8 +71,8 @@ }">
-
- +
+ -
- +
+
-
- -
+
+ + +
+ +
+ + +
+ +
+
+
+
+ +
+
+ +
-
- -
-
- - + +
+ +
+ +
-
- - + + + +
+
@@ -215,23 +240,77 @@
- -
- -
- - + + + +
+
+ + +
+
+ +
- - -
-
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + +
diff --git a/src/datasource-zabbix/query.controller.js b/src/datasource-zabbix/query.controller.js index ce141e4..360c722 100644 --- a/src/datasource-zabbix/query.controller.js +++ b/src/datasource-zabbix/query.controller.js @@ -48,6 +48,23 @@ export class ZabbixQueryController extends QueryCtrl { {text: 'acknowledged', value: 1}, ]; + this.problemAckFilters = [ + 'all triggers', + 'unacknowledged', + 'acknowledged' + ]; + + this.sortByFields = [ + { text: 'last change', value: 'lastchange' }, + { text: 'severity', value: 'priority' } + ]; + + this.showEventsFields = [ + { text: 'All', value: [0,1] }, + { text: 'OK', value: [0] }, + { text: 'Problems', value: 1 } + ]; + this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }]; this.triggerSeverity = c.TRIGGER_SEVERITY; @@ -307,7 +324,12 @@ export class ZabbixQueryController extends QueryCtrl { renderQueryOptionsText() { var optionsMap = { showDisabledItems: "Show disabled items", - skipEmptyValues: "Skip empty values" + skipEmptyValues: "Skip empty values", + hostsInMaintenance: "Show hosts in maintenance", + showTriggers: "Acknowledged", + sortTriggersBy: "Sort problems", + showEvents: "Show events", + limit: "Limit problems", }; var options = []; _.forOwn(this.target.options, (value, key) => { @@ -317,7 +339,13 @@ export class ZabbixQueryController extends QueryCtrl { options.push(optionsMap[key]); } else { // Show "option = value" for another options - options.push(optionsMap[key] + " = " + value); + let optionValue = value; + if (value && value.text) { + optionValue = value.text; + } else if (value && value.value) { + optionValue = value.value; + } + options.push(optionsMap[key] + " = " + optionValue); } } });