IT-services: refactor

This commit is contained in:
Alexander Zobnin
2017-07-24 19:08:28 +03:00
parent 70f34db385
commit 39000acbf6
6 changed files with 29 additions and 122 deletions

View File

@@ -37,7 +37,7 @@
<label class="gf-form-label query-keyword">Property</label>
<div class="gf-form-select-wrapper">
<select class="gf-form-input"
ng-change="ctrl.selectITService()"
ng-change="ctrl.onTargetBlur()"
ng-model="ctrl.target.slaProperty"
ng-options="slaProperty.name for slaProperty in ctrl.slaPropertyList track by slaProperty.name">
</select>

View File

@@ -1,5 +1,4 @@
import {QueryCtrl} from 'app/plugins/sdk';
import angular from 'angular';
import _ from 'lodash';
import * as c from './constants';
import * as utils from './utils';
@@ -66,14 +65,14 @@ export class ZabbixQueryController extends QueryCtrl {
// Load default values
var targetDefaults = {
mode: c.MODE_METRICS,
group: { filter: "" },
host: { filter: "" },
application: { filter: "" },
item: { filter: "" },
functions: [],
options: {
showDisabledItems: false
'mode': c.MODE_METRICS,
'group': { 'filter': "" },
'host': { 'filter': "" },
'application': { 'filter': "" },
'item': { 'filter': "" },
'functions': [],
'options': {
'showDisabledItems': false
}
};
_.defaults(target, targetDefaults);
@@ -86,14 +85,6 @@ export class ZabbixQueryController extends QueryCtrl {
if (target.mode === c.MODE_METRICS ||
target.mode === c.MODE_TEXT) {
this.downsampleFunctionList = [
{name: "avg", value: "avg"},
{name: "min", value: "min"},
{name: "max", value: "max"},
{name: "sum", value: "sum"},
{name: "count", value: "count"}
];
this.initFilters();
}
else if (target.mode === c.MODE_ITSERVICE) {
@@ -303,30 +294,6 @@ export class ZabbixQueryController extends QueryCtrl {
this.target.mode = mode;
this.init();
}
/////////////////
// IT Services //
/////////////////
/**
* Update list of IT services
*/
updateITServiceList() {
this.zabbix.getITService().then((iteservices) => {
this.itserviceList = [];
this.itserviceList = this.itserviceList.concat(iteservices);
});
}
/**
* Call when IT service is selected.
*/
selectITService() {
if (!_.isEqual(this.oldTarget, this.target) && _.isEmpty(this.target.errors)) {
this.oldTarget = angular.copy(this.target);
this.panelCtrl.refresh();
}
}
}
// Set templateUrl as static property