1 |
b887ecc3
|
hlavja
|
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 |
cbb91c90
|
hlavja
|
/**
|
15 |
|
|
* Error message
|
16 |
|
|
* @param err error
|
17 |
|
|
*/
|
18 |
b887ecc3
|
hlavja
|
showError(err: any) {
|
19 |
|
|
this.messageService.add({key: 'mainToast', severity:'error', summary: 'Unsuccessful!', detail: err});
|
20 |
|
|
}
|
21 |
|
|
|
22 |
cbb91c90
|
hlavja
|
/**
|
23 |
|
|
* Show warning NoData message
|
24 |
|
|
*/
|
25 |
b887ecc3
|
hlavja
|
showWarningNoData() {
|
26 |
|
|
this.messageService.add({key: 'mainToast', severity:'warn', summary: 'No data!', detail: 'Can not display any data for given interval and aggregation!'});
|
27 |
|
|
}
|
28 |
|
|
|
29 |
cbb91c90
|
hlavja
|
/**
|
30 |
|
|
* Show success request message
|
31 |
|
|
*/
|
32 |
b887ecc3
|
hlavja
|
showSuccess() {
|
33 |
4b76cfa7
|
hlavja
|
this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: 'Successful request!'});
|
34 |
|
|
}
|
35 |
|
|
|
36 |
cbb91c90
|
hlavja
|
/**
|
37 |
|
|
* Show message as success
|
38 |
|
|
* @param message message string
|
39 |
|
|
*/
|
40 |
4b76cfa7
|
hlavja
|
showSuccessMessage(message: any) {
|
41 |
|
|
this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: message});
|
42 |
|
|
}
|
43 |
|
|
|
44 |
cbb91c90
|
hlavja
|
/**
|
45 |
|
|
* Show operation rejected
|
46 |
|
|
*/
|
47 |
4b76cfa7
|
hlavja
|
operationRejected() {
|
48 |
|
|
this.messageService.add({key: 'mainToast', severity:'warn', summary: 'Reject!', detail: 'Operation rejected!'});
|
49 |
b887ecc3
|
hlavja
|
}
|
50 |
|
|
}
|