Merge branch 'feature/sortseries' of https://github.com/Verivox-GmbH/grafana-zabbix into Verivox-GmbH-feature/sortseries

This commit is contained in:
Alexander Zobnin
2017-10-16 15:31:11 +03:00
3 changed files with 23 additions and 4 deletions

View File

@@ -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": {

View File

@@ -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,

View File

@@ -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({