Impoved query for text items - get only last value.

This commit is contained in:
Alexander Zobnin
2016-02-01 16:22:11 +03:00
parent 2b91f417f4
commit efc51fdcf6
2 changed files with 43 additions and 21 deletions

View File

@@ -132,7 +132,13 @@ function (angular, _) {
p.getItems = function() {
var params = {
output: ['name', 'key_', 'value_type', 'hostid', 'status', 'state'],
output: [
'name', 'key_',
'value_type',
'hostid',
'status',
'state'
],
sortfield: 'name',
selectApplications: []
};
@@ -140,6 +146,20 @@ function (angular, _) {
return this.request('item.get', params);
};
p.getLastValue = function(itemid) {
var params = {
output: ['lastvalue'],
itemids: itemid
};
return this.request('item.get', params).then(function(items) {
if (items.length) {
return items[0].lastvalue;
} else {
return null;
}
});
};
/**
* Perform history query from Zabbix API
*