mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 21:13:07 +00:00
duplicates
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { INotification, Notification } from './models/notification.model';
|
||||
// import {Icons, defaultIcons} from './interfaces/icons';
|
||||
import { NotificationType } from './models/notification-type';
|
||||
import { NotificationOptions } from './models/notification-options.model';
|
||||
import { uniqueId } from 'lodash';
|
||||
@@ -16,13 +15,8 @@ import { DomSanitizer } from '@angular/platform-browser';
|
||||
@Injectable()
|
||||
export class NotificationsService {
|
||||
|
||||
public static htmlArray = new Map<string, any>();
|
||||
|
||||
// public emitter = new Subject<NotificationEvent>();
|
||||
// public icons: Icons = defaultIcons;
|
||||
constructor(private store: Store<Notification>,
|
||||
private domSanitizer: DomSanitizer,) {
|
||||
|
||||
}
|
||||
|
||||
private add(notification: Notification) {
|
||||
@@ -35,47 +29,37 @@ export class NotificationsService {
|
||||
this.store.dispatch(notificationAction);
|
||||
}
|
||||
|
||||
success(title: any = '', content: any = '', options = new NotificationOptions()): Notification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Success, title, content, options);
|
||||
success(title: any = '', content: any = '', options = new NotificationOptions(), html?: any): INotification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Success, title, content, options, html);
|
||||
this.add(notification);
|
||||
return notification;
|
||||
}
|
||||
|
||||
error(title: any = '', content: any = '', options = new NotificationOptions()): Notification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Error, title, content, options);
|
||||
error(title: any = '', content: any = '', options = new NotificationOptions(), html?: any): INotification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Error, title, content, options, html);
|
||||
this.add(notification);
|
||||
return notification;
|
||||
}
|
||||
|
||||
info(title: any = '', content: any = '', options = new NotificationOptions()): Notification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Info, title, content, options);
|
||||
info(title: any = '', content: any = '', options = new NotificationOptions(), html?: any): INotification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Info, title, content, options, html);
|
||||
this.add(notification);
|
||||
return notification;
|
||||
}
|
||||
|
||||
warning(title: any = '', content: any = '', options = new NotificationOptions()): Notification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Warning, title, content, options);
|
||||
this.add(notification);
|
||||
return notification;
|
||||
}
|
||||
|
||||
html(html: any, type = NotificationType.Success, options = new NotificationOptions()): Notification {
|
||||
const notification = new Notification(uniqueId(), type, '', '', options);
|
||||
NotificationsService.htmlArray.set(notification.id, html);
|
||||
// notification.html = true;
|
||||
warning(title: any = '', content: any = '', options = new NotificationOptions(), html?: any): INotification {
|
||||
const notification = new Notification(uniqueId(), NotificationType.Warning, title, content, options, html);
|
||||
this.add(notification);
|
||||
return notification;
|
||||
}
|
||||
|
||||
remove(notification: INotification) {
|
||||
const actionRemove = new RemoveNotificationAction(notification.id);
|
||||
NotificationsService.htmlArray.delete(notification.id);
|
||||
this.store.dispatch(actionRemove);
|
||||
}
|
||||
|
||||
removeAll() {
|
||||
const actionRemoveAll = new RemoveAllNotificationsAction();
|
||||
NotificationsService.htmlArray.clear();
|
||||
this.store.dispatch(actionRemoveAll);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user