{"version":3,"sources":["hicomNotify.ts"],"names":["HicomNotify","_readUrl","hicomPage","BaseUrl","_clearUrl","_stackTop","_stackBottomRight","constructor","this","init","window","addEventListener","PNotify","Stack","dir1","dir2","firstpos1","firstpos2","innerWidth","Number","defaults","width","replace","modal","maxOpen","showNotification","title","text","notificationType","stack","autohide","delay","textTrusted","let","options","hide","NotificationType","Alert","alert","Notice","notice","Info","info","Success","success","Error","error","console","clearNotification","notificationAuditId","fetchPostJson","NotificationAuditId","catch","showNotificationWithRead","elements","document","getElementsByClassName","Title","then","length","res","Data","id","showPersistentNotification","showSaveSuccessNotification","showSaveFailureNotification","showPublishSuccessNotification","showPublishFailureNotification","showUnpublishSuccessNotification","showUnpublishFailureNotification","showArchiveSuccessNotification","showArchiveFailureNotification","showUnarchiveSuccessNotification","showUnarchiveFailureNotification","showDeleteSuccessNotification","showDeleteFailureNotification","sendDesktopNotification","message","Notification","permission","body","requestPermission"],"mappings":";MAAMA,YAGFC,SAAsBC,UAAUC,QAAb,4BAEnBC,UAAuBF,UAAUC,QAAb,6BACpBE,UAAiB,GACjBC,kBAAyB,GAEzBC,cACIC,KAAKC,KAAI,CACb,CAEAA,OACIC,OAAOC,iBAAiB,OAAQ,IAE5BH,KAAKH,UAAY,IAAIO,QAAQC,MAAM,CAC/BC,KAAM,OACNC,KAAM,QACNC,UAAW,GAEXC,UAAYP,OAAOQ,WAAa,EAAMC,OAAOP,QAAQQ,SAASC,MAAMC,QAAQ,MAAO,EAAE,CAAC,EAAI,EAC1FC,MAAO,CAAA,EACPC,QAAS,C,CACZ,EAEDhB,KAAKF,kBAAoB,IAAIM,QAAQC,MAAM,CACvCC,KAAM,KACNC,KAAM,OACNC,UAAW,GACXC,UAAW,E,CACd,CACL,CAAC,EACDP,OAAOC,iBAAiB,SAAU,IAE9BH,KAAKH,UAAY,IAAIO,QAAQC,MAAM,CAC/BC,KAAM,OACNC,KAAM,QACNC,UAAW,GAEXC,UAAYP,OAAOQ,WAAa,EAAMC,OAAO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A5BC,aAAaC,YAClBD,aAAaG,kBAAiB,EAAGvB,KAAK,SAAUqB,GACzB,YAAfA,GAImB,IAAID,aAAapD,EAHtB,CACVsD,KAAMH,C,CAEwC,CAE1D,CAAC,EAhBDvC,MAAM,oDAAoD,CAkBlE,C,CAGJ,IAAKF,kBAAAA,IACDA,EAAAA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,OAAA,GAAA,SACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,QAAA,GAAA,UACAA,EAAAA,EAAA,MAAA,GAAA,OACH,GANIA,iBAAAA,kBAAgB,EAAA","file":"hicomNotify.js","sourcesContent":["class HicomNotify implements IHicomNotify {\r\n\r\n // @ts-ignore\r\n _readUrl: string = `${hicomPage.BaseUrl}/WebApi/Notification/Read`;\r\n // @ts-ignore\r\n _clearUrl: string = `${hicomPage.BaseUrl}/WebApi/Notification/Clear`;\r\n _stackTop: any = {};\r\n _stackBottomRight: any = {};\r\n\r\n constructor() {\r\n this.init();\r\n }\r\n\r\n init() {\r\n window.addEventListener('load', (event) => {\r\n // @ts-ignore\r\n this._stackTop = new PNotify.Stack({\r\n dir1: \"down\",\r\n dir2: \"right\",\r\n firstpos1: 25,\r\n // @ts-ignore\r\n firstpos2: (window.innerWidth / 2) - (Number(PNotify.defaults.width.replace(/\\D/g, '')) / 2),\r\n modal: false,\r\n maxOpen: 5\r\n })\r\n // @ts-ignore\r\n this._stackBottomRight = new PNotify.Stack({\r\n dir1: 'up',\r\n dir2: 'left',\r\n firstpos1: 25,\r\n firstpos2: 25\r\n })\r\n })\r\n window.addEventListener('resize', (event) => {\r\n // @ts-ignore\r\n this._stackTop = new PNotify.Stack({\r\n dir1: \"down\",\r\n dir2: \"right\",\r\n firstpos1: 25,\r\n // @ts-ignore\r\n firstpos2: (window.innerWidth / 2) - (Number(PNotify.defaults.width.replace(/\\D/g, '')) / 2),\r\n modal: false,\r\n maxOpen: 5\r\n })\r\n })\r\n }\r\n\r\n showNotification(\r\n title: string,\r\n text: string,\r\n notificationType: NotificationType,\r\n stack: string = null,\r\n autohide: boolean = true,\r\n delay: number = 5000,\r\n textTrusted: boolean = false\r\n ) {\r\n try {\r\n let options = {\r\n title: title,\r\n text: text,\r\n hide: autohide,\r\n delay: delay,\r\n stack: this._stackTop,\r\n textTrusted: textTrusted\r\n }\r\n\r\n switch (stack) {\r\n case \"stackBottomRight\":\r\n options.stack = this._stackBottomRight;\r\n break;\r\n }\r\n\r\n switch (notificationType) {\r\n case NotificationType.Alert:\r\n // @ts-ignore\r\n PNotify.alert(options);\r\n break;\r\n case NotificationType.Notice:\r\n // @ts-ignore\r\n PNotify.notice(options);\r\n break;\r\n case NotificationType.Info:\r\n // @ts-ignore\r\n PNotify.info(options);\r\n break;\r\n case NotificationType.Success:\r\n // @ts-ignore\r\n PNotify.success(options);\r\n break;\r\n case NotificationType.Error:\r\n // @ts-ignore\r\n PNotify.error(options);\r\n break;\r\n default:\r\n }\r\n } catch (error) {\r\n console.error('HicomNotify::showNotification - Error:', error);\r\n }\r\n }\r\n\r\n clearNotification(notificationAuditId: number) {\r\n let data = { NotificationAuditId: notificationAuditId };\r\n // @ts-ignore\r\n hicomPage.fetchPostJson(this._clearUrl, data)\r\n .catch((error) => {\r\n console.error('HicomNotify::clearNotification - Error:', error);\r\n });\r\n }\r\n\r\n showNotificationWithRead(\r\n title: string,\r\n text: string,\r\n notificationType: NotificationType,\r\n stack: string = null,\r\n autohide: boolean = true\r\n ) {\r\n this.showNotification(title, text, notificationType, stack, autohide);\r\n\r\n let elements = document.getElementsByClassName(\"pnotify-closer\");\r\n\r\n let data = { Title: title }\r\n\r\n // @ts-ignore\r\n hicomPage.fetchPostJson(this._readUrl, data)\r\n .then((res) => {\r\n elements[elements.length - 1].addEventListener('click', () => { this.clearNotification(res.Data.id) }, false)\r\n })\r\n .catch((error) => {\r\n console.error('HicomNotify::showNotificationWithRead - Error:', error);\r\n });\r\n }\r\n\r\n showPersistentNotification(\r\n title: string,\r\n text: string,\r\n notificationType: NotificationType,\r\n stack: string\r\n ) {\r\n this.showNotification(title, text, notificationType, stack, false);\r\n }\r\n\r\n showSaveSuccessNotification() {\r\n this.showNotification(\"Save complete!\", \"This record has been successfully saved.\", NotificationType.Success);\r\n }\r\n\r\n showSaveFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be saved. Please check for any mandatory fields or try again later.\", NotificationType.Error);\r\n }\r\n\r\n showPublishSuccessNotification() {\r\n this.showNotification(\"Publish complete!\", \"This record has been successfully published.\", NotificationType.Success);\r\n }\r\n\r\n showPublishFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be published. Please check for any validation messages or try again later.\", NotificationType.Error);\r\n }\r\n\r\n showUnpublishSuccessNotification() {\r\n this.showNotification(\"Unpublish complete!\", \"This record has been successfully unpublished.\", NotificationType.Success);\r\n }\r\n\r\n showUnpublishFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be unpublished. Please check for any validation messages or try again later.\", NotificationType.Error);\r\n }\r\n\r\n showArchiveSuccessNotification() {\r\n this.showNotification(\"Archive complete!\", \"This record has been successfully archived.\", NotificationType.Success);\r\n }\r\n\r\n showArchiveFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be archived. Please check for any validation messages or try again later.\", NotificationType.Error);\r\n }\r\n\r\n showUnarchiveSuccessNotification() {\r\n this.showNotification(\"Unarchive complete!\", \"This record has been successfully unarchived.\", NotificationType.Success);\r\n }\r\n\r\n showUnarchiveFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be unarchived. Please check for any validation messages or try again later.\", NotificationType.Error);\r\n }\r\n\r\n showDeleteSuccessNotification() {\r\n this.showNotification(\"Delete complete!\", \"This record has been successfully deleted.\", NotificationType.Success);\r\n }\r\n\r\n showDeleteFailureNotification() {\r\n this.showNotification(\"Oh no!\", \"This record could not be deleted. Please check for any validation messages or try again later.\", NotificationType.Error);\r\n }\r\n\r\n sendDesktopNotification(\r\n title: string,\r\n message: string\r\n ) {\r\n if (!(\"Notification\" in window)) {\r\n alert(\"This browser does not support desktop notification\");\r\n }\r\n else if (Notification.permission === \"granted\") {\r\n let options = {\r\n body: message\r\n }\r\n let notification = new Notification(title, options);\r\n }\r\n else if (Notification.permission !== \"denied\") {\r\n Notification.requestPermission().then(function (permission) {\r\n if (permission === \"granted\") {\r\n let options = {\r\n body: message\r\n }\r\n let notification = new Notification(title, options);\r\n }\r\n });\r\n }\r\n }\r\n}\r\n\r\nenum NotificationType {\r\n Alert,\r\n Notice,\r\n Info,\r\n Success,\r\n Error\r\n}"]}