1 import { MessageService } from 'primeng/api'
2 import { Injectable } from '@angular/core'
3 import { logger } from '@root-helpers/logger'
6 export class Notifier {
7 readonly TIMEOUT = 5000
9 constructor (private messageService: MessageService) { }
11 info (text: string, title?: string, timeout?: number, sticky?: boolean) {
12 if (!title) title = $localize`Info`
14 logger.info(`${title}: ${text}`)
15 return this.notify('info', text, title, timeout, sticky)
18 error (text: string, title?: string, timeout?: number, sticky?: boolean) {
19 if (!title) title = $localize`Error`
21 logger.error(`${title}: ${text}`)
22 return this.notify('error', text, title, timeout, sticky)
25 success (text: string, title?: string, timeout?: number, sticky?: boolean) {
26 if (!title) title = $localize`Success`
28 logger.info(`${title}: ${text}`)
29 return this.notify('success', text, title, timeout, sticky)
32 private notify (severity: 'success' | 'info' | 'warn' | 'error', text: string, title: string, timeout?: number, sticky?: boolean) {
33 this.messageService.add({
38 life: timeout || this.TIMEOUT,