From 13f6fa81833efde53b3968e550cf1e60c8d91a3f Mon Sep 17 00:00:00 2001 From: Marcel Dorenkamp Date: Tue, 10 Oct 2017 10:23:03 +0200 Subject: [PATCH 1/3] added sortSeries function --- src/datasource-zabbix/dataProcessor.js | 7 +++++++ src/datasource-zabbix/metricFunctions.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index 456829ad6..547e65a27 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -35,6 +35,12 @@ function limit(order, n, orderByFunc, timeseries) { } } +function sortSeries(direction, timeseries) { + return _.orderBy(timeseries, [function (ts) { + return ts.target.toLowerCase(); + }], direction); +} + function setAlias(alias, timeseries) { timeseries.target = alias; return timeseries; @@ -117,6 +123,7 @@ let metricFunctions = { sumSeries: sumSeries, top: _.partial(limit, 'top'), bottom: _.partial(limit, 'bottom'), + sortSeries: sortSeries, timeShift: timeShift, setAlias: setAlias, setAliasByRegex: setAliasByRegex, diff --git a/src/datasource-zabbix/metricFunctions.js b/src/datasource-zabbix/metricFunctions.js index ca04c32ca..f5ad950f2 100644 --- a/src/datasource-zabbix/metricFunctions.js +++ b/src/datasource-zabbix/metricFunctions.js @@ -171,6 +171,15 @@ addFuncDef({ defaultParams: [5, 'avg'], }); +addFuncDef({ + name: 'sortSeries', + category: 'Filter', + params: [ + { name: 'direction', type: 'string', options: ['asc', 'desc'] } + ], + defaultParams: ['asc'] +}); + // Trends addFuncDef({ From 397bd673f84abca6bc2a9a5ba4d4af4801335453 Mon Sep 17 00:00:00 2001 From: Marcel Dorenkamp Date: Tue, 10 Oct 2017 10:27:28 +0200 Subject: [PATCH 2/3] added dev dependencies, build command --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04251ffb7..e4c7b6b12 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "version": "3.6.0", "description": "Zabbix plugin for Grafana", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "./node_modules/.bin/grunt" }, "repository": { "type": "git", @@ -42,7 +43,8 @@ "moment": "~2.14.1", "prunk": "~1.2.1", "q": "~1.4.1", - "sinon-chai": "~2.8.0" + "sinon-chai": "~2.13.0", + "sinon":"^3.2.1" }, "dependencies": { "lodash": "~4.0.0" From 46f35ee1269f63b37c9180da30130e9830a4cfb7 Mon Sep 17 00:00:00 2001 From: Marcel Dorenkamp Date: Tue, 10 Oct 2017 10:33:32 +0200 Subject: [PATCH 3/3] added grunt-cli to devdependencies --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e4c7b6b12..8b1a54332 100644 --- a/package.json +++ b/package.json @@ -17,15 +17,15 @@ "url": "https://github.com/alexanderzobnin/grafana-zabbix/issues" }, "devDependencies": { - "babel": "~6.5.1", "babel-plugin-transform-es2015-for-of": "^6.6.0", "babel-plugin-transform-es2015-modules-systemjs": "^6.5.0", "babel-preset-es2015": "^6.5.0", + "babel": "~6.5.1", "benchmark":"^2.1.4", "chai": "~3.5.0", - "grunt": "~0.4.5", "grunt-babel": "~6.0.0", "grunt-benchmark": "^1.0.0", + "grunt-cli": "~1.2.0", "grunt-contrib-clean": "~0.6.0", "grunt-contrib-copy": "~0.8.2", "grunt-contrib-jshint": "^1.0.0", @@ -36,6 +36,7 @@ "grunt-mocha-test": "~0.12.7", "grunt-sass": "^1.1.0", "grunt-systemjs-builder": "^0.2.5", + "grunt": "~0.4.5", "jsdom": "~3.1.2", "jshint-stylish": "^2.1.0", "load-grunt-tasks": "~3.2.0",