Modules renamed using John Papa Angular Style Guide.
This commit is contained in:
@@ -238,4 +238,4 @@ function (angular, _, moment, utils) {
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,16 +3,15 @@ import _ from 'lodash';
|
||||
import * as dateMath from 'app/core/utils/datemath';
|
||||
import * as utils from './utils';
|
||||
import metricFunctions from './metricFunctions';
|
||||
import {zabbixHelperSrv} from './helperFunctions';
|
||||
import './zabbixAPIService';
|
||||
import {ZabbixCachingProxy} from './zabbixCache';
|
||||
import {QueryProcessor} from './queryProcessor';
|
||||
import {DataProcessingService} from './dataProcessingService';
|
||||
import './zabbixAPI.service.js';
|
||||
import './zabbixCache.service.js';
|
||||
import './queryProcessor.service.js';
|
||||
import './dataProcessing.service';
|
||||
|
||||
export class ZabbixAPIDatasource {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(instanceSettings, $q, templateSrv, alertSrv, zabbixAPIService, ZabbixCachingProxy, QueryProcessor, zabbixHelperSrv, DataProcessingService) {
|
||||
constructor(instanceSettings, $q, templateSrv, alertSrv, zabbixAPIService, ZabbixCachingProxy, QueryProcessor, DataProcessingService) {
|
||||
|
||||
// General data source settings
|
||||
this.name = instanceSettings.name;
|
||||
@@ -46,7 +45,6 @@ export class ZabbixAPIDatasource {
|
||||
this.q = $q;
|
||||
this.templateSrv = templateSrv;
|
||||
this.alertSrv = alertSrv;
|
||||
this.zabbixHelperSrv = zabbixHelperSrv;
|
||||
this.DataProcessingService = DataProcessingService;
|
||||
|
||||
console.log(this.zabbixCache);
|
||||
@@ -243,13 +241,13 @@ export class ZabbixAPIDatasource {
|
||||
return [];
|
||||
} else {
|
||||
return this.zabbixAPI.getSLA(target.itservice.serviceid, from, to)
|
||||
.then(_.bind(zabbixHelperSrv.handleSLAResponse, zabbixHelperSrv, target.itservice, target.slaProperty));
|
||||
.then(slaObject => {
|
||||
return self.queryProcessor.handleSLAResponse(target.itservice, target.slaProperty, slaObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
var self = this;
|
||||
|
||||
// Data for panel (all targets)
|
||||
return this.q.all(_.flatten(promises))
|
||||
.then(_.flatten)
|
||||
|
||||
@@ -1,105 +1,102 @@
|
||||
define([
|
||||
'lodash',
|
||||
'jquery'
|
||||
],
|
||||
function (_, $) {
|
||||
'use strict';
|
||||
import _ from 'lodash';
|
||||
import $ from 'jquery';
|
||||
|
||||
var index = [];
|
||||
var categories = {
|
||||
Transform: [],
|
||||
Aggregate: [],
|
||||
Trends: [],
|
||||
Alias: []
|
||||
};
|
||||
var index = [];
|
||||
var categories = {
|
||||
Transform: [],
|
||||
Aggregate: [],
|
||||
Trends: [],
|
||||
Alias: []
|
||||
};
|
||||
|
||||
function addFuncDef(funcDef) {
|
||||
funcDef.params = funcDef.params || [];
|
||||
funcDef.defaultParams = funcDef.defaultParams || [];
|
||||
function addFuncDef(funcDef) {
|
||||
funcDef.params = funcDef.params || [];
|
||||
funcDef.defaultParams = funcDef.defaultParams || [];
|
||||
|
||||
if (funcDef.category) {
|
||||
categories[funcDef.category].push(funcDef);
|
||||
}
|
||||
index[funcDef.name] = funcDef;
|
||||
index[funcDef.shortName || funcDef.name] = funcDef;
|
||||
if (funcDef.category) {
|
||||
categories[funcDef.category].push(funcDef);
|
||||
}
|
||||
index[funcDef.name] = funcDef;
|
||||
index[funcDef.shortName || funcDef.name] = funcDef;
|
||||
}
|
||||
|
||||
addFuncDef({
|
||||
name: 'groupBy',
|
||||
category: 'Transform',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string'},
|
||||
{ name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }
|
||||
],
|
||||
defaultParams: ['1m', 'avg'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'groupBy',
|
||||
category: 'Transform',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string'},
|
||||
{ name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }
|
||||
],
|
||||
defaultParams: ['1m', 'avg'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sumSeries',
|
||||
category: 'Aggregate',
|
||||
params: [],
|
||||
defaultParams: [],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'sumSeries',
|
||||
category: 'Aggregate',
|
||||
params: [],
|
||||
defaultParams: [],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'median',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string'}
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'median',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string'}
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'average',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'average',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'max',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'max',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' }
|
||||
],
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'trendValue',
|
||||
category: 'Trends',
|
||||
params: [
|
||||
{ name: 'type', type: 'string', options: ['avg', 'min', 'max'] }
|
||||
],
|
||||
defaultParams: ['avg'],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'trendValue',
|
||||
category: 'Trends',
|
||||
params: [
|
||||
{ name: 'type', type: 'string', options: ['avg', 'min', 'max'] }
|
||||
],
|
||||
defaultParams: ['avg'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'setAlias',
|
||||
category: 'Alias',
|
||||
params: [
|
||||
{ name: 'alias', type: 'string'}
|
||||
],
|
||||
defaultParams: [],
|
||||
});
|
||||
addFuncDef({
|
||||
name: 'setAlias',
|
||||
category: 'Alias',
|
||||
params: [
|
||||
{ name: 'alias', type: 'string'}
|
||||
],
|
||||
defaultParams: [],
|
||||
});
|
||||
|
||||
_.each(categories, function(funcList, catName) {
|
||||
categories[catName] = _.sortBy(funcList, 'name');
|
||||
});
|
||||
_.each(categories, function(funcList, catName) {
|
||||
categories[catName] = _.sortBy(funcList, 'name');
|
||||
});
|
||||
|
||||
function FuncInstance(funcDef, params) {
|
||||
class FuncInstance {
|
||||
constructor(funcDef, params) {
|
||||
this.def = funcDef;
|
||||
|
||||
if (params) {
|
||||
@@ -113,7 +110,7 @@ function (_, $) {
|
||||
this.updateText();
|
||||
}
|
||||
|
||||
FuncInstance.prototype.bindFunction = function(metricFunctions) {
|
||||
bindFunction(metricFunctions) {
|
||||
var func = metricFunctions[this.def.name];
|
||||
if (func) {
|
||||
|
||||
@@ -126,9 +123,9 @@ function (_, $) {
|
||||
} else {
|
||||
throw { message: 'Method not found ' + this.def.name };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
FuncInstance.prototype.render = function(metricExp) {
|
||||
render(metricExp) {
|
||||
var str = this.def.name + '(';
|
||||
var parameters = _.map(this.params, function(value, index) {
|
||||
|
||||
@@ -149,17 +146,17 @@ function (_, $) {
|
||||
}
|
||||
|
||||
return str + parameters.join(', ') + ')';
|
||||
};
|
||||
}
|
||||
|
||||
FuncInstance.prototype._hasMultipleParamsInString = function(strValue, index) {
|
||||
_hasMultipleParamsInString(strValue, index) {
|
||||
if (strValue.indexOf(',') === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.def.params[index + 1] && this.def.params[index + 1].optional;
|
||||
};
|
||||
}
|
||||
|
||||
FuncInstance.prototype.updateParam = function(strValue, index) {
|
||||
updateParam(strValue, index) {
|
||||
// handle optional parameters
|
||||
// if string contains ',' and next param is optional, split and update both
|
||||
if (this._hasMultipleParamsInString(strValue, index)) {
|
||||
@@ -177,9 +174,9 @@ function (_, $) {
|
||||
}
|
||||
|
||||
this.updateText();
|
||||
};
|
||||
}
|
||||
|
||||
FuncInstance.prototype.updateText = function () {
|
||||
updateText() {
|
||||
if (this.params.length === 0) {
|
||||
this.text = this.def.name + '()';
|
||||
return;
|
||||
@@ -189,26 +186,25 @@ function (_, $) {
|
||||
text += this.params.join(', ');
|
||||
text += ')';
|
||||
this.text = text;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
createFuncInstance: function(funcDef, params) {
|
||||
if (_.isString(funcDef)) {
|
||||
if (!index[funcDef]) {
|
||||
throw { message: 'Method not found ' + name };
|
||||
}
|
||||
funcDef = index[funcDef];
|
||||
export default {
|
||||
createFuncInstance: function(funcDef, params) {
|
||||
if (_.isString(funcDef)) {
|
||||
if (!index[funcDef]) {
|
||||
throw { message: 'Method not found ' + name };
|
||||
}
|
||||
return new FuncInstance(funcDef, params);
|
||||
},
|
||||
|
||||
getFuncDef: function(name) {
|
||||
return index[name];
|
||||
},
|
||||
|
||||
getCategories: function() {
|
||||
return categories;
|
||||
funcDef = index[funcDef];
|
||||
}
|
||||
};
|
||||
return new FuncInstance(funcDef, params);
|
||||
},
|
||||
|
||||
});
|
||||
getFuncDef: function(name) {
|
||||
return index[name];
|
||||
},
|
||||
|
||||
getCategories: function() {
|
||||
return categories;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import {ZabbixAPIDatasource} from './datasource';
|
||||
import {ZabbixQueryCtrl} from './queryCtrl';
|
||||
import {ZabbixQueryController} from './query.controller';
|
||||
|
||||
class ZabbixConfigCtrl {}
|
||||
ZabbixConfigCtrl.templateUrl = 'partials/config.html';
|
||||
class ZabbixConfigController {}
|
||||
ZabbixConfigController.templateUrl = 'partials/config.html';
|
||||
|
||||
class ZabbixQueryOptionsCtrl {}
|
||||
ZabbixQueryOptionsCtrl.templateUrl = 'partials/query.options.html';
|
||||
class ZabbixQueryOptionsController {}
|
||||
ZabbixQueryOptionsController.templateUrl = 'partials/query.options.html';
|
||||
|
||||
class ZabbixAnnotationsQueryCtrl {}
|
||||
ZabbixAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html';
|
||||
class ZabbixAnnotationsQueryController {}
|
||||
ZabbixAnnotationsQueryController.templateUrl = 'partials/annotations.editor.html';
|
||||
|
||||
export {
|
||||
ZabbixAPIDatasource as Datasource,
|
||||
ZabbixQueryCtrl as QueryCtrl,
|
||||
ZabbixConfigCtrl as ConfigCtrl,
|
||||
ZabbixQueryOptionsCtrl as QueryOptionsCtrl,
|
||||
ZabbixAnnotationsQueryCtrl as AnnotationsQueryCtrl
|
||||
ZabbixConfigController as ConfigCtrl,
|
||||
ZabbixQueryController as QueryCtrl,
|
||||
ZabbixQueryOptionsController as QueryOptionsCtrl,
|
||||
ZabbixAnnotationsQueryController as AnnotationsQueryCtrl
|
||||
};
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
/*define([
|
||||
'app/plugins/sdk',
|
||||
'angular',
|
||||
'lodash',
|
||||
'./metricFunctions',
|
||||
'./utils'
|
||||
],*/
|
||||
|
||||
import {QueryCtrl} from 'app/plugins/sdk';
|
||||
import _ from 'lodash';
|
||||
import * as utils from './utils';
|
||||
import metricFunctions from './metricFunctions';
|
||||
|
||||
export class ZabbixQueryCtrl extends QueryCtrl {
|
||||
export class ZabbixQueryController extends QueryCtrl {
|
||||
|
||||
// ZabbixQueryCtrl constructor
|
||||
constructor($scope, $injector, $sce, $q, templateSrv) {
|
||||
@@ -229,9 +221,9 @@ export class ZabbixQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
// Set templateUrl as static property
|
||||
ZabbixQueryCtrl.templateUrl = 'partials/query.editor.html';
|
||||
ZabbixQueryController.templateUrl = 'partials/query.editor.html';
|
||||
|
||||
// Get list of metric names for bs-typeahead directive
|
||||
function getMetricNames(scope, metricList) {
|
||||
return _.uniq(_.map(scope.metric[metricList], 'name'));
|
||||
}
|
||||
}
|
||||
@@ -416,6 +416,27 @@ function (angular, _, utils) {
|
||||
return this.convertHistory(history, addHostName, convertPointCallback);
|
||||
};
|
||||
|
||||
this.handleSLAResponse = function (itservice, slaProperty, slaObject) {
|
||||
var targetSLA = slaObject[itservice.serviceid].sla[0];
|
||||
if (slaProperty.property === 'status') {
|
||||
var targetStatus = parseInt(slaObject[itservice.serviceid].status);
|
||||
return {
|
||||
target: itservice.name + ' ' + slaProperty.name,
|
||||
datapoints: [
|
||||
[targetStatus, targetSLA.to * 1000]
|
||||
]
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
target: itservice.name + ' ' + slaProperty.name,
|
||||
datapoints: [
|
||||
[targetSLA[slaProperty.property], targetSLA.from * 1000],
|
||||
[targetSLA[slaProperty.property], targetSLA.to * 1000]
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [
|
||||
@@ -450,4 +471,4 @@ function (angular, _, utils) {
|
||||
return QueryProcessor;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import './zabbixAPICoreService';
|
||||
import './zabbixAPICore.service';
|
||||
|
||||
/** @ngInject */
|
||||
function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
|
||||
Reference in New Issue
Block a user