Return only numeric or text items depend of editor mode.
This commit is contained in:
@@ -93,10 +93,11 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
|
||||
initFilters() {
|
||||
var self = this;
|
||||
var itemtype = self.editorModes[self.target.mode];
|
||||
return this.$q.when(this.suggestGroups())
|
||||
.then(() => {return self.suggestHosts();})
|
||||
.then(() => {return self.suggestApps();})
|
||||
.then(() => {return self.suggestItems();});
|
||||
.then(() => {return self.suggestItems(itemtype);});
|
||||
}
|
||||
|
||||
suggestGroups() {
|
||||
@@ -138,7 +139,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
suggestItems() {
|
||||
suggestItems(itemtype='num') {
|
||||
var self = this;
|
||||
var appFilter = this.templateSrv.replace(this.target.application.filter);
|
||||
if (appFilter) {
|
||||
@@ -148,7 +149,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
.then(apps => {
|
||||
var appids = _.map(apps, 'applicationid');
|
||||
return self.zabbix
|
||||
.getItems(undefined, appids)
|
||||
.getItems(undefined, appids, itemtype)
|
||||
.then(items => {
|
||||
if (!self.target.showDisabledItems) {
|
||||
items = _.filter(items, {'status': '0'});
|
||||
@@ -161,7 +162,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
// Return all items belonged to selected hosts
|
||||
var hostids = _.map(self.metric.hostList, 'hostid');
|
||||
return self.zabbix
|
||||
.getItems(hostids)
|
||||
.getItems(hostids, undefined, itemtype)
|
||||
.then(items => {
|
||||
if (!self.target.showDisabledItems) {
|
||||
items = _.filter(items, {'status': '0'});
|
||||
|
||||
@@ -145,7 +145,14 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
|
||||
return this.request('application.get', params);
|
||||
}
|
||||
|
||||
getItems(hostids, appids) {
|
||||
/**
|
||||
* Get Zabbix items
|
||||
* @param {[type]} hostids host ids
|
||||
* @param {[type]} appids application ids
|
||||
* @param {String} itemtype 'num' or 'text'
|
||||
* @return {[type]} array of items
|
||||
*/
|
||||
getItems(hostids, appids, itemtype='num') {
|
||||
var params = {
|
||||
output: [
|
||||
'name', 'key_',
|
||||
@@ -156,6 +163,10 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
|
||||
],
|
||||
sortfield: 'name',
|
||||
webitems: true,
|
||||
filter: {
|
||||
// Return only numeric items by default
|
||||
value_type: [0, 3]
|
||||
},
|
||||
selectHosts: [
|
||||
'hostid',
|
||||
'name'
|
||||
@@ -167,6 +178,10 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
|
||||
if (appids) {
|
||||
params.applicationids = appids;
|
||||
}
|
||||
if (itemtype === 'text') {
|
||||
// Return only text metrics
|
||||
params.filter.value_type = [1, 2, 4];
|
||||
}
|
||||
|
||||
return this.request('item.get', params)
|
||||
.then(items => {
|
||||
|
||||
Reference in New Issue
Block a user