Projekt

Obecné

Profil

Stáhnout (1.22 KB) Statistiky
| Větev: | Tag: | Revize:
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
  /**
15
   * Error message
16
   * @param err error
17
   */
18
  showError(err: any) {
19
    this.messageService.add({key: 'mainToast', severity:'error', summary: 'Unsuccessful!', detail: err});
20
  }
21

    
22
  /**
23
   * Show warning NoData message
24
   */
25
  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
  /**
30
   * Show success request message
31
   */
32
  showSuccess() {
33
    this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: 'Successful request!'});
34
  }
35

    
36
  /**
37
   * Show message as success
38
   * @param message message string
39
   */
40
  showSuccessMessage(message: any) {
41
    this.messageService.add({key: 'mainToast', severity:'success', summary: 'Success!', detail: message});
42
  }
43

    
44
  /**
45
   * Show operation rejected
46
   */
47
  operationRejected() {
48
    this.messageService.add({key: 'mainToast', severity:'warn', summary: 'Reject!', detail: 'Operation rejected!'});
49
  }
50
}
(2-2/2)