2022-07-22 20:42:58 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
|
|
import { NotifierComponent } from './notifier/notifier.component';
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class NotifierService {
|
|
|
|
|
|
|
|
constructor(private snackBar:MatSnackBar) { }
|
|
|
|
|
2022-09-06 21:03:38 +00:00
|
|
|
showNotification(displayMessage:string, buttonText: string, messageType: 'error' | 'success' | 'warning') {
|
2022-07-22 20:42:58 +00:00
|
|
|
this.snackBar.openFromComponent(NotifierComponent, {
|
|
|
|
data: {
|
|
|
|
message: displayMessage,
|
|
|
|
buttonText: buttonText,
|
|
|
|
type : messageType
|
|
|
|
},
|
|
|
|
duration: 4000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
panelClass: [messageType]
|
2022-09-06 21:03:38 +00:00
|
|
|
});
|
|
|
|
this.playSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
playSound() {
|
2022-09-07 22:04:07 +00:00
|
|
|
// console.log('Play sound called...');
|
2022-09-06 21:03:38 +00:00
|
|
|
let audio = new Audio();
|
|
|
|
audio.src = '../assets/notifier.mp3';
|
|
|
|
audio.load();
|
|
|
|
audio.play();
|
2022-07-22 20:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|