@digital-realty/ix-notifications 1.0.21 → 1.0.23
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 +4 -3
|
@@ -38,32 +38,38 @@ let GroupFilters = class GroupFilters extends MobxLitElement {
|
|
|
38
38
|
this.requestUpdate();
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return html ` <div class="flex flex-col items-start
|
|
42
|
-
<div class="ix-switch-
|
|
43
|
-
<ix-switch
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
return html ` <div class="flex flex-col items-start py-2">
|
|
42
|
+
<div class="ix-switch-hover">
|
|
43
|
+
<div class="ix-switch-wrapper p-2">
|
|
44
|
+
<ix-switch
|
|
45
|
+
name=${NotificationGroups.PLANNED_MAINTENANCE}
|
|
46
|
+
selected=${NotificationsState.notificationFilters
|
|
46
47
|
.SHOW_PLANNED_MAINTENANCE}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
@change=${this.onSwitchChange}
|
|
49
|
+
></ix-switch>
|
|
50
|
+
<label class="pl-1">${NotificationGroups.PLANNED_MAINTENANCE}</label>
|
|
51
|
+
</div>
|
|
50
52
|
</div>
|
|
51
|
-
<div class="ix-switch-
|
|
52
|
-
<ix-switch
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
<div class="ix-switch-hover">
|
|
54
|
+
<div class="ix-switch-wrapper p-2">
|
|
55
|
+
<ix-switch
|
|
56
|
+
name=${NotificationGroups.SERVICE_TICKETS}
|
|
57
|
+
selected=${NotificationsState.notificationFilters
|
|
55
58
|
.SHOW_SERVICE_TICKETS}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
@change=${this.onSwitchChange}
|
|
60
|
+
></ix-switch>
|
|
61
|
+
<label class="pl-1">${NotificationGroups.SERVICE_TICKETS}</label>
|
|
62
|
+
</div>
|
|
59
63
|
</div>
|
|
60
|
-
<div class="ix-switch-
|
|
61
|
-
<ix-switch
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
<div class="ix-switch-hover">
|
|
65
|
+
<div class="ix-switch-wrapper p-2">
|
|
66
|
+
<ix-switch
|
|
67
|
+
name=${NotificationGroups.DCIM_ALERTS}
|
|
68
|
+
selected=${NotificationsState.notificationFilters.SHOW_DCIM_ALERTS}
|
|
69
|
+
@change=${this.onSwitchChange}
|
|
70
|
+
></ix-switch>
|
|
71
|
+
<label class="pl-1">${NotificationGroups.DCIM_ALERTS}</label>
|
|
72
|
+
</div>
|
|
67
73
|
</div>
|
|
68
74
|
</div>`;
|
|
69
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-filters.js","sourceRoot":"","sources":["../../../src/components/notifications/group-filters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGlE,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,cAAc;IAC9C,MAAM,KAAK,MAAM;QACf,OAAO;YACL,kBAAkB;YAClB,QAAQ;YACR,GAAG,CAAA;;;;;;;;;;;;;;OAcF;SACF,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,CAAQ;;QACrB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAa,CAAC;QAC/B,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,0CAAE,KAAK,CAAC;QAEhE,kBAAkB,CAAC,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA
|
|
1
|
+
{"version":3,"file":"group-filters.js","sourceRoot":"","sources":["../../../src/components/notifications/group-filters.ts"],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AkB,CAAC,WAAW;uBAC1B,kBAAkB,CAAC,mBAAmB,CAAC,gBAAgB;sBACxD,IAAI,CAAC,cAAc;;gCAET,kBAAkB,CAAC,WAAW;;;WAGnD,CAAC;IACV,CAAC;CACF,CAAA;AAnEY,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAmExB;SAnEY,YAAY","sourcesContent":["import { html, css } from 'lit';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-switch/ix-switch.js';\nimport { TWStyles } from '../../tw.js';\nimport { NotificationsState } from '../../state/NotificationState.js';\nimport { NotificationGroups } from '../../constants/notifications.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\n\n@customElement('group-filters')\nexport class GroupFilters extends MobxLitElement {\n static get styles() {\n return [\n NotificationsStyle,\n TWStyles,\n css`\n :host {\n --md-switch-state-layer-size: 1rem;\n --md-switch-hover-handle-width: 1rem;\n --md-switch-hover-handle-height: 1rem;\n --md-switch-pressed-handle-width: 1rem;\n --md-switch-pressed-handle-height: 1rem;\n --md-switch-selected-handle-width: 1.3rem;\n --md-switch-selected-handle-height: 1.3rem;\n --md-switch-handle-width: 0.5rem;\n --md-switch-handle-height: 0.5rem;\n --md-switch-track-width: 2.5rem;\n --md-switch-track-height: 1rem;\n }\n `,\n ];\n }\n\n onSwitchChange(e: Event) {\n const target = e.target as any;\n const groupName = target.attributes.getNamedItem('name')?.value;\n\n NotificationsState.setNotificationFilter(groupName, target.selected);\n this.requestUpdate();\n }\n\n render() {\n return html` <div class=\"flex flex-col items-start py-2\">\n <div class=\"ix-switch-hover\">\n <div class=\"ix-switch-wrapper p-2\">\n <ix-switch\n name=${NotificationGroups.PLANNED_MAINTENANCE}\n selected=${NotificationsState.notificationFilters\n .SHOW_PLANNED_MAINTENANCE}\n @change=${this.onSwitchChange}\n ></ix-switch>\n <label class=\"pl-1\">${NotificationGroups.PLANNED_MAINTENANCE}</label>\n </div>\n </div>\n <div class=\"ix-switch-hover\">\n <div class=\"ix-switch-wrapper p-2\">\n <ix-switch\n name=${NotificationGroups.SERVICE_TICKETS}\n selected=${NotificationsState.notificationFilters\n .SHOW_SERVICE_TICKETS}\n @change=${this.onSwitchChange}\n ></ix-switch>\n <label class=\"pl-1\">${NotificationGroups.SERVICE_TICKETS}</label>\n </div>\n </div>\n <div class=\"ix-switch-hover\">\n <div class=\"ix-switch-wrapper p-2\">\n <ix-switch\n name=${NotificationGroups.DCIM_ALERTS}\n selected=${NotificationsState.notificationFilters.SHOW_DCIM_ALERTS}\n @change=${this.onSwitchChange}\n ></ix-switch>\n <label class=\"pl-1\">${NotificationGroups.DCIM_ALERTS}</label>\n </div>\n </div>\n </div>`;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
|
3
3
|
import { Notification } from '../../models/notification.js';
|
|
4
4
|
export declare class GroupedItem extends MobxLitElement {
|
|
5
5
|
groupTitle: string;
|
|
6
|
-
|
|
6
|
+
groupIcon: string;
|
|
7
7
|
childItems?: Notification[];
|
|
8
8
|
private isOpen;
|
|
9
9
|
onClick: () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { html, nothing } from 'lit';
|
|
3
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
3
4
|
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
4
5
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
6
|
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
@@ -12,7 +13,7 @@ let GroupedItem = class GroupedItem extends MobxLitElement {
|
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
15
|
this.groupTitle = 'Group 1';
|
|
15
|
-
this.
|
|
16
|
+
this.groupIcon = 'public';
|
|
16
17
|
this.childItems = NotificationsState.notifications;
|
|
17
18
|
this.isOpen = false;
|
|
18
19
|
this.onClick = () => {
|
|
@@ -29,14 +30,16 @@ let GroupedItem = class GroupedItem extends MobxLitElement {
|
|
|
29
30
|
((_b = this.childItems) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
30
31
|
return html `<div class="notification-items-container">
|
|
31
32
|
${(_c = this.childItems) === null || _c === void 0 ? void 0 : _c.map(item => html `<notification-item
|
|
32
|
-
.
|
|
33
|
+
.notification=${item}
|
|
33
34
|
?disabled=${item.resourceType === NotificationGroups.INCIDENTS}
|
|
34
35
|
>
|
|
35
36
|
</notification-item>`)}
|
|
36
37
|
</div>`;
|
|
37
38
|
}
|
|
38
39
|
return html `<p class="m-0 pl-8 font-bold mr-4">
|
|
39
|
-
<small style="padding-left: 16px"
|
|
40
|
+
<small style="padding-left: 16px"
|
|
41
|
+
><strong>No notifications yet.</strong></small
|
|
42
|
+
>
|
|
40
43
|
</p>`;
|
|
41
44
|
}
|
|
42
45
|
return html `${nothing}`;
|
|
@@ -51,7 +54,9 @@ let GroupedItem = class GroupedItem extends MobxLitElement {
|
|
|
51
54
|
@click="${this.onClick}"
|
|
52
55
|
>
|
|
53
56
|
</ix-icon-button>
|
|
54
|
-
<ix-icon class="ix-icon-groups"
|
|
57
|
+
<ix-icon slot="default" class="ix-icon-groups"
|
|
58
|
+
>${unsafeSVG(this.groupIcon)}</ix-icon
|
|
59
|
+
>
|
|
55
60
|
<p class="m-0 group-name font-bold pl-1">${this.groupTitle}</p>
|
|
56
61
|
<p class="m-0 pl-4">
|
|
57
62
|
${(_a = this.childItems) === null || _a === void 0 ? void 0 : _a.length.toString().padStart(2, '0')}
|
|
@@ -67,7 +72,7 @@ __decorate([
|
|
|
67
72
|
], GroupedItem.prototype, "groupTitle", void 0);
|
|
68
73
|
__decorate([
|
|
69
74
|
property({ type: String, attribute: true })
|
|
70
|
-
], GroupedItem.prototype, "
|
|
75
|
+
], GroupedItem.prototype, "groupIcon", void 0);
|
|
71
76
|
__decorate([
|
|
72
77
|
property({ type: Array, attribute: true })
|
|
73
78
|
], GroupedItem.prototype, "childItems", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouped-item.js","sourceRoot":"","sources":["../../../src/components/notifications/grouped-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAG/D,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,cAAc;IAAxC;;QACwC,eAAU,GAAG,SAAS,CAAC;QAEvB,
|
|
1
|
+
{"version":3,"file":"grouped-item.js","sourceRoot":"","sources":["../../../src/components/notifications/grouped-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAk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AC;;qDAEa,IAAI,CAAC,UAAU;;cAEtD,MAAA,IAAI,CAAC,UAAU,0CAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;;;;QAIzD,IAAI,CAAC,uBAAuB,EAAE;WAC3B,CAAC;IACV,CAAC;CACF,CAAA;AAhE8C;IAA5C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CAAwB;AAEvB;IAA5C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;8CAAsB;AAEtB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACR;AAE1B;IAAR,KAAK,EAAE;2CAAwB;AARrB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAiEvB;SAjEY,WAAW","sourcesContent":["import { html, nothing } from 'lit';\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { baseTheme } from '@digital-realty/theme';\nimport { TWStyles } from '../../tw.js';\nimport { NotificationsState } from '../../state/NotificationState.js';\nimport { Notification } from '../../models/notification.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\nimport { NotificationGroups } from '../../constants/notifications.js';\n\n@customElement('grouped-item')\nexport class GroupedItem extends MobxLitElement {\n @property({ type: String, attribute: true }) groupTitle = 'Group 1';\n\n @property({ type: String, attribute: true }) groupIcon = 'public';\n\n @property({ type: Array, attribute: true }) childItems?: Notification[] =\n NotificationsState.notifications;\n\n @state() private isOpen = false;\n\n onClick = () => {\n this.isOpen = !this.isOpen;\n };\n\n static get styles() {\n return [NotificationsStyle, baseTheme, TWStyles];\n }\n\n renderNotificationItems() {\n if (this.isOpen) {\n if (\n this.childItems?.length !== undefined &&\n this.childItems?.length > 0\n ) {\n return html`<div class=\"notification-items-container\">\n ${this.childItems?.map(\n item => html`<notification-item\n .notification=${item}\n ?disabled=${item.resourceType === NotificationGroups.INCIDENTS}\n >\n </notification-item>`\n )}\n </div>`;\n }\n return html`<p class=\"m-0 pl-8 font-bold mr-4\">\n <small style=\"padding-left: 16px\"\n ><strong>No notifications yet.</strong></small\n >\n </p>`;\n }\n\n return html`${nothing}`;\n }\n\n render() {\n return html`<div class=\"group-container-row\">\n <div class=\"flex items-center justify-between\">\n <div class=\"flex items-center align-middle\">\n <ix-icon-button\n icon=${this.isOpen ? 'arrow_drop_down' : 'arrow_right'}\n @click=\"${this.onClick}\"\n >\n </ix-icon-button>\n <ix-icon slot=\"default\" class=\"ix-icon-groups\"\n >${unsafeSVG(this.groupIcon)}</ix-icon\n >\n <p class=\"m-0 group-name font-bold pl-1\">${this.groupTitle}</p>\n <p class=\"m-0 pl-4\">\n ${this.childItems?.length.toString().padStart(2, '0')}\n </p>\n </div>\n </div>\n ${this.renderNotificationItems()}\n </div>`;\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import './view-item-dialog.js';
|
|
|
7
7
|
import '@digital-realty/ix-toast/ix-message-toast.js';
|
|
8
8
|
export declare class NotificationItem extends MobxLitElement {
|
|
9
9
|
disabled: boolean;
|
|
10
|
-
|
|
10
|
+
notification: Notification;
|
|
11
11
|
private showModal;
|
|
12
12
|
private showDeleteConfirmation;
|
|
13
13
|
static get styles(): import("lit").CSSResult[];
|
|
@@ -16,6 +16,7 @@ export declare class NotificationItem extends MobxLitElement {
|
|
|
16
16
|
private confirmedDelete;
|
|
17
17
|
private showDeleteResultMessage;
|
|
18
18
|
calculateDuration(): string;
|
|
19
|
-
|
|
19
|
+
getNotificationIcon(): import("lit").TemplateResult<2> | "sync_saved_locally" | "report";
|
|
20
|
+
getNotificationTitle(): string;
|
|
20
21
|
render(): import("lit").TemplateResult<1>;
|
|
21
22
|
}
|
|
@@ -13,11 +13,13 @@ import { NotificationsStyle } from '../../styles/notifications-style.js';
|
|
|
13
13
|
import './confirmation-dialog.js';
|
|
14
14
|
import './view-item-dialog.js';
|
|
15
15
|
import '@digital-realty/ix-toast/ix-message-toast.js';
|
|
16
|
+
import { dcim, plannedMaintenance, trash } from '../../assets/iconset.js';
|
|
17
|
+
import { handleMouseOver, handleMouseOut } from './notification-tooltip.js';
|
|
16
18
|
let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
17
19
|
constructor() {
|
|
18
20
|
super(...arguments);
|
|
19
21
|
this.disabled = false;
|
|
20
|
-
this.
|
|
22
|
+
this.notification = {};
|
|
21
23
|
this.showModal = false;
|
|
22
24
|
this.showDeleteConfirmation = false;
|
|
23
25
|
}
|
|
@@ -35,6 +37,7 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
35
37
|
letter-spacing: 0.4px;
|
|
36
38
|
text-align: left;
|
|
37
39
|
}
|
|
40
|
+
|
|
38
41
|
.notification-item-unread h2 {
|
|
39
42
|
font-family: 'Open Sans', sans-serif;
|
|
40
43
|
font-size: 12px;
|
|
@@ -43,6 +46,7 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
43
46
|
letter-spacing: 0.4px;
|
|
44
47
|
text-align: left;
|
|
45
48
|
}
|
|
49
|
+
|
|
46
50
|
h3 {
|
|
47
51
|
font-family: 'Open Sans', sans-serif;
|
|
48
52
|
font-size: 12px;
|
|
@@ -53,26 +57,23 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
53
57
|
color: rgba(9, 34, 65, 0.6);
|
|
54
58
|
padding: 0;
|
|
55
59
|
}
|
|
60
|
+
|
|
56
61
|
ix-icon {
|
|
57
62
|
--ix-icon-font-size: 24px;
|
|
58
63
|
--ix-icon-line-height: 24px;
|
|
59
64
|
color: var(--md-sys-text-color-primary);
|
|
60
65
|
}
|
|
61
|
-
.notification-item-read ix-icon {
|
|
62
|
-
margin-right: 12px;
|
|
63
|
-
color: rgba(9, 34, 65);
|
|
64
|
-
}
|
|
65
66
|
|
|
66
|
-
.notification-item-
|
|
67
|
+
.notification-item-read > ix-icon:first-child,
|
|
68
|
+
.notification-item-unread > ix-icon:first-child {
|
|
67
69
|
margin-right: 12px;
|
|
68
|
-
color: rgb(20, 86, 224);
|
|
69
70
|
}
|
|
70
71
|
`,
|
|
71
72
|
];
|
|
72
73
|
}
|
|
73
74
|
displayItem() {
|
|
74
|
-
if (this.
|
|
75
|
-
NotificationsState.setNotificationReadStatus(this.
|
|
75
|
+
if (this.notification.status === NotificationStatus.UNREAD) {
|
|
76
|
+
NotificationsState.setNotificationReadStatus(this.notification.id);
|
|
76
77
|
}
|
|
77
78
|
this.showModal = true;
|
|
78
79
|
}
|
|
@@ -84,72 +85,93 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
84
85
|
confirmedDelete(e) {
|
|
85
86
|
// DELETE IF CONFIRMED TRUE
|
|
86
87
|
if (e.detail.returnValue) {
|
|
87
|
-
NotificationsState.setNotificationDeleted(this.
|
|
88
|
-
this.showDeleteResultMessage(result, this.
|
|
88
|
+
NotificationsState.setNotificationDeleted(this.notification.id).then((result) => {
|
|
89
|
+
this.showDeleteResultMessage(result, this.notification.id);
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
this.showDeleteConfirmation = false;
|
|
92
93
|
}
|
|
94
|
+
// eslint-disable-next-line class-methods-use-this
|
|
93
95
|
showDeleteResultMessage(result, id) {
|
|
94
|
-
window.dispatchEvent(new CustomEvent(
|
|
96
|
+
window.dispatchEvent(new CustomEvent('add-toast', {
|
|
97
|
+
detail: {
|
|
95
98
|
id,
|
|
96
|
-
content: html `
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
content: html ` <ix-message-toast
|
|
100
|
+
toastId=${id}
|
|
101
|
+
.TMessageToast=${result.State.toLowerCase()}
|
|
102
|
+
forceClose
|
|
103
|
+
>
|
|
104
|
+
${result.Message}
|
|
105
|
+
</ix-message-toast>`,
|
|
100
106
|
autoClose: 2000,
|
|
101
107
|
durationOut: 2000,
|
|
102
108
|
vertical: 'bottom',
|
|
103
109
|
horizontal: 'center',
|
|
104
110
|
animated: true,
|
|
105
111
|
above: false,
|
|
106
|
-
}
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
107
114
|
}
|
|
108
115
|
calculateDuration() {
|
|
109
|
-
if (this.
|
|
110
|
-
if (differenceInHours(new Date(), this.
|
|
111
|
-
return formatDistance(this.
|
|
116
|
+
if (this.notification.createdAt !== undefined) {
|
|
117
|
+
if (differenceInHours(new Date(), this.notification.createdAt) < 24)
|
|
118
|
+
return formatDistance(this.notification.createdAt, new Date(), {
|
|
112
119
|
addSuffix: true,
|
|
113
120
|
});
|
|
114
|
-
return format(this.
|
|
121
|
+
return format(this.notification.createdAt, DefaultDateTimeFormat);
|
|
115
122
|
}
|
|
116
|
-
return '
|
|
123
|
+
return 'N/A';
|
|
117
124
|
}
|
|
118
|
-
|
|
119
|
-
switch (this.
|
|
125
|
+
getNotificationIcon() {
|
|
126
|
+
switch (this.notification.resourceType) {
|
|
120
127
|
case NotificationGroups.PLANNED_MAINTENANCE:
|
|
121
|
-
return
|
|
128
|
+
return plannedMaintenance;
|
|
122
129
|
case NotificationGroups.SERVICE_TICKETS:
|
|
123
|
-
return '
|
|
130
|
+
return 'sync_saved_locally';
|
|
124
131
|
case NotificationGroups.INCIDENTS:
|
|
125
|
-
return '
|
|
132
|
+
return 'report';
|
|
126
133
|
case NotificationGroups.DCIM_ALERTS:
|
|
127
|
-
return
|
|
134
|
+
return dcim;
|
|
135
|
+
default:
|
|
136
|
+
return 'sync_saved_locally';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
getNotificationTitle() {
|
|
140
|
+
var _a;
|
|
141
|
+
switch (this.notification.resourceType) {
|
|
142
|
+
case NotificationGroups.PLANNED_MAINTENANCE:
|
|
143
|
+
return 'Planned Site Maintenance';
|
|
144
|
+
case NotificationGroups.SERVICE_TICKETS:
|
|
145
|
+
return `${(_a = this.notification) === null || _a === void 0 ? void 0 : _a.subGroup} Service Ticket Update`;
|
|
146
|
+
case NotificationGroups.INCIDENTS:
|
|
147
|
+
return 'Emergency Repair';
|
|
148
|
+
case NotificationGroups.DCIM_ALERTS:
|
|
149
|
+
return 'DCIM Alert';
|
|
128
150
|
default:
|
|
129
151
|
return 'sync_saved_locally';
|
|
130
152
|
}
|
|
131
153
|
}
|
|
132
154
|
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
133
155
|
render() {
|
|
134
|
-
var _a, _b
|
|
135
|
-
return html `
|
|
156
|
+
var _a, _b;
|
|
157
|
+
return html `
|
|
136
158
|
<div class="relative bg-white-gp notification-item">
|
|
137
159
|
<div
|
|
138
|
-
class=${((_a = this.
|
|
160
|
+
class=${((_a = this.notification) === null || _a === void 0 ? void 0 : _a.status) === 'unread'
|
|
139
161
|
? 'notification-item-unread'
|
|
140
162
|
: 'notification-item-read'}
|
|
141
163
|
>
|
|
142
164
|
<ix-icon
|
|
143
|
-
icon=${this.
|
|
144
|
-
class=${((_b = this.
|
|
145
|
-
? '
|
|
146
|
-
: '
|
|
165
|
+
icon=${this.getNotificationIcon()}
|
|
166
|
+
class=${((_b = this.notification) === null || _b === void 0 ? void 0 : _b.status) === 'unread'
|
|
167
|
+
? 'active-icon'
|
|
168
|
+
: 'inactive-icon'}
|
|
147
169
|
@click=${this.displayItem}
|
|
148
|
-
>${this.
|
|
170
|
+
>${this.getNotificationIcon()}
|
|
149
171
|
</ix-icon>
|
|
150
172
|
<div class="flex flex-col grow" @click=${this.displayItem}>
|
|
151
173
|
<div class="grow text-base">
|
|
152
|
-
<h2>${
|
|
174
|
+
<h2>${this.getNotificationTitle()}</h2>
|
|
153
175
|
</div>
|
|
154
176
|
<div class="grow text-xs">
|
|
155
177
|
<h3>${this.calculateDuration()}</h3>
|
|
@@ -158,7 +180,7 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
158
180
|
<div>
|
|
159
181
|
<view-item-dialog
|
|
160
182
|
?open=${this.showModal}
|
|
161
|
-
.
|
|
183
|
+
.notification=${this.notification}
|
|
162
184
|
@view-item-dialog-closed=${() => {
|
|
163
185
|
this.showModal = false;
|
|
164
186
|
}}
|
|
@@ -176,9 +198,19 @@ let NotificationItem = class NotificationItem extends MobxLitElement {
|
|
|
176
198
|
</div>
|
|
177
199
|
<ix-icon-button
|
|
178
200
|
@click=${this.deleteItem}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
@mouseover=${(e) => handleMouseOver(e, this.disabled
|
|
202
|
+
? 'Emergency Repair Notification cannot be removed'
|
|
203
|
+
: 'Remove Notification')}
|
|
204
|
+
@mouseout=${handleMouseOut}
|
|
205
|
+
?disabled=${this.disabled}
|
|
206
|
+
>
|
|
207
|
+
<ix-icon
|
|
208
|
+
slot="default"
|
|
209
|
+
class="${this.disabled ? 'inactive-icon' : 'destructive-icon'}"
|
|
210
|
+
>
|
|
211
|
+
${trash}
|
|
212
|
+
</ix-icon>
|
|
213
|
+
</ix-icon-button>
|
|
182
214
|
</div>
|
|
183
215
|
</div>
|
|
184
216
|
`;
|
|
@@ -189,7 +221,7 @@ __decorate([
|
|
|
189
221
|
], NotificationItem.prototype, "disabled", void 0);
|
|
190
222
|
__decorate([
|
|
191
223
|
property({ type: Object, attribute: false })
|
|
192
|
-
], NotificationItem.prototype, "
|
|
224
|
+
], NotificationItem.prototype, "notification", void 0);
|
|
193
225
|
__decorate([
|
|
194
226
|
state()
|
|
195
227
|
], NotificationItem.prototype, "showModal", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-item.js","sourceRoot":"","sources":["../../../src/components/notifications/notification-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EA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,CAAC,CAAC,CAAC,WAAW;;;;KAIxD,CAAC;IACJ,CAAC;CACF,CAAA;AAtL8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAkB;AAEA;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDACxB;AAEZ;IAAR,KAAK,EAAE;mDAA2B;AAE1B;IAAR,KAAK,EAAE;gEAAwC;AARrC,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAuL5B;SAvLY,gBAAgB","sourcesContent":["import { html, css } from 'lit';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport { elementTheme } from '@digital-realty/theme';\nimport { format, formatDistance, differenceInHours } from 'date-fns';\nimport { TWStyles } from '../../tw.js';\nimport { NotificationsState } from '../../state/NotificationState.js';\nimport { ApiCallResult, Notification } from '../../models/notification.js';\nimport {\n NotificationStatus,\n DefaultDateTimeFormat,\n NotificationGroups,\n} from '../../constants/notifications.js';\nimport { ConfirmationDialogEventDetail } from '../../constants/notification-types.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\nimport './confirmation-dialog.js';\nimport './view-item-dialog.js';\nimport '@digital-realty/ix-toast/ix-message-toast.js';\n\n@customElement('notification-item')\nexport class NotificationItem extends MobxLitElement {\n @property({ type: Boolean }) disabled = false;\n\n @property({ type: Object, attribute: false }) notificaiton =\n {} as Notification;\n\n @state() private showModal = false;\n\n @state() private showDeleteConfirmation = false;\n\n static get styles() {\n return [\n NotificationsStyle,\n elementTheme,\n TWStyles,\n css`\n .notification-item-read h2 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n }\n .notification-item-unread h2 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 700;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n }\n h3 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n color: rgba(9, 34, 65, 0.6);\n padding: 0;\n }\n ix-icon {\n --ix-icon-font-size: 24px;\n --ix-icon-line-height: 24px;\n color: var(--md-sys-text-color-primary);\n }\n .notification-item-read ix-icon {\n margin-right: 12px;\n color: rgba(9, 34, 65);\n }\n\n .notification-item-unread ix-icon {\n margin-right: 12px;\n color: rgb(20, 86, 224);\n }\n `,\n ];\n }\n\n displayItem() {\n if (this.notificaiton.status === NotificationStatus.UNREAD) {\n NotificationsState.setNotificationReadStatus(this.notificaiton.id);\n }\n this.showModal = true;\n }\n\n deleteItem() {\n if (!this.disabled) {\n this.showDeleteConfirmation = true;\n }\n }\n\n private confirmedDelete(e: CustomEvent<ConfirmationDialogEventDetail>) {\n // DELETE IF CONFIRMED TRUE\n if (e.detail.returnValue)\n {\n NotificationsState.setNotificationDeleted(this.notificaiton.id).then((result: ApiCallResult) => { \n this.showDeleteResultMessage(result,this.notificaiton.id);\n });\n }\n this.showDeleteConfirmation = false;\n }\n\n private showDeleteResultMessage(result: ApiCallResult, id: string )\n {\n \n window.dispatchEvent(\n new CustomEvent(\"add-toast\", { detail: {\n id,\n content: html`\n <ix-message-toast toastId=${id} .TMessageToast=${result.State.toLowerCase()} forceClose> \n ${result.Message}\n </ix-message-toast>`,\n autoClose: 2000,\n durationOut: 2000,\n vertical: 'bottom',\n horizontal: 'center',\n animated: true, \n above: false,\n } })\n );\n }\n\n calculateDuration() {\n if (this.notificaiton.createdAt !== undefined) {\n if (differenceInHours(new Date(), this.notificaiton.createdAt) < 24)\n return formatDistance(this.notificaiton.createdAt, new Date(), {\n addSuffix: true,\n });\n return format(this.notificaiton.createdAt, DefaultDateTimeFormat);\n }\n return 'NA';\n }\n\n GetNotificationIcon() {\n switch (this.notificaiton.resourceType) {\n case NotificationGroups.PLANNED_MAINTENANCE:\n return 'lab_profile';\n case NotificationGroups.SERVICE_TICKETS:\n return 'dvr';\n case NotificationGroups.INCIDENTS:\n return 'emergency_home';\n case NotificationGroups.DCIM_ALERTS:\n return 'public';\n default:\n return 'sync_saved_locally';\n }\n }\n\n /* eslint-disable lit-a11y/click-events-have-key-events */\n render() {\n return html` \n <div class=\"relative bg-white-gp notification-item\">\n <div\n class=${this.notificaiton?.status === 'unread'\n ? 'notification-item-unread'\n : 'notification-item-read'}\n >\n <ix-icon\n icon=${this.GetNotificationIcon()}\n class=${this.notificaiton?.status === 'unread'\n ? 'blue-icon'\n : 'grey-icon'}\n @click=${this.displayItem}\n >${this.GetNotificationIcon()}\n </ix-icon>\n <div class=\"flex flex-col grow\" @click=${this.displayItem}>\n <div class=\"grow text-base\">\n <h2>${this.notificaiton?.resourceType}</h2>\n </div>\n <div class=\"grow text-xs\">\n <h3>${this.calculateDuration()}</h3>\n </div>\n </div>\n <div>\n <view-item-dialog\n ?open=${this.showModal}\n .notificaiton=${this.notificaiton}\n @view-item-dialog-closed=${() => {\n this.showModal = false;\n }}\n >\n </view-item-dialog>\n <confirmation-dialog\n ?open=${this.showDeleteConfirmation}\n @on-confirm-selection=${this.confirmedDelete}\n @confirm-dialog-closed=${() => {\n this.showModal = false;\n }}\n textMessage=\"Are you sure you want to delete this notification?\"\n >\n </confirmation-dialog>\n </div>\n <ix-icon-button\n @click=${this.deleteItem}\n icon=\"delete\"\n class=${!this.disabled ? 'red-icon' : 'grey-icon'}\n ></ix-icon-button>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"notification-item.js","sourceRoot":"","sources":["../../../src/components/notifications/notification-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CA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,MAAM,MAAK,QAAQ;YAC5C,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,eAAe;qBACV,IAAI,CAAC,WAAW;eACtB,IAAI,CAAC,mBAAmB,EAAE;;mDAEU,IAAI,CAAC,WAAW;;oBAE/C,IAAI,CAAC,oBAAoB,EAAE;;;oBAG3B,IAAI,CAAC,iBAAiB,EAAE;;;;;sBAKtB,IAAI,CAAC,SAAS;8BACN,IAAI,CAAC,YAAY;yCACN,GAAG,EAAE;YAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;;;;sBAIO,IAAI,CAAC,sBAAsB;sCACX,IAAI,CAAC,eAAe;uCACnB,GAAG,EAAE;YAC5B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;;;;;;qBAMM,IAAI,CAAC,UAAU;yBACX,CAAC,CAAM,EAAE,EAAE,CACtB,eAAe,CACb,CAAC,EACD,IAAI,CAAC,QAAQ;YACX,CAAC,CAAC,iDAAiD;YACnD,CAAC,CAAC,qBAAqB,CAC1B;wBACS,cAAc;wBACd,IAAI,CAAC,QAAQ;;;;uBAId,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB;;gBAE3D,KAAK;;;;;KAKhB,CAAC;IACJ,CAAC;CACF,CAAA;AAvN8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAkB;AAEA;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDACxB;AAEZ;IAAR,KAAK,EAAE;mDAA2B;AAE1B;IAAR,KAAK,EAAE;gEAAwC;AARrC,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAwN5B;SAxNY,gBAAgB","sourcesContent":["import { html, css } from 'lit';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport { elementTheme } from '@digital-realty/theme';\nimport { format, formatDistance, differenceInHours } from 'date-fns';\nimport { TWStyles } from '../../tw.js';\nimport { NotificationsState } from '../../state/NotificationState.js';\nimport { ApiCallResult, Notification } from '../../models/notification.js';\nimport {\n NotificationStatus,\n DefaultDateTimeFormat,\n NotificationGroups,\n} from '../../constants/notifications.js';\nimport { ConfirmationDialogEventDetail } from '../../constants/notification-types.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\nimport './confirmation-dialog.js';\nimport './view-item-dialog.js';\nimport '@digital-realty/ix-toast/ix-message-toast.js';\nimport { dcim, plannedMaintenance, trash } from '../../assets/iconset.js';\nimport { handleMouseOver, handleMouseOut } from './notification-tooltip.js';\n\n@customElement('notification-item')\nexport class NotificationItem extends MobxLitElement {\n @property({ type: Boolean }) disabled = false;\n\n @property({ type: Object, attribute: false }) notification =\n {} as Notification;\n\n @state() private showModal = false;\n\n @state() private showDeleteConfirmation = false;\n\n static get styles() {\n return [\n NotificationsStyle,\n elementTheme,\n TWStyles,\n css`\n .notification-item-read h2 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n }\n\n .notification-item-unread h2 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 700;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n }\n\n h3 {\n font-family: 'Open Sans', sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 16px;\n letter-spacing: 0.4px;\n text-align: left;\n color: rgba(9, 34, 65, 0.6);\n padding: 0;\n }\n\n ix-icon {\n --ix-icon-font-size: 24px;\n --ix-icon-line-height: 24px;\n color: var(--md-sys-text-color-primary);\n }\n\n .notification-item-read > ix-icon:first-child,\n .notification-item-unread > ix-icon:first-child {\n margin-right: 12px;\n }\n `,\n ];\n }\n\n displayItem() {\n if (this.notification.status === NotificationStatus.UNREAD) {\n NotificationsState.setNotificationReadStatus(this.notification.id);\n }\n this.showModal = true;\n }\n\n deleteItem() {\n if (!this.disabled) {\n this.showDeleteConfirmation = true;\n }\n }\n\n private confirmedDelete(e: CustomEvent<ConfirmationDialogEventDetail>) {\n // DELETE IF CONFIRMED TRUE\n if (e.detail.returnValue) {\n NotificationsState.setNotificationDeleted(this.notification.id).then(\n (result: ApiCallResult) => {\n this.showDeleteResultMessage(result, this.notification.id);\n }\n );\n }\n this.showDeleteConfirmation = false;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private showDeleteResultMessage(result: ApiCallResult, id: string) {\n window.dispatchEvent(\n new CustomEvent('add-toast', {\n detail: {\n id,\n content: html` <ix-message-toast\n toastId=${id}\n .TMessageToast=${result.State.toLowerCase()}\n forceClose\n >\n ${result.Message}\n </ix-message-toast>`,\n autoClose: 2000,\n durationOut: 2000,\n vertical: 'bottom',\n horizontal: 'center',\n animated: true,\n above: false,\n },\n })\n );\n }\n\n calculateDuration() {\n if (this.notification.createdAt !== undefined) {\n if (differenceInHours(new Date(), this.notification.createdAt) < 24)\n return formatDistance(this.notification.createdAt, new Date(), {\n addSuffix: true,\n });\n return format(this.notification.createdAt, DefaultDateTimeFormat);\n }\n return 'N/A';\n }\n\n getNotificationIcon() {\n switch (this.notification.resourceType) {\n case NotificationGroups.PLANNED_MAINTENANCE:\n return plannedMaintenance;\n case NotificationGroups.SERVICE_TICKETS:\n return 'sync_saved_locally';\n case NotificationGroups.INCIDENTS:\n return 'report';\n case NotificationGroups.DCIM_ALERTS:\n return dcim;\n default:\n return 'sync_saved_locally';\n }\n }\n\n getNotificationTitle() {\n switch (this.notification.resourceType) {\n case NotificationGroups.PLANNED_MAINTENANCE:\n return 'Planned Site Maintenance';\n case NotificationGroups.SERVICE_TICKETS:\n return `${this.notification?.subGroup} Service Ticket Update`;\n case NotificationGroups.INCIDENTS:\n return 'Emergency Repair';\n case NotificationGroups.DCIM_ALERTS:\n return 'DCIM Alert';\n default:\n return 'sync_saved_locally';\n }\n }\n\n /* eslint-disable lit-a11y/click-events-have-key-events */\n render() {\n return html`\n <div class=\"relative bg-white-gp notification-item\">\n <div\n class=${this.notification?.status === 'unread'\n ? 'notification-item-unread'\n : 'notification-item-read'}\n >\n <ix-icon\n icon=${this.getNotificationIcon()}\n class=${this.notification?.status === 'unread'\n ? 'active-icon'\n : 'inactive-icon'}\n @click=${this.displayItem}\n >${this.getNotificationIcon()}\n </ix-icon>\n <div class=\"flex flex-col grow\" @click=${this.displayItem}>\n <div class=\"grow text-base\">\n <h2>${this.getNotificationTitle()}</h2>\n </div>\n <div class=\"grow text-xs\">\n <h3>${this.calculateDuration()}</h3>\n </div>\n </div>\n <div>\n <view-item-dialog\n ?open=${this.showModal}\n .notification=${this.notification}\n @view-item-dialog-closed=${() => {\n this.showModal = false;\n }}\n >\n </view-item-dialog>\n <confirmation-dialog\n ?open=${this.showDeleteConfirmation}\n @on-confirm-selection=${this.confirmedDelete}\n @confirm-dialog-closed=${() => {\n this.showModal = false;\n }}\n textMessage=\"Are you sure you want to delete this notification?\"\n >\n </confirmation-dialog>\n </div>\n <ix-icon-button\n @click=${this.deleteItem}\n @mouseover=${(e: any) =>\n handleMouseOver(\n e,\n this.disabled\n ? 'Emergency Repair Notification cannot be removed'\n : 'Remove Notification'\n )}\n @mouseout=${handleMouseOut}\n ?disabled=${this.disabled}\n >\n <ix-icon\n slot=\"default\"\n class=\"${this.disabled ? 'inactive-icon' : 'destructive-icon'}\"\n >\n ${trash}\n </ix-icon>\n </ix-icon-button>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
2
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
3
|
+
export declare class NotificationTooltip extends MobxLitElement {
|
|
4
|
+
static get styles(): import("lit").CSSResult[];
|
|
5
|
+
render(): import("lit").TemplateResult<1>;
|
|
6
|
+
}
|
|
7
|
+
declare function handleMouseOut(): void;
|
|
8
|
+
declare function handleMouseOver(event: any, label: string): void;
|
|
9
|
+
export { handleMouseOut, handleMouseOver };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
4
|
+
import { customElement } from 'lit/decorators.js';
|
|
5
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
6
|
+
import { baseTheme } from '@digital-realty/theme';
|
|
7
|
+
import { computePosition } from '@floating-ui/dom';
|
|
8
|
+
import { TWStyles } from '../../tw.js';
|
|
9
|
+
import { NotificationsStyle } from '../../styles/notifications-style.js';
|
|
10
|
+
// Tooltip code, to be replaced with a generic component
|
|
11
|
+
let NotificationTooltip = class NotificationTooltip extends MobxLitElement {
|
|
12
|
+
static get styles() {
|
|
13
|
+
return [NotificationsStyle, baseTheme, TWStyles];
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return html ` <div
|
|
17
|
+
class="notification-tooltip z-[999] hidden rounded absolute p-2 white-text"
|
|
18
|
+
></div>`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
NotificationTooltip = __decorate([
|
|
22
|
+
customElement('notification-tooltip')
|
|
23
|
+
], NotificationTooltip);
|
|
24
|
+
export { NotificationTooltip };
|
|
25
|
+
function getNotificationTooltip() {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
return (_d = (_c = (_b = (_a = document
|
|
28
|
+
.querySelector('ix-notifications')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('notification-tooltip')) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.notification-tooltip');
|
|
29
|
+
}
|
|
30
|
+
function handleMouseOut() {
|
|
31
|
+
const notificationTooltip = getNotificationTooltip();
|
|
32
|
+
if (notificationTooltip) {
|
|
33
|
+
notificationTooltip.style.display = 'none';
|
|
34
|
+
notificationTooltip.innerHTML = '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function handleMouseOver(event, label) {
|
|
38
|
+
const notificationTooltip = getNotificationTooltip();
|
|
39
|
+
if (notificationTooltip) {
|
|
40
|
+
const element = event.currentTarget;
|
|
41
|
+
// Compute the position of the tooltip
|
|
42
|
+
computePosition(element, notificationTooltip, {
|
|
43
|
+
placement: 'bottom-end',
|
|
44
|
+
}).then(({ x, y }) => {
|
|
45
|
+
notificationTooltip.innerHTML = label;
|
|
46
|
+
notificationTooltip.style.display = 'block';
|
|
47
|
+
notificationTooltip.style.left = `${x}px`;
|
|
48
|
+
notificationTooltip.style.top = `${y + 12}px`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export { handleMouseOut, handleMouseOver };
|
|
53
|
+
//# sourceMappingURL=notification-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-tooltip.js","sourceRoot":"","sources":["../../../src/components/notifications/notification-tooltip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,wDAAwD;AAEjD,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,cAAc;IACrD,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,kBAAkB,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;AACH,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { html } from 'lit';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { customElement } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { baseTheme } from '@digital-realty/theme';\nimport { computePosition } from '@floating-ui/dom';\nimport { TWStyles } from '../../tw.js';\nimport { NotificationsStyle } from '../../styles/notifications-style.js';\n\n// Tooltip code, to be replaced with a generic component\n@customElement('notification-tooltip')\nexport class NotificationTooltip extends MobxLitElement {\n static get styles() {\n return [NotificationsStyle, baseTheme, TWStyles];\n }\n\n render() {\n return html` <div\n class=\"notification-tooltip z-[999] hidden rounded absolute p-2 white-text\"\n ></div>`;\n }\n}\n\nfunction getNotificationTooltip() {\n return document\n .querySelector('ix-notifications')\n ?.shadowRoot?.querySelector('notification-tooltip')\n ?.shadowRoot?.querySelector('.notification-tooltip') as HTMLElement;\n}\n\nfunction handleMouseOut() {\n const notificationTooltip = getNotificationTooltip();\n if (notificationTooltip) {\n notificationTooltip.style.display = 'none';\n notificationTooltip.innerHTML = '';\n }\n}\n\nfunction handleMouseOver(event: any, label: string) {\n const notificationTooltip = getNotificationTooltip();\n if (notificationTooltip) {\n const element = event.currentTarget;\n // Compute the position of the tooltip\n computePosition(element, notificationTooltip, {\n placement: 'bottom-end',\n }).then(({ x, y }) => {\n notificationTooltip.innerHTML = label;\n notificationTooltip.style.display = 'block';\n notificationTooltip.style.left = `${x}px`;\n notificationTooltip.style.top = `${y + 12}px`;\n });\n }\n}\n\nexport { handleMouseOut, handleMouseOver };\n"]}
|
|
@@ -3,7 +3,7 @@ import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
|
3
3
|
import { Notification } from '../../models/notification.js';
|
|
4
4
|
export declare class ViewItemDialog extends MobxLitElement {
|
|
5
5
|
static get styles(): import("lit").CSSResult[];
|
|
6
|
-
|
|
6
|
+
notification: Notification;
|
|
7
7
|
open: boolean;
|
|
8
8
|
getUrl(): string;
|
|
9
9
|
getLocation(): string;
|