Modules renamed using John Papa Angular Style Guide.

This commit is contained in:
Alexander Zobnin
2016-03-16 21:15:46 +03:00
parent def3f9115d
commit 816870136c
12 changed files with 170 additions and 162 deletions

View File

@@ -17,18 +17,19 @@ module.exports = function(grunt) {
'**/*',
'!**/datasource.js',
'!**/module.js',
'!**/queryCtrl.js',
'!**/query.controller.js',
'!**/utils.js',
'!**/zabbixAPICoreService.js',
'!**/zabbixAPIService.js',
'!**/zabbixAPICore.service.js',
'!**/zabbixAPI.service.js',
'!**/metricFunctions.js',
'!**/*.scss'
],
dest: 'dist/src'
dest: 'dist/'
},
pluginDef: {
expand: true,
src: ['plugin.json', 'README.md'],
dest: 'dist',
dest: 'dist/',
}
},
@@ -42,7 +43,7 @@ module.exports = function(grunt) {
babel: {
options: {
sourceMap: true,
sourceMap: false,
presets: ["es2015"],
plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"],
},
@@ -53,13 +54,13 @@ module.exports = function(grunt) {
src: [
'**/**/module.js',
'**/**/datasource.js',
'**/**/queryCtrl.js',
'**/**/query.controller.js',
'**/**/utils.js',
'**/**/zabbixAPICoreService.js',
'**/**/zabbixAPIService.js',
'**/**/zabbixAPICore.service.js',
'**/**/zabbixAPI.service.js',
'**/**/metricFunctions.js'
],
dest: 'dist/src',
ext:'.js'
dest: 'dist/'
}]
},
},

View File

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

View File

@@ -1,9 +1,5 @@
define([
'lodash',
'jquery'
],
function (_, $) {
'use strict';
import _ from 'lodash';
import $ from 'jquery';
var index = [];
var categories = {
@@ -99,7 +95,8 @@ function (_, $) {
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,9 +186,10 @@ function (_, $) {
text += this.params.join(', ');
text += ')';
this.text = text;
};
}
}
return {
export default {
createFuncInstance: function(funcDef, params) {
if (_.isString(funcDef)) {
if (!index[funcDef]) {
@@ -210,5 +208,3 @@ function (_, $) {
return categories;
}
};
});

View File

@@ -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
};

View File

@@ -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,7 +221,7 @@ 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) {

View File

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

View File

@@ -1,6 +1,6 @@
import angular from 'angular';
import _ from 'lodash';
import './zabbixAPICoreService';
import './zabbixAPICore.service';
/** @ngInject */
function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {