IT-services: refactor
This commit is contained in:
@@ -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>
|
||||
|
||||
42
dist/datasource-zabbix/query.controller.js
vendored
42
dist/datasource-zabbix/query.controller.js
vendored
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['app/plugins/sdk', 'angular', 'lodash', './constants', './utils', './metricFunctions', './migrations', './add-metric-function.directive', './metric-function-editor.directive', './css/query-editor.css!'], function (_export, _context) {
|
||||
System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metricFunctions', './migrations', './add-metric-function.directive', './metric-function-editor.directive', './css/query-editor.css!'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var QueryCtrl, angular, _, c, utils, metricFunctions, migrations, _createClass, ZabbixQueryController;
|
||||
var QueryCtrl, _, c, utils, metricFunctions, migrations, _createClass, ZabbixQueryController;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
@@ -38,8 +38,6 @@ System.register(['app/plugins/sdk', 'angular', 'lodash', './constants', './utils
|
||||
return {
|
||||
setters: [function (_appPluginsSdk) {
|
||||
QueryCtrl = _appPluginsSdk.QueryCtrl;
|
||||
}, function (_angular) {
|
||||
angular = _angular.default;
|
||||
}, function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_constants) {
|
||||
@@ -125,14 +123,14 @@ System.register(['app/plugins/sdk', 'angular', 'lodash', './constants', './utils
|
||||
|
||||
// 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);
|
||||
@@ -144,8 +142,6 @@ System.register(['app/plugins/sdk', 'angular', 'lodash', './constants', './utils
|
||||
|
||||
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) {
|
||||
_.defaults(target, { slaProperty: { name: "SLA", property: "sla" } });
|
||||
@@ -369,24 +365,6 @@ System.register(['app/plugins/sdk', 'angular', 'lodash', './constants', './utils
|
||||
this.target.mode = mode;
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: 'updateITServiceList',
|
||||
value: function updateITServiceList() {
|
||||
var _this8 = this;
|
||||
|
||||
this.zabbix.getITService().then(function (iteservices) {
|
||||
_this8.itserviceList = [];
|
||||
_this8.itserviceList = _this8.itserviceList.concat(iteservices);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'selectITService',
|
||||
value: function selectITService() {
|
||||
if (!_.isEqual(this.oldTarget, this.target) && _.isEmpty(this.target.errors)) {
|
||||
this.oldTarget = angular.copy(this.target);
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixQueryController;
|
||||
|
||||
File diff suppressed because one or more lines are too long
54
dist/test/datasource-zabbix/query.controller.js
vendored
54
dist/test/datasource-zabbix/query.controller.js
vendored
@@ -9,10 +9,6 @@ var _createClass = function () { function defineProperties(target, props) { for
|
||||
|
||||
var _sdk = require('app/plugins/sdk');
|
||||
|
||||
var _angular = require('angular');
|
||||
|
||||
var _angular2 = _interopRequireDefault(_angular);
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
@@ -104,14 +100,14 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_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
|
||||
}
|
||||
};
|
||||
_lodash2.default.defaults(target, targetDefaults);
|
||||
@@ -123,8 +119,6 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_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) {
|
||||
_lodash2.default.defaults(target, { slaProperty: { name: "SLA", property: "sla" } });
|
||||
@@ -365,38 +359,6 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
this.target.mode = mode;
|
||||
this.init();
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// IT Services //
|
||||
/////////////////
|
||||
|
||||
/**
|
||||
* Update list of IT services
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: 'updateITServiceList',
|
||||
value: function updateITServiceList() {
|
||||
var _this8 = this;
|
||||
|
||||
this.zabbix.getITService().then(function (iteservices) {
|
||||
_this8.itserviceList = [];
|
||||
_this8.itserviceList = _this8.itserviceList.concat(iteservices);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when IT service is selected.
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: 'selectITService',
|
||||
value: function selectITService() {
|
||||
if (!_lodash2.default.isEqual(this.oldTarget, this.target) && _lodash2.default.isEmpty(this.target.errors)) {
|
||||
this.oldTarget = _angular2.default.copy(this.target);
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixQueryController;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user