Skip to content

Commit

Permalink
removing empty labels
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysied committed Dec 11, 2018
1 parent 813f854 commit a33a8cd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions perfdash/www/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ function verifySelectedLabels(selectedLabels, allLabels) {
return result;
}

function isEmptySet(obj) {
var count = 0;
for (k in obj) {
if (obj.hasOwnProperty(k)) {
count++;
}
}
if (count == 0) {
return true
}
if (count == 1) {
if (obj.hasOwnProperty("")) {
return true
}
}
return false
}

// Get the set of all labels (e.g. 'resources', 'verbs') in the data set
PerfDashApp.prototype.getLabels = function() {
Expand All @@ -180,6 +197,11 @@ PerfDashApp.prototype.getLabels = function() {
});
});

angular.forEach(set, function(labels, name) {
if (isEmptySet(labels)) {
delete set[name]
}
});
if (!verifySelectedLabels(this.selectedLabels, set)) {
this.selectedLabels = {}
}
Expand Down

0 comments on commit a33a8cd

Please sign in to comment.