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