diff --git a/package.json b/package.json index ca7c7f0..5f9a127 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", @@ -16,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", @@ -35,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", @@ -42,7 +44,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", "tether-drop": "^1.4.2" }, "dependencies": { diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index a5bb2d9..63bf29c 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -36,6 +36,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; @@ -125,6 +131,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 56dc31e..261b284 100644 --- a/src/datasource-zabbix/metricFunctions.js +++ b/src/datasource-zabbix/metricFunctions.js @@ -181,6 +181,15 @@ addFuncDef({ defaultParams: [5, 'avg'], }); +addFuncDef({ + name: 'sortSeries', + category: 'Filter', + params: [ + { name: 'direction', type: 'string', options: ['asc', 'desc'] } + ], + defaultParams: ['asc'] +}); + // Trends addFuncDef({