|
-
- export class Notification {
-
- static setNotifications(notifications) {
- var currentNotifications = new Array();
- for (var type in notifications) {
- for (var key in notifications[type]) {
- if (!currentNotifications.includes(notifications[type][key])) {
- currentNotifications.push(notifications[type][key]);
- self.addNotification(type, notifications[type][key]);
- }
- }
- }
- }
-
- static addNotification(type, text) {
-
- toastr.options.timeOut = 3000;
- toastr.options.onHidden = function () {
- if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove();
- };
-
- toastr[type](text);
-
- if ($('#toast-close-all').length == 0) {
- $('#toast-container').prepend('<button id="toast-close-all"><i class="fa fa-times"></i></button>');
- }
- $('#toast-close-all').off('click');
- $('#toast-close-all').on('click', function () {
- toastr.remove();
- if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove();
- });
- }
-
- }
|