{ "version": 3, "sources": ["src/app/core/service/alert.service.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\nimport { Router, NavigationStart } from '@angular/router';\r\nimport { Observable } from 'rxjs';\r\nimport { Subject } from 'rxjs';\r\n\r\nimport { Alert, AlertType, DialogType } from '../../main/model/alert.model';\r\n\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AlertService {\r\n private subject = new Subject();\r\n\r\n constructor(router: Router) {\r\n // clear alert messages on route change\r\n router.events.subscribe(event => {\r\n if (event instanceof NavigationStart) {\r\n this.clear();\r\n }\r\n });\r\n }\r\n\r\n getAlert(): Observable {\r\n return this.subject.asObservable();\r\n }\r\n\r\n success(message: string, ...args: [dialogType?: DialogType] | [keepAfterRouteChange?: boolean] | [dialogType?: DialogType, keepAfterRouteChange?: boolean]) {\r\n this.alert(AlertType.Success, message, ...args);\r\n }\r\n\r\n error(message: string, ...args: [dialogType?: DialogType] | [keepAfterRouteChange?: boolean] | [dialogType?: DialogType, keepAfterRouteChange?: boolean]) {\r\n this.alert(AlertType.Error, message, ...args);\r\n }\r\n\r\n info(message: string, ...args: [dialogType?: DialogType] | [keepAfterRouteChange?: boolean] | [dialogType?: DialogType, keepAfterRouteChange?: boolean]) {\r\n this.alert(AlertType.Info, message, ...args);\r\n }\r\n\r\n warning(message: string, ...args: [dialogType?: DialogType] | [keepAfterRouteChange?: boolean] | [dialogType?: DialogType, keepAfterRouteChange?: boolean]) {\r\n this.alert(AlertType.Warning, message, ...args);\r\n }\r\n\r\n alert(type: AlertType, message: string, ...args: [dialogType?: DialogType] | [keepAfterRouteChange?: boolean] | [dialogType?: DialogType, keepAfterRouteChange?: boolean]) {\r\n const dialogType = args?.length > 0 && typeof args[0] !== 'boolean' ? args[0] : DialogType.Banner;\r\n let keepAfterRouteChange = args?.length > 0 && typeof args[0] === 'boolean' ? args[0] : false;\r\n keepAfterRouteChange = args?.length > 1 && typeof args[1] !== 'boolean' ? args[1] : keepAfterRouteChange;\r\n\r\n this.subject.next({ type: type, message: message, dialogType: dialogType, keepAfterRouteChange: keepAfterRouteChange });\r\n }\r\n\r\n clear() {\r\n // clear alerts\r\n this.subject.next(undefined);\r\n }\r\n}\r\n"], "mappings": "+IAWA,IAAaA,GAAY,IAAA,CAAnB,IAAOA,EAAP,MAAOA,CAAY,CAGrBC,YAAYC,EAAc,CAFlB,KAAAC,QAAU,IAAIC,EAIlBF,EAAOG,OAAOC,UAAUC,GAAQ,CACxBA,aAAiBC,GACjB,KAAKC,MAAK,CAElB,CAAC,CACL,CAEAC,UAAQ,CACJ,OAAO,KAAKP,QAAQQ,aAAY,CACpC,CAEAC,QAAQC,KAAoBC,EAA8H,CACtJ,KAAKC,MAAMC,EAAUC,QAASJ,EAAS,GAAGC,CAAI,CAClD,CAEAI,MAAML,KAAoBC,EAA8H,CACpJ,KAAKC,MAAMC,EAAUG,MAAON,EAAS,GAAGC,CAAI,CAChD,CAEAM,KAAKP,KAAoBC,EAA8H,CACnJ,KAAKC,MAAMC,EAAUK,KAAMR,EAAS,GAAGC,CAAI,CAC/C,CAEAQ,QAAQT,KAAoBC,EAA8H,CACtJ,KAAKC,MAAMC,EAAUO,QAASV,EAAS,GAAGC,CAAI,CAClD,CAEAC,MAAMS,EAAiBX,KAAoBC,EAA8H,CACrK,IAAMW,GAAaX,GAAAA,YAAAA,EAAMY,QAAS,GAAK,OAAOZ,EAAK,CAAC,GAAM,UAAYA,EAAK,CAAC,EAAIa,EAAWC,OACvFC,GAAuBf,GAAAA,YAAAA,EAAMY,QAAS,GAAK,OAAOZ,EAAK,CAAC,GAAM,UAAYA,EAAK,CAAC,EAAI,GACxFe,GAAuBf,GAAAA,YAAAA,EAAMY,QAAS,GAAK,OAAOZ,EAAK,CAAC,GAAM,UAAYA,EAAK,CAAC,EAAIe,EAEpF,KAAK1B,QAAQ2B,KAAY,CAAEN,KAAMA,EAAMX,QAASA,EAASY,WAAYA,EAAYI,qBAAsBA,CAAoB,CAAE,CACjI,CAEApB,OAAK,CAED,KAAKN,QAAQ2B,KAAKC,MAAS,CAC/B,yCA3CS/B,GAAYgC,EAAAC,CAAA,CAAA,CAAA,wBAAZjC,EAAYkC,QAAZlC,EAAYmC,UAAAC,WAFT,MAAM,CAAA,EAEhB,IAAOpC,EAAPqC,SAAOrC,CAAY,GAAA", "names": ["AlertService", "constructor", "router", "subject", "Subject", "events", "subscribe", "event", "NavigationStart", "clear", "getAlert", "asObservable", "success", "message", "args", "alert", "AlertType", "Success", "error", "Error", "info", "Info", "warning", "Warning", "type", "dialogType", "length", "DialogType", "Banner", "keepAfterRouteChange", "next", "undefined", "\u0275\u0275inject", "Router", "factory", "\u0275fac", "providedIn", "_AlertService"] }