1 import { MessageService } from 'primeng/api'
2 import { Injectable } from '@angular/core'
5 export class Notifier {
6 readonly TIMEOUT = 5000
8 constructor (private messageService: MessageService) { }
10 info (text: string, title?: string, timeout?: number) {
11 if (!title) title = $localize`Info`
13 return this.notify('info', text, title, timeout)
16 error (text: string, title?: string, timeout?: number) {
17 if (!title) title = $localize`Error`
19 return this.notify('error', text, title, timeout)
22 success (text: string, title?: string, timeout?: number) {
23 if (!title) title = $localize`Success`
25 return this.notify('success', text, title, timeout)
28 private notify (severity: 'success' | 'info' | 'warn' | 'error', text: string, title: string, timeout?: number) {
29 this.messageService.add({
34 life: timeout || this.TIMEOUT