From 5034c2ca900bb646ec58db84d1cad0ec6a4021ef Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 15 May 2020 19:05:07 +0300 Subject: [PATCH] Problems: add min severity filter --- src/datasource-zabbix/datasource.ts | 6 ++++++ src/datasource-zabbix/partials/query.editor.html | 12 +++++++++++- src/datasource-zabbix/query.controller.js | 7 ++++++- src/panel-triggers/migrations.ts | 1 + src/panel-triggers/specs/migrations.spec.ts | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/datasource-zabbix/datasource.ts b/src/datasource-zabbix/datasource.ts index 5c0d7a7..d3731ee 100644 --- a/src/datasource-zabbix/datasource.ts +++ b/src/datasource-zabbix/datasource.ts @@ -414,9 +414,15 @@ export class ZabbixDatasource { const problemsOptions: any = { recent: showProblems === ShowProblemTypes.Recent, + minSeverity: target.options?.minSeverity, limit: target.options?.limit, }; + if (target.options?.minSeverity) { + const severities = [0, 1, 2, 3, 4, 5].filter(v => v >= target.options?.minSeverity); + problemsOptions.severities = severities; + } + if (showProblems !== ShowProblemTypes.Problems) { problemsOptions.timeFrom = timeFrom; problemsOptions.timeTo = timeTo; diff --git a/src/datasource-zabbix/partials/query.editor.html b/src/datasource-zabbix/partials/query.editor.html index fe26b4b..7025d1f 100644 --- a/src/datasource-zabbix/partials/query.editor.html +++ b/src/datasource-zabbix/partials/query.editor.html @@ -178,13 +178,23 @@ +
+ +
+ +
+
diff --git a/src/datasource-zabbix/query.controller.js b/src/datasource-zabbix/query.controller.js index d78d44d..a4bf66e 100644 --- a/src/datasource-zabbix/query.controller.js +++ b/src/datasource-zabbix/query.controller.js @@ -42,6 +42,7 @@ function getProblemsTargetDefaults() { return { showProblems: ShowProblemTypes.Problems, options: { + minSeverity: 0, sortProblems: 'default', acknowledged: 2, hostsInMaintenance: false, @@ -51,6 +52,10 @@ function getProblemsTargetDefaults() { }; } +function getSeverityOptions() { + return c.TRIGGER_SEVERITY; +} + export class ZabbixQueryController extends QueryCtrl { /** @ngInject */ @@ -120,7 +125,7 @@ export class ZabbixQueryController extends QueryCtrl { this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }]; - this.triggerSeverity = c.TRIGGER_SEVERITY; + this.severityOptions = getSeverityOptions(); // Map functions for bs-typeahead this.getGroupNames = _.bind(this.getMetricNames, this, 'groupList'); diff --git a/src/panel-triggers/migrations.ts b/src/panel-triggers/migrations.ts index 1e0adce..770c249 100644 --- a/src/panel-triggers/migrations.ts +++ b/src/panel-triggers/migrations.ts @@ -132,6 +132,7 @@ function migrateOptions(panel) { return { hostsInMaintenance: panel.hostsInMaintenance, sortProblems: panel.sortTriggersBy?.value === 'priority' ? 'priority' : 'default', + minSeverity: 0, acknowledged: acknowledged, limit: limit, }; diff --git a/src/panel-triggers/specs/migrations.spec.ts b/src/panel-triggers/specs/migrations.spec.ts index 6108877..189ffe7 100644 --- a/src/panel-triggers/specs/migrations.spec.ts +++ b/src/panel-triggers/specs/migrations.spec.ts @@ -67,6 +67,7 @@ describe('Triggers Panel schema migration', () => { hostsInMaintenance: false, acknowledged: 0, sortProblems: 'default', + minSeverity: 0, limit: 10, }, }