@digital-realty/ix-notifications 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IxNotifications.js +90 -48
- package/dist/IxNotifications.js.map +1 -1
- package/dist/assets/iconset.d.ts +6 -0
- package/dist/assets/iconset.js +8 -0
- package/dist/assets/iconset.js.map +1 -0
- package/dist/components/notifications/date-filters.js +20 -20
- package/dist/components/notifications/date-filters.js.map +1 -1
- package/dist/components/notifications/group-filters.js +28 -22
- package/dist/components/notifications/group-filters.js.map +1 -1
- package/dist/components/notifications/grouped-item.d.ts +1 -1
- package/dist/components/notifications/grouped-item.js +10 -5
- package/dist/components/notifications/grouped-item.js.map +1 -1
- package/dist/components/notifications/notification-item.d.ts +3 -2
- package/dist/components/notifications/notification-item.js +74 -42
- package/dist/components/notifications/notification-item.js.map +1 -1
- package/dist/components/notifications/notification-tooltip.d.ts +9 -0
- package/dist/components/notifications/notification-tooltip.js +53 -0
- package/dist/components/notifications/notification-tooltip.js.map +1 -0
- package/dist/components/notifications/view-item-dialog.d.ts +1 -1
- package/dist/components/notifications/view-item-dialog.js +15 -20
- package/dist/components/notifications/view-item-dialog.js.map +1 -1
- package/dist/constants/notifications.d.ts +1 -1
- package/dist/constants/notifications.js +1 -1
- package/dist/constants/notifications.js.map +1 -1
- package/dist/helper/common.js +3 -4
- package/dist/helper/common.js.map +1 -1
- package/dist/ix-notifications.min.js +1 -1
- package/dist/models/notification.js.map +1 -1
- package/dist/state/NotificationState.js +14 -14
- package/dist/state/NotificationState.js.map +1 -1
- package/dist/styles/notifications-style.js +49 -6
- package/dist/styles/notifications-style.js.map +1 -1
- package/package.json +3 -2
|
@@ -11,7 +11,7 @@ import { NotificationsStyle } from '../../styles/notifications-style.js';
|
|
|
11
11
|
let ViewItemDialog = class ViewItemDialog extends MobxLitElement {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
|
-
this.
|
|
14
|
+
this.notification = {};
|
|
15
15
|
this.open = false;
|
|
16
16
|
this.dialogClosed = () => {
|
|
17
17
|
this.dispatchEvent(new CustomEvent('view-item-dialog-closed'));
|
|
@@ -21,12 +21,12 @@ let ViewItemDialog = class ViewItemDialog extends MobxLitElement {
|
|
|
21
21
|
return [NotificationsStyle, elementTheme, TWStyles];
|
|
22
22
|
}
|
|
23
23
|
getUrl() {
|
|
24
|
-
const ticketid = this.
|
|
25
|
-
switch (this.
|
|
24
|
+
const ticketid = this.notification.resourceId;
|
|
25
|
+
switch (this.notification.resourceType) {
|
|
26
26
|
case NotificationGroups.PLANNED_MAINTENANCE:
|
|
27
27
|
return `/service-management/reports`;
|
|
28
28
|
case NotificationGroups.SERVICE_TICKETS:
|
|
29
|
-
switch (this.
|
|
29
|
+
switch (this.notification.subGroup) {
|
|
30
30
|
case SubGroups.Remote_Hands:
|
|
31
31
|
return `/service-management/service-tickets/remote-hands/${ticketid}`;
|
|
32
32
|
case SubGroups.Customer_Care:
|
|
@@ -51,14 +51,14 @@ let ViewItemDialog = class ViewItemDialog extends MobxLitElement {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
getLocation() {
|
|
54
|
-
if (this.
|
|
55
|
-
this.
|
|
54
|
+
if (this.notification.locations === undefined ||
|
|
55
|
+
this.notification.locations.length < 1) {
|
|
56
56
|
return '';
|
|
57
57
|
}
|
|
58
|
-
if (this.
|
|
58
|
+
if (this.notification.locations.length > 1) {
|
|
59
59
|
return 'Multiple Locations';
|
|
60
60
|
}
|
|
61
|
-
return this.
|
|
61
|
+
return this.notification.locations[0];
|
|
62
62
|
}
|
|
63
63
|
render() {
|
|
64
64
|
return html ` <ix-dialog
|
|
@@ -66,32 +66,27 @@ let ViewItemDialog = class ViewItemDialog extends MobxLitElement {
|
|
|
66
66
|
class="w-[420px]"
|
|
67
67
|
@closed=${this.dialogClosed}
|
|
68
68
|
>
|
|
69
|
-
<div
|
|
69
|
+
<div slot="headline" class="px-8">
|
|
70
70
|
<div class="flex flex-col flex-start">
|
|
71
71
|
<div class="text-xl font-bold py-2 text-balance">
|
|
72
|
-
${this.
|
|
72
|
+
${this.notification.resourceType}
|
|
73
73
|
</div>
|
|
74
74
|
<div class="text-sm font-bold py-2 text-balance">
|
|
75
|
-
${this.
|
|
75
|
+
${this.notification.subGroup}
|
|
76
76
|
</div>
|
|
77
77
|
</div>
|
|
78
78
|
</div>
|
|
79
|
-
<form
|
|
80
|
-
class="px-8"
|
|
81
|
-
slot="content"
|
|
82
|
-
id="form-id"
|
|
83
|
-
method="dialog"
|
|
84
|
-
>
|
|
79
|
+
<form class="px-8" slot="content" id="form-id" method="dialog">
|
|
85
80
|
<div class="flex flex-row py-1">
|
|
86
81
|
<div class="w-[100px] block">Subject</div>
|
|
87
82
|
<div class="w-[280px] font-semibold text-wrap flex flex-start">
|
|
88
|
-
${this.
|
|
83
|
+
${this.notification.subject}
|
|
89
84
|
</div>
|
|
90
85
|
</div>
|
|
91
86
|
<div class="flex flex-row py-1">
|
|
92
87
|
<div class="w-[100px] block">Create Date</div>
|
|
93
88
|
<div class="w-[280px] font-semibold flex">
|
|
94
|
-
${format(this.
|
|
89
|
+
${format(this.notification.createdAt, 'dd/MM/yyyy HH:mm:ss')}
|
|
95
90
|
</div>
|
|
96
91
|
</div>
|
|
97
92
|
<div class="flex flex-row py-1">
|
|
@@ -108,7 +103,7 @@ let ViewItemDialog = class ViewItemDialog extends MobxLitElement {
|
|
|
108
103
|
};
|
|
109
104
|
__decorate([
|
|
110
105
|
property({ type: Object, attribute: false })
|
|
111
|
-
], ViewItemDialog.prototype, "
|
|
106
|
+
], ViewItemDialog.prototype, "notification", void 0);
|
|
112
107
|
__decorate([
|
|
113
108
|
property({ type: Boolean, attribute: true })
|
|
114
109
|
], ViewItemDialog.prototype, "open", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-item-dialog.js","sourceRoot":"","sources":["../../../src/components/notifications/view-item-dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EACL,kBAAkB,EAClB,SAAS,GACV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGlE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,cAAc;IAA3C;;QAKyC,iBAAY,GACxD,EAAkB,CAAC;QAEyB,SAAI,GAAG,KAAK,CAAC;QAgD3D,iBAAY,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"view-item-dialog.js","sourceRoot":"","sources":["../../../src/components/notifications/view-item-dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EACL,kBAAkB,EAClB,SAAS,GACV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGlE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,cAAc;IAA3C;;QAKyC,iBAAY,GACxD,EAAkB,CAAC;QAEyB,SAAI,GAAG,KAAK,CAAC;QAgD3D,iBAAY,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;IA0CJ,CAAC;IAnGC,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,kBAAkB,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAOD,MAAM;QACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QAE9C,QAAQ,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;YACtC,KAAK,kBAAkB,CAAC,mBAAmB;gBACzC,OAAO,6BAA6B,CAAC;YACvC,KAAK,kBAAkB,CAAC,eAAe;gBACrC,QAAQ,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;oBAClC,KAAK,SAAS,CAAC,YAAY;wBACzB,OAAO,oDAAoD,QAAQ,EAAE,CAAC;oBACxE,KAAK,SAAS,CAAC,aAAa;wBAC1B,OAAO,qDAAqD,QAAQ,EAAE,CAAC;oBACzE,KAAK,SAAS,CAAC,UAAU;wBACvB,OAAO,uCAAuC,SAAS,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;oBACnF,KAAK,SAAS,CAAC,eAAe;wBAC5B,OAAO,uDAAuD,QAAQ,EAAE,CAAC;oBAC3E,KAAK,SAAS,CAAC,QAAQ;wBACrB,OAAO,gDAAgD,QAAQ,EAAE,CAAC;oBACpE,KAAK,SAAS,CAAC,cAAc;wBAC3B,OAAO,uDAAuD,QAAQ,EAAE,CAAC;oBAE3E;wBACE,OAAO,EAAE,CAAC;iBACb;YACH,KAAK,kBAAkB,CAAC,SAAS;gBAC/B,OAAO,iCAAiC,QAAQ,EAAE,CAAC;YACrD,KAAK,kBAAkB,CAAC,WAAW;gBACjC,OAAO,SAAS,QAAQ,EAAE,CAAC;YAC7B;gBACE,OAAO,EAAE,CAAC;SACb;IACH,CAAC;IAED,WAAW;QACT,IACE,IAAI,CAAC,YAAY,CAAC,SAAS,KAAK,SAAS;YACzC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EACtC;YACA,OAAO,EAAE,CAAC;SACX;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1C,OAAO,oBAAoB,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAMD,MAAM;QACJ,OAAO,IAAI,CAAA;cACD,IAAI,CAAC,IAAI;;gBAEP,IAAI,CAAC,YAAY;;;;;cAKnB,IAAI,CAAC,YAAY,CAAC,YAAY;;;cAG9B,IAAI,CAAC,YAAY,CAAC,QAAQ;;;;;;;;cAQ1B,IAAI,CAAC,YAAY,CAAC,OAAO;;;;;;cAMzB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,qBAAqB,CAAC;;;;;uCAKjC,IAAI,CAAC,WAAW,EAAE;;;;;kBAKvC,IAAI,CAAC,MAAM,EAAE;;iBAEd,CAAC;IAChB,CAAC;CACF,CAAA;AA/F+C;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACxB;AAEyB;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;4CAAc;AARhD,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAoG1B;SApGY,cAAc","sourcesContent":["import { html } from 'lit';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement, property } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { elementTheme } from '@digital-realty/theme';\nimport { format } from 'date-fns';\nimport { TWStyles } from '../../tw.js';\nimport { Notification } from '../../models/notification.js';\nimport {\n NotificationGroups,\n SubGroups,\n} from '../../constants/notifications.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\n\n@customElement('view-item-dialog')\nexport class ViewItemDialog extends MobxLitElement {\n static get styles() {\n return [NotificationsStyle, elementTheme, TWStyles];\n }\n\n @property({ type: Object, attribute: false }) notification =\n {} as Notification;\n\n @property({ type: Boolean, attribute: true }) open = false;\n\n getUrl(): string {\n const ticketid = this.notification.resourceId;\n\n switch (this.notification.resourceType) {\n case NotificationGroups.PLANNED_MAINTENANCE:\n return `/service-management/reports`;\n case NotificationGroups.SERVICE_TICKETS:\n switch (this.notification.subGroup) {\n case SubGroups.Remote_Hands:\n return `/service-management/service-tickets/remote-hands/${ticketid}`;\n case SubGroups.Customer_Care:\n return `/service-management/service-tickets/customer-care/${ticketid}`;\n case SubGroups.Deliveries:\n return `/service-management/service-tickets/${SubGroups.Deliveries}/${ticketid}`;\n case SubGroups.Facility_Access:\n return `/service-management/service-tickets/facility-access/${ticketid}`;\n case SubGroups.Removals:\n return `/service-management/service-tickets/removals/${ticketid}`;\n case SubGroups.Trouble_Ticket:\n return `/service-management/service-tickets/trouble-tickets/${ticketid}`;\n\n default:\n return '';\n }\n case NotificationGroups.INCIDENTS:\n return `/service-management/incidents/${ticketid}`;\n case NotificationGroups.DCIM_ALERTS:\n return `/dcim/${ticketid}`;\n default:\n return '';\n }\n }\n\n getLocation() {\n if (\n this.notification.locations === undefined ||\n this.notification.locations.length < 1\n ) {\n return '';\n }\n if (this.notification.locations.length > 1) {\n return 'Multiple Locations';\n }\n return this.notification.locations[0];\n }\n\n dialogClosed = () => {\n this.dispatchEvent(new CustomEvent('view-item-dialog-closed'));\n };\n\n render() {\n return html` <ix-dialog\n ?open=${this.open}\n class=\"w-[420px]\"\n @closed=${this.dialogClosed}\n >\n <div slot=\"headline\" class=\"px-8\">\n <div class=\"flex flex-col flex-start\">\n <div class=\"text-xl font-bold py-2 text-balance\">\n ${this.notification.resourceType}\n </div>\n <div class=\"text-sm font-bold py-2 text-balance\">\n ${this.notification.subGroup}\n </div>\n </div>\n </div>\n <form class=\"px-8\" slot=\"content\" id=\"form-id\" method=\"dialog\">\n <div class=\"flex flex-row py-1\">\n <div class=\"w-[100px] block\">Subject</div>\n <div class=\"w-[280px] font-semibold text-wrap flex flex-start\">\n ${this.notification.subject}\n </div>\n </div>\n <div class=\"flex flex-row py-1\">\n <div class=\"w-[100px] block\">Create Date</div>\n <div class=\"w-[280px] font-semibold flex\">\n ${format(this.notification.createdAt, 'dd/MM/yyyy HH:mm:ss')}\n </div>\n </div>\n <div class=\"flex flex-row py-1\">\n <div class=\"w-[100px] block\">Site</div>\n <div class=\"font-semibold\">${this.getLocation()}</div>\n </div>\n </form>\n <div slot=\"actions\" class=\"flex flex-row flex-end px-8 py-8\">\n <button form=\"form-id\" class=\"modal-text-blue\">CLOSE</button>\n <a href=${this.getUrl()} class=\"modal-text-blue\">VIEW RECORD</a>\n </div>\n </ix-dialog>`;\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export declare enum SubGroups {
|
|
|
13
13
|
Deliveries = "Deliveries",
|
|
14
14
|
Removals = "Removals",
|
|
15
15
|
Facility_Access = "Facility Access",
|
|
16
|
-
Trouble_Ticket = "Trouble
|
|
16
|
+
Trouble_Ticket = "Trouble Ticket",
|
|
17
17
|
Customer_Care = "Customer Care"
|
|
18
18
|
}
|
|
19
19
|
export declare enum ApiCallState {
|
|
@@ -17,7 +17,7 @@ export var SubGroups;
|
|
|
17
17
|
SubGroups["Deliveries"] = "Deliveries";
|
|
18
18
|
SubGroups["Removals"] = "Removals";
|
|
19
19
|
SubGroups["Facility_Access"] = "Facility Access";
|
|
20
|
-
SubGroups["Trouble_Ticket"] = "Trouble
|
|
20
|
+
SubGroups["Trouble_Ticket"] = "Trouble Ticket";
|
|
21
21
|
SubGroups["Customer_Care"] = "Customer Care";
|
|
22
22
|
})(SubGroups || (SubGroups = {}));
|
|
23
23
|
export var ApiCallState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/constants/notifications.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,uCAAiB,CAAA;AACnB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAA2C,CAAA;IAC3C,6CAAuB,CAAA;IACvB,iDAA2B,CAAA;IAC3B,yDAAmC,CAAA;AACrC,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,0CAA6B,CAAA;IAC7B,sCAAyB,CAAA;IACzB,kCAAqB,CAAA;IACrB,gDAAmC,CAAA;IACnC
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/constants/notifications.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,uCAAiB,CAAA;AACnB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAA2C,CAAA;IAC3C,6CAAuB,CAAA;IACvB,iDAA2B,CAAA;IAC3B,yDAAmC,CAAA;AACrC,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,0CAA6B,CAAA;IAC7B,sCAAyB,CAAA;IACzB,kCAAqB,CAAA;IACrB,gDAAmC,CAAA;IACnC,8CAAiC,CAAA;IACjC,4CAA+B,CAAA;AACjC,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB;AAED,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,mCAAmB,CAAA;AACrB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC","sourcesContent":["/* eslint-disable */\nexport enum NotificationStatus {\n READ = 'read',\n UNREAD = 'unread',\n}\n\nexport enum NotificationGroups {\n PLANNED_MAINTENANCE = 'Planned Maintenance',\n INCIDENTS = 'Incidents',\n DCIM_ALERTS = 'DCIM Alerts',\n SERVICE_TICKETS = 'Service Tickets',\n}\n\nexport enum SubGroups {\n Remote_Hands = 'Remote Hands',\n Deliveries = 'Deliveries',\n Removals = 'Removals',\n Facility_Access = 'Facility Access',\n Trouble_Ticket = 'Trouble Ticket',\n Customer_Care = 'Customer Care',\n}\n\nexport enum ApiCallState {\n LOADING = 'Loading',\n ERROR = 'Error',\n SUCCESS = 'Success',\n}\n\nexport const DefaultDateFormat = 'yyyy-MM-dd';\n\nexport const DefaultTimeFormat = 'HH:mm:ss';\n\nexport const DefaultDisplayDays = 30;\n\nexport const DefaultDateTimeFormat = 'yyyy-MM-dd HH:mm:ss';\n"]}
|
package/dist/helper/common.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export const isNullOrUndefinedOrEmpty = (value) => {
|
|
2
2
|
if (value === null)
|
|
3
3
|
return true;
|
|
4
|
-
|
|
4
|
+
if (value === undefined)
|
|
5
5
|
return true;
|
|
6
|
-
|
|
6
|
+
if (value === '')
|
|
7
7
|
return true;
|
|
8
|
-
|
|
9
|
-
return false;
|
|
8
|
+
return false;
|
|
10
9
|
};
|
|
11
10
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/helper/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/helper/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,KAAuC,EAC9B,EAAE;IACX,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,KAAM,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["export const isNullOrUndefinedOrEmpty = (\n value: string | Date | undefined | null\n): Boolean => {\n if (value === null) return true;\n if (value === undefined) return true;\n if (value! === '') return true;\n return false;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{css,html,nothing}from"lit";import{property,customElement,state,query}from"lit/decorators.js";import{MobxLitElement}from"@adobe/lit-mobx";import{format,subDays,parse,differenceInHours,formatDistance,differenceInDays}from"date-fns";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-drawer/ix-drawer.js";import"@digital-realty/ix-icon";import"@material/web/icon/icon.js";import{makeAutoObservable}from"mobx";import{makePersistable,isHydrated,hydrateStore,clearPersistedStore,getPersistedStore}from"mobx-persist-store";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-icon/ix-icon.js";import{elementTheme,baseTheme}from"@digital-realty/theme";import"@digital-realty/ix-toast/ix-message-toast.js";import"@digital-realty/ix-switch/ix-switch.js";import"@digital-realty/ix-date/ix-date.js";import"@digital-realty/ix-divider/ix-divider.js";const TWStyles=css`*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}::after,::before{--tw-content:''}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Open Sans,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::after,::before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.absolute{position:absolute}.relative{position:relative}.-start-0{inset-inline-start:0}.z-50{z-index:50}.m-0{margin:0}.mr-4{margin-right:1rem}.block{display:block}.inline{display:inline}.flex{display:flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.w-\\[100px\\]{width:100px}.w-\\[480px\\]{width:480px}.w-\\[580px\\]{width:580px}.w-\\[420px\\]{width:420px}.w-\\[0px\\]{width:0}.w-\\[280px\\]{width:280px}.flex-grow{flex-grow:1}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.resize{resize:both}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-between{justify-content:space-between}.text-wrap{text-wrap:wrap}.text-balance{text-wrap:balance}.rounded-full{border-radius:9999px}.border{border-width:1px}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68 / var(--tw-bg-opacity))}.p-0{padding:0}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-4{padding:1rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-16{padding-left:4rem;padding-right:4rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.px-8{padding-left:2rem;padding-right:2rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.pb-2{padding-bottom:.5rem}.pl-1{padding-left:.25rem}.pl-11{padding-left:2.75rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-8{padding-left:2rem}.pr-1{padding-right:.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-justify{text-align:justify}.align-top{vertical-align:top}.align-middle{vertical-align:middle}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-semibold{font-weight:600}.text-white{--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:150ms}@media (min-width:640px){.sm\\:flex-col{flex-direction:column}}@media (min-width:768px){.md\\:flex-col{flex-direction:column}}@media (min-width:1024px){.lg\\:flex-col{flex-direction:column}}@media (min-width:1280px){.xl\\:flex-row{flex-direction:row}}`;var NotificationStatus,NotificationGroups,SubGroups,ApiCallState;!function(t){t.READ="read",t.UNREAD="unread"}(NotificationStatus=NotificationStatus||{}),function(t){t.PLANNED_MAINTENANCE="Planned Maintenance",t.INCIDENTS="Incidents",t.DCIM_ALERTS="DCIM Alerts",t.SERVICE_TICKETS="Service Tickets"}(NotificationGroups=NotificationGroups||{}),function(t){t.Remote_Hands="Remote Hands",t.Deliveries="Deliveries",t.Removals="Removals",t.Facility_Access="Facility Access",t.Trouble_Ticket="Trouble Tickets",t.Customer_Care="Customer Care"}(SubGroups=SubGroups||{}),function(t){t.LOADING="Loading",t.ERROR="Error",t.SUCCESS="Success"}(ApiCallState=ApiCallState||{});const DefaultDateFormat="yyyy-MM-dd",DefaultDisplayDays=30,DefaultDateTimeFormat="yyyy-MM-dd HH:mm:ss",BASE_PATH="http://api.digitalrealty.com/notifications".replace(/\/+$/,"");class Configuration{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:BASE_PATH}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||querystring}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return"function"==typeof t?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return"function"==typeof t?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const DefaultConfig=new Configuration;class BaseAPI{constructor(t=DefaultConfig){this.configuration=t,this.fetchApi=async(t,e)=>{let i={url:t,init:e};for(const a of this.middleware)a.pre&&(i=await a.pre({fetch:this.fetchApi,...i})||i);let o=void 0;try{o=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(t){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:t,response:o?o.clone():void 0})||o);if(void 0===o)throw t instanceof Error?new FetchError(t,"The request failed and the interceptors did not return an alternative response"):t}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:i.url,init:i.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){var e=this.clone();return e.middleware=e.middleware.concat(...t),e}withPreMiddleware(...t){t=t.map(t=>({pre:t}));return this.withMiddleware(...t)}withPostMiddleware(...t){t=t.map(t=>({post:t}));return this.withMiddleware(...t)}isJsonMime(t){return!!t&&BaseAPI.jsonRegex.test(t)}async request(t,e){var{url:t,init:e}=await this.createFetchParams(t,e),t=await this.fetchApi(t,e);if(t&&200<=t.status&&t.status<300)return t;throw new ResponseError(t,"Response returned an error code")}async createFetchParams(t,e){let i=this.configuration.basePath+t.path;void 0!==t.query&&0!==Object.keys(t.query).length&&(i+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(t=>void 0===o[t]?delete o[t]:{});var a="function"==typeof e?e:async()=>e,r={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...r,...await a({init:r,context:t})};let n;n=!(isFormData(a.body)||a.body instanceof URLSearchParams||isBlob(a.body))&&this.isJsonMime(o["Content-Type"])?JSON.stringify(a.body):a.body;r={...a,body:n};return{url:i,init:r}}clone(){var t=new this.constructor(this.configuration);return t.middleware=this.middleware.slice(),t}}function isBlob(t){return"undefined"!=typeof Blob&&t instanceof Blob}function isFormData(t){return"undefined"!=typeof FormData&&t instanceof FormData}BaseAPI.jsonRegex=new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$","i");class ResponseError extends Error{constructor(t,e){super(e),this.response=t,this.name="ResponseError"}}class FetchError extends Error{constructor(t,e){super(e),this.cause=t,this.name="FetchError"}}class RequiredError extends Error{constructor(t,e){super(e),this.field=t,this.name="RequiredError"}}const COLLECTION_FORMATS={csv:",",ssv:" ",tsv:"\t",pipes:"|"};function exists(t,e){t=t[e];return null!=t}function querystring(e,i=""){return Object.keys(e).map(t=>querystringSingleKey(t,e[t],i)).filter(t=>0<t.length).join("&")}function querystringSingleKey(t,e,i=""){var o,a=i+(i.length?`[${t}]`:t);return e instanceof Array?(o=e.map(t=>encodeURIComponent(String(t))).join(`&${encodeURIComponent(a)}=`),encodeURIComponent(a)+"="+o):e instanceof Set?querystringSingleKey(t,Array.from(e),i):e instanceof Date?encodeURIComponent(a)+"="+encodeURIComponent(e.toISOString()):e instanceof Object?querystring(e,a):encodeURIComponent(a)+"="+encodeURIComponent(String(e))}class JSONApiResponse{constructor(t,e=t=>t){this.raw=t,this.transformer=e}async value(){return this.transformer(await this.raw.json())}}class VoidApiResponse{constructor(t){this.raw=t}async value(){}}function StatusFromJSON(t){return StatusFromJSONTyped(t)}function StatusFromJSONTyped(t,e){return t}function StatusToJSON(t){return t}function NotificationFromJSON(t){return NotificationFromJSONTyped(t)}function NotificationFromJSONTyped(t,e){return null==t?t:{id:exists(t,"id")?t.id:void 0,resourceType:exists(t,"resource_type")?t.resource_type:void 0,subGroup:exists(t,"sub_group")?t.sub_group:void 0,createdAt:exists(t,"created_at")?null===t.created_at?null:new Date(t.created_at):void 0,createdBy:exists(t,"created_by")?t.created_by:void 0,subject:exists(t,"subject")?t.subject:void 0,locations:exists(t,"locations")?t.locations:void 0,resourceId:exists(t,"resource_id")?t.resource_id:void 0,status:exists(t,"status")?StatusFromJSON(t.status):void 0,accountNumber:exists(t,"account_number")?t.account_number:void 0}}function GetNotifications200ResponseFromJSON(t){return GetNotifications200ResponseFromJSONTyped(t)}function GetNotifications200ResponseFromJSONTyped(t,e){return null==t?t:{self:exists(t,"self")?t.self:void 0,first:exists(t,"first")?t.first:void 0,prev:exists(t,"prev")?t.prev:void 0,next:exists(t,"next")?t.next:void 0,last:exists(t,"last")?t.last:void 0,items:t.items.map(NotificationFromJSON)}}function NotificationPatchFromJSON(t){return NotificationPatchFromJSONTyped(t)}function NotificationPatchFromJSONTyped(t,e){return null==t?t:{status:StatusFromJSON(t.status)}}function NotificationPatchToJSON(t){if(void 0!==t)return null===t?null:{status:StatusToJSON(t.status)}}function NotificationRequestToJSON(t){if(void 0!==t)return null===t?null:{resource_type:t.resourceType,sub_group:t.subGroup,recipients:t.recipients,account_number:t.accountNumber,locations:t.locations,resource_id:t.resourceId,subject:t.subject,created_at:void 0===t.createdAt?void 0:null===t.createdAt?null:t.createdAt.toISOString()}}class NotificationsApi extends BaseAPI{async createNotificationRaw(t,e){var i={"Content-Type":"application/json"},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications",method:"POST",headers:i,query:{},body:NotificationRequestToJSON(t.notificationRequest)},e));return new JSONApiResponse(o,t=>NotificationFromJSON(t))}async createNotification(t={},e){return(await this.createNotificationRaw(t,e)).value()}async deleteNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling deleteNotificationsById.");var i={},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:i,query:{}},e));return new VoidApiResponse(o)}async deleteNotificationsById(t,e){await this.deleteNotificationsByIdRaw(t,e)}async getNotificationsRaw(t,e){var i={},o=(void 0!==t.sort&&(i.sort=t.sort),void 0!==t.cursor&&(i.cursor=t.cursor),void 0!==t.resourceType&&(i.resource_type=t.resourceType),void 0!==t.accountNumber&&(i.account_number=t.accountNumber),void 0!==t.createdAfter&&(i.created_after=t.createdAfter.toISOString()),void 0!==t.createdBefore&&(i.created_before=t.createdBefore.toISOString()),void 0!==t.locationId&&(i.location_id=t.locationId),void 0!==t.subGroup&&(i.sub_group=t.subGroup),void 0!==t.status&&(i.status=t.status),{}),t=(t.prefer&&(o.Prefer=t.prefer.join(COLLECTION_FORMATS.csv)),this.configuration&&this.configuration.accessToken&&(t=await(0,this.configuration.accessToken)("bearerToken",[]))&&(o.Authorization="Bearer "+t),await this.request({path:"/notifications",method:"GET",headers:o,query:i},e));return new JSONApiResponse(t,t=>GetNotifications200ResponseFromJSON(t))}async getNotifications(t={},e){return(await this.getNotificationsRaw(t,e)).value()}async getNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling getNotificationsById.");var i={},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:i,query:{}},e));return new JSONApiResponse(o,t=>NotificationFromJSON(t))}async getNotificationsById(t,e){return(await this.getNotificationsByIdRaw(t,e)).value()}async patchNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling patchNotificationsById.");var i={"Content-Type":"application/json"},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PATCH",headers:i,query:{},body:NotificationPatchToJSON(t.notificationPatch)},e));return new JSONApiResponse(o,t=>NotificationPatchFromJSON(t))}async patchNotificationsById(t,e){return(await this.patchNotificationsByIdRaw(t,e)).value()}}const APIEndpointPrefixes={Notifications:"notifications"};class ApiClient{constructor(t){this.noInit=!1,this.configuration=t}get notificationsApi(){return new NotificationsApi(new Configuration({basePath:this.configuration.NotificationApiUrl+"/"+APIEndpointPrefixes.Notifications,headers:{Authorization:this.getAuthorization()}}))}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}const isNullOrUndefinedOrEmpty=t=>null==t||""===t,mapResourceTypeToNotificationGroups=t=>{switch(t.toLowerCase()){case"planned maintenance":return NotificationGroups.PLANNED_MAINTENANCE;case"incidents":return NotificationGroups.INCIDENTS;case"dcim alerts":return NotificationGroups.DCIM_ALERTS;case"service tickets":return NotificationGroups.SERVICE_TICKETS;default:return NotificationGroups.PLANNED_MAINTENANCE}},mapStringToNotificationStatus=t=>{switch(t.toLowerCase()){case"unread":return NotificationStatus.UNREAD;case"read":return NotificationStatus.READ;default:return NotificationStatus.UNREAD}},mapParametersToNotificationRequest=t=>({sort:"-created_at",cursor:t,prefer:[""]}),mapParametersToPatchNotificationRequest=(t,e)=>({id:t,notificationPatch:{status:e}}),mapParametersToDeleteNotificationRequest=t=>({id:t}),mapNotificationDataToNotification=t=>{var e;return{subject:null!=(e=t.subject)?e:"",id:t.id,accountNumber:null!=(e=t.accountNumber)?e:"",resourceType:mapResourceTypeToNotificationGroups(null!=(e=t.resourceType)?e:""),subGroup:null!=(e=t.subGroup)?e:"",resourceId:null!=(e=t.resourceId)?e:"",status:mapStringToNotificationStatus(null!=(e=t.status)?e:""),createdAt:isNullOrUndefinedOrEmpty(t.createdAt)?format(new Date,DefaultDateTimeFormat):format(t.createdAt,DefaultDateTimeFormat),createdBy:null!=(e=t.createdBy)?e:"",locations:null!=(e=t.locations)?e:[]}},mapNotificationResponseToNotifications=t=>t.map(t=>mapNotificationDataToNotification(t)),getNextPageCursorfromQueryParam=t=>{t=new URLSearchParams(t),t=t.has("cursor")?t.get("cursor"):"";return null!==t?t:""},handleError=async(e,t=!0)=>{if(e instanceof ResponseError&&400===e.response.status)try{var i=(await e.response.json())["detail"];t&&console.error(i)}catch(t){console.error(e)}else console.error(e)},getLocalStorageUser=t=>{t=localStorage.getItem(t);return t?JSON.parse(t):null},getUserAuthorization=t=>{return"Bearer "+(null==(t=getLocalStorageUser(t))?void 0:t.access_token)};class NotificationState{constructor(){this.apiClient={noInit:!0},this.baseApiUrl="",this.localStorageKey="",this.NewApiClient=()=>{this.apiClient=new ApiClient({NotificationApiUrl:this.baseApiUrl,getAuthorizationFn:()=>getUserAuthorization(this.localStorageKey)}),this.getNotifications()},this.nextPageCursor="",this.notifications=[],this.unreadNotificationCount=0,this.notificationFilters={SHOW_PLANNED_MAINTENANCE:!0,SHOW_SERVICE_TICKETS:!0,SHOW_DCIM_ALERTS:!0},this.selectedNotification={id:"",resourceType:NotificationGroups.PLANNED_MAINTENANCE,subGroup:"",subject:"",resourceId:"",locations:[],createdAt:"",accountNumber:"",createdBy:"",status:NotificationStatus.READ},this.dateFilters={FROM_DATE:subDays(new Date,DefaultDisplayDays),TO_DATE:new Date},makeAutoObservable(this),makePersistable(this,{name:"notification-state",properties:["notificationFilters","dateFilters"],storage:window.localStorage})}get isHydrated(){return isHydrated(this)}async hydrateStore(){await hydrateStore(this)}async clearStoredData(){await clearPersistedStore(this)}async getStoredData(){return getPersistedStore(this)}ConstructApiClient(){return this.apiClient.noInit?this.NewApiClient():this.apiClient}async clearStoredNotificationsData(){this.notifications=[],this.unreadNotificationCount=0,this.nextPageCursor=""}async setNotificationReadStatus(e){var t,i=await this.setNotificationAsRead(e.toString());return!0===await i&&(this.ReduceUnreadNotificationCount(),t=this.notifications.findIndex(t=>t.id===e),this.notifications[t].status=NotificationStatus.READ,this.selectedNotification=this.notifications[t]),i}async setNotificationDeleted(e){var t,i=await this.DeleteNotification(e.toString());return!0===i&&("unread"==(null==(t=this.notifications.find(t=>t.id===e))?void 0:t.status)&&this.ReduceUnreadNotificationCount(),t=this.notifications.findIndex(t=>t.id===e),this.notifications.splice(t,1)),{State:!0===i?ApiCallState.SUCCESS:ApiCallState.ERROR,Message:!0===i?"Successfully deleted the notificaion":"Error while deleting the notification"}}setNotificationDateFilter(t,e){this.dateFilters.FROM_DATE=void 0!==t?parse(t,DefaultDateFormat,new Date):void 0,this.dateFilters.TO_DATE=void 0!==e?parse(e,DefaultDateFormat,new Date):void 0}setNotificationFilter(t,e){switch(t){case NotificationGroups.PLANNED_MAINTENANCE:this.notificationFilters.SHOW_PLANNED_MAINTENANCE=e;break;case NotificationGroups.SERVICE_TICKETS:this.notificationFilters.SHOW_SERVICE_TICKETS=e;break;case NotificationGroups.DCIM_ALERTS:this.notificationFilters.SHOW_DCIM_ALERTS=e}}async getNotifications(){var t,e;void 0!==this.nextPageCursor&&(e=await(null==(e=this.apiClient)?void 0:e.notificationsApi.getNotificationsRaw(mapParametersToNotificationRequest(getNextPageCursorfromQueryParam(this.nextPageCursor))).catch(t=>{handleError(t,!1)})))&&(this.unreadNotificationCount=Number(null!=(t=e.raw.headers.get("x-total-unread-count"))?t:"0"),t=await(null==e?void 0:e.value()),this.notifications=""===this.nextPageCursor?mapNotificationResponseToNotifications(null==t?void 0:t.items):this.notifications.concat(mapNotificationResponseToNotifications(null==t?void 0:t.items)),this.nextPageCursor=void 0===(null==t?void 0:t.next)||null==t?void 0:t.next)}async getNotificationsById(t){var e;let i;(i=t?await(null==(e=this.apiClient)?void 0:e.notificationsApi.getNotificationsById({id:t}).catch(t=>{handleError(t,!1)})):i)&&(this.selectedNotification=mapNotificationDataToNotification(i))}async setNotificationAsRead(t){var e;return!!t&&(await(null==(e=this.apiClient)?void 0:e.notificationsApi.patchNotificationsById(mapParametersToPatchNotificationRequest(t,"read")).catch(t=>(handleError(t,!1),!1))),!0)}async DeleteNotification(t){var e;let i=!1;return t&&await(null==(e=this.apiClient)?void 0:e.notificationsApi.deleteNotificationsById(mapParametersToDeleteNotificationRequest(t)).catch(t=>{handleError(t,!1),i=!1}).then(t=>{i=!0})),i}ReduceUnreadNotificationCount(){0<this.unreadNotificationCount&&(this.unreadNotificationCount=this.unreadNotificationCount-1)}}const NotificationsState=new NotificationState,NotificationsStyle=css`.red-icon{--md-icon-button-icon-color:var(--md-sys-color-error);--md-sys-color-on-surface-variant:var(--md-sys-color-error)}.blue-icon{--md-icon-button-icon-color:var(--ix-sys-primary);--md-sys-color-on-surface-variant:var(--ix-sys-primary)}.grey-icon{--md-icon-button-icon-color:var(--md-sys-color-tertiary);--md-sys-color-on-surface-variant:var(--md-sys-color-tertiary);cursor:default}.notification-item-read,.notification-item-unread{position:relative;display:flex;flex-direction:row;flex-grow:1;padding:.5rem .75rem 1rem 1rem;background-color:#fff;font-weight:700;cursor:pointer;align-items:center}.notification-item-unread{border-left:3px solid var(--ix-button-confirm-color);padding-left:14px}.notification-item-read:hover,.notification-item-unread:hover{cursor:pointer;background-color:rgba(0,0,0,.04)}.group-container-row{display:block;font-size:12px;padding:12px 0 12px 0;margin-top:0;margin-bottom:0;border-bottom:#e1e4e8 inset 1px;color:var(--md-sys-text-color-primary);font-weight:400;font-size:15px;line-height:20px;letter-spacing:.15px}.group-name{line-height:24px;color:var(--md-sys-text-color-primary)}.group-item-name{display:grid;grid-template-columns:1fr 20%;gap:16px;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex-grow:1;padding-top:5px}.notification-items-container{padding:0}.ix-icon-groups{--ix-icon-font-size:32px;--ix-icon-line-height:32px;color:var(--md-sys-text-color-primary)}:host{--ix-drawer-border-radius:0;--ix-drawer-padding:0;--ix-draw-width-sm:50vw;--ix-draw-width-lg:30vw}.ix-switch-wrapper{margin:4px;padding:4px;display:flex;column-gap:.75rem;align-items:center}ix-switch{--md-switch-selected-handle-color:var(--ix-sys-primary);--md-switch-selected-pressed-handle-color:var(--ix-sys-primary);--md-switch-selected-hover-handle-color:var(--ix-sys-primary);--md-switch-selected-focus-handle-color:var(--ix-sys-primary);--md-switch-selected-track-color:#7ba0ee;--md-switch-selected-pressed-track-color:#7ba0ee;--md-switch-selected-hover-track-color:#7ba0ee;--md-switch-selected-focus-track-color:#7ba0ee;--md-switch-track-height:14px;--md-switch-track-width:36px;--md-switch-track-outline-width:0;--md-switch-handle-color:white;--md-switch-pressed-handle-color:white;--md-switch-hover-handle-color:white;--md-switch-focus-handle-color:white;--md-switch-handle-width:20px;--md-switch-handle-height:20px;display:flex}.datefilter-dropdown-content,.filter-dropdown-content{display:none;position:absolute;right:5%;top:3rem;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:3;transition:box-shadow .3s cubic-bezier(.4,0,.2,1) 0s;border-radius:3px;box-shadow:rgba(0,0,0,.2) 0 5px 5px -3px,rgba(0,0,0,.14) 0 8px 10px 1px,rgba(0,0,0,.12) 0 3px 14px 2px;background-color:#fff}.filter-dropdown-content.active{display:inline}.datefilter-dropdown-content.active{display:inline}.modal-text-blue{color:var(--ix-sys-primary);padding-left:1.8rem;font-weight:700}.unread{font-family:'Open Sans',sans-serif;padding:0 5px;font-size:12px;line-height:16px;left:22px;top:0;background:var(--ix-button-cancel-color,#db0028)}.notification-header{font-family:'Red Hat Display',sans-serif;padding:20px 16px;font-weight:770;font-size:20px;line-height:24px}h3{font-family:'Open Sans',sans-serif;font-size:16px;font-weight:400;line-height:20px;letter-spacing:.15px;text-align:left;padding:8px 16px}.empty{margin:8px 0 8px 16px;font-family:"Open Sans",sans-serif;font-style:normal;font-size:12px;line-height:16px;letter-spacing:.4px;color:#092241;font-weight:400}.notifification-item ix-icon-button{padding:12px}.options{padding-right:1rem;position:relative}`;let ConfirmationDialog=class extends MobxLitElement{constructor(){super(...arguments),this.textMessage="Are you sure?",this.open=!1,this.dialogClosed=()=>{this.dispatchEvent(new CustomEvent("confirm-dialog-closed"))}}static get styles(){return[NotificationsStyle,elementTheme,baseTheme,TWStyles]}onClick(t){t=new CustomEvent("on-confirm-selection",{detail:{returnValue:t},bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return html`<ix-dialog ?open="${this.open}" class="w-[580px]" @closed="${this.dialogClosed}"><div slot="headline"><div class="p-4 text-xl font-bold">${this.textMessage}</div></div><div slot="actions"><div class="flex flex-row justify-end p-1"><ix-button name="cancel" appearance="text" @click="${()=>this.onClick(!1)}">DISMISS</ix-button><ix-button name="confirm" appearance="text" @click="${()=>this.onClick(!0)}">YES</ix-button></div></div></ix-dialog>`}},ViewItemDialog=(__decorate([property({type:String,attribute:!0})],ConfirmationDialog.prototype,"textMessage",void 0),__decorate([property({type:Boolean,attribute:!0})],ConfirmationDialog.prototype,"open",void 0),ConfirmationDialog=__decorate([customElement("confirmation-dialog")],ConfirmationDialog),class extends MobxLitElement{constructor(){super(...arguments),this.notificaiton={},this.open=!1,this.dialogClosed=()=>{this.dispatchEvent(new CustomEvent("view-item-dialog-closed"))}}static get styles(){return[NotificationsStyle,elementTheme,TWStyles]}getUrl(){var t=this.notificaiton.id;switch(this.notificaiton.resourceType){case NotificationGroups.PLANNED_MAINTENANCE:return"/service-management/reports";case NotificationGroups.SERVICE_TICKETS:switch(this.notificaiton.subGroup){case SubGroups.Remote_Hands:return"/service-management/service-tickets/remote-hands/"+t;case SubGroups.Customer_Care:return"/service-management/service-tickets/customer-care/"+t;case SubGroups.Deliveries:return`/service-management/service-tickets/${SubGroups.Deliveries}/`+t;case SubGroups.Facility_Access:return"/service-management/service-tickets/facility-access/"+t;case SubGroups.Removals:return"/service-management/service-tickets/removals/"+t;case SubGroups.Trouble_Ticket:return"/service-management/service-tickets/trouble-tickets/"+t;default:return""}case NotificationGroups.INCIDENTS:return"/service-management/incidents/"+t;case NotificationGroups.DCIM_ALERTS:return"/dcim/"+t;default:return""}}getLocation(){return void 0===this.notificaiton.locations||this.notificaiton.locations.length<1?"":1<this.notificaiton.locations.length?"Multiple Locations":this.notificaiton.locations[0]}render(){return html`<ix-dialog ?open="${this.open}" class="w-[420px]" @closed="${this.dialogClosed}"><div slot="headline" class="px-8"><div class="flex flex-col flex-start"><div class="text-xl font-bold py-2 text-balance">${this.notificaiton.resourceType}</div><div class="text-sm font-bold py-2 text-balance">${this.notificaiton.subGroup}</div></div></div><form class="px-8" slot="content" id="form-id" method="dialog"><div class="flex flex-row py-1"><div class="w-[100px] block">Subject</div><div class="w-[280px] font-semibold text-wrap flex flex-start">${this.notificaiton.subject}</div></div><div class="flex flex-row py-1"><div class="w-[100px] block">Create Date</div><div class="w-[280px] font-semibold flex">${format(this.notificaiton.createdAt,"dd/MM/yyyy HH:mm:ss")}</div></div><div class="flex flex-row py-1"><div class="w-[100px] block">Site</div><div class="font-semibold">${this.getLocation()}</div></div></form><div slot="actions" class="flex flex-row flex-end px-8 py-8"><button form="form-id" class="modal-text-blue">CLOSE</button> <a href="${this.getUrl()}" class="modal-text-blue">VIEW RECORD</a></div></ix-dialog>`}}),NotificationItem=(__decorate([property({type:Object,attribute:!1})],ViewItemDialog.prototype,"notificaiton",void 0),__decorate([property({type:Boolean,attribute:!0})],ViewItemDialog.prototype,"open",void 0),ViewItemDialog=__decorate([customElement("view-item-dialog")],ViewItemDialog),class extends MobxLitElement{constructor(){super(...arguments),this.disabled=!1,this.notificaiton={},this.showModal=!1,this.showDeleteConfirmation=!1}static get styles(){return[NotificationsStyle,elementTheme,TWStyles,css`.notification-item-read h2{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:400;line-height:16px;letter-spacing:.4px;text-align:left}.notification-item-unread h2{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:700;line-height:16px;letter-spacing:.4px;text-align:left}h3{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:400;line-height:16px;letter-spacing:.4px;text-align:left;color:rgba(9,34,65,.6);padding:0}ix-icon{--ix-icon-font-size:24px;--ix-icon-line-height:24px;color:var(--md-sys-text-color-primary)}.notification-item-read ix-icon{margin-right:12px;color:rgba(9,34,65)}.notification-item-unread ix-icon{margin-right:12px;color:#1456e0}`]}displayItem(){this.notificaiton.status===NotificationStatus.UNREAD&&NotificationsState.setNotificationReadStatus(this.notificaiton.id),this.showModal=!0}deleteItem(){this.disabled||(this.showDeleteConfirmation=!0)}confirmedDelete(t){t.detail.returnValue&&NotificationsState.setNotificationDeleted(this.notificaiton.id).then(t=>{this.showDeleteResultMessage(t,this.notificaiton.id)}),this.showDeleteConfirmation=!1}showDeleteResultMessage(t,e){window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:e,content:html`<ix-message-toast toastId="${e}" .TMessageToast="${t.State.toLowerCase()}" forceClose>${t.Message}</ix-message-toast>`,autoClose:2e3,durationOut:2e3,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))}calculateDuration(){return void 0!==this.notificaiton.createdAt?differenceInHours(new Date,this.notificaiton.createdAt)<24?formatDistance(this.notificaiton.createdAt,new Date,{addSuffix:!0}):format(this.notificaiton.createdAt,DefaultDateTimeFormat):"NA"}GetNotificationIcon(){switch(this.notificaiton.resourceType){case NotificationGroups.PLANNED_MAINTENANCE:return"lab_profile";case NotificationGroups.SERVICE_TICKETS:return"dvr";case NotificationGroups.INCIDENTS:return"emergency_home";case NotificationGroups.DCIM_ALERTS:return"public";default:return"sync_saved_locally"}}render(){var t;return html`<div class="relative bg-white-gp notification-item"><div class="${"unread"===(null==(t=this.notificaiton)?void 0:t.status)?"notification-item-unread":"notification-item-read"}"><ix-icon icon="${this.GetNotificationIcon()}" class="${"unread"===(null==(t=this.notificaiton)?void 0:t.status)?"blue-icon":"grey-icon"}" @click="${this.displayItem}">${this.GetNotificationIcon()}</ix-icon><div class="flex flex-col grow" @click="${this.displayItem}"><div class="grow text-base"><h2>${null==(t=this.notificaiton)?void 0:t.resourceType}</h2></div><div class="grow text-xs"><h3>${this.calculateDuration()}</h3></div></div><div><view-item-dialog ?open="${this.showModal}" .notificaiton="${this.notificaiton}" @view-item-dialog-closed="${()=>{this.showModal=!1}}"></view-item-dialog><confirmation-dialog ?open="${this.showDeleteConfirmation}" @on-confirm-selection="${this.confirmedDelete}" @confirm-dialog-closed="${()=>{this.showModal=!1}}" textMessage="Are you sure you want to delete this notification?"></confirmation-dialog></div><ix-icon-button @click="${this.deleteItem}" icon="delete" class="${this.disabled?"grey-icon":"red-icon"}"></ix-icon-button></div></div>`}}),GroupedItem=(__decorate([property({type:Boolean})],NotificationItem.prototype,"disabled",void 0),__decorate([property({type:Object,attribute:!1})],NotificationItem.prototype,"notificaiton",void 0),__decorate([state()],NotificationItem.prototype,"showModal",void 0),__decorate([state()],NotificationItem.prototype,"showDeleteConfirmation",void 0),NotificationItem=__decorate([customElement("notification-item")],NotificationItem),class extends MobxLitElement{constructor(){super(...arguments),this.groupTitle="Group 1",this.iconName="public",this.childItems=NotificationsState.notifications,this.isOpen=!1,this.onClick=()=>{this.isOpen=!this.isOpen}}static get styles(){return[NotificationsStyle,baseTheme,TWStyles]}renderNotificationItems(){var t;return this.isOpen?void 0!==(null==(t=this.childItems)?void 0:t.length)&&0<(null==(t=this.childItems)?void 0:t.length)?html`<div class="notification-items-container">${null==(t=this.childItems)?void 0:t.map(t=>html`<notification-item .notificaiton="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`)}</div>`:html`<p class="m-0 pl-8 font-bold mr-4"><small style="padding-left:16px">No notifications yet.</small></p>`:html`${nothing}`}render(){var t;return html`<div class="group-container-row"><div class="flex items-center justify-between"><div class="flex items-center align-middle"><ix-icon-button icon="${this.isOpen?"arrow_drop_down":"arrow_right"}" @click="${this.onClick}"></ix-icon-button><ix-icon class="ix-icon-groups">${this.iconName}</ix-icon><p class="m-0 group-name font-bold pl-1">${this.groupTitle}</p><p class="m-0 pl-4">${null==(t=this.childItems)?void 0:t.length.toString().padStart(2,"0")}</p></div></div>${this.renderNotificationItems()}</div>`}}),GroupFilters=(__decorate([property({type:String,attribute:!0})],GroupedItem.prototype,"groupTitle",void 0),__decorate([property({type:String,attribute:!0})],GroupedItem.prototype,"iconName",void 0),__decorate([property({type:Array,attribute:!0})],GroupedItem.prototype,"childItems",void 0),__decorate([state()],GroupedItem.prototype,"isOpen",void 0),GroupedItem=__decorate([customElement("grouped-item")],GroupedItem),class extends MobxLitElement{static get styles(){return[NotificationsStyle,TWStyles,css`:host{--md-switch-state-layer-size:1rem;--md-switch-hover-handle-width:1rem;--md-switch-hover-handle-height:1rem;--md-switch-pressed-handle-width:1rem;--md-switch-pressed-handle-height:1rem;--md-switch-selected-handle-width:1.3rem;--md-switch-selected-handle-height:1.3rem;--md-switch-handle-width:0.5rem;--md-switch-handle-height:0.5rem;--md-switch-track-width:2.5rem;--md-switch-track-height:1rem}`]}onSwitchChange(t){var t=t.target,e=null==(e=t.attributes.getNamedItem("name"))?void 0:e.value;NotificationsState.setNotificationFilter(e,t.selected),this.requestUpdate()}render(){return html`<div class="flex flex-col items-start p-2"><div class="ix-switch-wrapper"><ix-switch name="${NotificationGroups.PLANNED_MAINTENANCE}" .selected="${NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.PLANNED_MAINTENANCE}</label></div><div class="ix-switch-wrapper"><ix-switch name="${NotificationGroups.SERVICE_TICKETS}" .selected="${NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.SERVICE_TICKETS}</label></div><div class="ix-switch-wrapper"><ix-switch name="${NotificationGroups.DCIM_ALERTS}" .selected="${NotificationsState.notificationFilters.SHOW_DCIM_ALERTS}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.DCIM_ALERTS}</label></div></div>`}}),DateFilters=(GroupFilters=__decorate([customElement("group-filters")],GroupFilters),class extends MobxLitElement{constructor(){super(...arguments),this.fromDate=isNullOrUndefinedOrEmpty(NotificationsState.dateFilters.FROM_DATE)?void 0:format(NotificationsState.dateFilters.FROM_DATE,DefaultDateFormat),this.toDate=isNullOrUndefinedOrEmpty(NotificationsState.dateFilters.TO_DATE)?void 0:format(NotificationsState.dateFilters.TO_DATE,DefaultDateFormat),this.maxDate=format(new Date,DefaultDateFormat),this.fromDateErrorText="",this.toDateErrorText=""}static get styles(){return[NotificationsStyle,baseTheme,elementTheme,TWStyles]}onFromDateChange(t){null===t||""===t?this.fromDate=void 0:(this.fromDate=t,void 0!==this.fromDate&&(this.fromDateErrorText=void 0))}onToDateChange(t){null===t||""===t?this.toDate=void 0:(this.toDate=t,void 0!==this.toDate&&(this.toDateErrorText=void 0))}onApplyDateFilter(t){if(t){if(void 0===this.toDate&&void 0!==this.fromDate)return void(this.toDateErrorText="Please select to date");if(void 0===this.fromDate&&void 0!==this.toDate)return void(this.fromDateErrorText="Please select from date");if(this.fromDate>this.toDate)return this.fromDateErrorText="From date cannot be later than To date.",void(this.fromDate=void 0);if(this.fromDateErrorText=void 0,this.toDate<this.fromDate)return this.toDateErrorText="To date cannot be earlier than From date.",void(this.toDate=void 0);this.toDateErrorText=void 0}t=t&&void 0===this.toDateErrorText&&void 0===this.fromDateErrorText,t&&(NotificationsState.setNotificationDateFilter(this.fromDate,this.toDate),this.requestUpdate()),t=new CustomEvent("on-selection",{detail:{returnValue:t},bubbles:!0,composed:!0});this.dispatchEvent(t)}clearDateFilters(){this.fromDate=void 0,this.toDate=void 0,this.fromDateErrorText=void 0,this.toDateErrorText=void 0}render(){return html`<div class="flex flex-col p-2"><div class="flex flex-row text-justify"><div class="grow items-center text-xl font-bold text-left p-2">Filter by Date</div><div class="flex flex-row items-center p-2" @click="${this.clearDateFilters}"><label class="grow text-sm text-right pr-1 cursor-pointer">Clear Filter</label><ix-icon-button appearance="default" icon="domain_verification_off" class="blue-icon"></ix-icon-button></div></div><ix-divider class="px-2"></ix-divider><div class="flex xl:flex-row lg:flex-col md:flex-col sm:flex-col justify-between item-center p-2"><div class="p-2"><ix-date .value="${this.fromDate}" max="${this.maxDate}" label="From" name="FromDate" .errorText="${this.fromDateErrorText}" .onChanged="${t=>this.onFromDateChange(t)}"></ix-date></div><div class="p-2"><ix-date .value="${this.toDate}" max="${this.maxDate}" label="To" name="ToDate" .errorText="${this.toDateErrorText}" .onChanged="${t=>this.onToDateChange(t)}"></ix-date></div></div><div class="flex flex-row justify-between p-2"><ix-button type="" target="" appearance="text" @click="${()=>this.onApplyDateFilter(!1)}">Cancel</ix-button><ix-button type="" target="" appearance="text" @click="${()=>this.onApplyDateFilter(!0)}">Filter List</ix-button></div></div>`}});__decorate([state()],DateFilters.prototype,"fromDate",void 0),__decorate([state()],DateFilters.prototype,"toDate",void 0),__decorate([state()],DateFilters.prototype,"maxDate",void 0),__decorate([state()],DateFilters.prototype,"fromDateErrorText",void 0),__decorate([state()],DateFilters.prototype,"toDateErrorText",void 0),DateFilters=__decorate([customElement("date-filters")],DateFilters);class IxNotifications extends MobxLitElement{constructor(){super(...arguments),this.showDrawer=!1,this.showGroupedView=!1,this.showFilters=!1,this.showDateFilters=!1,this.showMarkAllReadConfirmation=!1,this.baseApiUrl="",this.localStorageKey=""}async firstUpdated(){NotificationsState.baseApiUrl=this.baseApiUrl,NotificationsState.localStorageKey=this.localStorageKey,NotificationsState.ConstructApiClient()}connectedCallback(){super.connectedCallback(),window.addEventListener("account-switched",NotificationsState.NewApiClient),window.addEventListener("beforeunload",this.handleOnbeforeunload)}disconnectedCallback(){window.removeEventListener("account-switched",NotificationsState.NewApiClient),window.removeEventListener("beforeunload",this.handleOnbeforeunload),super.disconnectedCallback()}handleOnbeforeunload(t){NotificationsState.clearStoredNotificationsData()}toggleDrawer(){this.showDrawer=!this.showDrawer,this.showDrawer||(this.showFilters=!1,this.showDateFilters=!1)}renderUnReadCountText(){if(NotificationsState.unreadNotificationCount<=0)return html`${nothing}`;let t="";return t=99<NotificationsState.unreadNotificationCount?"99+":NotificationsState.unreadNotificationCount.toString(),html`<div class="unread rounded-full text-center text-white text-sm absolute icon-position -start-0">${t}</div>`}markAllread(){this.showMarkAllReadConfirmation=!0}confirmedMarkAllRead(t){if(t.detail.returnValue){var t=this.applyNotificationFilters(),i=null==t?void 0:t.filter(t=>t.status===NotificationStatus.UNREAD);if(0<i.length){let e=!0;null!=t&&t.forEach(t=>{NotificationsState.setNotificationReadStatus(t.id).then(t=>{e=e&&t})});t={State:!0===e?ApiCallState.SUCCESS:ApiCallState.ERROR,Message:!0===e?"Successfully marked all the notifications as read":"Error occurred while marking the notifications as read, Please try again"};this.showResultMessage(t,i[0].id),this.renderUnReadCountText(),this.requestUpdate()}}this.showMarkAllReadConfirmation=!1}showResultMessage(t,e){window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:e,content:html`<ix-message-toast toastId="${e}" .TMessageToast="${t.State.toLowerCase()}" forceClose>${t.Message}</ix-message-toast>`,autoClose:3e3,durationOut:3e3,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))}toggleGroupView(){this.showGroupedView=!this.showGroupedView}displayFilters(){this.showFilters=!this.showFilters}applyNotificationFilters(){var t=null==(t=NotificationsState.notifications)?void 0:t.filter(t=>t.resourceType===NotificationGroups.PLANNED_MAINTENANCE&&!0===NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE||t.resourceType===NotificationGroups.SERVICE_TICKETS&&!0===NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS||t.resourceType===NotificationGroups.DCIM_ALERTS&&!0===NotificationsState.notificationFilters.SHOW_DCIM_ALERTS||t.resourceType===NotificationGroups.INCIDENTS);return void 0===NotificationsState.dateFilters.FROM_DATE&&void 0===NotificationsState.dateFilters.TO_DATE?t:void 0===NotificationsState.dateFilters.FROM_DATE?t.filter(t=>differenceInDays(new Date(t.createdAt),NotificationsState.dateFilters.TO_DATE)<=0):void 0===NotificationsState.dateFilters.TO_DATE?t.filter(t=>0<=differenceInHours(new Date(t.createdAt),NotificationsState.dateFilters.FROM_DATE)):t.filter(t=>0<=differenceInHours(new Date(t.createdAt),NotificationsState.dateFilters.FROM_DATE)&&differenceInDays(new Date(t.createdAt),NotificationsState.dateFilters.TO_DATE)<=0)}displayDateFilters(){this.showDateFilters=!this.showDateFilters}renderGroupedView(){var t=this.applyNotificationFilters();return html`<div style="margin:0"><grouped-item groupTitle="${NotificationGroups.PLANNED_MAINTENANCE}" iconName="lab_profile" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.PLANNED_MAINTENANCE)}"></grouped-item><grouped-item groupTitle="${NotificationGroups.INCIDENTS}" iconName="emergency_home" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.INCIDENTS)}"></grouped-item><grouped-item groupTitle="${NotificationGroups.SERVICE_TICKETS}" iconName="dvr" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.SERVICE_TICKETS)}"></grouped-item><grouped-item groupTitle="${NotificationGroups.DCIM_ALERTS}" iconName="public" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.DCIM_ALERTS)}"></grouped-item></div>`}renderDefaultView(){var t=this.applyNotificationFilters(),e=t.filter(t=>0===differenceInDays(t.createdAt,new Date)),i=t.filter(t=>0!==differenceInDays(t.createdAt,new Date));return 0<(null==t?void 0:t.length)?html`<h3 class="grow">Latest</h3><div class="m-0 p-0">${0<e.length?null==e?void 0:e.map(t=>html`<notification-item .notificaiton="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`):this.renderNoResult()}</div><h3 class="grow">Earlier</h3><div>${0<i.length?null==i?void 0:i.map(t=>html`<notification-item .notificaiton="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`):this.renderNoResult()}</div>`:html`<p class="empty">No notifications yet.</p>`}renderNoResult(){return html`<p class="empty">No notifications yet.</p>`}handleCloseClick(t){this.showDateFilters=!1,this.showFilters=!1}handleContentScroll(t){null!==t&&t.detail.scrollTop+t.detail.clientHeight>=t.detail.scrollHeight&&NotificationsState.getNotifications()}manageFilterVisibility(t){t=t.composedPath();!this.showFilters||t.includes(this.groupFilters)||t.includes(this.groupFiltersButton)||(this.showFilters=!1),!this.showDateFilters||t.includes(this.dateFilters)||t.includes(this.dateFiltersButton)||(this.showDateFilters=!1)}render(){return html`<div class="relative"><ix-icon-button class="blue-icon" @click="${()=>this.toggleDrawer()}"><slot name="icon" slot="default"></slot></ix-icon-button>${this.renderUnReadCountText()}</div><confirmation-dialog ?open="${this.showMarkAllReadConfirmation}" @confirm-dialog-closed="${()=>{this.showMarkAllReadConfirmation=!1}}" @on-confirm-selection="${this.confirmedMarkAllRead}" textMessage="Are you sure you want to mark all notifications as read?"></confirmation-dialog><ix-drawer ?isVisible="${this.showDrawer}" .onClosed="${()=>this.toggleDrawer()}" animate-vertical hide-close @on-content-scroll="${this.handleContentScroll}" @click="${this.manageFilterVisibility}"><div class="flex flex-row justify-between grow py-2" slot="header"><h2 class="grow items-center notification-header">Notifications</h2><div class="flex flex-row justify-end grow items-center options"><ix-icon-button @click="${this.markAllread}" icon="markunread_mailbox" class="blue-icon"></ix-icon-button><ix-icon-button @click="${this.toggleGroupView}" icon="sort" class="blue-icon"></ix-icon-button><ix-icon-button @click="${this.displayFilters}" icon="list" class="blue-icon" id="group-filter-button"></ix-icon-button><div class="filter-dropdown-content ${this.showFilters?"active z-50":""}"><group-filters></group-filters></div><ix-icon-button @click="${this.displayDateFilters}" icon="calendar_month" class="blue-icon" id="date-filters-button"></ix-icon-button><div class="datefilter-dropdown-content ${this.showDateFilters?"active z-50":""}" @on-selection="${this.handleCloseClick}"><date-filters></date-filters></div></div></div><div slot="content">${this.showGroupedView?this.renderGroupedView():this.renderDefaultView()}</div></ix-drawer>`}}IxNotifications.styles=[TWStyles,NotificationsStyle],__decorate([query("group-filters")],IxNotifications.prototype,"groupFilters",void 0),__decorate([query("ix-icon-button#group-filter-button")],IxNotifications.prototype,"groupFiltersButton",void 0),__decorate([query("date-filters")],IxNotifications.prototype,"dateFilters",void 0),__decorate([query("ix-icon-button#date-filters-button")],IxNotifications.prototype,"dateFiltersButton",void 0),__decorate([state()],IxNotifications.prototype,"showDrawer",void 0),__decorate([state()],IxNotifications.prototype,"showGroupedView",void 0),__decorate([state()],IxNotifications.prototype,"showFilters",void 0),__decorate([state()],IxNotifications.prototype,"showDateFilters",void 0),__decorate([state()],IxNotifications.prototype,"showMarkAllReadConfirmation",void 0),__decorate([property({type:String})],IxNotifications.prototype,"baseApiUrl",void 0),__decorate([property({type:String})],IxNotifications.prototype,"localStorageKey",void 0),window.customElements.define("ix-notifications",IxNotifications);
|
|
1
|
+
import{__decorate}from"tslib";import{svg,css,html,nothing}from"lit";import{property,customElement,state,query}from"lit/decorators.js";import{MobxLitElement}from"@adobe/lit-mobx";import{format,subDays,parse,differenceInHours,formatDistance,differenceInDays}from"date-fns";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-drawer/ix-drawer.js";import"@digital-realty/ix-icon";import"@material/web/icon/icon.js";import{makeAutoObservable}from"mobx";import{makePersistable,isHydrated,hydrateStore,clearPersistedStore,getPersistedStore}from"mobx-persist-store";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-icon/ix-icon.js";import{elementTheme,baseTheme}from"@digital-realty/theme";import"@digital-realty/ix-toast/ix-message-toast.js";import{computePosition}from"@floating-ui/dom";import{unsafeSVG}from"lit/directives/unsafe-svg.js";import"@digital-realty/ix-switch/ix-switch.js";import"@digital-realty/ix-date/ix-date.js";import"@digital-realty/ix-divider/ix-divider.js";const viewList=svg`<svg viewBox="0 0 24 24"><path d="M3 9H7V5H3V9ZM7 14H3V10H7V14ZM7 19H3V15H7V19ZM20 14H8V10H20V14ZM8 19H20V15H8V19ZM8 9V5H20V9H8Z"/></svg>`,dcim=svg`<svg viewBox="0 0 24 24"><path d="M20 0C17.791 0 16 1.791 16 4C16 6.857 20 11 20 11C20 11 24 6.857 24 4C24 1.791 22.209 0 20 0ZM12 2C6.486 2 2 6.486 2 12C2 17.514 6.486 22 12 22C17.514 22 22 17.514 22 12C22 11.93 21.9912 11.862 21.9902 11.793C21.7532 12.059 21.5575 12.2677 21.4395 12.3887L19.6504 14.3047C19.4484 14.9657 19.1695 15.5919 18.8145 16.1699C18.4985 15.4819 17.806 15 17 15H16V13C16 12.447 15.552 12 15 12H9V10H10C10.552 10 11 9.553 11 9V7.02344L13.0156 7.00781C13.5986 7.00381 14.1175 6.74289 14.4805 6.33789C14.3145 5.89389 14.1875 5.445 14.1035 5L9.99219 5.03125C9.44319 5.03525 9 5.48225 9 6.03125V8H8C7.448 8 7 8.447 7 9V10.1855L4.98047 8.16797C6.34047 5.68697 8.977 4 12 4H14C14 3.397 14.0908 2.81658 14.2578 2.26758C13.5308 2.09858 12.777 2 12 2ZM20 2.57031C20.789 2.57031 21.4297 3.211 21.4297 4C21.4297 4.789 20.789 5.42969 20 5.42969C19.211 5.42969 18.5703 4.789 18.5703 4C18.5703 3.211 19.211 2.57031 20 2.57031ZM4.20703 10.2207L9 15.0137V16C9 17.103 9.897 18 11 18V19.9316C7.06 19.4366 4 16.072 4 12C4 11.388 4.07603 10.7947 4.20703 10.2207ZM10.7793 14H14V16C14 16.553 14.448 17 15 17H17V18.2344C15.875 19.1384 14.502 19.7417 13 19.9297V17C13 16.447 12.552 16 12 16H11V14.5996C11 14.3776 10.9123 14.174 10.7793 14Z"/></svg>`,plannedMaintenance=svg`<svg viewBox="0 0 24 24"><path d="M6 2C4.90575 2 4 2.90575 4 4V20C4 21.0943 4.90575 22 6 22H11V20H6V4H13V9H18V13H20V8L14 2H6ZM12 11V14H15C15 12.343 13.641 11.031 12 11ZM11 12C9.343 12 8 13.343 8 15C8 16.657 9.343 18 11 18C12.657 18 13.969 16.641 14 15H11V12ZM16 15V21H13C13 22.654 14.346 24 16 24H21C22.645 24 24 22.645 24 21V15H16ZM18 17H22V21C22 21.565 21.565 22 21 22C20.449 22 20 21.552 20 21H18V17Z"/></svg>`,trash=svg`<svg viewBox="0 0 24 24"><path d="M15.5 4H19V6H5V4H8.5L9.5 3H14.5L15.5 4ZM8 21C6.9 21 6 20.1 6 19V7H18V19C18 20.1 17.1 21 16 21H8Z"/></svg>`,sortCheck=(svg`<svg viewBox="0 0 24 24"><path d="M11 12C13.21 12 15 10.21 15 8C15 5.79 13.21 4 11 4C8.79 4 7 5.79 7 8C7 10.21 8.79 12 11 12ZM9 17L12 14.06C11.61 14.02 11.32 14 11 14C8.33 14 3 15.34 3 18V20H12L9 17ZM12 17L15.47 20.5L22 13.91L20.6 12.5L15.47 17.67L13.4 15.59L12 17Z"/></svg>`,svg`<svg viewbox="0 0 24 24"><path d="M 3,6 V 8 H 21 V 6 Z M 3,18 H 9 V 16 H 3 Z M 15,13 H 3 v -2 h 12 z"/><rect x="8" y="0.5" width="16" height="16" rx="8"/><path d="M 14.5,10.585 12.415,8.50001 11.705,9.20501 14.5,12 l 6,-5.99999 -0.705,-0.705 z" style="fill:#fff"/></svg>`),TWStyles=css`*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}::after,::before{--tw-content:''}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Open Sans,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::after,::before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.absolute{position:absolute}.relative{position:relative}.-start-0{inset-inline-start:0}.z-50{z-index:50}.m-0{margin:0}.mr-4{margin-right:1rem}.block{display:block}.inline{display:inline}.flex{display:flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.w-\\[100px\\]{width:100px}.w-\\[480px\\]{width:480px}.w-\\[580px\\]{width:580px}.w-\\[420px\\]{width:420px}.w-\\[0px\\]{width:0}.w-\\[280px\\]{width:280px}.flex-grow{flex-grow:1}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.resize{resize:both}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-between{justify-content:space-between}.text-wrap{text-wrap:wrap}.text-balance{text-wrap:balance}.rounded-full{border-radius:9999px}.border{border-width:1px}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68 / var(--tw-bg-opacity))}.p-0{padding:0}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-4{padding:1rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-16{padding-left:4rem;padding-right:4rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.px-8{padding-left:2rem;padding-right:2rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.pb-2{padding-bottom:.5rem}.pl-1{padding-left:.25rem}.pl-11{padding-left:2.75rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-8{padding-left:2rem}.pr-1{padding-right:.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-justify{text-align:justify}.align-top{vertical-align:top}.align-middle{vertical-align:middle}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-semibold{font-weight:600}.text-white{--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:150ms}@media (min-width:640px){.sm\\:flex-col{flex-direction:column}}@media (min-width:768px){.md\\:flex-col{flex-direction:column}}@media (min-width:1024px){.lg\\:flex-col{flex-direction:column}}@media (min-width:1280px){.xl\\:flex-row{flex-direction:row}}`;var NotificationStatus,NotificationGroups,SubGroups,ApiCallState;!function(t){t.READ="read",t.UNREAD="unread"}(NotificationStatus=NotificationStatus||{}),function(t){t.PLANNED_MAINTENANCE="Planned Maintenance",t.INCIDENTS="Incidents",t.DCIM_ALERTS="DCIM Alerts",t.SERVICE_TICKETS="Service Tickets"}(NotificationGroups=NotificationGroups||{}),function(t){t.Remote_Hands="Remote Hands",t.Deliveries="Deliveries",t.Removals="Removals",t.Facility_Access="Facility Access",t.Trouble_Ticket="Trouble Ticket",t.Customer_Care="Customer Care"}(SubGroups=SubGroups||{}),function(t){t.LOADING="Loading",t.ERROR="Error",t.SUCCESS="Success"}(ApiCallState=ApiCallState||{});const DefaultDateFormat="yyyy-MM-dd",DefaultDisplayDays=30,DefaultDateTimeFormat="yyyy-MM-dd HH:mm:ss",BASE_PATH="http://api.digitalrealty.com/notifications".replace(/\/+$/,"");class Configuration{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:BASE_PATH}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||querystring}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return"function"==typeof t?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return"function"==typeof t?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const DefaultConfig=new Configuration;class BaseAPI{constructor(t=DefaultConfig){this.configuration=t,this.fetchApi=async(t,e)=>{let i={url:t,init:e};for(const a of this.middleware)a.pre&&(i=await a.pre({fetch:this.fetchApi,...i})||i);let o=void 0;try{o=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(t){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:t,response:o?o.clone():void 0})||o);if(void 0===o)throw t instanceof Error?new FetchError(t,"The request failed and the interceptors did not return an alternative response"):t}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:i.url,init:i.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){var e=this.clone();return e.middleware=e.middleware.concat(...t),e}withPreMiddleware(...t){t=t.map(t=>({pre:t}));return this.withMiddleware(...t)}withPostMiddleware(...t){t=t.map(t=>({post:t}));return this.withMiddleware(...t)}isJsonMime(t){return!!t&&BaseAPI.jsonRegex.test(t)}async request(t,e){var{url:t,init:e}=await this.createFetchParams(t,e),t=await this.fetchApi(t,e);if(t&&200<=t.status&&t.status<300)return t;throw new ResponseError(t,"Response returned an error code")}async createFetchParams(t,e){let i=this.configuration.basePath+t.path;void 0!==t.query&&0!==Object.keys(t.query).length&&(i+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(t=>void 0===o[t]?delete o[t]:{});var a="function"==typeof e?e:async()=>e,r={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...r,...await a({init:r,context:t})};let n;n=!(isFormData(a.body)||a.body instanceof URLSearchParams||isBlob(a.body))&&this.isJsonMime(o["Content-Type"])?JSON.stringify(a.body):a.body;r={...a,body:n};return{url:i,init:r}}clone(){var t=new this.constructor(this.configuration);return t.middleware=this.middleware.slice(),t}}function isBlob(t){return"undefined"!=typeof Blob&&t instanceof Blob}function isFormData(t){return"undefined"!=typeof FormData&&t instanceof FormData}BaseAPI.jsonRegex=new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$","i");class ResponseError extends Error{constructor(t,e){super(e),this.response=t,this.name="ResponseError"}}class FetchError extends Error{constructor(t,e){super(e),this.cause=t,this.name="FetchError"}}class RequiredError extends Error{constructor(t,e){super(e),this.field=t,this.name="RequiredError"}}const COLLECTION_FORMATS={csv:",",ssv:" ",tsv:"\t",pipes:"|"};function exists(t,e){t=t[e];return null!=t}function querystring(e,i=""){return Object.keys(e).map(t=>querystringSingleKey(t,e[t],i)).filter(t=>0<t.length).join("&")}function querystringSingleKey(t,e,i=""){var o,a=i+(i.length?`[${t}]`:t);return e instanceof Array?(o=e.map(t=>encodeURIComponent(String(t))).join(`&${encodeURIComponent(a)}=`),encodeURIComponent(a)+"="+o):e instanceof Set?querystringSingleKey(t,Array.from(e),i):e instanceof Date?encodeURIComponent(a)+"="+encodeURIComponent(e.toISOString()):e instanceof Object?querystring(e,a):encodeURIComponent(a)+"="+encodeURIComponent(String(e))}class JSONApiResponse{constructor(t,e=t=>t){this.raw=t,this.transformer=e}async value(){return this.transformer(await this.raw.json())}}class VoidApiResponse{constructor(t){this.raw=t}async value(){}}function StatusFromJSON(t){return StatusFromJSONTyped(t)}function StatusFromJSONTyped(t,e){return t}function StatusToJSON(t){return t}function NotificationFromJSON(t){return NotificationFromJSONTyped(t)}function NotificationFromJSONTyped(t,e){return null==t?t:{id:exists(t,"id")?t.id:void 0,resourceType:exists(t,"resource_type")?t.resource_type:void 0,subGroup:exists(t,"sub_group")?t.sub_group:void 0,createdAt:exists(t,"created_at")?null===t.created_at?null:new Date(t.created_at):void 0,createdBy:exists(t,"created_by")?t.created_by:void 0,subject:exists(t,"subject")?t.subject:void 0,locations:exists(t,"locations")?t.locations:void 0,resourceId:exists(t,"resource_id")?t.resource_id:void 0,status:exists(t,"status")?StatusFromJSON(t.status):void 0,accountNumber:exists(t,"account_number")?t.account_number:void 0}}function GetNotifications200ResponseFromJSON(t){return GetNotifications200ResponseFromJSONTyped(t)}function GetNotifications200ResponseFromJSONTyped(t,e){return null==t?t:{self:exists(t,"self")?t.self:void 0,first:exists(t,"first")?t.first:void 0,prev:exists(t,"prev")?t.prev:void 0,next:exists(t,"next")?t.next:void 0,last:exists(t,"last")?t.last:void 0,items:t.items.map(NotificationFromJSON)}}function NotificationPatchFromJSON(t){return NotificationPatchFromJSONTyped(t)}function NotificationPatchFromJSONTyped(t,e){return null==t?t:{status:StatusFromJSON(t.status)}}function NotificationPatchToJSON(t){if(void 0!==t)return null===t?null:{status:StatusToJSON(t.status)}}function NotificationRequestToJSON(t){if(void 0!==t)return null===t?null:{resource_type:t.resourceType,sub_group:t.subGroup,recipients:t.recipients,account_number:t.accountNumber,locations:t.locations,resource_id:t.resourceId,subject:t.subject,created_at:void 0===t.createdAt?void 0:null===t.createdAt?null:t.createdAt.toISOString()}}class NotificationsApi extends BaseAPI{async createNotificationRaw(t,e){var i={"Content-Type":"application/json"},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications",method:"POST",headers:i,query:{},body:NotificationRequestToJSON(t.notificationRequest)},e));return new JSONApiResponse(o,t=>NotificationFromJSON(t))}async createNotification(t={},e){return(await this.createNotificationRaw(t,e)).value()}async deleteNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling deleteNotificationsById.");var i={},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:i,query:{}},e));return new VoidApiResponse(o)}async deleteNotificationsById(t,e){await this.deleteNotificationsByIdRaw(t,e)}async getNotificationsRaw(t,e){var i={},o=(void 0!==t.sort&&(i.sort=t.sort),void 0!==t.cursor&&(i.cursor=t.cursor),void 0!==t.resourceType&&(i.resource_type=t.resourceType),void 0!==t.accountNumber&&(i.account_number=t.accountNumber),void 0!==t.createdAfter&&(i.created_after=t.createdAfter.toISOString()),void 0!==t.createdBefore&&(i.created_before=t.createdBefore.toISOString()),void 0!==t.locationId&&(i.location_id=t.locationId),void 0!==t.subGroup&&(i.sub_group=t.subGroup),void 0!==t.status&&(i.status=t.status),{}),t=(t.prefer&&(o.Prefer=t.prefer.join(COLLECTION_FORMATS.csv)),this.configuration&&this.configuration.accessToken&&(t=await(0,this.configuration.accessToken)("bearerToken",[]))&&(o.Authorization="Bearer "+t),await this.request({path:"/notifications",method:"GET",headers:o,query:i},e));return new JSONApiResponse(t,t=>GetNotifications200ResponseFromJSON(t))}async getNotifications(t={},e){return(await this.getNotificationsRaw(t,e)).value()}async getNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling getNotificationsById.");var i={},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:i,query:{}},e));return new JSONApiResponse(o,t=>NotificationFromJSON(t))}async getNotificationsById(t,e){return(await this.getNotificationsByIdRaw(t,e)).value()}async patchNotificationsByIdRaw(t,e){if(null===t.id||void 0===t.id)throw new RequiredError("id","Required parameter requestParameters.id was null or undefined when calling patchNotificationsById.");var i={"Content-Type":"application/json"},o=(this.configuration&&this.configuration.accessToken&&(o=await(0,this.configuration.accessToken)("bearerToken",[]))&&(i.Authorization="Bearer "+o),await this.request({path:"/notifications/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PATCH",headers:i,query:{},body:NotificationPatchToJSON(t.notificationPatch)},e));return new JSONApiResponse(o,t=>NotificationPatchFromJSON(t))}async patchNotificationsById(t,e){return(await this.patchNotificationsByIdRaw(t,e)).value()}}const APIEndpointPrefixes={Notifications:"notifications"};class ApiClient{constructor(t){this.noInit=!1,this.configuration=t}get notificationsApi(){return new NotificationsApi(new Configuration({basePath:this.configuration.NotificationApiUrl+"/"+APIEndpointPrefixes.Notifications,headers:{Authorization:this.getAuthorization()}}))}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}const isNullOrUndefinedOrEmpty=t=>null==t||""===t,mapResourceTypeToNotificationGroups=t=>{switch(t.toLowerCase()){case"planned maintenance":return NotificationGroups.PLANNED_MAINTENANCE;case"incidents":return NotificationGroups.INCIDENTS;case"dcim alerts":return NotificationGroups.DCIM_ALERTS;case"service tickets":return NotificationGroups.SERVICE_TICKETS;default:return NotificationGroups.PLANNED_MAINTENANCE}},mapStringToNotificationStatus=t=>{switch(t.toLowerCase()){case"unread":return NotificationStatus.UNREAD;case"read":return NotificationStatus.READ;default:return NotificationStatus.UNREAD}},mapParametersToNotificationRequest=t=>({sort:"-created_at",cursor:t,prefer:[""]}),mapParametersToPatchNotificationRequest=(t,e)=>({id:t,notificationPatch:{status:e}}),mapParametersToDeleteNotificationRequest=t=>({id:t}),mapNotificationDataToNotification=t=>{var e;return{subject:null!=(e=t.subject)?e:"",id:t.id,accountNumber:null!=(e=t.accountNumber)?e:"",resourceType:mapResourceTypeToNotificationGroups(null!=(e=t.resourceType)?e:""),subGroup:null!=(e=t.subGroup)?e:"",resourceId:null!=(e=t.resourceId)?e:"",status:mapStringToNotificationStatus(null!=(e=t.status)?e:""),createdAt:isNullOrUndefinedOrEmpty(t.createdAt)?format(new Date,DefaultDateTimeFormat):format(t.createdAt,DefaultDateTimeFormat),createdBy:null!=(e=t.createdBy)?e:"",locations:null!=(e=t.locations)?e:[]}},mapNotificationResponseToNotifications=t=>t.map(t=>mapNotificationDataToNotification(t)),getNextPageCursorfromQueryParam=t=>{t=new URLSearchParams(t),t=t.has("cursor")?t.get("cursor"):"";return null!==t?t:""},handleError=async(e,t=!0)=>{if(e instanceof ResponseError&&400===e.response.status)try{var i=(await e.response.json())["detail"];t&&console.error(i)}catch(t){console.error(e)}else console.error(e)},getLocalStorageUser=t=>{t=localStorage.getItem(t);return t?JSON.parse(t):null},getUserAuthorization=t=>{return"Bearer "+(null==(t=getLocalStorageUser(t))?void 0:t.access_token)};class NotificationState{constructor(){this.apiClient={noInit:!0},this.baseApiUrl="",this.localStorageKey="",this.NewApiClient=()=>{this.apiClient=new ApiClient({NotificationApiUrl:this.baseApiUrl,getAuthorizationFn:()=>getUserAuthorization(this.localStorageKey)}),this.getNotifications()},this.nextPageCursor="",this.notifications=[],this.unreadNotificationCount=0,this.notificationFilters={SHOW_PLANNED_MAINTENANCE:!0,SHOW_SERVICE_TICKETS:!0,SHOW_DCIM_ALERTS:!0},this.selectedNotification={id:"",resourceType:NotificationGroups.PLANNED_MAINTENANCE,subGroup:"",subject:"",resourceId:"",locations:[],createdAt:"",accountNumber:"",createdBy:"",status:NotificationStatus.READ},this.dateFilters={FROM_DATE:subDays(new Date,DefaultDisplayDays),TO_DATE:new Date},makeAutoObservable(this),makePersistable(this,{name:"notification-state",properties:["notificationFilters","nextPageCursor"],storage:window.localStorage})}get isHydrated(){return isHydrated(this)}async hydrateStore(){await hydrateStore(this)}async clearStoredData(){await clearPersistedStore(this)}async getStoredData(){return getPersistedStore(this)}ConstructApiClient(){return this.apiClient.noInit?this.NewApiClient():this.apiClient}async clearStoredNotificationsData(){this.notifications=[],this.unreadNotificationCount=0,this.nextPageCursor=""}async setNotificationReadStatus(e){var t,i=await this.setNotificationAsRead(e.toString());return!0===await i&&(this.ReduceUnreadNotificationCount(),t=this.notifications.findIndex(t=>t.id===e),this.notifications[t].status=NotificationStatus.READ,this.selectedNotification=this.notifications[t]),i}async setNotificationDeleted(e){var t,i=await this.DeleteNotification(e.toString());return!0===i&&("unread"===(null==(t=this.notifications.find(t=>t.id===e))?void 0:t.status)&&this.ReduceUnreadNotificationCount(),t=this.notifications.findIndex(t=>t.id===e),this.notifications.splice(t,1)),{State:!0===i?ApiCallState.SUCCESS:ApiCallState.ERROR,Message:!0===i?"Successfully deleted the notificaion":"Error while deleting the notification"}}setNotificationDateFilter(t,e){this.dateFilters.FROM_DATE=void 0!==t?parse(t,DefaultDateFormat,new Date):void 0,this.dateFilters.TO_DATE=void 0!==e?parse(e,DefaultDateFormat,new Date):void 0}setNotificationFilter(t,e){switch(t){case NotificationGroups.PLANNED_MAINTENANCE:this.notificationFilters.SHOW_PLANNED_MAINTENANCE=e;break;case NotificationGroups.SERVICE_TICKETS:this.notificationFilters.SHOW_SERVICE_TICKETS=e;break;case NotificationGroups.DCIM_ALERTS:this.notificationFilters.SHOW_DCIM_ALERTS=e}}async getNotifications(){var t;void 0!==this.nextPageCursor&&(t=await(null==(t=this.apiClient)?void 0:t.notificationsApi.getNotificationsRaw(mapParametersToNotificationRequest(getNextPageCursorfromQueryParam(this.nextPageCursor))).catch(t=>{handleError(t,!1)})))&&(t=await(null==t?void 0:t.value()),this.notifications=""===this.nextPageCursor?mapNotificationResponseToNotifications(null==t?void 0:t.items):this.notifications.concat(mapNotificationResponseToNotifications(null==t?void 0:t.items)),this.nextPageCursor=void 0===(null==t?void 0:t.next)||null==t?void 0:t.next,this.unreadNotificationCount=this.notifications.filter(t=>t.status===NotificationStatus.UNREAD).length)}async getNotificationsById(t){var e;let i;(i=t?await(null==(e=this.apiClient)?void 0:e.notificationsApi.getNotificationsById({id:t}).catch(t=>{handleError(t,!1)})):i)&&(this.selectedNotification=mapNotificationDataToNotification(i))}async setNotificationAsRead(t){var e;return!!t&&(await(null==(e=this.apiClient)?void 0:e.notificationsApi.patchNotificationsById(mapParametersToPatchNotificationRequest(t,"read")).catch(t=>(handleError(t,!1),!1))),!0)}async DeleteNotification(t){var e;let i=!1;return t&&await(null==(e=this.apiClient)?void 0:e.notificationsApi.deleteNotificationsById(mapParametersToDeleteNotificationRequest(t)).catch(t=>{handleError(t,!1),i=!1}).then(()=>{i=!0})),i}ReduceUnreadNotificationCount(){0<this.unreadNotificationCount&&--this.unreadNotificationCount}}const NotificationsState=new NotificationState,NotificationsStyle=css`.destructive-icon{color:var(--md-sys-color-error);--md-icon-button-icon-color:var(--md-sys-color-error);--md-sys-color-on-surface-variant:var(--md-sys-color-error)}.destructive-icon path{fill:var(--md-sys-color-error)}.active-icon{color:var(--ix-sys-primary);--md-icon-button-icon-color:var(--ix-sys-primary);--md-sys-color-on-surface-variant:var(--ix-sys-primary)}.active-icon path{fill:var(--ix-sys-primary)}.inactive-icon{color:var(--ix-font-color);--md-icon-button-icon-color:var(--ix-font-color);--md-sys-color-on-surface-variant:var(--ix-font-color);cursor:default;opacity:.6}.inactive-icon path{fill:var(--ix-font-color);opacity:.6}ix-icon-button.sharp{--md-icon-font:'Material Symbols Sharp'!important}.notification-item-read,.notification-item-unread{position:relative;display:flex;flex-direction:row;flex-grow:1;padding:.5rem .75rem 1rem 1rem;background-color:#fff;font-weight:700;cursor:pointer;align-items:center;padding-left:14px}.notification-item-read{border-left:3px solid transparent}.notification-item-unread{border-left:3px solid var(--ix-button-confirm-color)}.notification-item-read:hover,.notification-item-unread:hover{cursor:pointer;background-color:rgba(0,0,0,.04)}.group-container-row{display:block;font-size:12px;padding:12px 0 12px 0;margin-top:0;margin-bottom:0;border-bottom:#e1e4e8 inset 1px;color:var(--md-sys-text-color-primary);font-weight:400;font-size:15px;line-height:20px;letter-spacing:.15px}.group-name{line-height:24px;color:var(--md-sys-text-color-primary)}.group-item-name{display:grid;grid-template-columns:1fr 20%;gap:16px;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex-grow:1;padding-top:5px}.notification-items-container{padding:0}.ix-icon-groups{--ix-icon-font-size:32px;--ix-icon-line-height:32px}.ix-icon-groups ix-icon{color:var(--md-sys-text-color-primary);opacity:.6}.ix-icon-groups ix-icon path{fill:var(--md-sys-text-color-primary)}:host{--ix-drawer-border-radius:0;--ix-drawer-padding:0;--ix-draw-width-sm:50vw;--ix-draw-width-lg:30vw}.ix-switch-hover{width:100%}.ix-switch-hover:hover{background-color:rgba(123,160,238,.1)}.ix-switch-wrapper{margin:4px;padding:4px;display:flex;column-gap:.75rem;align-items:center}ix-switch{--md-switch-selected-handle-color:var(--ix-sys-primary);--md-switch-selected-pressed-handle-color:var(--ix-sys-primary);--md-switch-selected-hover-handle-color:var(--ix-sys-primary);--md-switch-selected-focus-handle-color:var(--ix-sys-primary);--md-switch-selected-track-color:#7ba0ee;--md-switch-selected-pressed-track-color:#7ba0ee;--md-switch-selected-hover-track-color:#7ba0ee;--md-switch-selected-focus-track-color:#7ba0ee;--md-switch-track-height:14px;--md-switch-track-width:36px;--md-switch-track-outline-width:0;--md-switch-handle-color:white;--md-switch-pressed-handle-color:white;--md-switch-hover-handle-color:white;--md-switch-focus-handle-color:white;--md-switch-handle-width:20px;--md-switch-handle-height:20px;display:flex}.datefilter-dropdown-content,.filter-dropdown-content{display:none;position:absolute;right:5%;top:3rem;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:3;transition:box-shadow .3s cubic-bezier(.4,0,.2,1) 0s;border-radius:3px;box-shadow:rgba(0,0,0,.2) 0 5px 5px -3px,rgba(0,0,0,.14) 0 8px 10px 1px,rgba(0,0,0,.12) 0 3px 14px 2px;background-color:#fff}.filter-dropdown-content.active{display:inline}.datefilter-dropdown-content.active{display:inline}.modal-text-blue{color:var(--ix-sys-primary);padding-left:1.8rem;font-weight:700}.unread{font-family:'Open Sans',sans-serif;padding:0 5px;font-size:12px;line-height:16px;left:22px;top:0;background:var(--ix-button-cancel-color,#db0028)}.notification-header{font-family:'Red Hat Display',sans-serif;padding:20px 16px;font-weight:770;font-size:20px;line-height:24px}h2{font-family:'Open Sans',sans-serif}h3{font-family:'Open Sans',sans-serif;font-size:16px;font-weight:400;line-height:20px;letter-spacing:.15px;text-align:left;padding:8px 16px}.empty{margin:8px 0 8px 16px;font-family:"Open Sans",sans-serif;font-style:normal;font-size:12px;line-height:16px;letter-spacing:.4px;color:#092241;font-weight:400}.notifification-item ix-icon-button{padding:12px}.options{padding-right:1rem;position:relative}.notification-tooltip{transform:translateX(-100%);background-color:#040d19;white-space:nowrap;font-size:.75rem;z-index:999;color:#fff}`;let ConfirmationDialog=class extends MobxLitElement{constructor(){super(...arguments),this.textMessage="Are you sure?",this.open=!1,this.dialogClosed=()=>{this.dispatchEvent(new CustomEvent("confirm-dialog-closed"))}}static get styles(){return[NotificationsStyle,elementTheme,baseTheme,TWStyles]}onClick(t){t=new CustomEvent("on-confirm-selection",{detail:{returnValue:t},bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return html`<ix-dialog ?open="${this.open}" class="w-[580px]" @closed="${this.dialogClosed}"><div slot="headline"><div class="p-4 text-xl font-bold">${this.textMessage}</div></div><div slot="actions"><div class="flex flex-row justify-end p-1"><ix-button name="cancel" appearance="text" @click="${()=>this.onClick(!1)}">DISMISS</ix-button><ix-button name="confirm" appearance="text" @click="${()=>this.onClick(!0)}">YES</ix-button></div></div></ix-dialog>`}},ViewItemDialog=(__decorate([property({type:String,attribute:!0})],ConfirmationDialog.prototype,"textMessage",void 0),__decorate([property({type:Boolean,attribute:!0})],ConfirmationDialog.prototype,"open",void 0),ConfirmationDialog=__decorate([customElement("confirmation-dialog")],ConfirmationDialog),class extends MobxLitElement{constructor(){super(...arguments),this.notification={},this.open=!1,this.dialogClosed=()=>{this.dispatchEvent(new CustomEvent("view-item-dialog-closed"))}}static get styles(){return[NotificationsStyle,elementTheme,TWStyles]}getUrl(){var t=this.notification.resourceId;switch(this.notification.resourceType){case NotificationGroups.PLANNED_MAINTENANCE:return"/service-management/reports";case NotificationGroups.SERVICE_TICKETS:switch(this.notification.subGroup){case SubGroups.Remote_Hands:return"/service-management/service-tickets/remote-hands/"+t;case SubGroups.Customer_Care:return"/service-management/service-tickets/customer-care/"+t;case SubGroups.Deliveries:return`/service-management/service-tickets/${SubGroups.Deliveries}/`+t;case SubGroups.Facility_Access:return"/service-management/service-tickets/facility-access/"+t;case SubGroups.Removals:return"/service-management/service-tickets/removals/"+t;case SubGroups.Trouble_Ticket:return"/service-management/service-tickets/trouble-tickets/"+t;default:return""}case NotificationGroups.INCIDENTS:return"/service-management/incidents/"+t;case NotificationGroups.DCIM_ALERTS:return"/dcim/"+t;default:return""}}getLocation(){return void 0===this.notification.locations||this.notification.locations.length<1?"":1<this.notification.locations.length?"Multiple Locations":this.notification.locations[0]}render(){return html`<ix-dialog ?open="${this.open}" class="w-[420px]" @closed="${this.dialogClosed}"><div slot="headline" class="px-8"><div class="flex flex-col flex-start"><div class="text-xl font-bold py-2 text-balance">${this.notification.resourceType}</div><div class="text-sm font-bold py-2 text-balance">${this.notification.subGroup}</div></div></div><form class="px-8" slot="content" id="form-id" method="dialog"><div class="flex flex-row py-1"><div class="w-[100px] block">Subject</div><div class="w-[280px] font-semibold text-wrap flex flex-start">${this.notification.subject}</div></div><div class="flex flex-row py-1"><div class="w-[100px] block">Create Date</div><div class="w-[280px] font-semibold flex">${format(this.notification.createdAt,"dd/MM/yyyy HH:mm:ss")}</div></div><div class="flex flex-row py-1"><div class="w-[100px] block">Site</div><div class="font-semibold">${this.getLocation()}</div></div></form><div slot="actions" class="flex flex-row flex-end px-8 py-8"><button form="form-id" class="modal-text-blue">CLOSE</button> <a href="${this.getUrl()}" class="modal-text-blue">VIEW RECORD</a></div></ix-dialog>`}}),NotificationTooltip=(__decorate([property({type:Object,attribute:!1})],ViewItemDialog.prototype,"notification",void 0),__decorate([property({type:Boolean,attribute:!0})],ViewItemDialog.prototype,"open",void 0),ViewItemDialog=__decorate([customElement("view-item-dialog")],ViewItemDialog),class extends MobxLitElement{static get styles(){return[NotificationsStyle,baseTheme,TWStyles]}render(){return html`<div class="notification-tooltip z-[999] hidden rounded absolute p-2 white-text"></div>`}});function getNotificationTooltip(){var t;return null==(t=null==(t=null==(t=null==(t=document.querySelector("ix-notifications"))?void 0:t.shadowRoot)?void 0:t.querySelector("notification-tooltip"))?void 0:t.shadowRoot)?void 0:t.querySelector(".notification-tooltip")}function handleMouseOut(){var t=getNotificationTooltip();t&&(t.style.display="none",t.innerHTML="")}function handleMouseOver(t,i){const o=getNotificationTooltip();o&&(t=t.currentTarget,computePosition(t,o,{placement:"bottom-end"}).then(({x:t,y:e})=>{o.innerHTML=i,o.style.display="block",o.style.left=t+"px",o.style.top=e+12+"px"}))}NotificationTooltip=__decorate([customElement("notification-tooltip")],NotificationTooltip);let NotificationItem=class extends MobxLitElement{constructor(){super(...arguments),this.disabled=!1,this.notification={},this.showModal=!1,this.showDeleteConfirmation=!1}static get styles(){return[NotificationsStyle,elementTheme,TWStyles,css`.notification-item-read h2{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:400;line-height:16px;letter-spacing:.4px;text-align:left}.notification-item-unread h2{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:700;line-height:16px;letter-spacing:.4px;text-align:left}h3{font-family:'Open Sans',sans-serif;font-size:12px;font-weight:400;line-height:16px;letter-spacing:.4px;text-align:left;color:rgba(9,34,65,.6);padding:0}ix-icon{--ix-icon-font-size:24px;--ix-icon-line-height:24px;color:var(--md-sys-text-color-primary)}.notification-item-read>ix-icon:first-child,.notification-item-unread>ix-icon:first-child{margin-right:12px}`]}displayItem(){this.notification.status===NotificationStatus.UNREAD&&NotificationsState.setNotificationReadStatus(this.notification.id),this.showModal=!0}deleteItem(){this.disabled||(this.showDeleteConfirmation=!0)}confirmedDelete(t){t.detail.returnValue&&NotificationsState.setNotificationDeleted(this.notification.id).then(t=>{this.showDeleteResultMessage(t,this.notification.id)}),this.showDeleteConfirmation=!1}showDeleteResultMessage(t,e){window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:e,content:html`<ix-message-toast toastId="${e}" .TMessageToast="${t.State.toLowerCase()}" forceClose>${t.Message}</ix-message-toast>`,autoClose:2e3,durationOut:2e3,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))}calculateDuration(){return void 0!==this.notification.createdAt?differenceInHours(new Date,this.notification.createdAt)<24?formatDistance(this.notification.createdAt,new Date,{addSuffix:!0}):format(this.notification.createdAt,DefaultDateTimeFormat):"N/A"}getNotificationIcon(){switch(this.notification.resourceType){case NotificationGroups.PLANNED_MAINTENANCE:return plannedMaintenance;case NotificationGroups.SERVICE_TICKETS:return"sync_saved_locally";case NotificationGroups.INCIDENTS:return"report";case NotificationGroups.DCIM_ALERTS:return dcim;default:return"sync_saved_locally"}}getNotificationTitle(){var t;switch(this.notification.resourceType){case NotificationGroups.PLANNED_MAINTENANCE:return"Planned Site Maintenance";case NotificationGroups.SERVICE_TICKETS:return`${null==(t=this.notification)?void 0:t.subGroup} Service Ticket Update`;case NotificationGroups.INCIDENTS:return"Emergency Repair";case NotificationGroups.DCIM_ALERTS:return"DCIM Alert";default:return"sync_saved_locally"}}render(){var t;return html`<div class="relative bg-white-gp notification-item"><div class="${"unread"===(null==(t=this.notification)?void 0:t.status)?"notification-item-unread":"notification-item-read"}"><ix-icon icon="${this.getNotificationIcon()}" class="${"unread"===(null==(t=this.notification)?void 0:t.status)?"active-icon":"inactive-icon"}" @click="${this.displayItem}">${this.getNotificationIcon()}</ix-icon><div class="flex flex-col grow" @click="${this.displayItem}"><div class="grow text-base"><h2>${this.getNotificationTitle()}</h2></div><div class="grow text-xs"><h3>${this.calculateDuration()}</h3></div></div><div><view-item-dialog ?open="${this.showModal}" .notification="${this.notification}" @view-item-dialog-closed="${()=>{this.showModal=!1}}"></view-item-dialog><confirmation-dialog ?open="${this.showDeleteConfirmation}" @on-confirm-selection="${this.confirmedDelete}" @confirm-dialog-closed="${()=>{this.showModal=!1}}" textMessage="Are you sure you want to delete this notification?"></confirmation-dialog></div><ix-icon-button @click="${this.deleteItem}" @mouseover="${t=>handleMouseOver(t,this.disabled?"Emergency Repair Notification cannot be removed":"Remove Notification")}" @mouseout="${handleMouseOut}" ?disabled="${this.disabled}"><ix-icon slot="default" class="${this.disabled?"inactive-icon":"destructive-icon"}">${trash}</ix-icon></ix-icon-button></div></div>`}},GroupedItem=(__decorate([property({type:Boolean})],NotificationItem.prototype,"disabled",void 0),__decorate([property({type:Object,attribute:!1})],NotificationItem.prototype,"notification",void 0),__decorate([state()],NotificationItem.prototype,"showModal",void 0),__decorate([state()],NotificationItem.prototype,"showDeleteConfirmation",void 0),NotificationItem=__decorate([customElement("notification-item")],NotificationItem),class extends MobxLitElement{constructor(){super(...arguments),this.groupTitle="Group 1",this.groupIcon="public",this.childItems=NotificationsState.notifications,this.isOpen=!1,this.onClick=()=>{this.isOpen=!this.isOpen}}static get styles(){return[NotificationsStyle,baseTheme,TWStyles]}renderNotificationItems(){var t;return this.isOpen?void 0!==(null==(t=this.childItems)?void 0:t.length)&&0<(null==(t=this.childItems)?void 0:t.length)?html`<div class="notification-items-container">${null==(t=this.childItems)?void 0:t.map(t=>html`<notification-item .notification="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`)}</div>`:html`<p class="m-0 pl-8 font-bold mr-4"><small style="padding-left:16px"><strong>No notifications yet.</strong></small></p>`:html`${nothing}`}render(){var t;return html`<div class="group-container-row"><div class="flex items-center justify-between"><div class="flex items-center align-middle"><ix-icon-button icon="${this.isOpen?"arrow_drop_down":"arrow_right"}" @click="${this.onClick}"></ix-icon-button><ix-icon slot="default" class="ix-icon-groups">${unsafeSVG(this.groupIcon)}</ix-icon><p class="m-0 group-name font-bold pl-1">${this.groupTitle}</p><p class="m-0 pl-4">${null==(t=this.childItems)?void 0:t.length.toString().padStart(2,"0")}</p></div></div>${this.renderNotificationItems()}</div>`}}),GroupFilters=(__decorate([property({type:String,attribute:!0})],GroupedItem.prototype,"groupTitle",void 0),__decorate([property({type:String,attribute:!0})],GroupedItem.prototype,"groupIcon",void 0),__decorate([property({type:Array,attribute:!0})],GroupedItem.prototype,"childItems",void 0),__decorate([state()],GroupedItem.prototype,"isOpen",void 0),GroupedItem=__decorate([customElement("grouped-item")],GroupedItem),class extends MobxLitElement{static get styles(){return[NotificationsStyle,TWStyles,css`:host{--md-switch-state-layer-size:1rem;--md-switch-hover-handle-width:1rem;--md-switch-hover-handle-height:1rem;--md-switch-pressed-handle-width:1rem;--md-switch-pressed-handle-height:1rem;--md-switch-selected-handle-width:1.3rem;--md-switch-selected-handle-height:1.3rem;--md-switch-handle-width:0.5rem;--md-switch-handle-height:0.5rem;--md-switch-track-width:2.5rem;--md-switch-track-height:1rem}`]}onSwitchChange(t){var t=t.target,e=null==(e=t.attributes.getNamedItem("name"))?void 0:e.value;NotificationsState.setNotificationFilter(e,t.selected),this.requestUpdate()}render(){return html`<div class="flex flex-col items-start py-2"><div class="ix-switch-hover"><div class="ix-switch-wrapper p-2"><ix-switch name="${NotificationGroups.PLANNED_MAINTENANCE}" selected="${NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.PLANNED_MAINTENANCE}</label></div></div><div class="ix-switch-hover"><div class="ix-switch-wrapper p-2"><ix-switch name="${NotificationGroups.SERVICE_TICKETS}" selected="${NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.SERVICE_TICKETS}</label></div></div><div class="ix-switch-hover"><div class="ix-switch-wrapper p-2"><ix-switch name="${NotificationGroups.DCIM_ALERTS}" selected="${NotificationsState.notificationFilters.SHOW_DCIM_ALERTS}" @change="${this.onSwitchChange}"></ix-switch><label class="pl-1">${NotificationGroups.DCIM_ALERTS}</label></div></div></div>`}}),DateFilters=(GroupFilters=__decorate([customElement("group-filters")],GroupFilters),class extends MobxLitElement{constructor(){super(...arguments),this.fromDate=isNullOrUndefinedOrEmpty(NotificationsState.dateFilters.FROM_DATE)?void 0:format(NotificationsState.dateFilters.FROM_DATE,DefaultDateFormat),this.toDate=isNullOrUndefinedOrEmpty(NotificationsState.dateFilters.TO_DATE)?void 0:format(NotificationsState.dateFilters.TO_DATE,DefaultDateFormat),this.maxDate=format(new Date,DefaultDateFormat),this.fromDateErrorText="",this.toDateErrorText=""}static get styles(){return[NotificationsStyle,baseTheme,elementTheme,TWStyles]}onFromDateChange(t){null===t||""===t?this.fromDate=void 0:(this.fromDate=t,void 0!==this.fromDate&&(this.fromDateErrorText=void 0))}onToDateChange(t){null===t||""===t?this.toDate=void 0:(this.toDate=t,void 0!==this.toDate&&(this.toDateErrorText=void 0))}onApplyDateFilter(t){if(t){if(void 0===this.toDate&&void 0!==this.fromDate)return void(this.toDateErrorText="Please select to date");if(void 0===this.fromDate&&void 0!==this.toDate)return void(this.fromDateErrorText="Please select from date");if(this.fromDate>this.toDate)return this.fromDateErrorText="From date cannot be later than To date.",void(this.fromDate=void 0);if(this.fromDateErrorText=void 0,this.toDate<this.fromDate)return this.toDateErrorText="To date cannot be earlier than From date.",void(this.toDate=void 0);this.toDateErrorText=void 0}t=t&&void 0===this.toDateErrorText&&void 0===this.fromDateErrorText,t&&(NotificationsState.setNotificationDateFilter(this.fromDate,this.toDate),this.requestUpdate()),t=new CustomEvent("on-selection",{detail:{returnValue:t},bubbles:!0,composed:!0});this.dispatchEvent(t)}clearDateFilters(){this.fromDate=void 0,this.toDate=void 0,this.fromDateErrorText=void 0,this.toDateErrorText=void 0}render(){return html`<div class="flex flex-col p-2"><div class="flex flex-row text-justify"><div class="grow items-center text-xl font-bold text-left p-2">Filter by Date</div><div class="flex flex-row items-center p-2" @click="${this.clearDateFilters}"><label class="grow text-sm text-right pr-1 cursor-pointer">Clear Filter</label><ix-icon-button appearance="default" icon="domain_verification_off" class="active-icon"></ix-icon-button></div></div><ix-divider class="px-2"></ix-divider><div class="flex xl:flex-row lg:flex-col md:flex-col sm:flex-col justify-between item-center p-2"><div class="p-2"><ix-date .value="${this.fromDate}" max="${this.maxDate}" label="From" name="FromDate" .errorText="${this.fromDateErrorText}" .onChanged="${t=>this.onFromDateChange(t)}"></ix-date></div><div class="p-2"><ix-date .value="${this.toDate}" max="${this.maxDate}" label="To" name="ToDate" .errorText="${this.toDateErrorText}" .onChanged="${t=>this.onToDateChange(t)}"></ix-date></div></div><div class="flex flex-row justify-between p-2"><ix-button type="" target="" appearance="text" @click="${()=>this.onApplyDateFilter(!1)}">Cancel</ix-button><ix-button type="" target="" appearance="text" @click="${()=>this.onApplyDateFilter(!0)}">Filter List</ix-button></div></div>`}});__decorate([state()],DateFilters.prototype,"fromDate",void 0),__decorate([state()],DateFilters.prototype,"toDate",void 0),__decorate([state()],DateFilters.prototype,"maxDate",void 0),__decorate([state()],DateFilters.prototype,"fromDateErrorText",void 0),__decorate([state()],DateFilters.prototype,"toDateErrorText",void 0),DateFilters=__decorate([customElement("date-filters")],DateFilters);class IxNotifications extends MobxLitElement{constructor(){super(...arguments),this.showDrawer=!1,this.showGroupedView=!1,this.showFilters=!1,this.showDateFilters=!1,this.showMarkAllReadConfirmation=!1,this.baseApiUrl="",this.localStorageKey=""}async firstUpdated(){NotificationsState.baseApiUrl=this.baseApiUrl,NotificationsState.localStorageKey=this.localStorageKey,NotificationsState.ConstructApiClient()}connectedCallback(){super.connectedCallback(),window.addEventListener("account-switched",NotificationsState.NewApiClient),window.addEventListener("beforeunload",this.handleOnbeforeunload)}disconnectedCallback(){window.removeEventListener("account-switched",NotificationsState.NewApiClient),window.removeEventListener("beforeunload",this.handleOnbeforeunload),super.disconnectedCallback()}handleOnbeforeunload(t){NotificationsState.clearStoredNotificationsData()}toggleDrawer(){this.showDrawer=!this.showDrawer,this.showDrawer||(this.showFilters=!1,this.showDateFilters=!1)}renderUnReadCountText(){if(NotificationsState.unreadNotificationCount<=0)return html`${nothing}`;let t="";return t=99<NotificationsState.unreadNotificationCount?"99+":NotificationsState.unreadNotificationCount.toString(),html`<div class="unread rounded-full text-center text-white text-sm absolute icon-position -start-0">${t}</div>`}markAllread(){0<NotificationsState.unreadNotificationCount&&(this.showMarkAllReadConfirmation=!0)}confirmedMarkAllRead(t){if(t.detail.returnValue){var t=this.applyNotificationFilters(),i=null==t?void 0:t.filter(t=>t.status===NotificationStatus.UNREAD);if(0<i.length){let e=!0;null!=t&&t.forEach(t=>{NotificationsState.setNotificationReadStatus(t.id).then(t=>{e=e&&t})});t={State:!0===e?ApiCallState.SUCCESS:ApiCallState.ERROR,Message:!0===e?"Successfully marked all the notificaions as read":"Error while marking the notifications read, Please try again"};this.showResultMessage(t,i[0].id),this.renderUnReadCountText(),this.requestUpdate()}}this.showMarkAllReadConfirmation=!1}showResultMessage(t,e){window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:e,content:html`<ix-message-toast toastId="${e}" .TMessageToast="${t.State.toLowerCase()}" forceClose>${t.Message}</ix-message-toast>`,autoClose:3e3,durationOut:3e3,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))}toggleGroupView(){this.showGroupedView=!this.showGroupedView}displayFilters(){this.showFilters=!this.showFilters}applyNotificationFilters(){var t=null==(t=NotificationsState.notifications)?void 0:t.filter(t=>t.resourceType===NotificationGroups.PLANNED_MAINTENANCE&&!0===NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE||t.resourceType===NotificationGroups.SERVICE_TICKETS&&!0===NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS||t.resourceType===NotificationGroups.DCIM_ALERTS&&!0===NotificationsState.notificationFilters.SHOW_DCIM_ALERTS||t.resourceType===NotificationGroups.INCIDENTS);return void 0!==NotificationsState.dateFilters.FROM_DATE&&void 0!==NotificationsState.dateFilters.TO_DATE?t.filter(t=>0<=differenceInHours(new Date(t.createdAt),NotificationsState.dateFilters.FROM_DATE)&&differenceInDays(new Date(t.createdAt),NotificationsState.dateFilters.TO_DATE)<=0):void 0!==NotificationsState.dateFilters.FROM_DATE&&void 0===NotificationsState.dateFilters.TO_DATE?t.filter(t=>0<=differenceInHours(new Date(t.createdAt),NotificationsState.dateFilters.FROM_DATE)):void 0===NotificationsState.dateFilters.FROM_DATE&&void 0!==NotificationsState.dateFilters.TO_DATE?t.filter(t=>differenceInDays(new Date(t.createdAt),NotificationsState.dateFilters.TO_DATE)<=0):t}displayDateFilters(){this.showDateFilters=!this.showDateFilters}renderGroupedView(){var t=this.applyNotificationFilters();return html`<div style="margin:0"><grouped-item groupTitle="Planned Site Maintenance" groupIcon="${plannedMaintenance.strings[0]}" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.PLANNED_MAINTENANCE)}"></grouped-item><grouped-item groupTitle="Emergency Repairs" groupIcon="report" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.INCIDENTS)}"></grouped-item><grouped-item groupTitle="Service Ticket Updates" groupIcon="sync_saved_locally" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.SERVICE_TICKETS)}"></grouped-item><grouped-item groupTitle="${NotificationGroups.DCIM_ALERTS}" groupIcon="${dcim.strings[0]}" .childItems="${null==t?void 0:t.filter(t=>t.resourceType===NotificationGroups.DCIM_ALERTS)}"></grouped-item></div>`}renderDefaultView(){var t=this.applyNotificationFilters(),e=t.filter(t=>0===differenceInDays(t.createdAt,new Date)),i=t.filter(t=>0!==differenceInDays(t.createdAt,new Date));return 0<(null==t?void 0:t.length)?html`<h3 class="grow">Today</h3><div class="m-0 p-0">${0<e.length?null==e?void 0:e.map(t=>html`<notification-item .notification="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`):this.renderNoResult()}</div><h3 class="grow">Earlier</h3><div>${0<i.length?null==i?void 0:i.map(t=>html`<notification-item .notification="${t}" ?disabled="${t.resourceType===NotificationGroups.INCIDENTS}"></notification-item>`):this.renderNoResult()}</div>`:html`<p class="empty"><strong>No notifications yet.</strong></p>`}renderNoResult(){return html`<p class="empty"><strong>No notifications yet.</strong></p>`}handleCloseClick(t){this.showDateFilters=!1,this.showFilters=!1}handleContentScroll(t){null!==t&&t.detail.scrollTop+t.detail.clientHeight>=t.detail.scrollHeight&&NotificationsState.getNotifications()}manageFilterVisibility(t){t=t.composedPath();!this.showFilters||t.includes(this.groupFilters)||t.includes(this.groupFiltersButton)||(this.showFilters=!1),!this.showDateFilters||t.includes(this.dateFilters)||t.includes(this.dateFiltersButton)||(this.showDateFilters=!1)}render(){return html`<notification-tooltip></notification-tooltip><div class="relative"><ix-icon-button class="active-icon" @click="${()=>this.toggleDrawer()}"><slot name="icon" slot="default"></slot></ix-icon-button>${this.renderUnReadCountText()}</div><confirmation-dialog ?open="${this.showMarkAllReadConfirmation}" @confirm-dialog-closed="${()=>{this.showMarkAllReadConfirmation=!1}}" @on-confirm-selection="${this.confirmedMarkAllRead}" textMessage="Are you sure you want to mark all notifications as read?"></confirmation-dialog><ix-drawer ?isVisible="${this.showDrawer}" .onClosed="${()=>this.toggleDrawer()}" animate-vertical hide-close @on-content-scroll="${this.handleContentScroll}" @click="${this.manageFilterVisibility}"><div class="flex flex-row justify-between grow py-2" slot="header"><h2 class="grow items-center notification-header">Notifications</h2><div class="flex flex-row justify-end grow items-center options"><ix-icon-button @click="${this.markAllread}" @mouseover="${t=>handleMouseOver(t,"Mark All Read")}" @mouseout="${handleMouseOut}" icon="markunread_mailbox" class="${NotificationsState.unreadNotificationCount<=0?"inactive-icon":"active-icon"}" .disabled="${NotificationsState.unreadNotificationCount<=0}" filledIcon="true"></ix-icon-button><ix-icon-button @click="${this.toggleGroupView}" @mouseover="${t=>handleMouseOver(t,"Sort by Type")}" @mouseout="${handleMouseOut}" class="active-icon" label="Sort by Type"><ix-icon slot="default">${this.showGroupedView?sortCheck:"sort"}</ix-icon></ix-icon-button><ix-icon-button @click="${this.displayFilters}" @mouseover="${t=>handleMouseOver(t,"Filter by Type")}" @mouseout="${handleMouseOut}" class="active-icon" id="group-filter-button" label="Filter by Type"><ix-icon slot="default">${viewList}</ix-icon></ix-icon-button><div class="filter-dropdown-content ${this.showFilters?"active z-50":""}"><group-filters></group-filters></div><ix-icon-button @click="${this.displayDateFilters}" @mouseover="${t=>handleMouseOver(t,"Filter by Date")}" @mouseout="${handleMouseOut}" icon="date_range" class="active-icon" filledIcon="true" id="date-filters-button" label="Filter by Date"></ix-icon-button><div class="datefilter-dropdown-content ${this.showDateFilters?"active z-50":""}" @on-selection="${this.handleCloseClick}"><date-filters></date-filters></div></div></div><div slot="content">${this.showGroupedView?this.renderGroupedView():this.renderDefaultView()}</div></ix-drawer>`}}IxNotifications.styles=[TWStyles,NotificationsStyle],__decorate([query("group-filters")],IxNotifications.prototype,"groupFilters",void 0),__decorate([query("ix-icon-button#group-filter-button")],IxNotifications.prototype,"groupFiltersButton",void 0),__decorate([query("date-filters")],IxNotifications.prototype,"dateFilters",void 0),__decorate([query("ix-icon-button#date-filters-button")],IxNotifications.prototype,"dateFiltersButton",void 0),__decorate([state()],IxNotifications.prototype,"showDrawer",void 0),__decorate([state()],IxNotifications.prototype,"showGroupedView",void 0),__decorate([state()],IxNotifications.prototype,"showFilters",void 0),__decorate([state()],IxNotifications.prototype,"showDateFilters",void 0),__decorate([state()],IxNotifications.prototype,"showMarkAllReadConfirmation",void 0),__decorate([property({type:String})],IxNotifications.prototype,"baseApiUrl",void 0),__decorate([property({type:String})],IxNotifications.prototype,"localStorageKey",void 0),window.customElements.define("ix-notifications",IxNotifications);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../src/models/notification.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ApiCallState,\n NotificationGroups,\n NotificationStatus,\n} from '../constants/notifications.js';\n\nexport type Notification = {\n id: string;\n resourceType: NotificationGroups;\n subGroup: string;\n subject: string;\n resourceId: string;\n locations: string[];\n createdAt: string;\n accountNumber: string;\n createdBy: string;\n status: NotificationStatus;\n};\n\nexport type ApiCallResult = {\n State: ApiCallState;\n Message: string
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../src/models/notification.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ApiCallState,\n NotificationGroups,\n NotificationStatus,\n} from '../constants/notifications.js';\n\nexport type Notification = {\n id: string;\n resourceType: NotificationGroups;\n subGroup: string;\n subject: string;\n resourceId: string;\n locations: string[];\n createdAt: string;\n accountNumber: string;\n createdBy: string;\n status: NotificationStatus;\n};\n\nexport type ApiCallResult = {\n State: ApiCallState;\n Message: string;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeAutoObservable } from 'mobx';
|
|
2
|
-
import { clearPersistedStore, getPersistedStore, hydrateStore, isHydrated, makePersistable } from 'mobx-persist-store';
|
|
2
|
+
import { clearPersistedStore, getPersistedStore, hydrateStore, isHydrated, makePersistable, } from 'mobx-persist-store';
|
|
3
3
|
import { parse, subDays } from 'date-fns';
|
|
4
4
|
import { NotificationGroups, NotificationStatus, DefaultDateFormat, DefaultDisplayDays, ApiCallState, } from '../constants/notifications.js';
|
|
5
5
|
import { ApiClient } from '../services/api-client.js';
|
|
@@ -45,10 +45,7 @@ class NotificationState {
|
|
|
45
45
|
makeAutoObservable(this);
|
|
46
46
|
makePersistable(this, {
|
|
47
47
|
name: 'notification-state',
|
|
48
|
-
properties: [
|
|
49
|
-
'notificationFilters',
|
|
50
|
-
'dateFilters'
|
|
51
|
-
],
|
|
48
|
+
properties: ['notificationFilters', 'nextPageCursor'],
|
|
52
49
|
storage: window.localStorage,
|
|
53
50
|
});
|
|
54
51
|
}
|
|
@@ -70,11 +67,11 @@ class NotificationState {
|
|
|
70
67
|
async clearStoredNotificationsData() {
|
|
71
68
|
this.notifications = [];
|
|
72
69
|
this.unreadNotificationCount = 0;
|
|
73
|
-
this.nextPageCursor =
|
|
70
|
+
this.nextPageCursor = '';
|
|
74
71
|
}
|
|
75
72
|
async setNotificationReadStatus(Id) {
|
|
76
73
|
const result = await this.setNotificationAsRead(Id.toString());
|
|
77
|
-
if (await result === true) {
|
|
74
|
+
if ((await result) === true) {
|
|
78
75
|
this.ReduceUnreadNotificationCount();
|
|
79
76
|
const itemIndex = this.notifications.findIndex(item => item.id === Id);
|
|
80
77
|
this.notifications[itemIndex].status = NotificationStatus.READ;
|
|
@@ -86,13 +83,16 @@ class NotificationState {
|
|
|
86
83
|
const result = await this.DeleteNotification(Id.toString());
|
|
87
84
|
if (result === true) {
|
|
88
85
|
const deleteditem = this.notifications.find(item => item.id === Id);
|
|
89
|
-
if ((deleteditem === null || deleteditem === void 0 ? void 0 : deleteditem.status)
|
|
86
|
+
if ((deleteditem === null || deleteditem === void 0 ? void 0 : deleteditem.status) === 'unread')
|
|
90
87
|
this.ReduceUnreadNotificationCount();
|
|
91
88
|
const itemIndex = this.notifications.findIndex(item => item.id === Id);
|
|
92
89
|
this.notifications.splice(itemIndex, 1);
|
|
93
90
|
}
|
|
94
|
-
return {
|
|
95
|
-
|
|
91
|
+
return {
|
|
92
|
+
State: result === true ? ApiCallState.SUCCESS : ApiCallState.ERROR,
|
|
93
|
+
Message: result === true
|
|
94
|
+
? 'Successfully deleted the notificaion'
|
|
95
|
+
: 'Error while deleting the notification',
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
setNotificationDateFilter(fromDate, toDate) {
|
|
@@ -124,7 +124,7 @@ class NotificationState {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
async getNotifications() {
|
|
127
|
-
var _a
|
|
127
|
+
var _a;
|
|
128
128
|
let result;
|
|
129
129
|
// this.nextPageCursor === undefined means Next page not available
|
|
130
130
|
if (this.nextPageCursor !== undefined) {
|
|
@@ -133,7 +133,6 @@ class NotificationState {
|
|
|
133
133
|
return undefined;
|
|
134
134
|
}));
|
|
135
135
|
if (result) {
|
|
136
|
-
this.unreadNotificationCount = Number((_b = result.raw.headers.get('x-total-unread-count')) !== null && _b !== void 0 ? _b : '0');
|
|
137
136
|
const responseResult = await (result === null || result === void 0 ? void 0 : result.value());
|
|
138
137
|
this.notifications =
|
|
139
138
|
this.nextPageCursor === ''
|
|
@@ -141,6 +140,7 @@ class NotificationState {
|
|
|
141
140
|
: this.notifications.concat(mapNotificationResponseToNotifications(responseResult === null || responseResult === void 0 ? void 0 : responseResult.items));
|
|
142
141
|
this.nextPageCursor =
|
|
143
142
|
(responseResult === null || responseResult === void 0 ? void 0 : responseResult.next) !== undefined ? responseResult === null || responseResult === void 0 ? void 0 : responseResult.next : undefined;
|
|
143
|
+
this.unreadNotificationCount = this.notifications.filter(notification => notification.status === NotificationStatus.UNREAD).length;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -175,7 +175,7 @@ class NotificationState {
|
|
|
175
175
|
await ((_a = this.apiClient) === null || _a === void 0 ? void 0 : _a.notificationsApi.deleteNotificationsById(mapParametersToDeleteNotificationRequest(id)).catch((e) => {
|
|
176
176
|
handleError(e, false);
|
|
177
177
|
result = false;
|
|
178
|
-
}).then((
|
|
178
|
+
}).then(() => {
|
|
179
179
|
result = true;
|
|
180
180
|
}));
|
|
181
181
|
}
|
|
@@ -183,7 +183,7 @@ class NotificationState {
|
|
|
183
183
|
}
|
|
184
184
|
ReduceUnreadNotificationCount() {
|
|
185
185
|
if (this.unreadNotificationCount > 0)
|
|
186
|
-
this.unreadNotificationCount
|
|
186
|
+
this.unreadNotificationCount -= 1;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
const NotificationsState = new NotificationState();
|