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, sticky?: boolean) {
11 if (!title) title = $localize`Info`
13 console.info(`${title}: ${text}`)
14 return this.notify('info', text, title, timeout, sticky)
17 error (text: string, title?: string, timeout?: number, sticky?: boolean) {
18 if (!title) title = $localize`Error`
20 console.error(`${title}: ${text}`)
21 return this.notify('error', text, title, timeout, sticky)
24 success (text: string, title?: string, timeout?: number, sticky?: boolean) {
25 if (!title) title = $localize`Success`
27 console.log(`${title}: ${text}`)
28 return this.notify('success', text, title, timeout, sticky)
31 private notify (severity: 'success' | 'info' | 'warn' | 'error', text: string, title: string, timeout?: number, sticky?: boolean) {
32 this.messageService.add({
37 life: timeout || this.TIMEOUT,