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

View File

@@ -3,16 +3,15 @@ import _ from 'lodash';
import * as dateMath from 'app/core/utils/datemath'; import * as dateMath from 'app/core/utils/datemath';
import * as utils from './utils'; import * as utils from './utils';
import metricFunctions from './metricFunctions'; import metricFunctions from './metricFunctions';
import {zabbixHelperSrv} from './helperFunctions'; import './zabbixAPI.service.js';
import './zabbixAPIService'; import './zabbixCache.service.js';
import {ZabbixCachingProxy} from './zabbixCache'; import './queryProcessor.service.js';
import {QueryProcessor} from './queryProcessor'; import './dataProcessing.service';
import {DataProcessingService} from './dataProcessingService';
export class ZabbixAPIDatasource { export class ZabbixAPIDatasource {
/** @ngInject */ /** @ngInject */
constructor(instanceSettings, $q, templateSrv, alertSrv, zabbixAPIService, ZabbixCachingProxy, QueryProcessor, zabbixHelperSrv, DataProcessingService) { constructor(instanceSettings, $q, templateSrv, alertSrv, zabbixAPIService, ZabbixCachingProxy, QueryProcessor, DataProcessingService) {
// General data source settings // General data source settings
this.name = instanceSettings.name; this.name = instanceSettings.name;
@@ -46,7 +45,6 @@ export class ZabbixAPIDatasource {
this.q = $q; this.q = $q;
this.templateSrv = templateSrv; this.templateSrv = templateSrv;
this.alertSrv = alertSrv; this.alertSrv = alertSrv;
this.zabbixHelperSrv = zabbixHelperSrv;
this.DataProcessingService = DataProcessingService; this.DataProcessingService = DataProcessingService;
console.log(this.zabbixCache); console.log(this.zabbixCache);
@@ -243,13 +241,13 @@ export class ZabbixAPIDatasource {
return []; return [];
} else { } else {
return this.zabbixAPI.getSLA(target.itservice.serviceid, from, to) 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); }, this);
var self = this;
// Data for panel (all targets) // Data for panel (all targets)
return this.q.all(_.flatten(promises)) return this.q.all(_.flatten(promises))
.then(_.flatten) .then(_.flatten)

View File

@@ -1,9 +1,5 @@
define([ import _ from 'lodash';
'lodash', import $ from 'jquery';
'jquery'
],
function (_, $) {
'use strict';
var index = []; var index = [];
var categories = { var categories = {
@@ -99,7 +95,8 @@ function (_, $) {
categories[catName] = _.sortBy(funcList, 'name'); categories[catName] = _.sortBy(funcList, 'name');
}); });
function FuncInstance(funcDef, params) { class FuncInstance {
constructor(funcDef, params) {
this.def = funcDef; this.def = funcDef;
if (params) { if (params) {
@@ -113,7 +110,7 @@ function (_, $) {
this.updateText(); this.updateText();
} }
FuncInstance.prototype.bindFunction = function(metricFunctions) { bindFunction(metricFunctions) {
var func = metricFunctions[this.def.name]; var func = metricFunctions[this.def.name];
if (func) { if (func) {
@@ -126,9 +123,9 @@ function (_, $) {
} else { } else {
throw { message: 'Method not found ' + this.def.name }; throw { message: 'Method not found ' + this.def.name };
} }
}; }
FuncInstance.prototype.render = function(metricExp) { render(metricExp) {
var str = this.def.name + '('; var str = this.def.name + '(';
var parameters = _.map(this.params, function(value, index) { var parameters = _.map(this.params, function(value, index) {
@@ -149,17 +146,17 @@ function (_, $) {
} }
return str + parameters.join(', ') + ')'; return str + parameters.join(', ') + ')';
}; }
FuncInstance.prototype._hasMultipleParamsInString = function(strValue, index) { _hasMultipleParamsInString(strValue, index) {
if (strValue.indexOf(',') === -1) { if (strValue.indexOf(',') === -1) {
return false; return false;
} }
return this.def.params[index + 1] && this.def.params[index + 1].optional; return this.def.params[index + 1] && this.def.params[index + 1].optional;
}; }
FuncInstance.prototype.updateParam = function(strValue, index) { updateParam(strValue, index) {
// handle optional parameters // handle optional parameters
// if string contains ',' and next param is optional, split and update both // if string contains ',' and next param is optional, split and update both
if (this._hasMultipleParamsInString(strValue, index)) { if (this._hasMultipleParamsInString(strValue, index)) {
@@ -177,9 +174,9 @@ function (_, $) {
} }
this.updateText(); this.updateText();
}; }
FuncInstance.prototype.updateText = function () { updateText() {
if (this.params.length === 0) { if (this.params.length === 0) {
this.text = this.def.name + '()'; this.text = this.def.name + '()';
return; return;
@@ -189,9 +186,10 @@ function (_, $) {
text += this.params.join(', '); text += this.params.join(', ');
text += ')'; text += ')';
this.text = text; this.text = text;
}; }
}
return { export default {
createFuncInstance: function(funcDef, params) { createFuncInstance: function(funcDef, params) {
if (_.isString(funcDef)) { if (_.isString(funcDef)) {
if (!index[funcDef]) { if (!index[funcDef]) {
@@ -210,5 +208,3 @@ function (_, $) {
return categories; return categories;
} }
}; };
});

View File

@@ -1,19 +1,19 @@
import {ZabbixAPIDatasource} from './datasource'; import {ZabbixAPIDatasource} from './datasource';
import {ZabbixQueryCtrl} from './queryCtrl'; import {ZabbixQueryController} from './query.controller';
class ZabbixConfigCtrl {} class ZabbixConfigController {}
ZabbixConfigCtrl.templateUrl = 'partials/config.html'; ZabbixConfigController.templateUrl = 'partials/config.html';
class ZabbixQueryOptionsCtrl {} class ZabbixQueryOptionsController {}
ZabbixQueryOptionsCtrl.templateUrl = 'partials/query.options.html'; ZabbixQueryOptionsController.templateUrl = 'partials/query.options.html';
class ZabbixAnnotationsQueryCtrl {} class ZabbixAnnotationsQueryController {}
ZabbixAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html'; ZabbixAnnotationsQueryController.templateUrl = 'partials/annotations.editor.html';
export { export {
ZabbixAPIDatasource as Datasource, ZabbixAPIDatasource as Datasource,
ZabbixQueryCtrl as QueryCtrl, ZabbixConfigController as ConfigCtrl,
ZabbixConfigCtrl as ConfigCtrl, ZabbixQueryController as QueryCtrl,
ZabbixQueryOptionsCtrl as QueryOptionsCtrl, ZabbixQueryOptionsController as QueryOptionsCtrl,
ZabbixAnnotationsQueryCtrl as AnnotationsQueryCtrl ZabbixAnnotationsQueryController as AnnotationsQueryCtrl
}; };

View File

@@ -1,17 +1,9 @@
/*define([
'app/plugins/sdk',
'angular',
'lodash',
'./metricFunctions',
'./utils'
],*/
import {QueryCtrl} from 'app/plugins/sdk'; import {QueryCtrl} from 'app/plugins/sdk';
import _ from 'lodash'; import _ from 'lodash';
import * as utils from './utils'; import * as utils from './utils';
import metricFunctions from './metricFunctions'; import metricFunctions from './metricFunctions';
export class ZabbixQueryCtrl extends QueryCtrl { export class ZabbixQueryController extends QueryCtrl {
// ZabbixQueryCtrl constructor // ZabbixQueryCtrl constructor
constructor($scope, $injector, $sce, $q, templateSrv) { constructor($scope, $injector, $sce, $q, templateSrv) {
@@ -229,7 +221,7 @@ export class ZabbixQueryCtrl extends QueryCtrl {
} }
// Set templateUrl as static property // 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 // Get list of metric names for bs-typeahead directive
function getMetricNames(scope, metricList) { function getMetricNames(scope, metricList) {

View File

@@ -416,6 +416,27 @@ function (angular, _, utils) {
return this.convertHistory(history, addHostName, convertPointCallback); 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) { function convertHistoryPoint(point) {
// Value must be a number for properly work // Value must be a number for properly work
return [ return [

View File

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