Merge pull request #285 from xiaohuiz/not-show-host-name-when-only-1-host-selected

not show host name when only 1 host selected fix #261
This commit is contained in:
Alexander Zobnin
2016-10-06 14:09:35 +03:00
committed by GitHub

View File

@@ -230,12 +230,12 @@ angular.module('grafana.services').factory('QueryProcessor', function($q) {
// Group history by itemid // Group history by itemid
var grouped_history = _.groupBy(history, 'itemid'); var grouped_history = _.groupBy(history, 'itemid');
var hosts = _.flatten(_.map(items, 'hosts')); var hosts = _.uniq(_.flatten(_.map(items, 'hosts')),'hostid'); //uniq is needed to deduplicate
return _.map(grouped_history, function(hist, itemid) { return _.map(grouped_history, function(hist, itemid) {
var item = _.find(items, {'itemid': itemid}); var item = _.find(items, {'itemid': itemid});
var alias = item.name; var alias = item.name;
if (_.keys(hosts).length > 1 || addHostName) { if (_.keys(hosts).length > 1 && addHostName) { //only when actual multi hosts selected
var host = _.find(hosts, {'hostid': item.hostid}); var host = _.find(hosts, {'hostid': item.hostid});
alias = host.name + ": " + alias; alias = host.name + ": " + alias;
} }