Refactoring - reformat code.

This commit is contained in:
Alexander Zobnin
2015-07-25 18:48:08 +03:00
parent f53ebaa9fc
commit 9855c05f64

View File

@@ -2,16 +2,16 @@ define([
'angular',
'lodash',
'./helperFunctions'
],
function (angular, _) {
],
function (angular, _) {
'use strict';
var module = angular.module('grafana.controllers');
var targetLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
module.controller('ZabbixAPIQueryCtrl', function($scope, $sce, templateSrv, zabbixHelperSrv) {
module.controller('ZabbixAPIQueryCtrl', function ($scope, $sce, templateSrv, zabbixHelperSrv) {
$scope.init = function() {
$scope.init = function () {
$scope.targetLetters = targetLetters;
if ($scope.target.ITService) {
$scope.slaPropertyList = [
@@ -42,7 +42,7 @@ function (angular, _) {
$scope.target.errors = validateTarget($scope.target);
};
$scope.switchEditorMode = function() {
$scope.switchEditorMode = function () {
$scope.target.ITService = !$scope.target.ITService;
$scope.init();
};
@@ -56,7 +56,7 @@ function (angular, _) {
}
}
$scope.targetBlur = function() {
$scope.targetBlur = function () {
setItemAlias();
$scope.target.errors = validateTarget($scope.target);
if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) {
@@ -68,7 +68,7 @@ function (angular, _) {
/**
* Call when IT service is selected.
*/
$scope.selectITService = function() {
$scope.selectITService = function () {
$scope.target.errors = validateTarget($scope.target);
if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) {
$scope.oldTarget = angular.copy($scope.target);
@@ -79,7 +79,7 @@ function (angular, _) {
/**
* Call when host group selected
*/
$scope.selectHostGroup = function() {
$scope.selectHostGroup = function () {
$scope.updateHostList();
$scope.updateAppList();
$scope.updateItemList();
@@ -94,7 +94,7 @@ function (angular, _) {
/**
* Call when host selected
*/
$scope.selectHost = function() {
$scope.selectHost = function () {
$scope.updateAppList();
$scope.updateItemList();
@@ -108,7 +108,7 @@ function (angular, _) {
/**
* Call when application selected
*/
$scope.selectApplication = function() {
$scope.selectApplication = function () {
$scope.updateItemList();
$scope.target.errors = validateTarget($scope.target);
@@ -121,7 +121,7 @@ function (angular, _) {
/**
* Call when item selected
*/
$scope.selectItem = function() {
$scope.selectItem = function () {
setItemAlias();
$scope.target.errors = validateTarget($scope.target);
if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) {
@@ -130,12 +130,12 @@ function (angular, _) {
}
};
$scope.duplicate = function() {
$scope.duplicate = function () {
var clone = angular.copy($scope.target);
$scope.panel.targets.push(clone);
};
$scope.moveMetricQuery = function(fromIndex, toIndex) {
$scope.moveMetricQuery = function (fromIndex, toIndex) {
_.move($scope.panel.targets, fromIndex, toIndex);
};
@@ -143,11 +143,10 @@ function (angular, _) {
// SUGGESTION QUERIES
//////////////////////////////
/**
* Update list of IT services
*/
$scope.updateITServiceList = function() {
$scope.updateITServiceList = function () {
$scope.datasource.zabbixAPI.getITService().then(function (iteservices) {
$scope.itserviceList = [];
$scope.itserviceList = $scope.itserviceList.concat(iteservices);
@@ -157,7 +156,7 @@ function (angular, _) {
/**
* Update list of host groups
*/
$scope.updateGroupList = function() {
$scope.updateGroupList = function () {
$scope.datasource.zabbixAPI.performHostGroupSuggestQuery().then(function (groups) {
$scope.metric.groupList = [{name: '*', visible_name: 'All'}];
addTemplatedVariables($scope.metric.groupList);
@@ -168,7 +167,7 @@ function (angular, _) {
/**
* Update list of hosts
*/
$scope.updateHostList = function() {
$scope.updateHostList = function () {
var groups = $scope.target.group ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
if (groups) {
$scope.datasource.zabbixAPI.hostFindQuery(groups).then(function (hosts) {
@@ -182,7 +181,7 @@ function (angular, _) {
/**
* Update list of host applications
*/
$scope.updateAppList = function() {
$scope.updateAppList = function () {
var groups = $scope.target.group ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
var hosts = $scope.target.host ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.host.name)) : undefined;
if (groups && hosts) {
@@ -200,7 +199,7 @@ function (angular, _) {
/**
* Update list of items
*/
$scope.updateItemList = function() {
$scope.updateItemList = function () {
var groups = $scope.target.group ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
var hosts = $scope.target.host ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.host.name)) : undefined;
var apps = $scope.target.application ? zabbixHelperSrv.splitMetrics(templateSrv.replace($scope.target.application.name)) : undefined;
@@ -225,7 +224,7 @@ function (angular, _) {
* @param {Array} metricList List of metrics which variables add to
*/
function addTemplatedVariables(metricList) {
_.each(templateSrv.variables, function(variable) {
_.each(templateSrv.variables, function (variable) {
metricList.push({
name: '$' + variable.name,
templated: true
@@ -247,4 +246,4 @@ function (angular, _) {
});
});
});