Adjusted CSS and added default notification options in the environment config files

This commit is contained in:
Giuseppe Digilio
2018-05-07 15:49:03 +02:00
parent e0deb52ed7
commit bafa46bb24
9 changed files with 82 additions and 76 deletions

View File

@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { INotification, Notification } from './models/notification.model';
import { NotificationType } from './models/notification-type';
import { NotificationOptions } from './models/notification-options.model';
@@ -6,11 +6,13 @@ import { uniqueId } from 'lodash';
import { Store } from '@ngrx/store';
import { NewNotificationAction, RemoveAllNotificationsAction, RemoveNotificationAction } from './notifications.actions';
import { Observable } from 'rxjs/Observable';
import { GLOBAL_CONFIG, GlobalConfig } from '../../../config';
@Injectable()
export class NotificationsService {
constructor(private store: Store<Notification>) {
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
private store: Store<Notification>) {
}
private add(notification: Notification) {
@@ -21,7 +23,7 @@ export class NotificationsService {
success(title: any = Observable.of(''),
content: any = Observable.of(''),
options = new NotificationOptions(),
options: NotificationOptions = this.getDefaultOptions(),
html?: any): INotification {
const notification = new Notification(uniqueId(), NotificationType.Success, title, content, options, html);
this.add(notification);
@@ -30,7 +32,7 @@ export class NotificationsService {
error(title: any = Observable.of(''),
content: any = Observable.of(''),
options = new NotificationOptions(),
options: NotificationOptions = this.getDefaultOptions(),
html?: any): INotification {
const notification = new Notification(uniqueId(), NotificationType.Error, title, content, options, html);
this.add(notification);
@@ -39,7 +41,7 @@ export class NotificationsService {
info(title: any = Observable.of(''),
content: any = Observable.of(''),
options = new NotificationOptions(),
options: NotificationOptions = this.getDefaultOptions(),
html?: any): INotification {
const notification = new Notification(uniqueId(), NotificationType.Info, title, content, options, html);
this.add(notification);
@@ -48,7 +50,7 @@ export class NotificationsService {
warning(title: any = Observable.of(''),
content: any = Observable.of(''),
options = new NotificationOptions(),
options: NotificationOptions = this.getDefaultOptions(),
html?: any): INotification {
const notification = new Notification(uniqueId(), NotificationType.Warning, title, content, options, html);
this.add(notification);
@@ -65,4 +67,11 @@ export class NotificationsService {
this.store.dispatch(actionRemoveAll);
}
private getDefaultOptions(): NotificationOptions {
return new NotificationOptions(
this.config.notifications.timeOut,
this.config.notifications.clickToClose,
this.config.notifications.animate
);
}
}