Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feature to Sort series by their name #465

Merged
merged 3 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -35,14 +36,16 @@
"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",
"mocha": "^2.4.5",
"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"
Expand Down
7 changes: 7 additions & 0 deletions src/datasource-zabbix/dataProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,6 +123,7 @@ let metricFunctions = {
sumSeries: sumSeries,
top: _.partial(limit, 'top'),
bottom: _.partial(limit, 'bottom'),
sortSeries: sortSeries,
timeShift: timeShift,
setAlias: setAlias,
setAliasByRegex: setAliasByRegex,
Expand Down
9 changes: 9 additions & 0 deletions src/datasource-zabbix/metricFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down