Support more notification types

This commit is contained in:
Johannes Zellner
2016-01-18 13:39:27 +01:00
parent bebf480321
commit 2edd434474
2 changed files with 9 additions and 4 deletions

View File

@@ -112,15 +112,20 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
Client.notify('title', 'message', true, actionScope);
*/
Client.prototype.notify = function (title, message, delay, actionScope) {
var options = { title: title, message: message, delay: delay};
Client.prototype.notify = function (title, message, persitent, type, actionScope) {
var options = { title: title, message: message};
if (persitent) options.delay = 'never'; // any non Number means never timeout
if (actionScope) {
if (typeof actionScope.action !== 'string') throw('an actionScope has to have an action url');
options.scope = actionScope;
}
Notification.error(options);
if (type === 'error') Notification.error(options);
else if (type === 'success') Notification.success(options);
else if (type === 'info') Notification.info(options);
else throw('Invalid notification type "' + type + '"');
};
Client.prototype.setReady = function () {

View File

@@ -114,7 +114,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
if (result.provider === 'route53' && (!result.accessKeyId || !result.secretAccessKey)) {
var actionScope = $scope.$new(true);
actionScope.action = '/#/certs';
Client.notify('Missing AWS credentials', 'Please provide AWS credentials, click here to add them.', true, actionScope);
Client.notify('Missing AWS credentials', 'Please provide AWS credentials, click here to add them.', true, 'error', actionScope);
}
});
}