Commit cd919a3e by Rashid Khan

Merge pull request #447 from rashidkpc/singleAlerts

Duplicate alerts should not stack up
parents 2e9bdedc a8abaaf5
...@@ -11,11 +11,21 @@ angular.module('kibana.services', []) ...@@ -11,11 +11,21 @@ angular.module('kibana.services', [])
this.list = []; this.list = [];
this.set = function(title,text,severity,timeout) { this.set = function(title,text,severity,timeout) {
var _a = { var
_a = {
title: title || '', title: title || '',
text: text || '', text: text || '',
severity: severity || 'info', severity: severity || 'info',
}; },
_ca = angular.toJson(_a),
_clist = _.map(self.list,function(alert){return angular.toJson(alert);});
// If we already have this alert, remove it and add a new one
// Why do this instead of skipping the add because it resets the timer
if(_.contains(_clist,_ca)) {
_.remove(self.list,_.indexOf(_clist,_ca));
}
self.list.push(_a); self.list.push(_a);
if (timeout > 0) { if (timeout > 0) {
$timeout(function() { $timeout(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment