2013-02-22 19:28:10 +01:00
|
|
|
angular.module('webui.ctrls.alert', [
|
|
|
|
'webui.services.alerts'
|
|
|
|
])
|
|
|
|
.controller('AlertCtrl', ['$scope', '$alerts', function(scope, alerts) {
|
|
|
|
scope.pendingAlerts = [];
|
|
|
|
|
|
|
|
scope.removeAlert = function(ind) {
|
|
|
|
this.pendingAlerts.splice(ind, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
alerts.addAlerter(function(msg, type) {
|
|
|
|
type = type || 'warning';
|
2013-02-22 20:44:10 +01:00
|
|
|
var obj = { msg: msg, type: type };
|
|
|
|
scope.pendingAlerts.push(obj);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
var ind = scope.pendingAlerts.indexOf(obj);
|
|
|
|
if (ind != -1) scope.removeAlert(ind);
|
2013-03-11 17:01:58 +01:00
|
|
|
}, 10000);
|
2013-02-22 20:44:10 +01:00
|
|
|
|
2013-02-22 19:28:10 +01:00
|
|
|
scope.$digest();
|
|
|
|
});
|
|
|
|
}]);
|