Process all transform functions.
This commit is contained in:
@@ -92,6 +92,7 @@ function (angular, _, $, metricFunctions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createFunctionDropDownMenu(categories) {
|
function createFunctionDropDownMenu(categories) {
|
||||||
|
console.log(categories);
|
||||||
return _.map(categories, function(list, category) {
|
return _.map(categories, function(list, category) {
|
||||||
return {
|
return {
|
||||||
text: category,
|
text: category,
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'lodash',
|
'lodash',
|
||||||
'moment',
|
'moment',
|
||||||
'./utils'
|
'./utils',
|
||||||
|
'./metricFunctions'
|
||||||
],
|
],
|
||||||
function (angular, _, moment, utils) {
|
function (angular, _, moment, utils, metricFunctions) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ define([
|
|||||||
'lodash',
|
'lodash',
|
||||||
'app/core/utils/datemath',
|
'app/core/utils/datemath',
|
||||||
'./utils',
|
'./utils',
|
||||||
|
'./metricFunctions',
|
||||||
'./queryProcessor',
|
'./queryProcessor',
|
||||||
'./directives',
|
'./directives',
|
||||||
'./zabbixAPI',
|
'./zabbixAPI',
|
||||||
@@ -13,7 +14,7 @@ define([
|
|||||||
'./addMetricFunction',
|
'./addMetricFunction',
|
||||||
'./metricFunctionEditor'
|
'./metricFunctionEditor'
|
||||||
],
|
],
|
||||||
function (angular, _, dateMath, utils) {
|
function (angular, _, dateMath, utils, metricFunctions) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
@@ -145,22 +146,21 @@ function (angular, _, dateMath, utils) {
|
|||||||
return getHistory.then(function (timeseries_data) {
|
return getHistory.then(function (timeseries_data) {
|
||||||
return _.map(timeseries_data, function (timeseries) {
|
return _.map(timeseries_data, function (timeseries) {
|
||||||
|
|
||||||
// Metric data processing
|
// Filter only transform functions
|
||||||
var dp = timeseries.datapoints;
|
var transformFunctions = _.map(metricFunctions.getCategories()['Transform'], 'name');
|
||||||
if (false) {
|
var transFuncDefs = _.filter(target.functions, function(func) {
|
||||||
dp = DataProcessingService.groupBy(dp, options.interval,
|
return _.contains(transformFunctions, func.def.name);
|
||||||
DataProcessingService.AVERAGE);
|
});
|
||||||
timeseries.datapoints = dp;
|
var functions = _.map(transFuncDefs, function(func) {
|
||||||
}
|
|
||||||
|
|
||||||
var functions = _.map(target.functions, function(func) {
|
|
||||||
return func.bindFunction(DataProcessingService.metricFunctions);
|
return func.bindFunction(DataProcessingService.metricFunctions);
|
||||||
});
|
});
|
||||||
if (functions.length) {
|
|
||||||
//console.log(functions);
|
// Metric data processing
|
||||||
dp = functions[0](dp);
|
var dp = timeseries.datapoints;
|
||||||
timeseries.datapoints = dp;
|
for (var i = 0; i < functions.length; i++) {
|
||||||
|
dp = functions[i](dp);
|
||||||
}
|
}
|
||||||
|
timeseries.datapoints = dp;
|
||||||
|
|
||||||
return timeseries;
|
return timeseries;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.targetChanged = function() {
|
$scope.targetChanged = function() {
|
||||||
console.log($scope.target.functions);
|
//console.log($scope.target);
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user