From b4a3524115b597f1593964841a30222a05d6c2c5 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 5 Mar 2019 14:36:47 +0300 Subject: [PATCH 01/59] ci: release script --- .circleci/build-release.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 .circleci/build-release.sh diff --git a/.circleci/build-release.sh b/.circleci/build-release.sh new file mode 100755 index 0000000..8ae349a --- /dev/null +++ b/.circleci/build-release.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Exit script if you try to use an uninitialized variable. +set -o nounset +# Exit script if a statement returns a non-true return value. +set -o errexit +# Use the error status of the first failure, rather than that of the last item in a pipeline. +set -o pipefail + +RELEASE_VER=$(echo $CIRCLE_TAG | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") + +if [ -z $RELEASE_VER ]; then + echo "No release version provided" + exit 1 +fi +if [[ $RELEASE_VER =~ ^[0-9]\.[0-9]\.[0-9]-?.* ]]; then + echo "Preparing release $RELEASE_VER" +else + echo "Release should has format 1.2.3[-meta], got $RELEASE_VER" + exit 1 +fi + +RELEASE_BRANCH=release-$RELEASE_VER + +# Build plugin +git checkout -b $RELEASE_BRANCH +yarn install --pure-lockfile && yarn build + +# Commit release +git add --force dist/ +git commit -m "release $RELEASE_VER" + +RELEASE_COMMIT_HASH=$(git log -n 1 | grep -Po "(?<=commit )[0-9a-z]{40}") +echo $RELEASE_COMMIT_HASH + +# Push release branch +git push origin $RELEASE_BRANCH From 872d92d37fe92e515be94ca9756d68c4275e0c41 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 5 Mar 2019 14:43:23 +0300 Subject: [PATCH 02/59] ci: release process config --- .circleci/config.yml | 40 +++++++++++++++++++ .../{build-release.sh => make-release.sh} | 0 2 files changed, 40 insertions(+) rename .circleci/{build-release.sh => make-release.sh} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index ad534b3..0d86385 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,11 +6,17 @@ aliases: branches: ignore: - master + - /^release-[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ - docs - gh-pages - &filter-only-master branches: only: master + - &filter-only-release + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ - &filter-docs branches: only: docs @@ -87,6 +93,25 @@ jobs: - store_artifacts: path: /tmp/circleci-test-results + make-release: + working_directory: ~/alexanderzobnin/grafana-zabbix + docker: + - image: circleci/node:8 + steps: + - checkout + - restore_cache: + keys: + - dependency-cache-{{ checksum "yarn.lock" }} + - run: + name: yarn install + command: 'yarn install --pure-lockfile --no-progress' + no_output_timeout: 15m + - save_cache: + key: dependency-cache-{{ checksum "yarn.lock" }} + paths: + - ./node_modules + - run: ./.circleci/make-release.sh + build-docs: working_directory: ~/grafana-zabbix docker: @@ -144,6 +169,21 @@ workflows: - test: filters: *filter-not-release-or-master + build-release: + jobs: + - build: + filters: *filter-only-release + - lint: + filters: *filter-only-release + - test: + filters: *filter-only-release + - make-release: + requires: + - build + - lint + - test + filters: *filter-only-release + build-docs: jobs: - build-docs: diff --git a/.circleci/build-release.sh b/.circleci/make-release.sh similarity index 100% rename from .circleci/build-release.sh rename to .circleci/make-release.sh From 021473f86f6350e64e355848b5f8eea2b2af149a Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 5 Mar 2019 14:50:01 +0300 Subject: [PATCH 03/59] ci: add credentials for release script --- .circleci/config.yml | 6 ++++++ .circleci/make-release.sh | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d86385..ecbfe4f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,7 +97,13 @@ jobs: working_directory: ~/alexanderzobnin/grafana-zabbix docker: - image: circleci/node:8 + environment: + CI_GIT_USER: CircleCI + CI_GIT_EMAIL: ci@grafana.com steps: + - add_ssh_keys: + fingerprints: + - "dc:7e:54:e0:aa:56:4d:e5:60:7b:f3:51:24:2d:d3:29" - checkout - restore_cache: keys: diff --git a/.circleci/make-release.sh b/.circleci/make-release.sh index 8ae349a..06997cb 100755 --- a/.circleci/make-release.sh +++ b/.circleci/make-release.sh @@ -7,6 +7,11 @@ set -o errexit # Use the error status of the first failure, rather than that of the last item in a pipeline. set -o pipefail +# Setup git env +git config --global user.email $CI_GIT_EMAIL +git config --global user.name $CI_GIT_USER +echo "git user is $CI_GIT_USER ($CI_GIT_EMAIL)" + RELEASE_VER=$(echo $CIRCLE_TAG | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") if [ -z $RELEASE_VER ]; then From 3428137f7ce4493d26b8c3ac03de554066a494b7 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 5 Mar 2019 14:58:04 +0300 Subject: [PATCH 04/59] ci: fix release version test --- .circleci/make-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/make-release.sh b/.circleci/make-release.sh index 06997cb..e0efc96 100755 --- a/.circleci/make-release.sh +++ b/.circleci/make-release.sh @@ -18,7 +18,7 @@ if [ -z $RELEASE_VER ]; then echo "No release version provided" exit 1 fi -if [[ $RELEASE_VER =~ ^[0-9]\.[0-9]\.[0-9]-?.* ]]; then +if [[ $RELEASE_VER =~ ^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*) ]]; then echo "Preparing release $RELEASE_VER" else echo "Release should has format 1.2.3[-meta], got $RELEASE_VER" From e4bbecb18b189c7fe549631db8f1ca78f3fbf8a5 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 7 Mar 2019 10:35:36 +0300 Subject: [PATCH 05/59] fix multiple agg functions handling, closes #530 --- src/datasource-zabbix/dataProcessor.js | 6 ++--- src/datasource-zabbix/specs/utils.spec.js | 27 +++++++++++++++++++++++ src/datasource-zabbix/timeseries.js | 12 +++++++++- src/datasource-zabbix/utils.js | 11 +++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index 2d29bd4..1c5942e 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -107,7 +107,7 @@ function groupByWrapper(interval, groupFunc, datapoints) { function aggregateByWrapper(interval, aggregateFunc, datapoints) { // Flatten all points in frame and then just use groupBy() - const flattenedPoints = _.flatten(datapoints, true); + const flattenedPoints = ts.flattenDatapoints(datapoints); // groupBy_perf works with sorted series only const sortedPoints = ts.sortByTime(flattenedPoints); let groupByCallback = aggregationFunctions[aggregateFunc]; @@ -115,14 +115,14 @@ function aggregateByWrapper(interval, aggregateFunc, datapoints) { } function aggregateWrapper(groupByCallback, interval, datapoints) { - var flattenedPoints = _.flatten(datapoints, true); + var flattenedPoints = ts.flattenDatapoints(datapoints); // groupBy_perf works with sorted series only const sortedPoints = ts.sortByTime(flattenedPoints); return groupBy(sortedPoints, interval, groupByCallback); } function percentil(interval, n, datapoints) { - var flattenedPoints = _.flatten(datapoints, true); + var flattenedPoints = ts.flattenDatapoints(datapoints); var groupByCallback = _.partial(PERCENTIL, n); return groupBy(flattenedPoints, interval, groupByCallback); } diff --git a/src/datasource-zabbix/specs/utils.spec.js b/src/datasource-zabbix/specs/utils.spec.js index d460baa..3367f1f 100644 --- a/src/datasource-zabbix/specs/utils.spec.js +++ b/src/datasource-zabbix/specs/utils.spec.js @@ -138,4 +138,31 @@ describe('Utils', () => { done(); }); }); + + describe('getArrayDepth()', () => { + it('should calculate proper array depth', () => { + const test_cases = [ + { + array: [], + depth: 1 + }, + { + array: [1, 2, 3], + depth: 1 + }, + { + array: [[1, 2], [3, 4]], + depth: 2 + }, + { + array: [ [[1, 2], [3, 4]], [[1, 2], [3, 4]] ], + depth: 3 + }, + ]; + + for (const test_case of test_cases) { + expect(utils.getArrayDepth(test_case.array)).toBe(test_case.depth); + } + }); + }); }); diff --git a/src/datasource-zabbix/timeseries.js b/src/datasource-zabbix/timeseries.js index 9390c3f..1e23114 100644 --- a/src/datasource-zabbix/timeseries.js +++ b/src/datasource-zabbix/timeseries.js @@ -478,6 +478,15 @@ function findNearestLeft(series, pointIndex) { return null; } +function flattenDatapoints(datapoints) { + const depth = utils.getArrayDepth(datapoints); + if (depth <= 2) { + // Don't process if datapoints already flattened + return datapoints; + } + return _.flatten(datapoints); +} + //////////// // Export // //////////// @@ -501,7 +510,8 @@ const exportedFunctions = { MAX, MEDIAN, PERCENTIL, - sortByTime + sortByTime, + flattenDatapoints, }; export default exportedFunctions; diff --git a/src/datasource-zabbix/utils.js b/src/datasource-zabbix/utils.js index ab6639e..517569f 100644 --- a/src/datasource-zabbix/utils.js +++ b/src/datasource-zabbix/utils.js @@ -265,6 +265,17 @@ export function compactQuery(query) { return query.replace(/\s+/g, ' ').trim(); } +export function getArrayDepth(a, level = 0) { + if (a.length === 0) { + return 1; + } + const elem = a[0]; + if (_.isArray(elem)) { + return getArrayDepth(elem, level + 1); + } + return level + 1; +} + // Fix for backward compatibility with lodash 2.4 if (!_.includes) { _.includes = _.contains; From 86f2b879a28b032bf0b3bd5e743cc92e0e9010c5 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Wed, 10 Apr 2019 19:34:48 +0200 Subject: [PATCH 06/59] docs/*: Fix codespell issues See, $ codespell -S './src/img/*.png,./.git*' -L que Signed-off-by: Mario Trangoni --- CHANGELOG.md | 2 +- docs/sources/configuration/index.md | 2 +- docs/sources/guides/gettingstarted.md | 2 +- docs/sources/reference/alerting.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f34bdf..4fb0511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -189,7 +189,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - setAliasByRegex() function ### Changed -- **Docs**: deprecate special repo with builded plugin. +- **Docs**: deprecate special repo with built plugins. - **Triggers panel**: remove 'default' from datasources list (cause error), iss [#340](https://github.com/alexanderzobnin/grafana-zabbix/issues/340) - Add dist/ directory to repo to correspond development guide http://docs.grafana.org/plugins/development/ diff --git a/docs/sources/configuration/index.md b/docs/sources/configuration/index.md index a75be97..2958f53 100644 --- a/docs/sources/configuration/index.md +++ b/docs/sources/configuration/index.md @@ -56,7 +56,7 @@ Direct access is still supported because in some cases it may be useful to acces Direct DB Connection allows plugin to use existing SQL data source for querying history data directly from Zabbix database. This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces -amount of data transfered. +amount of data transferred. Read [how to configure](./sql_datasource) SQL data source in Grafana. diff --git a/docs/sources/guides/gettingstarted.md b/docs/sources/guides/gettingstarted.md index f160772..c5597ca 100644 --- a/docs/sources/guides/gettingstarted.md +++ b/docs/sources/guides/gettingstarted.md @@ -25,7 +25,7 @@ Another case to use regex is comparing the same metrics for different hosts. Use ![Backend system time](../img/getstarting-regex_backend_system_time.png) ## Bar Chart -Let's create a graph wich show queries stats for MySQL database. Select Group, Host, Application (_MySQL_ in my case) and Items. I use `/MySQL .* operations/` regex for filtering different types of operations. +Let's create a graph which show queries stats for MySQL database. Select Group, Host, Application (_MySQL_ in my case) and Items. I use `/MySQL .* operations/` regex for filtering different types of operations. ![MySQL operations 1](../img/getstarting-mysql_operations_1.png) diff --git a/docs/sources/reference/alerting.md b/docs/sources/reference/alerting.md index e1670d4..49dc0e1 100644 --- a/docs/sources/reference/alerting.md +++ b/docs/sources/reference/alerting.md @@ -14,7 +14,7 @@ consists of two main parts: - **Alerting execution engine** The alert rules are evaluated in the Grafana backend in a scheduler and query execution engine that is part of core - Grafana. Only some data soures are supported right now. They include Graphite, Prometheus, InfluxDB and OpenTSDB. + Grafana. Only some data sources are supported right now. They include Graphite, Prometheus, InfluxDB and OpenTSDB. - **Alerting visualisations** Alerts highlight panels with problems and it can easily be found on the dashboard. From 2f9be7a1847bf66c8e8fbe04933c130069a84e9f Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Wed, 10 Apr 2019 19:35:34 +0200 Subject: [PATCH 07/59] src/*: Fix codespell issues See, $ codespell -S './src/img/*.png,./.git*' -L que Signed-off-by: Mario Trangoni --- src/datasource-zabbix/add-metric-function.directive.js | 2 +- src/datasource-zabbix/dataProcessor.js | 8 ++++---- src/datasource-zabbix/partials/config.html | 2 +- src/datasource-zabbix/timeseries.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/datasource-zabbix/add-metric-function.directive.js b/src/datasource-zabbix/add-metric-function.directive.js index 795a254..64c2c41 100644 --- a/src/datasource-zabbix/add-metric-function.directive.js +++ b/src/datasource-zabbix/add-metric-function.directive.js @@ -66,7 +66,7 @@ angular }); $input.blur(function() { - // clicking the function dropdown menu wont + // clicking the function dropdown menu won't // work if you remove class at once setTimeout(function() { $input.val(''); diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index 1c5942e..4ff8c9e 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -19,7 +19,7 @@ let AVERAGE = ts.AVERAGE; let MIN = ts.MIN; let MAX = ts.MAX; let MEDIAN = ts.MEDIAN; -let PERCENTIL = ts.PERCENTIL; +let PERCENTILE = ts.PERCENTILE; function limit(order, n, orderByFunc, timeseries) { let orderByCallback = aggregationFunctions[orderByFunc]; @@ -121,9 +121,9 @@ function aggregateWrapper(groupByCallback, interval, datapoints) { return groupBy(sortedPoints, interval, groupByCallback); } -function percentil(interval, n, datapoints) { +function percentile(interval, n, datapoints) { var flattenedPoints = ts.flattenDatapoints(datapoints); - var groupByCallback = _.partial(PERCENTIL, n); + var groupByCallback = _.partial(PERCENTILE, n); return groupBy(flattenedPoints, interval, groupByCallback); } @@ -155,7 +155,7 @@ let metricFunctions = { transformNull: transformNull, aggregateBy: aggregateByWrapper, // Predefined aggs - percentil: percentil, + percentile: percentile, average: _.partial(aggregateWrapper, AVERAGE), min: _.partial(aggregateWrapper, MIN), max: _.partial(aggregateWrapper, MAX), diff --git a/src/datasource-zabbix/partials/config.html b/src/datasource-zabbix/partials/config.html index 1e9f682..0bd3a3e 100644 --- a/src/datasource-zabbix/partials/config.html +++ b/src/datasource-zabbix/partials/config.html @@ -99,7 +99,7 @@ In order to use this feature it should be created and configured first. Zabbix plugin uses this data source for querying history data directly from the database. This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces - amount of data transfered. + amount of data transferred.
diff --git a/src/datasource-zabbix/timeseries.js b/src/datasource-zabbix/timeseries.js index 1e23114..de20b4a 100644 --- a/src/datasource-zabbix/timeseries.js +++ b/src/datasource-zabbix/timeseries.js @@ -333,7 +333,7 @@ function expMovingAverage(datapoints, n) { return ema; } -function PERCENTIL(n, values) { +function PERCENTILE(n, values) { var sorted = _.sortBy(values); return sorted[Math.floor(sorted.length * n / 100)]; } @@ -509,7 +509,7 @@ const exportedFunctions = { MIN, MAX, MEDIAN, - PERCENTIL, + PERCENTILE, sortByTime, flattenDatapoints, }; From a114b3f3bcba60df41091a03b6ed9b394c18c6b5 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Wed, 10 Apr 2019 19:42:18 +0200 Subject: [PATCH 08/59] ci: Add codespell spelling check Signed-off-by: Mario Trangoni --- .circleci/config.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ecbfe4f..cf7cda4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -155,12 +155,23 @@ jobs: at: ../gh-pages - run: ./.circleci/deploy-docs.sh + codespell: + docker: + - image: circleci/python + + steps: + - checkout + - run: sudo pip install codespell + - run: codespell -S './.git*,./src/img*' -L que + workflows: version: 2 build-master: jobs: - build: filters: *filter-only-master + - codespell: + filters: *filter-only-master - lint: filters: *filter-only-master - test: @@ -170,6 +181,8 @@ workflows: jobs: - build: filters: *filter-not-release-or-master + - codespell: + filters: *filter-not-release-or-master - lint: filters: *filter-not-release-or-master - test: @@ -179,6 +192,8 @@ workflows: jobs: - build: filters: *filter-only-release + - codespell: + filters: *filter-only-release - lint: filters: *filter-only-release - test: @@ -186,6 +201,7 @@ workflows: - make-release: requires: - build + - codespell - lint - test filters: *filter-only-release From 0e81752ab82feb1eacc3b4dff8c2b5f2e2b89188 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Wed, 10 Apr 2019 20:00:17 +0200 Subject: [PATCH 09/59] lint: Fix disallowSpacesInsideArrayBrackets issues See, disallowSpacesInsideArrayBrackets: Illegal space after opening bracket at src/datasource-zabbix/specs/utils.spec.js : 156 | }, 157 | { 158 | array: [ [[1, 2], [3, 4]], [[1, 2], [3, 4]] ], --------------------------^ 159 | depth: 3 160 | }, disallowSpacesInsideArrayBrackets: Illegal space before closing bracket at src/datasource-zabbix/specs/utils.spec.js : 156 | }, 157 | { 158 | array: [ [[1, 2], [3, 4]], [[1, 2], [3, 4]] ], -------------------------------------------------------------^ 159 | depth: 3 160 | }, Signed-off-by: Mario Trangoni --- src/datasource-zabbix/specs/utils.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasource-zabbix/specs/utils.spec.js b/src/datasource-zabbix/specs/utils.spec.js index 3367f1f..01cc76f 100644 --- a/src/datasource-zabbix/specs/utils.spec.js +++ b/src/datasource-zabbix/specs/utils.spec.js @@ -155,7 +155,7 @@ describe('Utils', () => { depth: 2 }, { - array: [ [[1, 2], [3, 4]], [[1, 2], [3, 4]] ], + array: [[[1, 2], [3, 4]], [[1, 2], [3, 4]]], depth: 3 }, ]; From 869634ef62a88c0186278be59dc540c033f573c6 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 19 Apr 2019 12:56:51 +0300 Subject: [PATCH 10/59] Fix ds provisioning with direct DB connection enabled (#723) * fix ds provisioning with direct DB connection #711 * fix linter error --- src/datasource-zabbix/config.controller.js | 19 ++++++++++++++++++- src/datasource-zabbix/partials/config.html | 6 +++--- src/datasource-zabbix/specs/utils.spec.js | 2 +- .../zabbix/connectors/dbConnector.js | 3 +++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/datasource-zabbix/config.controller.js b/src/datasource-zabbix/config.controller.js index 0c87594..342c4f0 100644 --- a/src/datasource-zabbix/config.controller.js +++ b/src/datasource-zabbix/config.controller.js @@ -28,9 +28,16 @@ export class ZabbixDSConfigController { this.current.jsonData = migrateDSConfig(this.current.jsonData); _.defaults(this.current.jsonData, defaultConfig); + + this.dbConnectionEnable = this.current.jsonData.dbConnectionEnable; + this.dbConnectionDatasourceId = this.current.jsonData.dbConnectionDatasourceId; + this.dbDataSources = this.getSupportedDBDataSources(); this.zabbixVersions = _.cloneDeep(zabbixVersions); this.autoDetectZabbixVersion(); + if (!this.dbConnectionDatasourceId) { + this.loadCurrentDBDatasource(); + } } getSupportedDBDataSources() { @@ -41,11 +48,21 @@ export class ZabbixDSConfigController { } getCurrentDatasourceType() { - const dsId = this.current.jsonData.dbConnectionDatasourceId; + const dsId = this.dbConnectionDatasourceId; const currentDs = _.find(this.dbDataSources, { 'id': dsId }); return currentDs ? currentDs.type : null; } + loadCurrentDBDatasource() { + const dsName= this.current.jsonData.dbConnectionDatasourceName; + this.datasourceSrv.loadDatasource(dsName) + .then(ds => { + if (ds) { + this.dbConnectionDatasourceId = ds.id; + } + }); + } + autoDetectZabbixVersion() { if (!this.current.id) { return; diff --git a/src/datasource-zabbix/partials/config.html b/src/datasource-zabbix/partials/config.html index 1e9f682..8fd1ac1 100644 --- a/src/datasource-zabbix/partials/config.html +++ b/src/datasource-zabbix/partials/config.html @@ -88,9 +88,9 @@

Direct DB Connection

+ checked="ctrl.dbConnectionEnable"> -
+
Data Source @@ -103,7 +103,7 @@
-
diff --git a/src/datasource-zabbix/specs/utils.spec.js b/src/datasource-zabbix/specs/utils.spec.js index 3367f1f..01cc76f 100644 --- a/src/datasource-zabbix/specs/utils.spec.js +++ b/src/datasource-zabbix/specs/utils.spec.js @@ -155,7 +155,7 @@ describe('Utils', () => { depth: 2 }, { - array: [ [[1, 2], [3, 4]], [[1, 2], [3, 4]] ], + array: [[[1, 2], [3, 4]], [[1, 2], [3, 4]]], depth: 3 }, ]; diff --git a/src/datasource-zabbix/zabbix/connectors/dbConnector.js b/src/datasource-zabbix/zabbix/connectors/dbConnector.js index 8f3ee5a..c4039a1 100644 --- a/src/datasource-zabbix/zabbix/connectors/dbConnector.js +++ b/src/datasource-zabbix/zabbix/connectors/dbConnector.js @@ -65,6 +65,9 @@ export class DBConnector { if (!this.datasourceName) { this.datasourceName = ds.name; } + if (!this.datasourceId) { + this.datasourceId = ds.id; + } return ds; }); } From 938ca83e47e4bba570f7358f91dc772d0a266b4f Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 19 Apr 2019 13:14:41 +0300 Subject: [PATCH 11/59] add migration for percentile agg --- src/datasource-zabbix/metricFunctions.js | 2 +- src/datasource-zabbix/migrations.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/datasource-zabbix/metricFunctions.js b/src/datasource-zabbix/metricFunctions.js index 7953963..891e271 100644 --- a/src/datasource-zabbix/metricFunctions.js +++ b/src/datasource-zabbix/metricFunctions.js @@ -140,7 +140,7 @@ addFuncDef({ }); addFuncDef({ - name: 'percentil', + name: 'percentile', category: 'Aggregate', params: [ { name: 'interval', type: 'string' }, diff --git a/src/datasource-zabbix/migrations.ts b/src/datasource-zabbix/migrations.ts index fd77d9f..a4f60cc 100644 --- a/src/datasource-zabbix/migrations.ts +++ b/src/datasource-zabbix/migrations.ts @@ -33,6 +33,7 @@ export function migrate(target) { if (isGrafana2target(target)) { return migrateFrom2To3version(target); } + migratePercentileAgg(target); return target; } @@ -51,6 +52,16 @@ function convertToRegex(str) { } } +function migratePercentileAgg(target) { + if (target.functions) { + for (const f of target.functions) { + if (f.def && f.def.name === 'percentil') { + f.def.name = 'percentile'; + } + } + } +} + export const DS_CONFIG_SCHEMA = 2; export function migrateDSConfig(jsonData) { if (!jsonData) { From bc889ffe30df7b2600eff058c32661408b840dfe Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 22 Apr 2019 12:29:05 +0300 Subject: [PATCH 12/59] Fix problems fetching performance and memory issues (#724) * request only alert message when invoking alert.get * fetch problem alerts on demand * problems panel: refactor --- .../zabbix_api/zabbixAPIConnector.js | 7 +++- .../components/Problems/ProblemDetails.tsx | 17 ++++++++-- .../components/Problems/ProblemStatusBar.tsx | 9 ++--- .../components/Problems/Problems.tsx | 6 ++-- src/panel-triggers/triggers_panel_ctrl.js | 34 +++++++++---------- src/panel-triggers/types.ts | 1 + 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js index 8b12c96..0282fdf 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js @@ -421,7 +421,12 @@ export class ZabbixAPIConnector { getEventAlerts(eventids) { const params = { eventids: eventids, - output: 'extend', + output: [ + 'eventid', + 'message', + 'clock', + 'error' + ], selectUsers: true, }; diff --git a/src/panel-triggers/components/Problems/ProblemDetails.tsx b/src/panel-triggers/components/Problems/ProblemDetails.tsx index dba69a7..38fc515 100644 --- a/src/panel-triggers/components/Problems/ProblemDetails.tsx +++ b/src/panel-triggers/components/Problems/ProblemDetails.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import moment from 'moment'; import * as utils from '../../../datasource-zabbix/utils'; -import { ZBXTrigger, ZBXItem, ZBXAcknowledge, ZBXHost, ZBXGroup, ZBXEvent, GFTimeRange, RTRow, ZBXTag } from '../../types'; +import { ZBXTrigger, ZBXItem, ZBXAcknowledge, ZBXHost, ZBXGroup, ZBXEvent, GFTimeRange, RTRow, ZBXTag, ZBXAlert } from '../../types'; import { Modal, AckProblemData } from '../Modal'; import EventTag from '../EventTag'; import Tooltip from '../Tooltip/Tooltip'; @@ -15,12 +15,14 @@ interface ProblemDetailsProps extends RTRow { timeRange: GFTimeRange; showTimeline?: boolean; getProblemEvents: (problem: ZBXTrigger) => Promise; + getProblemAlerts: (problem: ZBXTrigger) => Promise; onProblemAck?: (problem: ZBXTrigger, data: AckProblemData) => Promise | any; onTagClick?: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void; } interface ProblemDetailsState { events: ZBXEvent[]; + alerts: ZBXAlert[]; show: boolean; showAckDialog: boolean; } @@ -30,6 +32,7 @@ export default class ProblemDetails extends PureComponent { this.setState({ show: true }); }); @@ -58,6 +62,14 @@ export default class ProblemDetails extends PureComponent { + this.setState({ alerts }); + }); + } + ackProblem = (data: AckProblemData) => { const problem = this.props.original as ZBXTrigger; return this.props.onProblemAck(problem, data).then(result => { @@ -78,6 +90,7 @@ export default class ProblemDetails extends PureComponent 1200; @@ -96,7 +109,7 @@ export default class ProblemDetails extends PureComponent {problem.items && }
- +
diff --git a/src/panel-triggers/components/Problems/Problems.tsx b/src/panel-triggers/components/Problems/Problems.tsx index 740c992..c2a1d2d 100644 --- a/src/panel-triggers/components/Problems/Problems.tsx +++ b/src/panel-triggers/components/Problems/Problems.tsx @@ -5,7 +5,7 @@ import _ from 'lodash'; import moment from 'moment'; import * as utils from '../../../datasource-zabbix/utils'; import { isNewProblem } from '../../utils'; -import { ProblemsPanelOptions, ZBXTrigger, ZBXEvent, GFTimeRange, RTCell, ZBXTag, TriggerSeverity, RTResized } from '../../types'; +import { ProblemsPanelOptions, ZBXTrigger, ZBXEvent, GFTimeRange, RTCell, ZBXTag, TriggerSeverity, RTResized, ZBXAlert } from '../../types'; import EventTag from '../EventTag'; import ProblemDetails from './ProblemDetails'; import { AckProblemData } from '../Modal'; @@ -18,7 +18,8 @@ export interface ProblemListProps { timeRange?: GFTimeRange; pageSize?: number; fontSize?: number; - getProblemEvents: (ids: string[]) => ZBXEvent[]; + getProblemEvents: (problem: ZBXTrigger) => ZBXEvent[]; + getProblemAlerts: (problem: ZBXTrigger) => ZBXAlert[]; onProblemAck?: (problem: ZBXTrigger, data: AckProblemData) => void; onTagClick?: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void; onPageSizeChange?: (pageSize: number, pageIndex: number) => void; @@ -159,6 +160,7 @@ export default class ProblemList extends PureComponent diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index 6f35beb..fc8135a 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -271,14 +271,12 @@ export class TriggerPanelCtrl extends PanelCtrl { })); return Promise.all([ this.datasources[ds].zabbix.getExtendedEventData(eventids), - this.datasources[ds].zabbix.getEventAlerts(eventids), Promise.resolve(triggers) ]); }) - .then(([events, alerts, triggers]) => { + .then(([events, triggers]) => { this.addEventTags(events, triggers); this.addAcknowledges(events, triggers); - this.addEventAlerts(alerts, triggers); return triggers; }) .then(triggers => this.setMaintenanceStatus(triggers)) @@ -337,18 +335,6 @@ export class TriggerPanelCtrl extends PanelCtrl { return triggers; } - addEventAlerts(alerts, triggers) { - alerts.forEach(alert => { - const trigger = _.find(triggers, t => { - return t.lastEvent && alert.eventid === t.lastEvent.eventid; - }); - if (trigger) { - trigger.alerts = trigger.alerts ? trigger.alerts.concat(alert) : [alert]; - } - }); - return triggers; - } - filterTriggersPre(triggerList, ds) { // Filter triggers by description let triggerFilter = this.panel.targets[ds].trigger.filter; @@ -503,16 +489,27 @@ export class TriggerPanelCtrl extends PanelCtrl { this.refresh(); } - getProblemEvents(trigger) { - const triggerids = [trigger.triggerid]; + getProblemEvents(problem) { + const triggerids = [problem.triggerid]; const timeFrom = Math.ceil(dateMath.parse(this.range.from) / 1000); const timeTo = Math.ceil(dateMath.parse(this.range.to) / 1000); - return this.datasourceSrv.get(trigger.datasource) + return this.datasourceSrv.get(problem.datasource) .then(datasource => { return datasource.zabbix.getEvents(triggerids, timeFrom, timeTo, [0, 1], PROBLEM_EVENTS_LIMIT); }); } + getProblemAlerts(problem) { + if (!problem.lastEvent || problem.lastEvent.length === 0) { + return Promise.resolve([]); + } + const eventids = [problem.lastEvent.eventid]; + return this.datasourceSrv.get(problem.datasource) + .then(datasource => { + return datasource.zabbix.getEventAlerts(eventids); + }); + } + formatHostName(trigger) { let host = ""; if (this.panel.hostField && this.panel.hostTechNameField) { @@ -663,6 +660,7 @@ export class TriggerPanelCtrl extends PanelCtrl { pageSize, fontSize: fontSizeProp, getProblemEvents: ctrl.getProblemEvents.bind(ctrl), + getProblemAlerts: ctrl.getProblemAlerts.bind(ctrl), onPageSizeChange: ctrl.handlePageSizeChange.bind(ctrl), onColumnResize: ctrl.handleColumnResize.bind(ctrl), onProblemAck: (trigger, data) => { diff --git a/src/panel-triggers/types.ts b/src/panel-triggers/types.ts index 51f60e5..4025aea 100644 --- a/src/panel-triggers/types.ts +++ b/src/panel-triggers/types.ts @@ -162,6 +162,7 @@ export interface ZBXAcknowledge { } export interface ZBXAlert { + eventid: string; clock: string; message: string; error: string; From f908376802c2de13b8d26a248e2b156517030188 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 22 Apr 2019 13:10:23 +0300 Subject: [PATCH 13/59] Problems panel: hide acknowledge button for read-only users, fix #722 --- .../AlertList/AlertAcknowledges.tsx | 12 +++++++----- .../components/AlertList/AlertCard.tsx | 19 ++++++++++++++----- .../components/Problems/ProblemDetails.tsx | 14 ++++++++------ src/panel-triggers/triggers_panel_ctrl.js | 11 +++++++++++ src/panel-triggers/types.ts | 1 + 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/panel-triggers/components/AlertList/AlertAcknowledges.tsx b/src/panel-triggers/components/AlertList/AlertAcknowledges.tsx index 378c44f..8ddf791 100644 --- a/src/panel-triggers/components/AlertList/AlertAcknowledges.tsx +++ b/src/panel-triggers/components/AlertList/AlertAcknowledges.tsx @@ -36,11 +36,13 @@ export default class AlertAcknowledges extends PureComponent -
- -
+ {problem.showAckButton && +
+ +
+ }
); } diff --git a/src/panel-triggers/components/AlertList/AlertCard.tsx b/src/panel-triggers/components/AlertList/AlertCard.tsx index d0977ad..9b08935 100644 --- a/src/panel-triggers/components/AlertList/AlertCard.tsx +++ b/src/panel-triggers/components/AlertList/AlertCard.tsx @@ -44,7 +44,10 @@ export default class AlertCard extends PureComponent { - this.setState({ showAckDialog: true }); + const problem = this.props.problem; + if (problem.showAckButton) { + this.setState({ showAckDialog: true }); + } } closeAckDialog = () => { @@ -258,14 +261,20 @@ class AlertAcknowledgesButton extends PureComponent - : + + ); + } else if (problem.showAckButton) { + content = ( - ); + ); + } + return content; } } diff --git a/src/panel-triggers/components/Problems/ProblemDetails.tsx b/src/panel-triggers/components/Problems/ProblemDetails.tsx index 38fc515..67154b1 100644 --- a/src/panel-triggers/components/Problems/ProblemDetails.tsx +++ b/src/panel-triggers/components/Problems/ProblemDetails.tsx @@ -110,12 +110,14 @@ export default class ProblemDetails extends PureComponent}
-
- -
+ {problem.showAckButton && +
+ +
+ }
{problem.comments &&
diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index fc8135a..d0d0ab8 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -234,9 +234,11 @@ export class TriggerPanelCtrl extends PanelCtrl { getTriggers() { const timeFrom = Math.ceil(dateMath.parse(this.range.from) / 1000); const timeTo = Math.ceil(dateMath.parse(this.range.to) / 1000); + const userIsEditor = this.contextSrv.isEditor || this.contextSrv.isGrafanaAdmin; let promises = _.map(this.panel.datasources, (ds) => { let proxies; + let showAckButton = true; return this.datasourceSrv.get(ds) .then(datasource => { const zabbix = datasource.zabbix; @@ -244,6 +246,7 @@ export class TriggerPanelCtrl extends PanelCtrl { const triggerFilter = this.panel.targets[ds]; const showProxy = this.panel.hostProxy; const getProxiesPromise = showProxy ? zabbix.getProxies() : () => []; + showAckButton = !datasource.disableReadOnlyUsersAck || userIsEditor; // Replace template variables const groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter); @@ -280,6 +283,7 @@ export class TriggerPanelCtrl extends PanelCtrl { return triggers; }) .then(triggers => this.setMaintenanceStatus(triggers)) + .then(triggers => this.setAckButtonStatus(triggers, showAckButton)) .then(triggers => this.filterTriggersPre(triggers, ds)) .then(triggers => this.addTriggerDataSource(triggers, ds)) .then(triggers => this.addTriggerHostProxy(triggers, proxies)); @@ -395,6 +399,13 @@ export class TriggerPanelCtrl extends PanelCtrl { return triggers; } + setAckButtonStatus(triggers, showAckButton) { + _.each(triggers, (trigger) => { + trigger.showAckButton = showAckButton; + }); + return triggers; + } + addTriggerDataSource(triggers, ds) { _.each(triggers, (trigger) => { trigger.datasource = ds; diff --git a/src/panel-triggers/types.ts b/src/panel-triggers/types.ts index 4025aea..477d8fb 100644 --- a/src/panel-triggers/types.ts +++ b/src/panel-triggers/types.ts @@ -75,6 +75,7 @@ export type TriggerColor = string; export interface ZBXTrigger { acknowledges?: ZBXAcknowledge[]; + showAckButton?: boolean; alerts?: ZBXAlert[]; age?: string; color?: TriggerColor; From 30ce9d8430d7104ec26a1ecd4a301b60e519fcda Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 22 Apr 2019 15:32:38 +0300 Subject: [PATCH 14/59] Problems: fix nodata styles, closes #717 --- src/sass/_panel-problems.scss | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/sass/_panel-problems.scss b/src/sass/_panel-problems.scss index 05901c5..87ba864 100644 --- a/src/sass/_panel-problems.scss +++ b/src/sass/_panel-problems.scss @@ -69,6 +69,8 @@ .rt-noData { z-index: 2; + background: unset; + color: $text-muted; } .pagination-bottom { @@ -522,15 +524,22 @@ @for $i from 11 through 25 { .item-#{$i} { width: 2em * $i; } - &.font-size--#{$i * 10} .rt-table { - font-size: 1% * $i * 10; + &.font-size--#{$i * 10} { + .rt-table { + font-size: 1% * $i * 10; - & .rt-tr .rt-td.custom-expander i { - font-size: 1.2rem * $i / 10; + & .rt-tr .rt-td.custom-expander i { + font-size: 1.2rem * $i / 10; + } + + .problem-details-container.show { + font-size: 13px; + } } - .problem-details-container.show { - font-size: 13px; + .rt-noData { + top: 4.5em; + font-size: 1% * $i * 10; } } } From f76cff2b89f4984604d618f161d837a4ba2cfd85 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 22 Apr 2019 15:51:07 +0300 Subject: [PATCH 15/59] Problems: fix multiline description at List view, closes #704 --- src/panel-triggers/components/AlertList/AlertCard.tsx | 4 ++-- src/sass/_panel-triggers.scss | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/panel-triggers/components/AlertList/AlertCard.tsx b/src/panel-triggers/components/AlertList/AlertCard.tsx index 9b08935..d5c265a 100644 --- a/src/panel-triggers/components/AlertList/AlertCard.tsx +++ b/src/panel-triggers/components/AlertList/AlertCard.tsx @@ -123,9 +123,9 @@ export default class AlertCard extends PureComponent {panelOptions.descriptionField && panelOptions.descriptionAtNewLine && ( -
+
diff --git a/src/sass/_panel-triggers.scss b/src/sass/_panel-triggers.scss index 220440e..b0f98dd 100644 --- a/src/sass/_panel-triggers.scss +++ b/src/sass/_panel-triggers.scss @@ -24,6 +24,10 @@ &.zbx-description--newline { max-height: unset; + + .zbx-description { + margin-left: 0px; + } } .zbx-description { From c5453041acce64235e9991da6b36fb9aea6671bc Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 23 Apr 2019 19:53:38 +0300 Subject: [PATCH 16/59] triggers mode: filter results by group, fix #709 --- src/datasource-zabbix/datasource.js | 12 ++++++++---- src/datasource-zabbix/responseHandler.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index 3f2ac58..8dae24d 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -330,7 +330,7 @@ export class ZabbixDatasource { queryTriggersData(target, timeRange) { let [timeFrom, timeTo] = timeRange; return this.zabbix.getHostsFromTarget(target) - .then((results) => { + .then(results => { let [hosts, apps] = results; if (hosts.length) { let hostids = _.map(hosts, 'hostid'); @@ -342,9 +342,13 @@ export class ZabbixDatasource { timeFrom: timeFrom, timeTo: timeTo }; - return this.zabbix.getHostAlerts(hostids, appids, options) - .then((triggers) => { - return responseHandler.handleTriggersResponse(triggers, timeRange); + const groupFilter = target.group.filter; + return Promise.all([ + this.zabbix.getHostAlerts(hostids, appids, options), + this.zabbix.getGroups(groupFilter) + ]) + .then(([triggers, groups]) => { + return responseHandler.handleTriggersResponse(triggers, groups, timeRange); }); } else { return Promise.resolve([]); diff --git a/src/datasource-zabbix/responseHandler.js b/src/datasource-zabbix/responseHandler.js index d25e282..d6f1347 100644 --- a/src/datasource-zabbix/responseHandler.js +++ b/src/datasource-zabbix/responseHandler.js @@ -143,7 +143,7 @@ function handleSLAResponse(itservice, slaProperty, slaObject) { } } -function handleTriggersResponse(triggers, timeRange) { +function handleTriggersResponse(triggers, groups, timeRange) { if (_.isNumber(triggers)) { return { target: "triggers count", @@ -152,16 +152,19 @@ function handleTriggersResponse(triggers, timeRange) { ] }; } else { - let stats = getTriggerStats(triggers); + const stats = getTriggerStats(triggers); + const groupNames = _.map(groups, 'name'); let table = new TableModel(); table.addColumn({text: 'Host group'}); _.each(_.orderBy(c.TRIGGER_SEVERITY, ['val'], ['desc']), (severity) => { table.addColumn({text: severity.text}); }); _.each(stats, (severity_stats, group) => { - let row = _.map(_.orderBy(_.toPairs(severity_stats), (s) => s[0], ['desc']), (s) => s[1]); - row = _.concat([group], ...row); - table.rows.push(row); + if (_.includes(groupNames, group)) { + let row = _.map(_.orderBy(_.toPairs(severity_stats), (s) => s[0], ['desc']), (s) => s[1]); + row = _.concat([group], ...row); + table.rows.push(row); + } }); return table; } From 16c889f3b6de7fec6633ef84213375d559b734b9 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 23 Apr 2019 20:07:26 +0300 Subject: [PATCH 17/59] update change log --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb0511..810dd96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [3.10.2] - 2019-04-23 +### Fixed +- Direct DB Connection: provisioned datasource fails to load, [#711](https://github.com/alexanderzobnin/grafana-zabbix/issues/711) +- Functions: `sumSeries` doesn't work in couple with other aggregation functions, [#530](https://github.com/alexanderzobnin/grafana-zabbix/issues/530) +- Problems panel: performance and memory issues, [#720](https://github.com/alexanderzobnin/grafana-zabbix/issues/720), [#712](https://github.com/alexanderzobnin/grafana-zabbix/issues/712) +- Problems panel: hide acknowledge button for read-only users, [#722](https://github.com/alexanderzobnin/grafana-zabbix/issues/722) +- Problems panel: "no data" overlaps table header when font size increased, [#717](https://github.com/alexanderzobnin/grafana-zabbix/issues/717) +- Problems panel: problem description does not resize problem bar, [#704](https://github.com/alexanderzobnin/grafana-zabbix/issues/704) +- Triggers query mode: problems not filtered by selected groups, [#709](https://github.com/alexanderzobnin/grafana-zabbix/issues/709) + ## [3.10.1] - 2019-03-05 ### Fixed - Problems panel: unable to edit panel in Grafana 6.0, [#685](https://github.com/alexanderzobnin/grafana-zabbix/issues/685) From 7d6c0c23985cd524be7515c7ed6b5252402f03f0 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 23 Apr 2019 20:09:49 +0300 Subject: [PATCH 18/59] bump plugin version to 3.10.2 --- src/plugin.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin.json b/src/plugin.json index b49dcbc..c3d6a2a 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -26,8 +26,8 @@ {"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"}, {"name": "Triggers", "path": "img/screenshot-triggers.png"} ], - "version": "3.10.1", - "updated": "2019-03-05" + "version": "3.10.2", + "updated": "2019-04-23" }, "includes": [ From e1e5ea193a0556c773507aa74f1e65e1a723caca Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 24 Apr 2019 10:04:24 +0300 Subject: [PATCH 19/59] fix triggers count in latest zabbix 4.x, closes #726 --- src/datasource-zabbix/responseHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasource-zabbix/responseHandler.js b/src/datasource-zabbix/responseHandler.js index d6f1347..524586d 100644 --- a/src/datasource-zabbix/responseHandler.js +++ b/src/datasource-zabbix/responseHandler.js @@ -144,7 +144,7 @@ function handleSLAResponse(itservice, slaProperty, slaObject) { } function handleTriggersResponse(triggers, groups, timeRange) { - if (_.isNumber(triggers)) { + if (!_.isArray(triggers)) { return { target: "triggers count", datapoints: [ From 3a7da58302374f6305fff080b292dc7a7b58679d Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 24 Apr 2019 10:12:38 +0300 Subject: [PATCH 20/59] fix triggers count with latest Zabbix 4.x, closes #726 --- src/datasource-zabbix/responseHandler.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/datasource-zabbix/responseHandler.js b/src/datasource-zabbix/responseHandler.js index 524586d..e340c80 100644 --- a/src/datasource-zabbix/responseHandler.js +++ b/src/datasource-zabbix/responseHandler.js @@ -145,10 +145,16 @@ function handleSLAResponse(itservice, slaProperty, slaObject) { function handleTriggersResponse(triggers, groups, timeRange) { if (!_.isArray(triggers)) { + let triggersCount = null; + try { + triggersCount = Number(triggers); + } catch (err) { + console.log("Error when handling triggers count: ", err); + } return { target: "triggers count", datapoints: [ - [triggers, timeRange[1] * 1000] + [triggersCount, timeRange[1] * 1000] ] }; } else { From 6b5b5f818bad2086903f307a4ef200eab9c1feea Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 5 Jul 2019 16:23:36 +0300 Subject: [PATCH 21/59] fix direct DB connection datasource config, closes #731 --- src/datasource-zabbix/config.controller.js | 6 ++++-- src/datasource-zabbix/partials/config.html | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/datasource-zabbix/config.controller.js b/src/datasource-zabbix/config.controller.js index 342c4f0..926d5b0 100644 --- a/src/datasource-zabbix/config.controller.js +++ b/src/datasource-zabbix/config.controller.js @@ -29,9 +29,7 @@ export class ZabbixDSConfigController { this.current.jsonData = migrateDSConfig(this.current.jsonData); _.defaults(this.current.jsonData, defaultConfig); - this.dbConnectionEnable = this.current.jsonData.dbConnectionEnable; this.dbConnectionDatasourceId = this.current.jsonData.dbConnectionDatasourceId; - this.dbDataSources = this.getSupportedDBDataSources(); this.zabbixVersions = _.cloneDeep(zabbixVersions); this.autoDetectZabbixVersion(); @@ -81,4 +79,8 @@ export class ZabbixDSConfigController { } }); } + + onDBConnectionDatasourceChange() { + this.current.jsonData.dbConnectionDatasourceId = this.dbConnectionDatasourceId; + } } diff --git a/src/datasource-zabbix/partials/config.html b/src/datasource-zabbix/partials/config.html index 2ca3538..6b389f3 100644 --- a/src/datasource-zabbix/partials/config.html +++ b/src/datasource-zabbix/partials/config.html @@ -88,9 +88,9 @@

Direct DB Connection

+ checked="ctrl.current.jsonData.dbConnectionEnable"> -
+
Data Source @@ -103,8 +103,10 @@
-
From 4346e133652ff809d1b3856bab2a8d487272724a Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 5 Jul 2019 17:42:46 +0300 Subject: [PATCH 22/59] fix function editor in Grafana 6, #765 --- package.json | 1 + src/datasource-zabbix/FunctionEditor.tsx | 109 ++++++++ .../FunctionEditorControls.tsx | 67 +++++ .../metric-function-editor.directive.js | 248 ----------------- .../metric-function-editor.directive.ts | 256 ++++++++++++++++++ .../partials/query.editor.html | 4 +- src/datasource-zabbix/query.controller.js | 6 + src/datasource-zabbix/react2angular.ts | 10 + webpack/webpack.base.conf.js | 4 +- yarn.lock | 213 +++++++++++++++ 10 files changed, 667 insertions(+), 251 deletions(-) create mode 100644 src/datasource-zabbix/FunctionEditor.tsx create mode 100644 src/datasource-zabbix/FunctionEditorControls.tsx delete mode 100644 src/datasource-zabbix/metric-function-editor.directive.js create mode 100644 src/datasource-zabbix/metric-function-editor.directive.ts create mode 100644 src/datasource-zabbix/react2angular.ts diff --git a/package.json b/package.json index 1dc5097..d7e8b01 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "react-table": "^6.8.6", "react-test-renderer": "^16.7.0", "react-transition-group": "^2.5.2", + "rst2html": "github:thoward/rst2html#990cb89", "sass-loader": "^7.1.0", "style-loader": "^0.23.1", "tether-drop": "^1.4.2", diff --git a/src/datasource-zabbix/FunctionEditor.tsx b/src/datasource-zabbix/FunctionEditor.tsx new file mode 100644 index 0000000..285a88a --- /dev/null +++ b/src/datasource-zabbix/FunctionEditor.tsx @@ -0,0 +1,109 @@ +import React from 'react'; +// import rst2html from 'rst2html'; +import { FunctionDescriptor, FunctionEditorControlsProps, FunctionEditorControls } from './FunctionEditorControls'; + +// @ts-ignore +import { PopperController, Popper } from '@grafana/ui'; + +interface FunctionEditorProps extends FunctionEditorControlsProps { + func: FunctionDescriptor; +} + +interface FunctionEditorState { + showingDescription: boolean; +} + +class FunctionEditor extends React.PureComponent { + private triggerRef = React.createRef(); + + constructor(props: FunctionEditorProps) { + super(props); + + this.state = { + showingDescription: false, + }; + } + + renderContent = ({ updatePopperPosition }) => { + const { + onMoveLeft, + onMoveRight, + func: { + def: { name, description }, + }, + } = this.props; + const { showingDescription } = this.state; + + if (showingDescription) { + return ( +
+

{name}

+
{description}
+ /> +
+ ); + } + + return ( + { + onMoveLeft(this.props.func); + updatePopperPosition(); + }} + onMoveRight={() => { + onMoveRight(this.props.func); + updatePopperPosition(); + }} + onDescriptionShow={() => { + this.setState({ showingDescription: true }, () => { + updatePopperPosition(); + }); + }} + /> + ); + }; + + render() { + return ( + + {(showPopper, hidePopper, popperProps) => { + return ( + <> + {this.triggerRef && ( + { + this.setState({ showingDescription: false }); + hidePopper(); + }} + onMouseEnter={showPopper} + renderArrow={({ arrowProps, placement }) => ( +
+ )} + /> + )} + + { + hidePopper(); + this.setState({ showingDescription: false }); + }} + style={{ cursor: 'pointer' }} + > + {this.props.func.def.name} + + + ); + }} + + ); + } +} + +export { FunctionEditor }; diff --git a/src/datasource-zabbix/FunctionEditorControls.tsx b/src/datasource-zabbix/FunctionEditorControls.tsx new file mode 100644 index 0000000..2fde684 --- /dev/null +++ b/src/datasource-zabbix/FunctionEditorControls.tsx @@ -0,0 +1,67 @@ +import React from 'react'; + +const DOCS_FUNC_REF_URL = 'https://alexanderzobnin.github.io/grafana-zabbix/reference/functions/'; + +export interface FunctionDescriptor { + text: string; + params: string[]; + def: { + category: string; + defaultParams: string[]; + description?: string; + fake: boolean; + name: string; + params: string[]; + }; +} + +export interface FunctionEditorControlsProps { + onMoveLeft: (func: FunctionDescriptor) => void; + onMoveRight: (func: FunctionDescriptor) => void; + onRemove: (func: FunctionDescriptor) => void; +} + +const FunctionHelpButton = (props: { description: string; name: string; onDescriptionShow: () => void }) => { + if (props.description) { + return ; + } + + return ( + { + window.open( + DOCS_FUNC_REF_URL + '#' + props.name, + '_blank' + ); + }} + /> + ); +}; + +export const FunctionEditorControls = ( + props: FunctionEditorControlsProps & { + func: FunctionDescriptor; + onDescriptionShow: () => void; + } +) => { + const { func, onMoveLeft, onMoveRight, onRemove, onDescriptionShow } = props; + return ( +
+ onMoveLeft(func)} /> + + onRemove(func)} /> + onMoveRight(func)} /> +
+ ); +}; diff --git a/src/datasource-zabbix/metric-function-editor.directive.js b/src/datasource-zabbix/metric-function-editor.directive.js deleted file mode 100644 index 03d07ae..0000000 --- a/src/datasource-zabbix/metric-function-editor.directive.js +++ /dev/null @@ -1,248 +0,0 @@ -import angular from 'angular'; -import _ from 'lodash'; -import $ from 'jquery'; - -const DOCS_FUNC_REF_URL = 'https://alexanderzobnin.github.io/grafana-zabbix/reference/functions/'; - -angular - .module('grafana.directives') - .directive('metricFunctionEditor', - - /** @ngInject */ - function($compile, templateSrv) { - - var funcSpanTemplate = '{{func.def.name}}('; - var paramTemplate = ''; - - var funcControlsTemplate = - '
' + - '' + - '' + - '' + - '' + - '
'; - - return { - restrict: 'A', - link: function postLink($scope, elem) { - var $funcLink = $(funcSpanTemplate); - var $funcControls = $(funcControlsTemplate); - var ctrl = $scope.ctrl; - var func = $scope.func; - var funcDef = func.def; - var scheduledRelink = false; - var paramCountAtLink = 0; - - function clickFuncParam(paramIndex) { - /*jshint validthis:true */ - - var $link = $(this); - var $input = $link.next(); - - $input.val(func.params[paramIndex]); - $input.css('width', ($link.width() + 16) + 'px'); - - $link.hide(); - $input.show(); - $input.focus(); - $input.select(); - - var typeahead = $input.data('typeahead'); - if (typeahead) { - $input.val(''); - typeahead.lookup(); - } - } - - function scheduledRelinkIfNeeded() { - if (paramCountAtLink === func.params.length) { - return; - } - - if (!scheduledRelink) { - scheduledRelink = true; - setTimeout(function() { - relink(); - scheduledRelink = false; - }, 200); - } - } - - function inputBlur(paramIndex) { - /*jshint validthis:true */ - var $input = $(this); - var $link = $input.prev(); - var newValue = $input.val(); - - if (newValue !== '' || func.def.params[paramIndex].optional) { - $link.html(templateSrv.highlightVariablesAsHtml(newValue)); - - func.updateParam($input.val(), paramIndex); - scheduledRelinkIfNeeded(); - - $scope.$apply(function() { - ctrl.targetChanged(); - }); - - $input.hide(); - $link.show(); - } - } - - function inputKeyPress(paramIndex, e) { - /*jshint validthis:true */ - if(e.which === 13) { - inputBlur.call(this, paramIndex); - } - } - - function inputKeyDown() { - /*jshint validthis:true */ - this.style.width = (3 + this.value.length) * 8 + 'px'; - } - - function addTypeahead($input, paramIndex) { - $input.attr('data-provide', 'typeahead'); - - var options = funcDef.params[paramIndex].options; - if (funcDef.params[paramIndex].type === 'int' || - funcDef.params[paramIndex].type === 'float') { - options = _.map(options, function(val) { return val.toString(); }); - } - - $input.typeahead({ - source: options, - minLength: 0, - items: 20, - updater: function (value) { - setTimeout(function() { - inputBlur.call($input[0], paramIndex); - }, 0); - return value; - } - }); - - var typeahead = $input.data('typeahead'); - typeahead.lookup = function () { - this.query = this.$element.val() || ''; - return this.process(this.source); - }; - } - - function toggleFuncControls() { - var targetDiv = elem.closest('.tight-form'); - - if (elem.hasClass('show-function-controls')) { - elem.removeClass('show-function-controls'); - targetDiv.removeClass('has-open-function'); - $funcControls.hide(); - return; - } - - elem.addClass('show-function-controls'); - targetDiv.addClass('has-open-function'); - - $funcControls.show(); - } - - function addElementsAndCompile() { - $funcControls.appendTo(elem); - $funcLink.appendTo(elem); - - _.each(funcDef.params, function(param, index) { - if (param.optional && func.params.length <= index) { - return; - } - - if (index > 0) { - $(', ').appendTo(elem); - } - - var paramValue = templateSrv.highlightVariablesAsHtml(func.params[index]); - var $paramLink = $('' + paramValue + ''); - var $input = $(paramTemplate); - - paramCountAtLink++; - - $paramLink.appendTo(elem); - $input.appendTo(elem); - - $input.blur(_.partial(inputBlur, index)); - $input.keyup(inputKeyDown); - $input.keypress(_.partial(inputKeyPress, index)); - $paramLink.click(_.partial(clickFuncParam, index)); - - if (funcDef.params[index].options) { - addTypeahead($input, index); - } - - }); - - $(')').appendTo(elem); - - $compile(elem.contents())($scope); - } - - function ifJustAddedFocusFistParam() { - if ($scope.func.added) { - $scope.func.added = false; - setTimeout(function() { - elem.find('.graphite-func-param-link').first().click(); - }, 10); - } - } - - function registerFuncControlsToggle() { - $funcLink.click(toggleFuncControls); - } - - function registerFuncControlsActions() { - $funcControls.click(function(e) { - var $target = $(e.target); - if ($target.hasClass('fa-remove')) { - toggleFuncControls(); - $scope.$apply(function() { - ctrl.removeFunction($scope.func); - }); - return; - } - - if ($target.hasClass('fa-arrow-left')) { - $scope.$apply(function() { - _.move($scope.target.functions, $scope.$index, $scope.$index - 1); - ctrl.targetChanged(); - }); - return; - } - - if ($target.hasClass('fa-arrow-right')) { - $scope.$apply(function() { - _.move($scope.target.functions, $scope.$index, $scope.$index + 1); - ctrl.targetChanged(); - }); - return; - } - - if ($target.hasClass('fa-question-circle')) { - var docSite = DOCS_FUNC_REF_URL; - window.open(docSite + '#' + funcDef.name.toLowerCase(),'_blank'); - return; - } - }); - } - - function relink() { - elem.children().remove(); - - addElementsAndCompile(); - ifJustAddedFocusFistParam(); - registerFuncControlsToggle(); - registerFuncControlsActions(); - } - - relink(); - } - }; - - }); diff --git a/src/datasource-zabbix/metric-function-editor.directive.ts b/src/datasource-zabbix/metric-function-editor.directive.ts new file mode 100644 index 0000000..232025d --- /dev/null +++ b/src/datasource-zabbix/metric-function-editor.directive.ts @@ -0,0 +1,256 @@ +import coreModule from 'grafana/app/core/core_module'; +import _ from 'lodash'; +import $ from 'jquery'; +import { react2AngularDirective } from './react2angular'; +import { FunctionEditor } from './FunctionEditor'; + +/** @ngInject */ +export function zabbixFunctionEditor($compile, templateSrv) { + const funcSpanTemplate = ` + ( + `; + const paramTemplate = + ''; + + return { + restrict: 'A', + link: function postLink($scope, elem) { + const $funcLink = $(funcSpanTemplate); + const ctrl = $scope.ctrl; + const func = $scope.func; + let scheduledRelink = false; + let paramCountAtLink = 0; + let cancelBlur = null; + + ctrl.handleRemoveFunction = func => { + ctrl.removeFunction(func); + }; + + ctrl.handleMoveLeft = func => { + ctrl.moveFunction(func, -1); + }; + + ctrl.handleMoveRight = func => { + ctrl.moveFunction(func, 1); + }; + + function clickFuncParam(this: any, paramIndex) { + /*jshint validthis:true */ + + const $link = $(this); + const $comma = $link.prev('.comma'); + const $input = $link.next(); + + $input.val(func.params[paramIndex]); + + $comma.removeClass('query-part__last'); + $link.hide(); + $input.show(); + $input.focus(); + $input.select(); + + const typeahead = $input.data('typeahead'); + if (typeahead) { + $input.val(''); + typeahead.lookup(); + } + } + + function scheduledRelinkIfNeeded() { + if (paramCountAtLink === func.params.length) { + return; + } + + if (!scheduledRelink) { + scheduledRelink = true; + setTimeout(() => { + relink(); + scheduledRelink = false; + }, 200); + } + } + + function paramDef(index) { + if (index < func.def.params.length) { + return func.def.params[index]; + } + if ((_.last(func.def.params) as any).multiple) { + return _.assign({}, _.last(func.def.params), { optional: true }); + } + return {}; + } + + function switchToLink(inputElem, paramIndex) { + /*jshint validthis:true */ + const $input = $(inputElem); + + clearTimeout(cancelBlur); + cancelBlur = null; + + const $link = $input.prev(); + const $comma = $link.prev('.comma'); + const newValue = $input.val(); + + // remove optional empty params + if (newValue !== '' || paramDef(paramIndex).optional) { + func.updateParam(newValue, paramIndex); + $link.html(newValue ? templateSrv.highlightVariablesAsHtml(newValue) : ' '); + } + + scheduledRelinkIfNeeded(); + + $scope.$apply(() => { + ctrl.targetChanged(); + }); + + if ($link.hasClass('query-part__last') && newValue === '') { + $comma.addClass('query-part__last'); + } else { + $link.removeClass('query-part__last'); + } + + $input.hide(); + $link.show(); + } + + // this = input element + function inputBlur(this: any, paramIndex) { + /*jshint validthis:true */ + const inputElem = this; + // happens long before the click event on the typeahead options + // need to have long delay because the blur + cancelBlur = setTimeout(() => { + switchToLink(inputElem, paramIndex); + }, 200); + } + + function inputKeyPress(this: any, paramIndex, e) { + /*jshint validthis:true */ + if (e.which === 13) { + $(this).blur(); + } + } + + function inputKeyDown(this: any) { + /*jshint validthis:true */ + this.style.width = (3 + this.value.length) * 8 + 'px'; + } + + function addTypeahead($input, paramIndex) { + $input.attr('data-provide', 'typeahead'); + + let options = paramDef(paramIndex).options; + if (paramDef(paramIndex).type === 'int' || paramDef(paramIndex).type === 'float') { + options = _.map(options, val => { + return val.toString(); + }); + } + + $input.typeahead({ + source: options, + minLength: 0, + items: 20, + updater: value => { + $input.val(value); + switchToLink($input[0], paramIndex); + return value; + }, + }); + + const typeahead = $input.data('typeahead'); + typeahead.lookup = function() { + this.query = this.$element.val() || ''; + return this.process(this.source); + }; + } + + function addElementsAndCompile() { + $funcLink.appendTo(elem); + + const defParams: any = _.clone(func.def.params); + const lastParam: any = _.last(func.def.params); + + while (func.params.length >= defParams.length && lastParam && lastParam.multiple) { + defParams.push(_.assign({}, lastParam, { optional: true })); + } + + _.each(defParams, (param: any, index: number) => { + if (param.optional && func.params.length < index) { + return false; + } + + let paramValue = templateSrv.highlightVariablesAsHtml(func.params[index]); + const hasValue = paramValue !== null && paramValue !== undefined; + + const last = index >= func.params.length - 1 && param.optional && !hasValue; + if (last && param.multiple) { + paramValue = '+'; + } + + if (index > 0) { + $(', ').appendTo(elem); + } + + const $paramLink = $( + '' + + (hasValue ? paramValue : ' ') + + '' + ); + const $input = $(paramTemplate); + $input.attr('placeholder', param.name); + + paramCountAtLink++; + + $paramLink.appendTo(elem); + $input.appendTo(elem); + + $input.blur(_.partial(inputBlur, index)); + $input.keyup(inputKeyDown); + $input.keypress(_.partial(inputKeyPress, index)); + $paramLink.click(_.partial(clickFuncParam, index)); + + if (param.options) { + addTypeahead($input, index); + } + + return true; + }); + + $(')').appendTo(elem); + + $compile(elem.contents())($scope); + } + + function ifJustAddedFocusFirstParam() { + if ($scope.func.added) { + $scope.func.added = false; + setTimeout(() => { + elem + .find('.graphite-func-param-link') + .first() + .click(); + }, 10); + } + } + + function relink() { + elem.children().remove(); + addElementsAndCompile(); + ifJustAddedFocusFirstParam(); + } + + relink(); + }, + }; +} + +coreModule.directive('zabbixFunctionEditor', zabbixFunctionEditor); + +react2AngularDirective('zbxFunctionEditor', FunctionEditor, ['func', 'onRemove', 'onMoveLeft', 'onMoveRight']); diff --git a/src/datasource-zabbix/partials/query.editor.html b/src/datasource-zabbix/partials/query.editor.html index de976ae..33b2f7d 100644 --- a/src/datasource-zabbix/partials/query.editor.html +++ b/src/datasource-zabbix/partials/query.editor.html @@ -204,7 +204,9 @@
-
+
+
+
diff --git a/src/datasource-zabbix/query.controller.js b/src/datasource-zabbix/query.controller.js index 95fa3e9..fc9f963 100644 --- a/src/datasource-zabbix/query.controller.js +++ b/src/datasource-zabbix/query.controller.js @@ -275,6 +275,12 @@ export class ZabbixQueryController extends QueryCtrl { this.targetChanged(); } + moveFunction(func, offset) { + const index = this.target.functions.indexOf(func); + _.move(this.target.functions, index, index + offset); + this.targetChanged(); + } + moveAliasFuncLast() { var aliasFunc = _.find(this.target.functions, function(func) { return func.def.name === 'alias' || diff --git a/src/datasource-zabbix/react2angular.ts b/src/datasource-zabbix/react2angular.ts new file mode 100644 index 0000000..2588746 --- /dev/null +++ b/src/datasource-zabbix/react2angular.ts @@ -0,0 +1,10 @@ +import coreModule from 'grafana/app/core/core_module'; + +export function react2AngularDirective(name: string, component: any, options: any) { + coreModule.directive(name, [ + 'reactDirective', + reactDirective => { + return reactDirective(component, options); + }, + ]); +} diff --git a/webpack/webpack.base.conf.js b/webpack/webpack.base.conf.js index 414ba44..af61e38 100644 --- a/webpack/webpack.base.conf.js +++ b/webpack/webpack.base.conf.js @@ -28,7 +28,7 @@ module.exports = { externals: [ // remove the line below if you don't want to use builtin versions 'jquery', 'lodash', 'moment', 'angular', - 'react', 'react-dom', + 'react', 'react-dom', '@grafana/ui', function (context, request, callback) { var prefix = 'grafana/'; if (request.indexOf(prefix) === 0) { @@ -53,7 +53,7 @@ module.exports = { ExtractTextPluginDark, ], resolve: { - extensions: [".js", ".ts", ".tsx", ".html", ".scss"] + extensions: ['.js', '.es6', '.ts', '.tsx', '.html', '.scss'] }, module: { rules: [ diff --git a/yarn.lock b/yarn.lock index 3c8a7e4..f1e362a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -373,6 +373,11 @@ acorn-dynamic-import@^3.0.0: dependencies: acorn "^5.0.0" +acorn-es7-plugin@^1.0.12: + version "1.1.7" + resolved "https://registry.yarnpkg.com/acorn-es7-plugin/-/acorn-es7-plugin-1.1.7.tgz#f2ee1f3228a90eead1245f9ab1922eb2e71d336b" + integrity sha1-8u4fMiipDurRJF+asZIusucdM2s= + acorn-globals@^4.0.0, acorn-globals@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538" @@ -555,6 +560,11 @@ array-equal@^1.0.0: resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" integrity sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM= +array-filter@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83" + integrity sha1-uveeYubvTCpMC4MSMtr/7CUfnYM= + array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" @@ -1623,6 +1633,11 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +call-signature@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/call-signature/-/call-signature-0.0.2.tgz#a84abc825a55ef4cb2b028bd74e205a65b9a4996" + integrity sha1-qEq8glpV70yysCi9dOIFpluaSZY= + callsites@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" @@ -1922,6 +1937,11 @@ commander@^2.12.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== +commander@^2.9.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -2039,6 +2059,11 @@ core-js@^1.0.0: resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY= +core-js@^2.0.0: + version "2.6.9" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2" + integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A== + core-js@^2.4.0, core-js@^2.5.0: version "2.5.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" @@ -2366,6 +2391,11 @@ detect-newline@^2.1.0: resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" integrity sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I= +diff-match-patch@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.4.tgz#6ac4b55237463761c4daf0dc603eb869124744b1" + integrity sha512-Uv3SW8bmH9nAtHKaKSanOQmj2DnlH65fUpcrMdfdaOxUG02QQ4YGZ8AE7kKOMisF7UqvOlGKVYWRvezdncW9lg== + diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -2450,6 +2480,11 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -2481,6 +2516,22 @@ emojis-list@^2.0.0: resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= +empower-core@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/empower-core/-/empower-core-1.2.0.tgz#ce3fb2484d5187fa29c23fba8344b0b2fdf5601c" + integrity sha512-g6+K6Geyc1o6FdXs9HwrXleCFan7d66G5xSCfSF7x1mJDCes6t0om9lFQG3zOrzh3Bkb/45N0cZ5Gqsf7YrzGQ== + dependencies: + call-signature "0.0.2" + core-js "^2.0.0" + +empower@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/empower/-/empower-1.3.1.tgz#768979cbbb36d71d8f5edaab663deacb9dab916c" + integrity sha512-uB6/ViBaawOO/uujFADTK3SqdYlxYNn+N4usK9MRKZ4Hbn/1QSy8k2PezxCA2/+JGbF8vd/eOfghZ90oOSDZCA== + dependencies: + core-js "^2.0.0" + empower-core "^1.2.0" + encoding@^0.1.11: version "0.1.12" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" @@ -2601,6 +2652,13 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== +espurify@^1.6.0: + version "1.8.1" + resolved "https://registry.yarnpkg.com/espurify/-/espurify-1.8.1.tgz#5746c6c1ab42d302de10bd1d5bf7f0e8c0515056" + integrity sha512-ZDko6eY/o+D/gHCWyHTU85mKDgYcS4FJj7S+YD6WIInm7GQ6AnOjmcL4+buFV/JOztVLELi/7MmuGU5NHta0Mg== + dependencies: + core-js "^2.0.0" + esrecurse@^4.1.0: version "4.2.1" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" @@ -5532,6 +5590,11 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-keys@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + object-keys@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2" @@ -6038,6 +6101,105 @@ postcss@^6.0.1, postcss@^6.0.23: source-map "^0.6.1" supports-color "^5.4.0" +power-assert-context-formatter@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-context-formatter/-/power-assert-context-formatter-1.2.0.tgz#8fbe72692288ec5a7203cdf215c8b838a6061d2a" + integrity sha512-HLNEW8Bin+BFCpk/zbyKwkEu9W8/zThIStxGo7weYcFkKgMuGCHUJhvJeBGXDZf0Qm2xis4pbnnciGZiX0EpSg== + dependencies: + core-js "^2.0.0" + power-assert-context-traversal "^1.2.0" + +power-assert-context-reducer-ast@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-context-reducer-ast/-/power-assert-context-reducer-ast-1.2.0.tgz#c7ca1c9e39a6fb717f7ac5fe9e76e192bf525df3" + integrity sha512-EgOxmZ/Lb7tw4EwSKX7ZnfC0P/qRZFEG28dx/690qvhmOJ6hgThYFm5TUWANDLK5NiNKlPBi5WekVGd2+5wPrw== + dependencies: + acorn "^5.0.0" + acorn-es7-plugin "^1.0.12" + core-js "^2.0.0" + espurify "^1.6.0" + estraverse "^4.2.0" + +power-assert-context-traversal@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-context-traversal/-/power-assert-context-traversal-1.2.0.tgz#f6e71454baf640de5c1c9c270349f5c9ab0b2e94" + integrity sha512-NFoHU6g2umNajiP2l4qb0BRWD773Aw9uWdWYH9EQsVwIZnog5bd2YYLFCVvaxWpwNzWeEfZIon2xtyc63026pQ== + dependencies: + core-js "^2.0.0" + estraverse "^4.1.0" + +power-assert-formatter@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/power-assert-formatter/-/power-assert-formatter-1.4.1.tgz#5dc125ed50a3dfb1dda26c19347f3bf58ec2884a" + integrity sha1-XcEl7VCj37HdomwZNH879Y7CiEo= + dependencies: + core-js "^2.0.0" + power-assert-context-formatter "^1.0.7" + power-assert-context-reducer-ast "^1.0.7" + power-assert-renderer-assertion "^1.0.7" + power-assert-renderer-comparison "^1.0.7" + power-assert-renderer-diagram "^1.0.7" + power-assert-renderer-file "^1.0.7" + +power-assert-renderer-assertion@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-renderer-assertion/-/power-assert-renderer-assertion-1.2.0.tgz#3db6ffcda106b37bc1e06432ad0d748a682b147a" + integrity sha512-3F7Q1ZLmV2ZCQv7aV7NJLNK9G7QsostrhOU7U0RhEQS/0vhEqrRg2jEJl1jtUL4ZyL2dXUlaaqrmPv5r9kRvIg== + dependencies: + power-assert-renderer-base "^1.1.1" + power-assert-util-string-width "^1.2.0" + +power-assert-renderer-base@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/power-assert-renderer-base/-/power-assert-renderer-base-1.1.1.tgz#96a650c6fd05ee1bc1f66b54ad61442c8b3f63eb" + integrity sha1-lqZQxv0F7hvB9mtUrWFELIs/Y+s= + +power-assert-renderer-comparison@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-renderer-comparison/-/power-assert-renderer-comparison-1.2.0.tgz#e4f88113225a69be8aa586ead05aef99462c0495" + integrity sha512-7c3RKPDBKK4E3JqdPtYRE9cM8AyX4LC4yfTvvTYyx8zSqmT5kJnXwzR0yWQLOavACllZfwrAGQzFiXPc5sWa+g== + dependencies: + core-js "^2.0.0" + diff-match-patch "^1.0.0" + power-assert-renderer-base "^1.1.1" + stringifier "^1.3.0" + type-name "^2.0.1" + +power-assert-renderer-diagram@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-renderer-diagram/-/power-assert-renderer-diagram-1.2.0.tgz#37f66e8542e5677c5b58e6d72b01c0d9a30e2219" + integrity sha512-JZ6PC+DJPQqfU6dwSmpcoD7gNnb/5U77bU5KgNwPPa+i1Pxiz6UuDeM3EUBlhZ1HvH9tMjI60anqVyi5l2oNdg== + dependencies: + core-js "^2.0.0" + power-assert-renderer-base "^1.1.1" + power-assert-util-string-width "^1.2.0" + stringifier "^1.3.0" + +power-assert-renderer-file@^1.0.7: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-renderer-file/-/power-assert-renderer-file-1.2.0.tgz#3f4bebd9e1455d75cf2ac541e7bb515a87d4ce4b" + integrity sha512-/oaVrRbeOtGoyyd7e4IdLP/jIIUFJdqJtsYzP9/88R39CMnfF/S/rUc8ZQalENfUfQ/wQHu+XZYRMaCEZmEesg== + dependencies: + power-assert-renderer-base "^1.1.1" + +power-assert-util-string-width@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/power-assert-util-string-width/-/power-assert-util-string-width-1.2.0.tgz#6e06d5e3581bb876c5d377c53109fffa95bd91a0" + integrity sha512-lX90G0igAW0iyORTILZ/QjZWsa1MZ6VVY3L0K86e2eKun3S4LKPH4xZIl8fdeMYLfOjkaszbNSzf1uugLeAm2A== + dependencies: + eastasianwidth "^0.2.0" + +power-assert@^1.2.0: + version "1.6.1" + resolved "https://registry.yarnpkg.com/power-assert/-/power-assert-1.6.1.tgz#b28cbc02ae808afd1431d0cd5093a39ac5a5b1fe" + integrity sha512-VWkkZV6Y+W8qLX/PtJu2Ur2jDPIs0a5vbP0TpKeybNcIXmT4vcKoVkyTp5lnQvTpY/DxacAZ4RZisHRHLJcAZQ== + dependencies: + define-properties "^1.1.2" + empower "^1.3.1" + power-assert-formatter "^1.4.1" + universal-deep-strict-equal "^1.2.1" + xtend "^4.0.0" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -6584,6 +6746,16 @@ resolve@^1.1.6, resolve@^1.1.7, resolve@^1.3.2: dependencies: path-parse "^1.0.5" +restructured@0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/restructured/-/restructured-0.0.11.tgz#f914f6b6f358b8e45d6d8ee268926cf1a783f710" + integrity sha1-+RT2tvNYuORdbY7iaJJs8aeD9xA= + dependencies: + commander "^2.9.0" + lodash "^4.0.0" + power-assert "^1.2.0" + unist-util-map "^1.0.2" + ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -6616,6 +6788,12 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +"rst2html@github:thoward/rst2html#990cb89": + version "1.0.4" + resolved "https://codeload.github.com/thoward/rst2html/tar.gz/990cb89f2a300cdd9151790be377c4c0840df809" + dependencies: + restructured "0.0.11" + rsvp@^3.3.3: version "3.6.2" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a" @@ -7107,6 +7285,15 @@ string_decoder@~0.10.x: resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= +stringifier@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/stringifier/-/stringifier-1.4.0.tgz#d704581567f4526265d00ed8ecb354a02c3fec28" + integrity sha512-cNsMOqqrcbLcHTXEVmkw9y0fwDwkdgtZwlfyolzpQDoAE1xdNGhQhxBUfiDvvZIKl1hnUEgMv66nHwtMz3OjPw== + dependencies: + core-js "^2.0.0" + traverse "^0.6.6" + type-name "^2.0.1" + stringmap@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/stringmap/-/stringmap-0.2.2.tgz#556c137b258f942b8776f5b2ef582aa069d7d1b1" @@ -7357,6 +7544,11 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +traverse@^0.6.6: + version "0.6.6" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" + integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -7459,6 +7651,11 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +type-name@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/type-name/-/type-name-2.0.2.tgz#efe7d4123d8ac52afff7f40c7e4dec5266008fb4" + integrity sha1-7+fUEj2KxSr/9/QMfk3sUmYAj7Q= + typed-styles@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/typed-styles/-/typed-styles-0.0.7.tgz#93392a008794c4595119ff62dde6809dbc40a3d9" @@ -7571,6 +7768,22 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" +unist-util-map@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/unist-util-map/-/unist-util-map-1.0.5.tgz#701069b72e1d1cc02db265502a5e82b77c2eb8b7" + integrity sha512-dFil/AN6vqhnQWNCZk0GF/G3+Q5YwsB+PqjnzvpO2wzdRtUJ1E8PN+XRE/PRr/G3FzKjRTJU0haqE0Ekl+O3Ag== + dependencies: + object-assign "^4.0.1" + +universal-deep-strict-equal@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/universal-deep-strict-equal/-/universal-deep-strict-equal-1.2.2.tgz#0da4ac2f73cff7924c81fa4de018ca562ca2b0a7" + integrity sha1-DaSsL3PP95JMgfpN4BjKViyisKc= + dependencies: + array-filter "^1.0.0" + indexof "0.0.1" + object-keys "^1.0.0" + unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" From fbefe66d75035d3322690184762ff9c0c001406a Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 8 Jul 2019 15:35:13 +0300 Subject: [PATCH 23/59] refactor: move react components to separate dir --- src/datasource-zabbix/{ => components}/FunctionEditor.tsx | 0 .../{ => components}/FunctionEditorControls.tsx | 0 src/datasource-zabbix/metric-function-editor.directive.ts | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename src/datasource-zabbix/{ => components}/FunctionEditor.tsx (100%) rename src/datasource-zabbix/{ => components}/FunctionEditorControls.tsx (100%) diff --git a/src/datasource-zabbix/FunctionEditor.tsx b/src/datasource-zabbix/components/FunctionEditor.tsx similarity index 100% rename from src/datasource-zabbix/FunctionEditor.tsx rename to src/datasource-zabbix/components/FunctionEditor.tsx diff --git a/src/datasource-zabbix/FunctionEditorControls.tsx b/src/datasource-zabbix/components/FunctionEditorControls.tsx similarity index 100% rename from src/datasource-zabbix/FunctionEditorControls.tsx rename to src/datasource-zabbix/components/FunctionEditorControls.tsx diff --git a/src/datasource-zabbix/metric-function-editor.directive.ts b/src/datasource-zabbix/metric-function-editor.directive.ts index 232025d..7046cc2 100644 --- a/src/datasource-zabbix/metric-function-editor.directive.ts +++ b/src/datasource-zabbix/metric-function-editor.directive.ts @@ -2,7 +2,7 @@ import coreModule from 'grafana/app/core/core_module'; import _ from 'lodash'; import $ from 'jquery'; import { react2AngularDirective } from './react2angular'; -import { FunctionEditor } from './FunctionEditor'; +import { FunctionEditor } from './components/FunctionEditor'; /** @ngInject */ export function zabbixFunctionEditor($compile, templateSrv) { From 348a5165f266759727c4e0657a5387b262bbea43 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 8 Jul 2019 15:38:30 +0300 Subject: [PATCH 24/59] function editor: fix moving alias func to the end --- src/datasource-zabbix/query.controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/query.controller.js b/src/datasource-zabbix/query.controller.js index fc9f963..eb1b6a2 100644 --- a/src/datasource-zabbix/query.controller.js +++ b/src/datasource-zabbix/query.controller.js @@ -282,10 +282,8 @@ export class ZabbixQueryController extends QueryCtrl { } moveAliasFuncLast() { - var aliasFunc = _.find(this.target.functions, function(func) { - return func.def.name === 'alias' || - func.def.name === 'aliasByNode' || - func.def.name === 'aliasByMetric'; + var aliasFunc = _.find(this.target.functions, func => { + return func.def.category === 'Alias'; }); if (aliasFunc) { From 7727d868042a870a9eea61cbd81d1553d0741d17 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 8 Jul 2019 15:45:50 +0300 Subject: [PATCH 25/59] fix tests (add mocks for some grafana modules) --- src/test-setup/jest-setup.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test-setup/jest-setup.js b/src/test-setup/jest-setup.js index 23a32b5..7107c92 100644 --- a/src/test-setup/jest-setup.js +++ b/src/test-setup/jest-setup.js @@ -18,6 +18,12 @@ jest.mock('angular', () => { }; }, {virtual: true}); +jest.mock('grafana/app/core/core_module', () => { + return { + directive: function() {}, + }; +}, {virtual: true}); + let mockPanelCtrl = PanelCtrl; jest.mock('grafana/app/plugins/sdk', () => { return { @@ -62,6 +68,10 @@ jest.mock('grafana/app/core/config', () => { jest.mock('jquery', () => 'module not found', {virtual: true}); +jest.mock('@grafana/ui', () => { + return {}; +}, {virtual: true}); + // Required for loading angularjs let dom = new JSDOM(''); // Setup jsdom From ca082c98a16afc231cd05e3c83c44a969d6434a5 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 8 Jul 2019 16:31:48 +0300 Subject: [PATCH 26/59] fix panel alert state icon in Grafana 6, closes #715 --- .../zabbixAlerting.service.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/datasource-zabbix/zabbixAlerting.service.js b/src/datasource-zabbix/zabbixAlerting.service.js index 5e1ecfa..b1644d2 100644 --- a/src/datasource-zabbix/zabbixAlerting.service.js +++ b/src/datasource-zabbix/zabbixAlerting.service.js @@ -10,7 +10,7 @@ class ZabbixAlertingService { } isFullScreen() { - return this.dashboardSrv.dash.meta.fullscreen; + return this.getDashboardModel().meta.fullscreen; } setPanelAlertState(panelId, alertState) { @@ -35,21 +35,18 @@ class ZabbixAlertingService { $(panelContainers[panelIndex]).removeClass(alertClass); if (alertState) { - if (alertState === 'alerting') { - alertClass = "panel-has-alert panel-alert-state--" + alertState; - $(panelContainers[panelIndex]).addClass(alertClass); - } - if (alertState === 'ok') { - alertClass = "panel-alert-state--" + alertState; - $(panelContainers[panelIndex]).addClass(alertClass); - $(panelContainers[panelIndex]).removeClass("panel-has-alert"); - } + alertClass = "panel-has-alert panel-alert-state--" + alertState; + $(panelContainers[panelIndex]).addClass(alertClass); } } } + getDashboardModel() { + return this.dashboardSrv.dash || this.dashboardSrv.dashboard; + } + getPanelModels() { - return _.filter(this.dashboardSrv.dash.panels, panel => panel.type !== 'row'); + return _.filter(this.getDashboardModel().panels, panel => panel.type !== 'row'); } getPanelModel(panelId) { From a4e33428c03841a06ee6de6a3be385d9f647ef1f Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 26 Jul 2019 14:45:06 +0300 Subject: [PATCH 27/59] update change log --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 810dd96..f6bac22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [3.10.3] - 2019-07-26 +### Fixed +- Direct DB Connection: can't stay enabled, [#731](https://github.com/alexanderzobnin/grafana-zabbix/issues/731) +- Triggers query mode: count doesn't work with Singlestat, [#726](https://github.com/alexanderzobnin/grafana-zabbix/issues/726) +- Query editor: function editor looks odd in Grafana 6.x, [#765](https://github.com/alexanderzobnin/grafana-zabbix/issues/765) +- Alerting: heart icon on panels in Grafana 6.x, [#715](https://github.com/alexanderzobnin/grafana-zabbix/issues/715) + ## [3.10.2] - 2019-04-23 ### Fixed - Direct DB Connection: provisioned datasource fails to load, [#711](https://github.com/alexanderzobnin/grafana-zabbix/issues/711) From 15d76dc941aa114823b2f55c9fa1294f700b1420 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 26 Jul 2019 14:46:39 +0300 Subject: [PATCH 28/59] bump plugin version to 3.10.3 --- package.json | 2 +- src/plugin.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d7e8b01..31c0793 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grafana-zabbix", "private": false, - "version": "3.10.1", + "version": "3.10.3", "description": "Zabbix plugin for Grafana", "scripts": { "build": "webpack --config webpack/webpack.prod.conf.js --progress --colors", diff --git a/src/plugin.json b/src/plugin.json index c3d6a2a..722f727 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -26,8 +26,8 @@ {"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"}, {"name": "Triggers", "path": "img/screenshot-triggers.png"} ], - "version": "3.10.2", - "updated": "2019-04-23" + "version": "3.10.3", + "updated": "2019-07-26" }, "includes": [ From 2fac45c11be1eba787f4e4a3fa64f6157ac6d949 Mon Sep 17 00:00:00 2001 From: JeferCatarina <37630538+JeferCatarina@users.noreply.github.com> Date: Tue, 30 Jul 2019 12:54:56 -0300 Subject: [PATCH 29/59] SLA over time (#764) * Added "Functions" to IT Services editor panel * Added support to IT Services graph over time --- src/datasource-zabbix/datasource.js | 4 ++-- .../partials/query.editor.html | 2 +- src/datasource-zabbix/responseHandler.js | 17 +++++++++++------ .../zabbix_api/zabbixAPIConnector.js | 19 +++++++++++++++---- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index 8dae24d..09faf6d 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -323,8 +323,8 @@ export class ZabbixDatasource { return this.zabbix.getITServices(itServiceFilter) .then(itservices => { - return this.zabbix.getSLA(itservices, timeRange, target, options); - }); + return this.zabbix.getSLA(itservices, timeRange, target, options);}) + .then(itservicesdp => this.applyDataProcessingFunctions(itservicesdp, target)); } queryTriggersData(target, timeRange) { diff --git a/src/datasource-zabbix/partials/query.editor.html b/src/datasource-zabbix/partials/query.editor.html index 33b2f7d..ccf5ee3 100644 --- a/src/datasource-zabbix/partials/query.editor.html +++ b/src/datasource-zabbix/partials/query.editor.html @@ -201,7 +201,7 @@
-
+
diff --git a/src/datasource-zabbix/responseHandler.js b/src/datasource-zabbix/responseHandler.js index e340c80..ab9174e 100644 --- a/src/datasource-zabbix/responseHandler.js +++ b/src/datasource-zabbix/responseHandler.js @@ -123,22 +123,27 @@ function extractText(str, pattern, useCaptureGroups) { } function handleSLAResponse(itservice, slaProperty, slaObject) { - var targetSLA = slaObject[itservice.serviceid].sla[0]; + var targetSLA = slaObject[itservice.serviceid].sla; if (slaProperty.property === 'status') { var targetStatus = parseInt(slaObject[itservice.serviceid].status); return { target: itservice.name + ' ' + slaProperty.name, datapoints: [ - [targetStatus, targetSLA.to * 1000] + [targetStatus, targetSLA[0].to * 1000] ] }; } else { + let i; + let slaArr = []; + for (i = 0; i < targetSLA.length; i++) { + if (i === 0) { + slaArr.push([targetSLA[i][slaProperty.property], targetSLA[i].from * 1000]); + } + slaArr.push([targetSLA[i][slaProperty.property], targetSLA[i].to * 1000]); + } return { target: itservice.name + ' ' + slaProperty.name, - datapoints: [ - [targetSLA[slaProperty.property], targetSLA.from * 1000], - [targetSLA[slaProperty.property], targetSLA.to * 1000] - ] + datapoints: slaArr }; } } diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js index 0282fdf..6fd7931 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js @@ -317,13 +317,24 @@ export class ZabbixAPIConnector { } getSLA(serviceids, timeRange) { + let defaultRange = 86400; + let i; + let getIntervals = []; let [timeFrom, timeTo] = timeRange; + + for (i = timeFrom; i <= timeTo; i = i + defaultRange) { + if (timeTo < (i + defaultRange)) { + if (timeTo !== i) { + getIntervals.push({from : i, to : timeTo}); + } + } else { + getIntervals.push({from : i, to : (i + defaultRange)}); + } + } + var params = { serviceids: serviceids, - intervals: [{ - from: timeFrom, - to: timeTo - }] + intervals: getIntervals }; return this.request('service.getsla', params); } From 8f139d0322c86fd146217447e53c85b8b2921831 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 30 Jul 2019 18:52:32 +0300 Subject: [PATCH 30/59] SLA over time: make intervals based on panel intervalMs, #728 --- src/datasource-zabbix/constants.js | 3 ++ .../zabbix_api/zabbixAPIConnector.js | 54 ++++++++++++------- src/datasource-zabbix/zabbix/zabbix.js | 2 +- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/datasource-zabbix/constants.js b/src/datasource-zabbix/constants.js index 3c8de51..af3c8d1 100644 --- a/src/datasource-zabbix/constants.js +++ b/src/datasource-zabbix/constants.js @@ -34,3 +34,6 @@ export const TRIGGER_SEVERITY = [ {val: 4, text: 'High'}, {val: 5, text: 'Disaster'} ]; + +/** Minimum interval for SLA over time (1 hour) */ +export const MIN_SLA_INTERVAL = 3600; diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js index 6fd7931..f3a9a9b 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js @@ -1,7 +1,8 @@ import _ from 'lodash'; +import kbn from 'grafana/app/core/utils/kbn'; import * as utils from '../../../utils'; import { ZabbixAPICore } from './zabbixAPICore'; -import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ACK, ZBX_ACK_ACTION_ADD_MESSAGE } from '../../../constants'; +import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ACK, ZBX_ACK_ACTION_ADD_MESSAGE, MIN_SLA_INTERVAL } from '../../../constants'; /** * Zabbix API Wrapper. @@ -316,25 +317,11 @@ export class ZabbixAPIConnector { return this.request('service.get', params); } - getSLA(serviceids, timeRange) { - let defaultRange = 86400; - let i; - let getIntervals = []; - let [timeFrom, timeTo] = timeRange; - - for (i = timeFrom; i <= timeTo; i = i + defaultRange) { - if (timeTo < (i + defaultRange)) { - if (timeTo !== i) { - getIntervals.push({from : i, to : timeTo}); - } - } else { - getIntervals.push({from : i, to : (i + defaultRange)}); - } - } - - var params = { - serviceids: serviceids, - intervals: getIntervals + getSLA(serviceids, timeRange, options) { + const intervals = buildSLAIntervals(timeRange, options.intervalMs); + const params = { + serviceids, + intervals }; return this.request('service.getsla', params); } @@ -536,3 +523,30 @@ function isNotAuthorized(message) { message === "Not authorized." ); } + +function getSLAInterval(intervalMs) { + // Too many intervals may cause significant load on the database, so decrease number of resulting points + const resolutionRatio = 100; + const interval = kbn.round_interval(intervalMs * resolutionRatio) / 1000; + return Math.max(interval, MIN_SLA_INTERVAL); +} + +function buildSLAIntervals(timeRange, intervalMs) { + let [timeFrom, timeTo] = timeRange; + const slaInterval = getSLAInterval(intervalMs); + const intervals = []; + + // Align time range with calculated interval + timeFrom = Math.floor(timeFrom / slaInterval) * slaInterval; + timeTo = Math.ceil(timeTo / slaInterval) * slaInterval; + + for (let i = timeFrom; i <= timeTo - slaInterval; i += slaInterval) { + intervals.push({ + from : i, + to : (i + slaInterval) + }); + + } + + return intervals; +} diff --git a/src/datasource-zabbix/zabbix/zabbix.js b/src/datasource-zabbix/zabbix/zabbix.js index 35bb96a..74139a4 100644 --- a/src/datasource-zabbix/zabbix/zabbix.js +++ b/src/datasource-zabbix/zabbix/zabbix.js @@ -363,7 +363,7 @@ export class Zabbix { itServices = _.filter(itServices, {'serviceid': target.itservice.serviceid}); } let itServiceIds = _.map(itServices, 'serviceid'); - return this.zabbixAPI.getSLA(itServiceIds, timeRange) + return this.zabbixAPI.getSLA(itServiceIds, timeRange, options) .then(slaResponse => { return _.map(itServiceIds, serviceid => { let itservice = _.find(itServices, {'serviceid': serviceid}); From 916205102acc6f52f07470816c19e15c8833ce99 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 30 Jul 2019 19:00:13 +0300 Subject: [PATCH 31/59] update change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6bac22..76a4514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased +### Added +- SLA over time graphs, [#728](https://github.com/alexanderzobnin/grafana-zabbix/issues/728) + ## [3.10.3] - 2019-07-26 ### Fixed - Direct DB Connection: can't stay enabled, [#731](https://github.com/alexanderzobnin/grafana-zabbix/issues/731) From ff5a7f0136e555d9ade25663a5aa77fefef93ac7 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 31 Jul 2019 14:36:30 +0300 Subject: [PATCH 32/59] fix tests (add kbn mock) --- src/test-setup/jest-setup.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test-setup/jest-setup.js b/src/test-setup/jest-setup.js index 7107c92..dedf7a2 100644 --- a/src/test-setup/jest-setup.js +++ b/src/test-setup/jest-setup.js @@ -42,6 +42,12 @@ jest.mock('grafana/app/core/utils/datemath', () => { }; }, {virtual: true}); +jest.mock('grafana/app/core/utils/kbn', () => { + return { + round_interval: n => n, + }; +}, {virtual: true}); + jest.mock('grafana/app/core/table_model', () => { return class TableModel { constructor() { From e02b660dfd7949c040ca7f66a276a70b6b310954 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:00:05 +0300 Subject: [PATCH 33/59] Problems panel: use skipDataQuery flag instead of deprecated dataFormats, fix #778 --- src/panel-triggers/plugin.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panel-triggers/plugin.json b/src/panel-triggers/plugin.json index 04572f8..6639999 100644 --- a/src/panel-triggers/plugin.json +++ b/src/panel-triggers/plugin.json @@ -4,6 +4,7 @@ "id": "alexanderzobnin-zabbix-triggers-panel", "dataFormats": [], + "skipDataQuery": true, "info": { "author": { From 55ffe5eded9d8d36a9728f82f893870478d28df7 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:34:21 +0300 Subject: [PATCH 34/59] Problems: fix heart icons, fix #754 --- .../components/AlertList/AlertIcon.tsx | 8 ++------ src/panel-triggers/components/GFHeartIcon.tsx | 3 +-- src/panel-triggers/triggers_panel_ctrl.js | 12 ++++-------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/panel-triggers/components/AlertList/AlertIcon.tsx b/src/panel-triggers/components/AlertList/AlertIcon.tsx index 0ecf6df..2b69d31 100644 --- a/src/panel-triggers/components/AlertList/AlertIcon.tsx +++ b/src/panel-triggers/components/AlertList/AlertIcon.tsx @@ -13,12 +13,8 @@ export default function AlertIcon(props: AlertIconProps) { const { problem, color, blink, highlightBackground } = props; const priority = Number(problem.priority); let iconClass = ''; - if (problem.value === '1') { - if (priority >= 3) { - iconClass = 'icon-gf-critical'; - } else { - iconClass = 'icon-gf-warning'; - } + if (problem.value === '1' && priority >= 2) { + iconClass = 'icon-gf-critical'; } else { iconClass = 'icon-gf-online'; } diff --git a/src/panel-triggers/components/GFHeartIcon.tsx b/src/panel-triggers/components/GFHeartIcon.tsx index 24bcc86..23c1826 100644 --- a/src/panel-triggers/components/GFHeartIcon.tsx +++ b/src/panel-triggers/components/GFHeartIcon.tsx @@ -9,8 +9,7 @@ interface GFHeartIconProps { export default function GFHeartIcon(props: GFHeartIconProps) { const status = props.status; const className = classNames("icon-gf", props.className, - { "icon-gf-critical": status === 'critical' || status === 'problem' }, - { "icon-gf-warning": status === 'warning' }, + { "icon-gf-critical": status === 'critical' || status === 'problem' || status === 'warning'}, { "icon-gf-online": status === 'online' || status === 'ok' }, ); return ( diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index d0d0ab8..d8d8247 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -557,12 +557,8 @@ export class TriggerPanelCtrl extends PanelCtrl { getAlertIconClass(trigger) { let iconClass = ''; - if (trigger.value === '1') { - if (trigger.priority >= 3) { - iconClass = 'icon-gf-critical'; - } else { - iconClass = 'icon-gf-warning'; - } + if (trigger.value === '1' && trigger.priority >= 2) { + iconClass = 'icon-gf-critical'; } else { iconClass = 'icon-gf-online'; } @@ -574,8 +570,8 @@ export class TriggerPanelCtrl extends PanelCtrl { } getAlertIconClassBySeverity(triggerSeverity) { - let iconClass = 'icon-gf-warning'; - if (triggerSeverity.priority >= 3) { + let iconClass = 'icon-gf-online'; + if (triggerSeverity.priority >= 2) { iconClass = 'icon-gf-critical'; } return iconClass; From 3be9d9ee123ad734e7a36b255ee423be28ee173e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:36:37 +0300 Subject: [PATCH 35/59] Update change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a4514..6c6fe73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - SLA over time graphs, [#728](https://github.com/alexanderzobnin/grafana-zabbix/issues/728) +### Fixed +- Problems panel: query editor broken in Grafana 6.3, [#778](https://github.com/alexanderzobnin/grafana-zabbix/issues/778) +- Problems panel: some heart icons are missing, [#754](https://github.com/alexanderzobnin/grafana-zabbix/issues/754) + ## [3.10.3] - 2019-07-26 ### Fixed - Direct DB Connection: can't stay enabled, [#731](https://github.com/alexanderzobnin/grafana-zabbix/issues/731) From df4d6b7967af41dd1215dc1d72f643f627539f6f Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:47:51 +0300 Subject: [PATCH 36/59] change log for release --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6fe73..b62c9b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## Unreleased -### Added -- SLA over time graphs, [#728](https://github.com/alexanderzobnin/grafana-zabbix/issues/728) - +## [3.10.4] - 2019-08-08 ### Fixed - Problems panel: query editor broken in Grafana 6.3, [#778](https://github.com/alexanderzobnin/grafana-zabbix/issues/778) - Problems panel: some heart icons are missing, [#754](https://github.com/alexanderzobnin/grafana-zabbix/issues/754) From 0855fe51896ab8b7fbb96c0bc84f04d7129639ec Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:49:50 +0300 Subject: [PATCH 37/59] Bump plugin version to 3.10.4 --- package.json | 2 +- src/plugin.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 31c0793..f44af40 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grafana-zabbix", "private": false, - "version": "3.10.3", + "version": "3.10.4", "description": "Zabbix plugin for Grafana", "scripts": { "build": "webpack --config webpack/webpack.prod.conf.js --progress --colors", diff --git a/src/plugin.json b/src/plugin.json index 722f727..25540d9 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -26,8 +26,8 @@ {"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"}, {"name": "Triggers", "path": "img/screenshot-triggers.png"} ], - "version": "3.10.3", - "updated": "2019-07-26" + "version": "3.10.4", + "updated": "2019-08-08" }, "includes": [ @@ -42,7 +42,7 @@ ], "dependencies": { - "grafanaVersion": "5.x", + "grafanaVersion": "6.x", "plugins": [] } } From 224caa034d428b0e86296508608ad477da1ce883 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 8 Aug 2019 12:59:24 +0300 Subject: [PATCH 38/59] Change log: push back unreleased --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b62c9b9..83bf8e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased +### Added +- SLA over time graphs, [#728](https://github.com/alexanderzobnin/grafana-zabbix/issues/728) + ## [3.10.4] - 2019-08-08 ### Fixed - Problems panel: query editor broken in Grafana 6.3, [#778](https://github.com/alexanderzobnin/grafana-zabbix/issues/778) From fe943ac0e40c1e8a619246bab5ed98ff136a9641 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Fri, 4 Oct 2019 17:10:17 +0200 Subject: [PATCH 39/59] CI: fix shellcheck issues (#789) Signed-off-by: Mario Trangoni --- .circleci/deploy-docs.sh | 10 +++++----- .circleci/make-release.sh | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.circleci/deploy-docs.sh b/.circleci/deploy-docs.sh index ab919f2..e497ad0 100755 --- a/.circleci/deploy-docs.sh +++ b/.circleci/deploy-docs.sh @@ -10,15 +10,15 @@ set -o pipefail echo "current dir: $(pwd)" # Setup git env -git config --global user.email $CI_GIT_EMAIL -git config --global user.name $CI_GIT_USER +git config --global user.email "$CI_GIT_EMAIL" +git config --global user.name "$CI_GIT_USER" echo "git user is $CI_GIT_USER ($CI_GIT_EMAIL)" -git checkout -b $GH_PAGES_BRANCH -rm -rf * || true +git checkout -b "$GH_PAGES_BRANCH" +rm -rf ./* || true mv ../gh-pages/docs/site/* ./ git add --force . git commit -m "build docs from commit ${CIRCLE_SHA1:0:7} (branch $CIRCLE_BRANCH)" git log -n 3 -git push origin $GH_PAGES_BRANCH --force +git push origin "$GH_PAGES_BRANCH" --force diff --git a/.circleci/make-release.sh b/.circleci/make-release.sh index e0efc96..de0e8d9 100755 --- a/.circleci/make-release.sh +++ b/.circleci/make-release.sh @@ -8,13 +8,13 @@ set -o errexit set -o pipefail # Setup git env -git config --global user.email $CI_GIT_EMAIL -git config --global user.name $CI_GIT_USER +git config --global user.email "$CI_GIT_EMAIL" +git config --global user.name "$CI_GIT_USER" echo "git user is $CI_GIT_USER ($CI_GIT_EMAIL)" -RELEASE_VER=$(echo $CIRCLE_TAG | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") +RELEASE_VER=$(echo "$CIRCLE_TAG" | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") -if [ -z $RELEASE_VER ]; then +if [ -z "$RELEASE_VER" ]; then echo "No release version provided" exit 1 fi @@ -28,7 +28,7 @@ fi RELEASE_BRANCH=release-$RELEASE_VER # Build plugin -git checkout -b $RELEASE_BRANCH +git checkout -b "$RELEASE_BRANCH" yarn install --pure-lockfile && yarn build # Commit release @@ -36,7 +36,7 @@ git add --force dist/ git commit -m "release $RELEASE_VER" RELEASE_COMMIT_HASH=$(git log -n 1 | grep -Po "(?<=commit )[0-9a-z]{40}") -echo $RELEASE_COMMIT_HASH +echo "$RELEASE_COMMIT_HASH" # Push release branch -git push origin $RELEASE_BRANCH +git push origin "$RELEASE_BRANCH" From 9cf13230ebb64bafbff81388f12525439a10fa8e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 8 Oct 2019 18:49:36 +0300 Subject: [PATCH 40/59] annotations: fix options in grafana 6.x, fix #813 --- .../partials/annotations.editor.html | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/datasource-zabbix/partials/annotations.editor.html b/src/datasource-zabbix/partials/annotations.editor.html index 6e2e495..16453e5 100644 --- a/src/datasource-zabbix/partials/annotations.editor.html +++ b/src/datasource-zabbix/partials/annotations.editor.html @@ -1,5 +1,4 @@
-
Filter Triggers
Group @@ -36,8 +35,9 @@
+
Options
- Minimum severity + Minimum severity
@@ -67,35 +67,35 @@
diff --git a/src/panel-triggers/specs/migrations.spec.js b/src/panel-triggers/specs/migrations.spec.ts similarity index 76% rename from src/panel-triggers/specs/migrations.spec.js rename to src/panel-triggers/specs/migrations.spec.ts index f411350..bd916e8 100644 --- a/src/panel-triggers/specs/migrations.spec.js +++ b/src/panel-triggers/specs/migrations.spec.ts @@ -5,16 +5,16 @@ import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_pane import {CURRENT_SCHEMA_VERSION} from '../migrations'; describe('Triggers Panel schema migration', () => { - let ctx = {}; + let ctx: any = {}; let updatePanelCtrl; - let datasourceSrvMock = { + const datasourceSrvMock = { getMetricSources: () => { return [{ meta: {id: 'alexanderzobnin-zabbix-datasource'}, value: {}, name: 'zabbix_default' }]; }, get: () => Promise.resolve({}) }; - let timeoutMock = () => {}; + const timeoutMock = () => {}; beforeEach(() => { ctx = { @@ -47,14 +47,16 @@ describe('Triggers Panel schema migration', () => { }); it('should update old panel schema', () => { - let updatedPanelCtrl = updatePanelCtrl(ctx.scope); + const updatedPanelCtrl = updatePanelCtrl(ctx.scope); - let expected = _.defaultsDeep({ + const expected = _.defaultsDeep({ schemaVersion: CURRENT_SCHEMA_VERSION, - datasources: ['zabbix'], - targets: { - 'zabbix': DEFAULT_TARGET - }, + targets: [ + { + ...DEFAULT_TARGET, + datasource: 'zabbix', + } + ], ageField: true, statusField: false, severityField: false, @@ -68,29 +70,29 @@ describe('Triggers Panel schema migration', () => { it('should create new panel with default schema', () => { ctx.scope.panel = {}; - let updatedPanelCtrl = updatePanelCtrl(ctx.scope); + const updatedPanelCtrl = updatePanelCtrl(ctx.scope); - let expected = _.defaultsDeep({ + const expected = _.defaultsDeep({ schemaVersion: CURRENT_SCHEMA_VERSION, - datasources: ['zabbix_default'], - targets: { - 'zabbix_default': DEFAULT_TARGET - } + targets: [{ + ...DEFAULT_TARGET, + datasource: 'zabbix_default' + }] }, PANEL_DEFAULTS); expect(updatedPanelCtrl.panel).toEqual(expected); }); it('should set default targets for new panel with empty targets', () => { ctx.scope.panel = { - targets: [{}] + targets: [] }; - let updatedPanelCtrl = updatePanelCtrl(ctx.scope); + const updatedPanelCtrl = updatePanelCtrl(ctx.scope); - let expected = _.defaultsDeep({ - datasources: ['zabbix_default'], - targets: { - 'zabbix_default': DEFAULT_TARGET - }, + const expected = _.defaultsDeep({ + targets: [{ + ...DEFAULT_TARGET, + datasource: 'zabbix_default' + }] }, PANEL_DEFAULTS); expect(updatedPanelCtrl.panel).toEqual(expected); diff --git a/src/panel-triggers/specs/panel_ctrl.spec.js b/src/panel-triggers/specs/panel_ctrl.spec.ts similarity index 84% rename from src/panel-triggers/specs/panel_ctrl.spec.js rename to src/panel-triggers/specs/panel_ctrl.spec.ts index bdfa90b..67283c9 100644 --- a/src/panel-triggers/specs/panel_ctrl.spec.js +++ b/src/panel-triggers/specs/panel_ctrl.spec.ts @@ -5,9 +5,9 @@ import {PANEL_DEFAULTS, DEFAULT_TARGET} from '../triggers_panel_ctrl'; // import { create } from 'domain'; describe('TriggerPanelCtrl', () => { - let ctx = {}; + let ctx: any = {}; let datasourceSrvMock, zabbixDSMock; - let timeoutMock = () => {}; + const timeoutMock = () => {}; let createPanelCtrl; beforeEach(() => { @@ -61,7 +61,7 @@ describe('TriggerPanelCtrl', () => { describe('When adding new panel', () => { it('should suggest all zabbix data sources', () => { ctx.scope.panel = {}; - let panelCtrl = createPanelCtrl(); + const panelCtrl = createPanelCtrl(); expect(panelCtrl.available_datasources).toEqual([ 'zabbix_default', 'zabbix' ]); @@ -69,10 +69,8 @@ describe('TriggerPanelCtrl', () => { it('should load first zabbix data source as default', () => { ctx.scope.panel = {}; - let panelCtrl = createPanelCtrl(); - expect(panelCtrl.panel.datasources).toEqual([ - 'zabbix_default' - ]); + const panelCtrl = createPanelCtrl(); + expect(panelCtrl.panel.targets[0].datasource).toEqual('zabbix_default'); }); it('should rewrite default empty target', () => { @@ -82,7 +80,7 @@ describe('TriggerPanelCtrl', () => { "refId": "A" }], }; - let panelCtrl = createPanelCtrl(); + const panelCtrl = createPanelCtrl(); expect(panelCtrl.available_datasources).toEqual([ 'zabbix_default', 'zabbix' ]); @@ -92,16 +90,22 @@ describe('TriggerPanelCtrl', () => { describe('When refreshing panel', () => { beforeEach(() => { ctx.scope.panel.datasources = ['zabbix_default', 'zabbix']; - ctx.scope.panel.targets = { - 'zabbix_default': DEFAULT_TARGET, - 'zabbix': DEFAULT_TARGET - }; + ctx.scope.panel.targets = [ + { + ...DEFAULT_TARGET, + datasource: 'zabbix_default' + }, + { + ...DEFAULT_TARGET, + datasource: 'zabbix' + }, + ]; ctx.panelCtrl = createPanelCtrl(); }); it('should format triggers', (done) => { ctx.panelCtrl.onRefresh().then(() => { - let formattedTrigger = _.find(ctx.panelCtrl.triggerList, {triggerid: "1"}); + const formattedTrigger: any = _.find(ctx.panelCtrl.triggerList, {triggerid: "1"}); expect(formattedTrigger.host).toBe('backend01'); expect(formattedTrigger.hostTechName).toBe('backend01_tech'); expect(formattedTrigger.datasource).toBe('zabbix_default'); @@ -113,7 +117,7 @@ describe('TriggerPanelCtrl', () => { it('should sort triggers by time by default', (done) => { ctx.panelCtrl.onRefresh().then(() => { - let trigger_ids = _.map(ctx.panelCtrl.triggerList, 'triggerid'); + const trigger_ids = _.map(ctx.panelCtrl.triggerList, 'triggerid'); expect(trigger_ids).toEqual([ '2', '4', '3', '1' ]); @@ -124,7 +128,7 @@ describe('TriggerPanelCtrl', () => { it('should sort triggers by severity', (done) => { ctx.panelCtrl.panel.sortTriggersBy = { text: 'severity', value: 'priority' }; ctx.panelCtrl.onRefresh().then(() => { - let trigger_ids = _.map(ctx.panelCtrl.triggerList, 'triggerid'); + const trigger_ids = _.map(ctx.panelCtrl.triggerList, 'triggerid'); expect(trigger_ids).toEqual([ '1', '3', '2', '4' ]); @@ -134,7 +138,7 @@ describe('TriggerPanelCtrl', () => { it('should add acknowledges to trigger', (done) => { ctx.panelCtrl.onRefresh().then(() => { - let trigger = getTriggerById(1, ctx); + const trigger = getTriggerById(1, ctx); expect(trigger.acknowledges).toHaveLength(1); expect(trigger.acknowledges[0].message).toBe("event ack"); @@ -153,15 +157,15 @@ describe('TriggerPanelCtrl', () => { it('should handle new lines in trigger description', () => { ctx.panelCtrl.setTriggerSeverity = jest.fn((trigger) => trigger); - let trigger = {comments: "this is\ndescription"}; + const trigger = {comments: "this is\ndescription"}; const formattedTrigger = ctx.panelCtrl.formatTrigger(trigger); expect(formattedTrigger.comments).toBe("this is
description"); }); it('should format host name to display (default)', (done) => { ctx.panelCtrl.onRefresh().then(() => { - let trigger = getTriggerById(1, ctx); - let hostname = ctx.panelCtrl.formatHostName(trigger); + const trigger = getTriggerById(1, ctx); + const hostname = ctx.panelCtrl.formatHostName(trigger); expect(hostname).toBe('backend01'); done(); }); @@ -171,8 +175,8 @@ describe('TriggerPanelCtrl', () => { ctx.panelCtrl.panel.hostField = false; ctx.panelCtrl.panel.hostTechNameField = true; ctx.panelCtrl.onRefresh().then(() => { - let trigger = getTriggerById(1, ctx); - let hostname = ctx.panelCtrl.formatHostName(trigger); + const trigger = getTriggerById(1, ctx); + const hostname = ctx.panelCtrl.formatHostName(trigger); expect(hostname).toBe('backend01_tech'); done(); }); @@ -182,8 +186,8 @@ describe('TriggerPanelCtrl', () => { ctx.panelCtrl.panel.hostField = true; ctx.panelCtrl.panel.hostTechNameField = true; ctx.panelCtrl.onRefresh().then(() => { - let trigger = getTriggerById(1, ctx); - let hostname = ctx.panelCtrl.formatHostName(trigger); + const trigger = getTriggerById(1, ctx); + const hostname = ctx.panelCtrl.formatHostName(trigger); expect(hostname).toBe('backend01 (backend01_tech)'); done(); }); @@ -193,8 +197,8 @@ describe('TriggerPanelCtrl', () => { ctx.panelCtrl.panel.hostField = false; ctx.panelCtrl.panel.hostTechNameField = false; ctx.panelCtrl.onRefresh().then(() => { - let trigger = getTriggerById(1, ctx); - let hostname = ctx.panelCtrl.formatHostName(trigger); + const trigger = getTriggerById(1, ctx); + const hostname = ctx.panelCtrl.formatHostName(trigger); expect(hostname).toBe(""); done(); }); @@ -222,7 +226,7 @@ describe('TriggerPanelCtrl', () => { }); }); -const defaultTrigger = { +const defaultTrigger: any = { "triggerid": "13565", "value": "1", "groups": [{"groupid": "1", "name": "Backend"}] , @@ -248,7 +252,7 @@ const defaultTrigger = { "flags": "0", "type": "0", "items": [] , "error": "" }; -const defaultEvent = { +const defaultEvent: any = { "eventid": "11", "acknowledges": [ { @@ -272,8 +276,8 @@ const defaultEvent = { "objectid": "1", }; -function generateTrigger(id, timestamp, severity) { - let trigger = _.cloneDeep(defaultTrigger); +function generateTrigger(id, timestamp?, severity?): any { + const trigger = _.cloneDeep(defaultTrigger); trigger.triggerid = id.toString(); if (severity) { trigger.priority = severity.toString(); @@ -284,13 +288,13 @@ function generateTrigger(id, timestamp, severity) { return trigger; } -function createTrigger(props) { +function createTrigger(props): any { let trigger = _.cloneDeep(defaultTrigger); trigger = _.merge(trigger, props); trigger.lastEvent.objectid = trigger.triggerid; return trigger; } -function getTriggerById(id, ctx) { +function getTriggerById(id, ctx): any { return _.find(ctx.panelCtrl.triggerList, {triggerid: id.toString()}); } diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index d8d8247..dad0d7a 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -10,6 +10,7 @@ import { triggerPanelTriggersTab } from './triggers_tab'; import { migratePanelSchema, CURRENT_SCHEMA_VERSION } from './migrations'; import ProblemList from './components/Problems/Problems'; import AlertList from './components/AlertList/AlertList'; +import { getNextRefIdChar } from './utils'; const ZABBIX_DS_ID = 'alexanderzobnin-zabbix-datasource'; const PROBLEM_EVENTS_LIMIT = 100; @@ -23,7 +24,17 @@ export const DEFAULT_TARGET = { proxy: {filter: ""}, }; -export const getDefaultTarget = () => DEFAULT_TARGET; +export const getDefaultTarget = (targets) => { + return { + group: {filter: ""}, + host: {filter: ""}, + application: {filter: ""}, + trigger: {filter: ""}, + tags: {filter: ""}, + proxy: {filter: ""}, + refId: getNextRefIdChar(targets), + }; +}; export const DEFAULT_SEVERITY = [ { priority: 0, severity: 'Not classified', color: 'rgb(108, 108, 108)', show: true}, @@ -40,8 +51,7 @@ const DEFAULT_TIME_FORMAT = "DD MMM YYYY HH:mm:ss"; export const PANEL_DEFAULTS = { schemaVersion: CURRENT_SCHEMA_VERSION, - datasources: [], - targets: {}, + targets: [getDefaultTarget([])], // Fields hostField: true, hostTechNameField: false, @@ -108,11 +118,8 @@ export class TriggerPanelCtrl extends PanelCtrl { _.defaultsDeep(this.panel, _.cloneDeep(PANEL_DEFAULTS)); this.available_datasources = _.map(this.getZabbixDataSources(), 'name'); - if (this.panel.datasources.length === 0) { - this.panel.datasources.push(this.available_datasources[0]); - } - if (this.isEmptyTargets()) { - this.panel.targets[this.panel.datasources[0]] = getDefaultTarget(); + if (this.panel.targets && !this.panel.targets[0].datasource) { + this.panel.targets[0].datasource = this.available_datasources[0]; } this.initDatasources(); @@ -138,7 +145,11 @@ export class TriggerPanelCtrl extends PanelCtrl { } initDatasources() { - let promises = _.map(this.panel.datasources, (ds) => { + if (!this.panel.targets) { + return; + } + const targetDatasources = _.compact(this.panel.targets.map(target => target.datasource)); + let promises = targetDatasources.map(ds => { // Load datasource return this.datasourceSrv.get(ds) .then(datasource => { @@ -236,14 +247,15 @@ export class TriggerPanelCtrl extends PanelCtrl { const timeTo = Math.ceil(dateMath.parse(this.range.to) / 1000); const userIsEditor = this.contextSrv.isEditor || this.contextSrv.isGrafanaAdmin; - let promises = _.map(this.panel.datasources, (ds) => { + let promises = _.map(this.panel.targets, (target) => { + const ds = target.datasource; let proxies; let showAckButton = true; return this.datasourceSrv.get(ds) .then(datasource => { const zabbix = datasource.zabbix; const showEvents = this.panel.showEvents.value; - const triggerFilter = this.panel.targets[ds]; + const triggerFilter = target; const showProxy = this.panel.hostProxy; const getProxiesPromise = showProxy ? zabbix.getProxies() : () => []; showAckButton = !datasource.disableReadOnlyUsersAck || userIsEditor; @@ -284,8 +296,8 @@ export class TriggerPanelCtrl extends PanelCtrl { }) .then(triggers => this.setMaintenanceStatus(triggers)) .then(triggers => this.setAckButtonStatus(triggers, showAckButton)) - .then(triggers => this.filterTriggersPre(triggers, ds)) - .then(triggers => this.addTriggerDataSource(triggers, ds)) + .then(triggers => this.filterTriggersPre(triggers, target)) + .then(triggers => this.addTriggerDataSource(triggers, target)) .then(triggers => this.addTriggerHostProxy(triggers, proxies)); }); @@ -339,16 +351,17 @@ export class TriggerPanelCtrl extends PanelCtrl { return triggers; } - filterTriggersPre(triggerList, ds) { + filterTriggersPre(triggerList, target) { // Filter triggers by description - let triggerFilter = this.panel.targets[ds].trigger.filter; + const ds = target.datasource; + let triggerFilter = target.trigger.filter; triggerFilter = this.datasources[ds].replaceTemplateVars(triggerFilter); if (triggerFilter) { triggerList = filterTriggers(triggerList, triggerFilter); } // Filter by tags - const target = this.panel.targets[ds]; + // const target = this.panel.targets[ds]; if (target.tags.filter) { let tagsFilter = this.datasources[ds].replaceTemplateVars(target.tags.filter); // replaceTemplateVars() builds regex-like string, so we should trim it. @@ -406,9 +419,9 @@ export class TriggerPanelCtrl extends PanelCtrl { return triggers; } - addTriggerDataSource(triggers, ds) { + addTriggerDataSource(triggers, target) { _.each(triggers, (trigger) => { - trigger.datasource = ds; + trigger.datasource = target.datasource; }); return triggers; } @@ -479,24 +492,24 @@ export class TriggerPanelCtrl extends PanelCtrl { return _.map(tags, (tag) => `${tag.tag}:${tag.value}`).join(', '); } - addTagFilter(tag, ds) { - let tagFilter = this.panel.targets[ds].tags.filter; + addTagFilter(tag, target) { + let tagFilter = target.tags.filter; let targetTags = this.parseTags(tagFilter); let newTag = {tag: tag.tag, value: tag.value}; targetTags.push(newTag); targetTags = _.uniqWith(targetTags, _.isEqual); let newFilter = this.tagsToString(targetTags); - this.panel.targets[ds].tags.filter = newFilter; + target.tags.filter = newFilter; this.refresh(); } - removeTagFilter(tag, ds) { - let tagFilter = this.panel.targets[ds].tags.filter; + removeTagFilter(tag, target) { + let tagFilter = target.tags.filter; let targetTags = this.parseTags(tagFilter); _.remove(targetTags, t => t.tag === tag.tag && t.value === tag.value); targetTags = _.uniqWith(targetTags, _.isEqual); let newFilter = this.tagsToString(targetTags); - this.panel.targets[ds].tags.filter = newFilter; + target.tags.filter = newFilter; this.refresh(); } diff --git a/src/panel-triggers/triggers_tab.js b/src/panel-triggers/triggers_tab.js index db230a0..9b3032b 100644 --- a/src/panel-triggers/triggers_tab.js +++ b/src/panel-triggers/triggers_tab.js @@ -10,7 +10,7 @@ class TriggersTabCtrl { this.panelCtrl = $scope.ctrl; this.panel = this.panelCtrl.panel; this.templateSrv = templateSrv; - this.datasources = this.panelCtrl.datasources; + this.datasources = {}; // Load scope defaults var scopeDefaults = { @@ -21,6 +21,7 @@ class TriggersTabCtrl { oldTarget: _.cloneDeep(this.panel.targets) }; _.defaultsDeep(this, scopeDefaults); + this.selectedDatasources = this.getSelectedDatasources(); this.initDatasources(); this.panelCtrl.refresh(); @@ -30,6 +31,7 @@ class TriggersTabCtrl { return this.panelCtrl.initDatasources() .then((datasources) => { _.each(datasources, (datasource) => { + this.datasources[datasource.name] = datasource; this.bindSuggestionFunctions(datasource); }); }); @@ -44,6 +46,10 @@ class TriggersTabCtrl { this.getProxyNames[ds] = _.bind(this.suggestProxies, this, datasource); } + getSelectedDatasources() { + return _.compact(this.panel.targets.map(target => target.datasource)); + } + suggestGroups(datasource, query, callback) { return datasource.zabbix.getAllGroups() .then(groups => { @@ -53,7 +59,8 @@ class TriggersTabCtrl { } suggestHosts(datasource, query, callback) { - let groupFilter = datasource.replaceTemplateVars(this.panel.targets[datasource.name].group.filter); + const target = this.panel.targets.find(t => t.datasource === datasource.name); + let groupFilter = datasource.replaceTemplateVars(target.group.filter); return datasource.zabbix.getAllHosts(groupFilter) .then(hosts => { return _.map(hosts, 'name'); @@ -62,8 +69,9 @@ class TriggersTabCtrl { } suggestApps(datasource, query, callback) { - let groupFilter = datasource.replaceTemplateVars(this.panel.targets[datasource.name].group.filter); - let hostFilter = datasource.replaceTemplateVars(this.panel.targets[datasource.name].host.filter); + const target = this.panel.targets.find(t => t.datasource === datasource.name); + let groupFilter = datasource.replaceTemplateVars(target.group.filter); + let hostFilter = datasource.replaceTemplateVars(target.host.filter); return datasource.zabbix.getAllApps(groupFilter, hostFilter) .then(apps => { return _.map(apps, 'name'); @@ -78,16 +86,17 @@ class TriggersTabCtrl { } datasourcesChanged() { - _.each(this.panel.datasources, (ds) => { - if (!this.panel.targets[ds]) { - this.panel.targets[ds] = getDefaultTarget(); - } - }); - // Remove unchecked targets - _.each(this.panel.targets, (target, ds) => { - if (!_.includes(this.panel.datasources, ds)) { - delete this.panel.targets[ds]; + const newTargets = []; + _.each(this.selectedDatasources, (ds) => { + const dsTarget = this.panel.targets.find((target => target.datasource === ds)); + if (dsTarget) { + newTargets.push(dsTarget); + } else { + const newTarget = getDefaultTarget(this.panel.targets); + newTarget.datasource = ds; + newTargets.push(newTarget); } + this.panel.targets = newTargets; }); this.parseTarget(); } diff --git a/src/panel-triggers/types.ts b/src/panel-triggers/types.ts index 477d8fb..ffa9e65 100644 --- a/src/panel-triggers/types.ts +++ b/src/panel-triggers/types.ts @@ -1,7 +1,7 @@ export interface ProblemsPanelOptions { schemaVersion: number; datasources: any[]; - targets: Map; + targets: ProblemsPanelTarget[]; // Fields hostField?: boolean; hostTechNameField?: boolean; @@ -62,6 +62,7 @@ export interface ProblemsPanelTarget { proxy: { filter: string }; + datasource: string; } export interface TriggerSeverity { diff --git a/src/panel-triggers/utils.ts b/src/panel-triggers/utils.ts index d88661f..d9e2124 100644 --- a/src/panel-triggers/utils.ts +++ b/src/panel-triggers/utils.ts @@ -1,4 +1,6 @@ +import _ from 'lodash'; import moment from 'moment'; +import { DataQuery } from '@grafana/ui/'; import * as utils from '../datasource-zabbix/utils'; import { ZBXTrigger } from './types'; @@ -20,3 +22,13 @@ export function formatLastChange(lastchangeUnix: number, customFormat?: string) const lastchange = timestamp.format(format); return lastchange; } + +export const getNextRefIdChar = (queries: DataQuery[]): string => { + const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + return _.find(letters, refId => { + return _.every(queries, other => { + return other.refId !== refId; + }); + }); +}; diff --git a/tslint.json b/tslint.json index 4c7ea71..ab2614b 100644 --- a/tslint.json +++ b/tslint.json @@ -64,7 +64,6 @@ ], "variable-name": [ true, - "check-format", "ban-keywords", "allow-leading-underscore", "allow-trailing-underscore", From 68aa093cf3b0d16a0b37152c2c1380bc7c5a202f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Dec 2019 16:33:36 +0300 Subject: [PATCH 53/59] build(deps-dev): bump lodash from 4.17.10 to 4.17.13 (#852) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.10 to 4.17.13. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.10...4.17.13) Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index d93af81..fe5405e 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "jshint": "^2.9.6", "jshint-stylish": "^2.1.0", "load-grunt-tasks": "~3.2.0", - "lodash": "~4.17.5", + "lodash": "~4.17.13", "moment": "~2.21.0", "ng-annotate-webpack-plugin": "^0.3.0", "node-sass": "^4.9.4", diff --git a/yarn.lock b/yarn.lock index 48c3a5a..fd59423 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5833,7 +5833,7 @@ lodash.tail@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" integrity sha1-0jM6NtnncXyK0vfKyv7HwytERmQ= -lodash@4.17.15, lodash@>4.17.4, lodash@^4.0.1, lodash@^4.1.1, lodash@^4.17.11, lodash@^4.17.13: +lodash@4.17.15, lodash@>4.17.4, lodash@^4.0.0, lodash@^4.0.1, lodash@^4.1.1, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.4, lodash@~4.17.10, lodash@~4.17.5: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -5843,15 +5843,10 @@ lodash@^3.5.0, lodash@^3.7.0, lodash@~3.10.0: resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y= -lodash@^4.0.0: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== - -lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@~4.17.10, lodash@~4.17.5: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" - integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg== +lodash@~4.17.13: + version "4.17.13" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93" + integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA== log-symbols@^1.0.0: version "1.0.2" From 4fcef290a7a2e28197a20961b9563431cde70b8b Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 26 Dec 2019 16:51:02 +0300 Subject: [PATCH 54/59] fix packages security alerts --- package.json | 14 ++- yarn.lock | 280 ++++++++++++--------------------------------------- 2 files changed, 76 insertions(+), 218 deletions(-) diff --git a/package.json b/package.json index fe5405e..8b21a42 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": false, "version": "3.10.4", "description": "Zabbix plugin for Grafana", + "homepage": "http://grafana-zabbix.org", "scripts": { "build": "webpack --config webpack/webpack.prod.conf.js --progress --colors", "dev": "webpack --config webpack/webpack.dev.conf.js --progress --colors", @@ -46,7 +47,7 @@ "classnames": "^2.2.6", "clean-webpack-plugin": "^0.1.19", "codecov": "^3.1.0", - "copy-webpack-plugin": "^4.5.4", + "copy-webpack-plugin": "^5.1.1", "css-loader": "2.1.1", "extract-text-webpack-plugin": "^4.0.0-beta.0", "grunt": "^1.0.3", @@ -63,7 +64,7 @@ "lodash": "~4.17.13", "moment": "~2.21.0", "ng-annotate-webpack-plugin": "^0.3.0", - "node-sass": "^4.9.4", + "node-sass": "^4.13.0", "prop-types": "^15.6.2", "react": "^16.7.0", "react-dom": "^16.7.0", @@ -82,5 +83,12 @@ "webpack": "4.29.6", "webpack-cli": "3.2.3" }, - "homepage": "http://grafana-zabbix.org" + "resolutions": { + "js-yaml": "^3.13.1", + "lodash": "~4.17.13", + "set-value": "^2.0.1", + "mixin-deep": "^1.3.2", + "minimatch": "^3.0.2", + "fstream": "^1.0.12" + } } diff --git a/yarn.lock b/yarn.lock index fd59423..00ba26b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1433,6 +1433,11 @@ amdefine@>=0.0.4: resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU= +ansi-colors@^3.0.0: + version "3.2.4" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf" + integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA== + ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" @@ -1491,7 +1496,7 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -argparse@^1.0.2, argparse@^1.0.7: +argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -1951,11 +1956,6 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.5.1: - version "3.7.0" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.0.tgz#56a6a886e03f6ae577cffedeb524f8f2450293cf" - integrity sha512-aBQ1FxIa7kSWCcmKHlcHFlT2jt6J/l4FzC7KcPELkOJOsPOb/bccdhmIrKDfXhwFrmc7vDoDrrepFvGqjyXGJg== - bluebird@^3.5.5: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -1966,7 +1966,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== -brace-expansion@^1.0.0, brace-expansion@^1.1.7: +brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== @@ -2118,26 +2118,7 @@ builtin-status-codes@^3.0.0: resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= -cacache@^10.0.4: - version "10.0.4" - resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460" - integrity sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA== - dependencies: - bluebird "^3.5.1" - chownr "^1.0.1" - glob "^7.1.2" - graceful-fs "^4.1.11" - lru-cache "^4.1.1" - mississippi "^2.0.0" - mkdirp "^0.5.1" - move-concurrently "^1.0.1" - promise-inflight "^1.0.1" - rimraf "^2.6.2" - ssri "^5.2.4" - unique-filename "^1.1.0" - y18n "^4.0.0" - -cacache@^12.0.2: +cacache@^12.0.2, cacache@^12.0.3: version "12.0.3" resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.3.tgz#be99abba4e1bf5df461cd5a2c1071fc432573390" integrity sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw== @@ -2313,7 +2294,7 @@ chokidar@^2.0.2: optionalDependencies: fsevents "^1.2.2" -chownr@^1.0.1, chownr@^1.1.1: +chownr@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.3.tgz#42d837d5239688d55f303003a508230fa6727142" integrity sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw== @@ -2626,19 +2607,23 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -copy-webpack-plugin@^4.5.4: - version "4.5.4" - resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.4.tgz#f2b2782b3cd5225535c3dc166a80067e7d940f27" - integrity sha512-0lstlEyj74OAtYMrDxlNZsU7cwFijAI3Ofz2fD6Mpo9r4xCv4yegfa3uHIKvZY1NSuOtE9nvG6TAhJ+uz9gDaQ== +copy-webpack-plugin@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-5.1.1.tgz#5481a03dea1123d88a988c6ff8b78247214f0b88" + integrity sha512-P15M5ZC8dyCjQHWwd4Ia/dm0SgVvZJMYeykVIVYXbGyqO4dWB5oyPHp9i7wjwo5LhtlhKbiBCdS2NvM07Wlybg== dependencies: - cacache "^10.0.4" - find-cache-dir "^1.0.0" + cacache "^12.0.3" + find-cache-dir "^2.1.0" + glob-parent "^3.1.0" globby "^7.1.1" - is-glob "^4.0.0" - loader-utils "^1.1.0" + is-glob "^4.0.1" + loader-utils "^1.2.3" minimatch "^3.0.4" - p-limit "^1.0.0" - serialize-javascript "^1.4.0" + normalize-path "^3.0.0" + p-limit "^2.2.1" + schema-utils "^1.0.0" + serialize-javascript "^2.1.2" + webpack-log "^2.0.0" core-js-compat@^3.6.0: version "3.6.0" @@ -3509,11 +3494,6 @@ eslint-scope@^4.0.0: esrecurse "^4.1.0" estraverse "^4.1.1" -esprima@^2.6.0: - version "2.7.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" - integrity sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE= - esprima@^3.1.3, esprima@~3.1.0: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" @@ -3772,15 +3752,6 @@ fill-range@^4.0.0: repeat-string "^1.6.1" to-regex-range "^2.1.0" -find-cache-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" - integrity sha1-kojj6ePMN0hxfTnq3hfPcfww7m8= - dependencies: - commondir "^1.0.1" - make-dir "^1.0.0" - pkg-dir "^2.0.0" - find-cache-dir@^2.0.0, find-cache-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" @@ -3803,13 +3774,6 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" -find-up@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= - dependencies: - locate-path "^2.0.0" - find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -3943,17 +3907,7 @@ fsevents@^1.2.2, fsevents@^1.2.7: bindings "^1.5.0" nan "^2.12.1" -fstream@^1.0.0: - version "1.0.11" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" - integrity sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE= - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - -fstream@^1.0.12: +fstream@^1.0.0, fstream@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045" integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg== @@ -4600,11 +4554,6 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherit@^2.2.2: - version "2.2.6" - resolved "https://registry.yarnpkg.com/inherit/-/inherit-2.2.6.tgz#f1614b06c8544e8128e4229c86347db73ad9788d" - integrity sha1-8WFLBshUToEo5CKchjR9tzrZeI0= - inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -4812,6 +4761,13 @@ is-glob@^4.0.0: dependencies: is-extglob "^2.1.1" +is-glob@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + is-hotkey@0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-hotkey/-/is-hotkey-0.1.4.tgz#c34d2c85d6ec8d09a871dcf71931c8067a824c7d" @@ -4829,7 +4785,7 @@ is-number@^3.0.0: dependencies: kind-of "^3.0.2" -is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: +is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== @@ -5363,15 +5319,7 @@ js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= -js-yaml@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" - integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -js-yaml@^3.13.1: +js-yaml@^3.12.0, js-yaml@^3.13.1, js-yaml@~3.4.0, js-yaml@~3.5.2: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== @@ -5379,23 +5327,6 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@~3.4.0: - version "3.4.6" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.4.6.tgz#6be1b23f6249f53d293370fd4d1aaa63ce1b4eb0" - integrity sha1-a+GyP2JJ9T0pM3D9TRqqY84bTrA= - dependencies: - argparse "^1.0.2" - esprima "^2.6.0" - inherit "^2.2.2" - -js-yaml@~3.5.2: - version "3.5.5" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.5.5.tgz#0377c38017cabc7322b0d1fbcd25a491641f2fbe" - integrity sha1-A3fDgBfKvHMisNH7zSWkkWQfL74= - dependencies: - argparse "^1.0.2" - esprima "^2.6.0" - jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -5768,14 +5699,6 @@ loader-utils@^1.0.2, loader-utils@^1.1.0: emojis-list "^2.0.0" json5 "^0.5.0" -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -5833,17 +5756,7 @@ lodash.tail@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" integrity sha1-0jM6NtnncXyK0vfKyv7HwytERmQ= -lodash@4.17.15, lodash@>4.17.4, lodash@^4.0.0, lodash@^4.0.1, lodash@^4.1.1, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.4, lodash@~4.17.10, lodash@~4.17.5: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== - -lodash@^3.5.0, lodash@^3.7.0, lodash@~3.10.0: - version "3.10.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" - integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y= - -lodash@~4.17.13: +lodash@4.17.15, lodash@>4.17.4, lodash@^3.5.0, lodash@^3.7.0, lodash@^4.0.0, lodash@^4.0.1, lodash@^4.1.1, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.4, lodash@~3.10.0, lodash@~4.17.10, lodash@~4.17.13, lodash@~4.17.5: version "4.17.13" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93" integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA== @@ -5875,7 +5788,7 @@ lower-case@^1.1.1: resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw= -lru-cache@^4.0.1, lru-cache@^4.1.1: +lru-cache@^4.0.1: version "4.1.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" integrity sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA== @@ -5890,13 +5803,6 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - make-dir@^2.0.0, make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -6069,20 +5975,13 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.0, minimatch@~3.0.2: +"minimatch@2 || 3", minimatch@^2.0.1, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.0, minimatch@~3.0.2: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - integrity sha1-jQh8OcazjAAbl/ynzm0OHoCvusc= - dependencies: - brace-expansion "^1.0.0" - minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -6098,22 +5997,6 @@ minimist@~0.0.1: resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= -mississippi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-2.0.0.tgz#3442a508fafc28500486feea99409676e4ee5a6f" - integrity sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw== - dependencies: - concat-stream "^1.5.0" - duplexify "^3.4.2" - end-of-stream "^1.1.0" - flush-write-stream "^1.0.0" - from2 "^2.1.0" - parallel-transform "^1.1.0" - pump "^2.0.1" - pumpify "^1.3.3" - stream-each "^1.1.0" - through2 "^2.0.0" - mississippi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" @@ -6130,10 +6013,10 @@ mississippi@^3.0.0: stream-each "^1.1.0" through2 "^2.0.0" -mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== +mixin-deep@^1.2.0, mixin-deep@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== dependencies: for-in "^1.0.2" is-extendable "^1.0.1" @@ -6368,10 +6251,10 @@ node-releases@^1.1.42: dependencies: semver "^6.3.0" -node-sass@^4.9.4: - version "4.12.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017" - integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ== +node-sass@^4.13.0: + version "4.13.0" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.13.0.tgz#b647288babdd6a1cb726de4545516b31f90da066" + integrity sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA== dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -6380,7 +6263,7 @@ node-sass@^4.9.4: get-stdin "^4.0.1" glob "^7.0.3" in-publish "^2.0.0" - lodash "^4.17.11" + lodash "^4.17.15" meow "^3.7.0" mkdirp "^0.5.1" nan "^2.13.2" @@ -6659,13 +6542,6 @@ p-is-promise@^1.1.0: resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-1.1.0.tgz#9c9456989e9f6588017b0434d56097675c3da05e" integrity sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4= -p-limit@^1.0.0, p-limit@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" - integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== - dependencies: - p-try "^1.0.0" - p-limit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec" @@ -6673,12 +6549,12 @@ p-limit@^2.0.0: dependencies: p-try "^2.0.0" -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= +p-limit@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.1.tgz#aa07a788cc3151c939b5131f63570f0dd2009537" + integrity sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg== dependencies: - p-limit "^1.1.0" + p-try "^2.0.0" p-locate@^3.0.0: version "3.0.0" @@ -6692,11 +6568,6 @@ p-reduce@^1.0.0: resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo= -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= - p-try@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" @@ -6934,13 +6805,6 @@ pirates@^4.0.1: dependencies: node-modules-regexp "^1.0.0" -pkg-dir@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" - integrity sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s= - dependencies: - find-up "^2.1.0" - pkg-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" @@ -7262,7 +7126,7 @@ public-encrypt@^4.0.0: randombytes "^2.0.1" safe-buffer "^5.1.2" -pump@^2.0.0, pump@^2.0.1: +pump@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== @@ -7928,7 +7792,7 @@ revalidator@0.1.x: resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b" integrity sha1-/s5hv6DBtSoga9axgZgYS91SOjs= -rimraf@2, rimraf@2.x.x, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3: +rimraf@2, rimraf@2.x.x, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -8113,11 +7977,6 @@ semver@~5.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -serialize-javascript@^1.4.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb" - integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A== - serialize-javascript@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" @@ -8128,20 +7987,10 @@ set-blocking@^2.0.0, set-blocking@~2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -set-value@^0.4.3: - version "0.4.3" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" - integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.1" - to-object-path "^0.3.0" - -set-value@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" - integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg== +set-value@^0.4.3, set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== dependencies: extend-shallow "^2.0.1" is-extendable "^0.1.1" @@ -8447,13 +8296,6 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" -ssri@^5.2.4: - version "5.3.0" - resolved "https://registry.yarnpkg.com/ssri/-/ssri-5.3.0.tgz#ba3872c9c6d33a0704a7d71ff045e5ec48999d06" - integrity sha512-XRSIPqLij52MtgoQavH/x/dU1qVKtWUAAZeOHsR9c2Ddi4XerFy3mc1alf+dLJKl9EUIm/Ht+EowFkTUOA6GAQ== - dependencies: - safe-buffer "^5.1.1" - ssri@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" @@ -9138,7 +8980,7 @@ uniq@^1.0.1: resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8= -unique-filename@^1.1.0, unique-filename@^1.1.1: +unique-filename@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== @@ -9381,6 +9223,14 @@ webpack-core@^0.6.5: source-list-map "~0.1.7" source-map "~0.4.1" +webpack-log@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/webpack-log/-/webpack-log-2.0.0.tgz#5b7928e0637593f119d32f6227c1e0ac31e1b47f" + integrity sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg== + dependencies: + ansi-colors "^3.0.0" + uuid "^3.3.2" + webpack-sources@^1.1.0, webpack-sources@^1.3.0, webpack-sources@^1.4.0: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" From 1e6ca2d518d2af43afa932fb92d6321edb3d3f65 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 26 Dec 2019 17:06:15 +0300 Subject: [PATCH 55/59] problems: fix tags adding and removal --- src/panel-triggers/triggers_panel_ctrl.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index dad0d7a..23c6011 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -492,7 +492,9 @@ export class TriggerPanelCtrl extends PanelCtrl { return _.map(tags, (tag) => `${tag.tag}:${tag.value}`).join(', '); } - addTagFilter(tag, target) { + addTagFilter(tag, datasource) { + const target = this.panel.targets.find(t => t.datasource === datasource); + console.log(target); let tagFilter = target.tags.filter; let targetTags = this.parseTags(tagFilter); let newTag = {tag: tag.tag, value: tag.value}; @@ -503,7 +505,8 @@ export class TriggerPanelCtrl extends PanelCtrl { this.refresh(); } - removeTagFilter(tag, target) { + removeTagFilter(tag, datasource) { + const target = this.panel.targets.find(t => t.datasource === datasource); let tagFilter = target.tags.filter; let targetTags = this.parseTags(tagFilter); _.remove(targetTags, t => t.tag === tag.tag && t.value === tag.value); From 90a9115958d7c048111cb2547740ce50a54494c6 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 26 Dec 2019 17:30:13 +0300 Subject: [PATCH 56/59] fix adding func from typeahead, closes #468 --- src/datasource-zabbix/add-metric-function.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasource-zabbix/add-metric-function.directive.js b/src/datasource-zabbix/add-metric-function.directive.js index 64c2c41..17f9103 100644 --- a/src/datasource-zabbix/add-metric-function.directive.js +++ b/src/datasource-zabbix/add-metric-function.directive.js @@ -47,7 +47,7 @@ angular } $scope.$apply(function() { - $scope.addFunction(funcDef); + $scope.ctrl.addFunction(funcDef); }); $input.trigger('blur'); From 51ef6f70d3e4eea78a859bd611750b628ffc0b0b Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 26 Dec 2019 17:56:08 +0300 Subject: [PATCH 57/59] update change log --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83bf8e4..6d76c30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased + +## [3.10.5] - 2019-12-26 ### Added - SLA over time graphs, [#728](https://github.com/alexanderzobnin/grafana-zabbix/issues/728) +- Additional time ranges in functions, [#531](https://github.com/alexanderzobnin/grafana-zabbix/issues/531) + +### Fixed +- Problems panel: query editor broken in Grafana 6.4, [#817](https://github.com/alexanderzobnin/grafana-zabbix/issues/817) +- Datasource: function editor is not working, [#810](https://github.com/alexanderzobnin/grafana-zabbix/issues/810) +- Datasource: cannot add a function to query from typeahead, [#468](https://github.com/alexanderzobnin/grafana-zabbix/issues/468) +- Datasource: annotations editor broken in Grafana 6.x, [#813](https://github.com/alexanderzobnin/grafana-zabbix/issues/813) +- React plugins issue, [#823](https://github.com/alexanderzobnin/grafana-zabbix/issues/823) ## [3.10.4] - 2019-08-08 ### Fixed From 90b8bfa99c7fd9f8a7c2cb41576fc042d6e98750 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 26 Dec 2019 17:59:24 +0300 Subject: [PATCH 58/59] bump plugin version to 3.10.5 --- package.json | 2 +- src/plugin.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8b21a42..e510d91 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grafana-zabbix", "private": false, - "version": "3.10.4", + "version": "3.10.5", "description": "Zabbix plugin for Grafana", "homepage": "http://grafana-zabbix.org", "scripts": { diff --git a/src/plugin.json b/src/plugin.json index 25540d9..59d75a3 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -26,8 +26,8 @@ {"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"}, {"name": "Triggers", "path": "img/screenshot-triggers.png"} ], - "version": "3.10.4", - "updated": "2019-08-08" + "version": "3.10.5", + "updated": "2019-12-26" }, "includes": [ From d54d6d29dc4e802d5cec37ac9a320182c2c96cb2 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 30 Dec 2019 10:36:36 +0300 Subject: [PATCH 59/59] problems: fix tag removal (list layout) --- src/panel-triggers/components/AlertList/AlertCard.tsx | 6 +++--- src/panel-triggers/components/AlertList/AlertList.tsx | 6 +++--- src/panel-triggers/components/Problems/Problems.tsx | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/panel-triggers/components/AlertList/AlertCard.tsx b/src/panel-triggers/components/AlertList/AlertCard.tsx index 46d9dd1..b893ac8 100644 --- a/src/panel-triggers/components/AlertList/AlertCard.tsx +++ b/src/panel-triggers/components/AlertList/AlertCard.tsx @@ -13,7 +13,7 @@ import AlertIcon from './AlertIcon'; interface AlertCardProps { problem: ZBXTrigger; panelOptions: ProblemsPanelOptions; - onTagClick?: (tag: ZBXTag, datasource: string) => void; + onTagClick?: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void; onProblemAck?: (problem: ZBXTrigger, data: AckProblemData) => Promise | any; } @@ -27,9 +27,9 @@ export default class AlertCard extends PureComponent { + handleTagClick = (tag: ZBXTag, ctrlKey?: boolean, shiftKey?: boolean) => { if (this.props.onTagClick) { - this.props.onTagClick(tag, this.props.problem.datasource); + this.props.onTagClick(tag, this.props.problem.datasource, ctrlKey, shiftKey); } } diff --git a/src/panel-triggers/components/AlertList/AlertList.tsx b/src/panel-triggers/components/AlertList/AlertList.tsx index 8d1d08b..a01c155 100644 --- a/src/panel-triggers/components/AlertList/AlertList.tsx +++ b/src/panel-triggers/components/AlertList/AlertList.tsx @@ -12,7 +12,7 @@ export interface AlertListProps { pageSize?: number; fontSize?: number; onProblemAck?: (problem: ZBXTrigger, data: AckProblemData) => void; - onTagClick?: (tag: ZBXTag, datasource: string) => void; + onTagClick?: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void; } interface AlertListState { @@ -45,9 +45,9 @@ export default class AlertList extends PureComponent { + handleTagClick = (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => { if (this.props.onTagClick) { - this.props.onTagClick(tag, datasource); + this.props.onTagClick(tag, datasource, ctrlKey, shiftKey); } } diff --git a/src/panel-triggers/components/Problems/Problems.tsx b/src/panel-triggers/components/Problems/Problems.tsx index c2a1d2d..7301f8d 100644 --- a/src/panel-triggers/components/Problems/Problems.tsx +++ b/src/panel-triggers/components/Problems/Problems.tsx @@ -260,13 +260,13 @@ function LastChangeCell(props: RTCell, customFormat?: string) { } interface TagCellProps extends RTCell { - onTagClick: (tag: ZBXTag, datasource: string) => void; + onTagClick: (tag: ZBXTag, datasource: string, ctrlKey?: boolean, shiftKey?: boolean) => void; } class TagCell extends PureComponent { - handleTagClick = (tag: ZBXTag) => { + handleTagClick = (tag: ZBXTag, ctrlKey?: boolean, shiftKey?: boolean) => { if (this.props.onTagClick) { - this.props.onTagClick(tag, this.props.original.datasource); + this.props.onTagClick(tag, this.props.original.datasource, ctrlKey, shiftKey); } }