1
|
import {Injectable} from '@angular/core';
|
2
|
import {MessageService} from 'primeng/api';
|
3
|
|
4
|
@Injectable({
|
5
|
providedIn: 'root'
|
6
|
})
|
7
|
export class ToastService {
|
8
|
|
9
|
constructor(
|
10
|
private messageService: MessageService
|
11
|
) {
|
12
|
}
|
13
|
|
14
|
showError(err: any) {
|
15
|
this.messageService.add({key: 'mainToast', severity:'error', summary: 'Unsuccessful!', detail: err});
|
16
|
}
|
17
|
|
18
|
showWarningNoData() {
|
19
|
this.messageService.add({key: 'mainToast', severity:'warn', summary: 'No data!', detail: 'Can not display any data for given interval and aggregation!'});
|
20
|
}
|
21
|
|
22
|
showSuccess() {
|
23
|
this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: 'Successful request!'});
|
24
|
}
|
25
|
|
26
|
showSuccessMessage(message: any) {
|
27
|
this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: message});
|
28
|
}
|
29
|
|
30
|
operationRejected() {
|
31
|
this.messageService.add({key: 'mainToast', severity:'warn', summary: 'Reject!', detail: 'Operation rejected!'});
|
32
|
}
|
33
|
}
|