duplicates

This commit is contained in:
Andrea Chiapparelli - 4Science
2018-03-06 18:32:48 +01:00
parent 74dc5f8067
commit afc915b943
8 changed files with 92 additions and 121 deletions

View File

@@ -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);
}