Revise the notification service
[portal/ric-dashboard.git] / webapp-frontend / src / app / services / ui / notification.service.ts
index 6477125..df4f03e 100644 (file)
  */
 
 import { Injectable } from '@angular/core';
-import { MatSnackBar, MatSnackBarConfig } from '@angular/material';
+import { ToastrService } from 'ngx-toastr';
 
 @Injectable({
   providedIn: 'root'
 })
 export class NotificationService {
 
-  constructor(public snackBar: MatSnackBar) { }
+  constructor(public toastr: ToastrService) { }
 
-  successConfig: MatSnackBarConfig = {
-    duration: 10000,
-    horizontalPosition: 'right',
-    verticalPosition: 'top'
+  successConfig = {
+    timeOut: 10000,
+    closeButton: true
   };
 
-  warningConfig: MatSnackBarConfig = {
-    horizontalPosition: 'right',
-    verticalPosition: 'top'
+  warningConfig = {
+    disableTimeOut: true,
+    closeButton: true
   };
 
-  errorConfig: MatSnackBarConfig = {
-    horizontalPosition: 'right',
-    verticalPosition: 'top'
+  errorConfig = {
+    disableTimeOut: true,
+    closeButton: true
   };
 
   success(msg: string) {
-    this.successConfig['panelClass'] = ['notification', 'success', 'default'];
-    this.snackBar.open(msg, '', this.successConfig);
+    this.toastr.success(msg, '', this.successConfig);
   }
 
   warn(msg: string) {
-    this.warningConfig['panelClass'] = ['notification', 'warn', 'default'];
-    this.snackBar.open(msg, 'Dismiss', this.warningConfig);
+    this.toastr.warning(msg, '', this.warningConfig);
   }
 
   error(msg: string) {
-    this.errorConfig['panelClass'] = ['notification', 'error', 'default'];
-    this.snackBar.open(msg, 'Dismiss', this.errorConfig);
+    this.toastr.error(msg, '', this.errorConfig);
   }
+
 }