You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/services/notifications.js

39 lines
1.1 KiB

angular.module('portainer.services')
.factory('Notifications', ['$sanitize', function NotificationsFactory($sanitize) {
'use strict';
var service = {};
service.success = function(title, text) {
toastr.success($sanitize(text), $sanitize(title));
};
service.warning = function(title, text) {
toastr.warning($sanitize(text), $sanitize(title), {timeOut: 6000});
};
service.error = function(title, e, fallbackText) {
var msg = fallbackText;
if (e.data && e.data.message) {
msg = e.data.message;
} else if (e.message) {
msg = e.message;
} else if (e.err && e.err.data && e.err.data.message) {
msg = e.err.data.message;
} else if (e.data && e.data.length > 0 && e.data[0].message) {
msg = e.data[0].message;
} else if (e.err && e.err.data && e.err.data.err) {
msg = e.err.data.err;
} else if (e.data && e.data.err) {
msg = e.data.err;
} else if (e.msg) {
msg = e.msg;
}
if (msg !== 'Invalid JWT token') {
toastr.error($sanitize(msg), $sanitize(title), {timeOut: 6000});
}
};
return service;
}]);