@digital-realty/ix-notifications 1.0.1 → 1.0.4
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.d.ts +37 -37
- package/dist/IxNotifications.js +163 -165
- package/dist/IxNotifications.js.map +1 -1
- package/dist/api/notifications-api/apis/NotificationsApi.d.ts +83 -83
- package/dist/api/notifications-api/apis/NotificationsApi.js +203 -203
- package/dist/api/notifications-api/apis/index.d.ts +1 -1
- package/dist/api/notifications-api/apis/index.js +3 -3
- package/dist/api/notifications-api/index.d.ts +3 -3
- package/dist/api/notifications-api/index.js +5 -5
- package/dist/api/notifications-api/models/ErrorResponse.d.ts +55 -55
- package/dist/api/notifications-api/models/ErrorResponse.js +51 -51
- package/dist/api/notifications-api/models/GetNotifications200Response.d.ts +62 -62
- package/dist/api/notifications-api/models/GetNotifications200Response.js +55 -55
- package/dist/api/notifications-api/models/Notification.d.ts +86 -86
- package/dist/api/notifications-api/models/Notification.js +62 -62
- package/dist/api/notifications-api/models/NotificationDelete.d.ts +31 -31
- package/dist/api/notifications-api/models/NotificationDelete.js +43 -43
- package/dist/api/notifications-api/models/NotificationPatch.d.ts +32 -32
- package/dist/api/notifications-api/models/NotificationPatch.js +44 -44
- package/dist/api/notifications-api/models/NotificationRequest.d.ts +73 -73
- package/dist/api/notifications-api/models/NotificationRequest.js +61 -61
- package/dist/api/notifications-api/models/PaginatedResponse.d.ts +61 -61
- package/dist/api/notifications-api/models/PaginatedResponse.js +54 -54
- package/dist/api/notifications-api/models/Status.d.ts +23 -23
- package/dist/api/notifications-api/models/Status.js +30 -30
- package/dist/api/notifications-api/models/index.d.ts +8 -8
- package/dist/api/notifications-api/models/index.js +10 -10
- package/dist/api/notifications-api/runtime.d.ts +182 -182
- package/dist/api/notifications-api/runtime.js +318 -318
- package/dist/components/notifications/confirmation-dialog.d.ts +10 -10
- package/dist/components/notifications/confirmation-dialog.js +42 -42
- package/dist/components/notifications/date-filters.d.ts +19 -19
- package/dist/components/notifications/date-filters.js +90 -90
- package/dist/components/notifications/group-filters.d.ts +8 -8
- package/dist/components/notifications/group-filters.js +35 -35
- package/dist/components/notifications/grouped-item.d.ts +13 -13
- package/dist/components/notifications/grouped-item.js +56 -56
- package/dist/components/notifications/notification-item.d.ts +18 -18
- package/dist/components/notifications/notification-item.js +95 -95
- package/dist/components/notifications/view-item-dialog.d.ts +12 -12
- package/dist/components/notifications/view-item-dialog.js +61 -61
- package/dist/constants/api-constants.d.ts +3 -3
- package/dist/constants/api-constants.js +3 -3
- package/dist/constants/notification-types.d.ts +15 -15
- package/dist/constants/notification-types.js +1 -1
- package/dist/constants/notifications.d.ts +15 -15
- package/dist/constants/notifications.js +18 -18
- package/dist/helper/errors.d.ts +1 -1
- package/dist/helper/errors.js +19 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ix-notifications.d.ts +1 -1
- package/dist/ix-notifications.js +2 -2
- package/dist/ix-notifications.min.js +1 -1
- package/dist/models/notification.d.ts +13 -13
- package/dist/models/notification.js +1 -1
- package/dist/services/api-client.d.ts +13 -13
- package/dist/services/api-client.js +23 -23
- package/dist/services/app-service.d.ts +1 -1
- package/dist/services/app-service.js +6 -6
- package/dist/services/notifications-service.d.ts +10 -10
- package/dist/services/notifications-service.js +55 -55
- package/dist/state/NotificationState.d.ts +28 -28
- package/dist/state/NotificationState.js +153 -152
- package/dist/state/NotificationState.js.map +1 -1
- package/dist/styles/notifications-style.d.ts +1 -1
- package/dist/styles/notifications-style.js +2 -2
- package/dist/tw.d.ts +1 -1
- package/dist/tw.js +2 -2
- package/package.json +3 -2
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
2
|
-
import '@digital-realty/ix-button/ix-button.js';
|
|
3
|
-
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
4
|
-
import '@digital-realty/ix-icon';
|
|
5
|
-
import '@material/web/icon/icon.js';
|
|
6
|
-
import { Notification } from './models/notification.js';
|
|
7
|
-
import { FilterDialogEventDetail } from './constants/notification-types.js';
|
|
8
|
-
import './components/notifications/notification-item.js';
|
|
9
|
-
import './components/notifications/grouped-item.js';
|
|
10
|
-
import './components/notifications/group-filters.js';
|
|
11
|
-
import './components/notifications/date-filters.js';
|
|
12
|
-
import './components/notifications/confirmation-dialog.js';
|
|
13
|
-
export declare class IxNotifications extends MobxLitElement {
|
|
14
|
-
static styles: import("lit").CSSResult[];
|
|
15
|
-
private showDrawer;
|
|
16
|
-
private showGroupedView;
|
|
17
|
-
private showFilters;
|
|
18
|
-
private showDateFilters;
|
|
19
|
-
private showMarkAllReadConfirmation;
|
|
20
|
-
baseApiUrl: string;
|
|
21
|
-
firstUpdated(): Promise<void>;
|
|
22
|
-
connectedCallback(): void;
|
|
23
|
-
disconnectedCallback(): void;
|
|
24
|
-
toggleDrawer(): void;
|
|
25
|
-
renderUnReadCountText(): import("lit").TemplateResult<1>;
|
|
26
|
-
markAllread(): void;
|
|
27
|
-
private confirmedMarkAllRead;
|
|
28
|
-
toggleGroupView(): void;
|
|
29
|
-
displayFilters(): void;
|
|
30
|
-
applyNotificationFilters(): Notification[];
|
|
31
|
-
displayDateFilters(): void;
|
|
32
|
-
renderGroupedView(): import("lit").TemplateResult<1>;
|
|
33
|
-
renderDefaultView(): import("lit").TemplateResult<1>;
|
|
34
|
-
renderNoResult(): import("lit").TemplateResult<1>;
|
|
35
|
-
handleCloseClick(_e: CustomEvent<FilterDialogEventDetail>): void;
|
|
36
|
-
render(): import("lit").TemplateResult<1>;
|
|
37
|
-
}
|
|
1
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
2
|
+
import '@digital-realty/ix-button/ix-button.js';
|
|
3
|
+
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
4
|
+
import '@digital-realty/ix-icon';
|
|
5
|
+
import '@material/web/icon/icon.js';
|
|
6
|
+
import { Notification } from './models/notification.js';
|
|
7
|
+
import { FilterDialogEventDetail } from './constants/notification-types.js';
|
|
8
|
+
import './components/notifications/notification-item.js';
|
|
9
|
+
import './components/notifications/grouped-item.js';
|
|
10
|
+
import './components/notifications/group-filters.js';
|
|
11
|
+
import './components/notifications/date-filters.js';
|
|
12
|
+
import './components/notifications/confirmation-dialog.js';
|
|
13
|
+
export declare class IxNotifications extends MobxLitElement {
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
private showDrawer;
|
|
16
|
+
private showGroupedView;
|
|
17
|
+
private showFilters;
|
|
18
|
+
private showDateFilters;
|
|
19
|
+
private showMarkAllReadConfirmation;
|
|
20
|
+
baseApiUrl: string;
|
|
21
|
+
firstUpdated(): Promise<void>;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
disconnectedCallback(): void;
|
|
24
|
+
toggleDrawer(): void;
|
|
25
|
+
renderUnReadCountText(): import("lit").TemplateResult<1>;
|
|
26
|
+
markAllread(): void;
|
|
27
|
+
private confirmedMarkAllRead;
|
|
28
|
+
toggleGroupView(): void;
|
|
29
|
+
displayFilters(): void;
|
|
30
|
+
applyNotificationFilters(): Notification[];
|
|
31
|
+
displayDateFilters(): void;
|
|
32
|
+
renderGroupedView(): import("lit").TemplateResult<1>;
|
|
33
|
+
renderDefaultView(): import("lit").TemplateResult<1>;
|
|
34
|
+
renderNoResult(): import("lit").TemplateResult<1>;
|
|
35
|
+
handleCloseClick(_e: CustomEvent<FilterDialogEventDetail>): void;
|
|
36
|
+
render(): import("lit").TemplateResult<1>;
|
|
37
|
+
}
|
package/dist/IxNotifications.js
CHANGED
|
@@ -1,116 +1,114 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { html, nothing } from 'lit';
|
|
3
|
-
import { property, state } from 'lit/decorators.js';
|
|
4
|
-
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
5
|
-
import { differenceInDays, differenceInHours } from 'date-fns';
|
|
6
|
-
import { TWStyles } from './tw.js';
|
|
7
|
-
import '@digital-realty/ix-button/ix-button.js';
|
|
8
|
-
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
9
|
-
import '@digital-realty/ix-icon';
|
|
10
|
-
import '@material/web/icon/icon.js';
|
|
11
|
-
import { NotificationsState } from './state/NotificationState.js';
|
|
12
|
-
import { NotificationGroups, NotificationStatus, } from './constants/notifications.js';
|
|
13
|
-
import './components/notifications/notification-item.js';
|
|
14
|
-
import './components/notifications/grouped-item.js';
|
|
15
|
-
import './components/notifications/group-filters.js';
|
|
16
|
-
import './components/notifications/date-filters.js';
|
|
17
|
-
import './components/notifications/confirmation-dialog.js';
|
|
18
|
-
import { NotificationsStyle } from './styles/notifications-style.js';
|
|
19
|
-
export class IxNotifications extends MobxLitElement {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.showDrawer = false;
|
|
23
|
-
this.showGroupedView = false;
|
|
24
|
-
this.showFilters = false;
|
|
25
|
-
this.showDateFilters = false;
|
|
26
|
-
this.showMarkAllReadConfirmation = false;
|
|
27
|
-
this.baseApiUrl = '';
|
|
28
|
-
}
|
|
29
|
-
async firstUpdated() {
|
|
30
|
-
// Construct ApiClient form baseApiUrl Prop
|
|
31
|
-
NotificationsState.baseApiUrl = this.baseApiUrl;
|
|
32
|
-
NotificationsState.ConstructApiClient();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
unreadCountText = NotificationsState.unreadNotificationCount.toString();
|
|
62
|
-
}
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { property, state } from 'lit/decorators.js';
|
|
4
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
5
|
+
import { differenceInDays, differenceInHours } from 'date-fns';
|
|
6
|
+
import { TWStyles } from './tw.js';
|
|
7
|
+
import '@digital-realty/ix-button/ix-button.js';
|
|
8
|
+
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
9
|
+
import '@digital-realty/ix-icon';
|
|
10
|
+
import '@material/web/icon/icon.js';
|
|
11
|
+
import { NotificationsState } from './state/NotificationState.js';
|
|
12
|
+
import { NotificationGroups, NotificationStatus, } from './constants/notifications.js';
|
|
13
|
+
import './components/notifications/notification-item.js';
|
|
14
|
+
import './components/notifications/grouped-item.js';
|
|
15
|
+
import './components/notifications/group-filters.js';
|
|
16
|
+
import './components/notifications/date-filters.js';
|
|
17
|
+
import './components/notifications/confirmation-dialog.js';
|
|
18
|
+
import { NotificationsStyle } from './styles/notifications-style.js';
|
|
19
|
+
export class IxNotifications extends MobxLitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.showDrawer = false;
|
|
23
|
+
this.showGroupedView = false;
|
|
24
|
+
this.showFilters = false;
|
|
25
|
+
this.showDateFilters = false;
|
|
26
|
+
this.showMarkAllReadConfirmation = false;
|
|
27
|
+
this.baseApiUrl = '';
|
|
28
|
+
}
|
|
29
|
+
async firstUpdated() {
|
|
30
|
+
// Construct ApiClient form baseApiUrl Prop
|
|
31
|
+
NotificationsState.baseApiUrl = this.baseApiUrl;
|
|
32
|
+
NotificationsState.ConstructApiClient();
|
|
33
|
+
}
|
|
34
|
+
connectedCallback() {
|
|
35
|
+
super.connectedCallback();
|
|
36
|
+
window.addEventListener('account-switched', NotificationsState.NewApiClient);
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
super.disconnectedCallback();
|
|
40
|
+
window.removeEventListener('account-switched', NotificationsState.NewApiClient);
|
|
41
|
+
}
|
|
42
|
+
toggleDrawer() {
|
|
43
|
+
this.showDrawer = !this.showDrawer;
|
|
44
|
+
if (!this.showDrawer) {
|
|
45
|
+
this.showFilters = false;
|
|
46
|
+
this.showDateFilters = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/* eslint-disable-next-line */
|
|
50
|
+
renderUnReadCountText() {
|
|
51
|
+
if (NotificationsState.unreadNotificationCount <= 0) {
|
|
52
|
+
return html `${nothing}`;
|
|
53
|
+
}
|
|
54
|
+
let unreadCountText = '';
|
|
55
|
+
if (NotificationsState.unreadNotificationCount > 99) {
|
|
56
|
+
unreadCountText = '99+';
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
unreadCountText = NotificationsState.unreadNotificationCount.toString();
|
|
60
|
+
}
|
|
63
61
|
return html ` <div
|
|
64
62
|
class="px-1 bg-red-500 rounded-full text-center text-white text-sm absolute icon-position -start-0"
|
|
65
63
|
style="top:0.05rem ;left: 1.5rem;"
|
|
66
64
|
>
|
|
67
65
|
${unreadCountText}
|
|
68
|
-
</div>`;
|
|
69
|
-
}
|
|
70
|
-
markAllread() {
|
|
71
|
-
this.showMarkAllReadConfirmation = true;
|
|
72
|
-
}
|
|
73
|
-
confirmedMarkAllRead(e) {
|
|
74
|
-
// Mark All read if Confirmed True
|
|
75
|
-
if (e.detail.returnValue) {
|
|
76
|
-
const filterNotification = this.applyNotificationFilters();
|
|
77
|
-
filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.forEach(item => {
|
|
78
|
-
if (item.status === NotificationStatus.UNREAD)
|
|
79
|
-
NotificationsState.setNotificationReadStatus(item.id);
|
|
80
|
-
});
|
|
81
|
-
this.renderUnReadCountText();
|
|
82
|
-
}
|
|
83
|
-
this.showMarkAllReadConfirmation = false;
|
|
84
|
-
}
|
|
85
|
-
toggleGroupView() {
|
|
86
|
-
this.showGroupedView = !this.showGroupedView;
|
|
87
|
-
}
|
|
88
|
-
displayFilters() {
|
|
89
|
-
this.showFilters = !this.showFilters;
|
|
90
|
-
}
|
|
91
|
-
/* eslint-disable-next-line */
|
|
92
|
-
applyNotificationFilters() {
|
|
93
|
-
var _a;
|
|
94
|
-
const filterredNotifications = (_a = NotificationsState.notifications) === null || _a === void 0 ? void 0 : _a.filter((x) => (x.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&
|
|
95
|
-
NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===
|
|
96
|
-
true) ||
|
|
97
|
-
(x.resourceType === NotificationGroups.SERVICE_TICKETS &&
|
|
98
|
-
NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===
|
|
99
|
-
true) ||
|
|
100
|
-
(x.resourceType === NotificationGroups.DCIM_ALERTS &&
|
|
101
|
-
NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||
|
|
102
|
-
x.resourceType === NotificationGroups.INCIDENTS); // Always display incidents
|
|
103
|
-
if (NotificationsState.dateFilters.FROM_DATE === undefined ||
|
|
104
|
-
NotificationsState.dateFilters.TO_DATE === undefined)
|
|
105
|
-
return filterredNotifications;
|
|
106
|
-
return filterredNotifications.filter(x => differenceInHours(new Date(x.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0 &&
|
|
107
|
-
differenceInDays(new Date(x.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
108
|
-
}
|
|
109
|
-
displayDateFilters() {
|
|
110
|
-
this.showDateFilters = !this.showDateFilters;
|
|
111
|
-
}
|
|
112
|
-
renderGroupedView() {
|
|
113
|
-
const filteredNotifications = this.applyNotificationFilters();
|
|
66
|
+
</div>`;
|
|
67
|
+
}
|
|
68
|
+
markAllread() {
|
|
69
|
+
this.showMarkAllReadConfirmation = true;
|
|
70
|
+
}
|
|
71
|
+
confirmedMarkAllRead(e) {
|
|
72
|
+
// Mark All read if Confirmed True
|
|
73
|
+
if (e.detail.returnValue) {
|
|
74
|
+
const filterNotification = this.applyNotificationFilters();
|
|
75
|
+
filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.forEach(item => {
|
|
76
|
+
if (item.status === NotificationStatus.UNREAD)
|
|
77
|
+
NotificationsState.setNotificationReadStatus(item.id);
|
|
78
|
+
});
|
|
79
|
+
this.renderUnReadCountText();
|
|
80
|
+
}
|
|
81
|
+
this.showMarkAllReadConfirmation = false;
|
|
82
|
+
}
|
|
83
|
+
toggleGroupView() {
|
|
84
|
+
this.showGroupedView = !this.showGroupedView;
|
|
85
|
+
}
|
|
86
|
+
displayFilters() {
|
|
87
|
+
this.showFilters = !this.showFilters;
|
|
88
|
+
}
|
|
89
|
+
/* eslint-disable-next-line */
|
|
90
|
+
applyNotificationFilters() {
|
|
91
|
+
var _a;
|
|
92
|
+
const filterredNotifications = (_a = NotificationsState.notifications) === null || _a === void 0 ? void 0 : _a.filter((x) => (x.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&
|
|
93
|
+
NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===
|
|
94
|
+
true) ||
|
|
95
|
+
(x.resourceType === NotificationGroups.SERVICE_TICKETS &&
|
|
96
|
+
NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===
|
|
97
|
+
true) ||
|
|
98
|
+
(x.resourceType === NotificationGroups.DCIM_ALERTS &&
|
|
99
|
+
NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||
|
|
100
|
+
x.resourceType === NotificationGroups.INCIDENTS); // Always display incidents
|
|
101
|
+
if (NotificationsState.dateFilters.FROM_DATE === undefined ||
|
|
102
|
+
NotificationsState.dateFilters.TO_DATE === undefined)
|
|
103
|
+
return filterredNotifications;
|
|
104
|
+
return filterredNotifications.filter(x => differenceInHours(new Date(x.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0 &&
|
|
105
|
+
differenceInDays(new Date(x.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
106
|
+
}
|
|
107
|
+
displayDateFilters() {
|
|
108
|
+
this.showDateFilters = !this.showDateFilters;
|
|
109
|
+
}
|
|
110
|
+
renderGroupedView() {
|
|
111
|
+
const filteredNotifications = this.applyNotificationFilters();
|
|
114
112
|
return html `<div>
|
|
115
113
|
<grouped-item
|
|
116
114
|
groupTitle=${NotificationGroups.PLANNED_MAINTENANCE}
|
|
@@ -132,54 +130,54 @@ export class IxNotifications extends MobxLitElement {
|
|
|
132
130
|
iconName="public"
|
|
133
131
|
.childItems=${filteredNotifications === null || filteredNotifications === void 0 ? void 0 : filteredNotifications.filter(item => item.resourceType === NotificationGroups.DCIM_ALERTS)}
|
|
134
132
|
></grouped-item>
|
|
135
|
-
</div>`;
|
|
136
|
-
}
|
|
137
|
-
renderDefaultView() {
|
|
138
|
-
const filterNotification = this.applyNotificationFilters();
|
|
139
|
-
const filterTodayItems = filterNotification.filter(x => differenceInDays(x.createdAt, new Date()) === 0);
|
|
140
|
-
const filterEarlierItems = filterNotification.filter(x => differenceInDays(x.createdAt, new Date()) !== 0);
|
|
141
|
-
if ((filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.length) > 0) {
|
|
133
|
+
</div>`;
|
|
134
|
+
}
|
|
135
|
+
renderDefaultView() {
|
|
136
|
+
const filterNotification = this.applyNotificationFilters();
|
|
137
|
+
const filterTodayItems = filterNotification.filter(x => differenceInDays(x.createdAt, new Date()) === 0);
|
|
138
|
+
const filterEarlierItems = filterNotification.filter(x => differenceInDays(x.createdAt, new Date()) !== 0);
|
|
139
|
+
if ((filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.length) > 0) {
|
|
142
140
|
return html ` <div class="grow text-sm font-bold py-4 pl-2 align-top">
|
|
143
141
|
Latest
|
|
144
142
|
</div>
|
|
145
143
|
<div class="m-0 p-0">
|
|
146
|
-
${filterTodayItems.length > 0
|
|
144
|
+
${filterTodayItems.length > 0
|
|
147
145
|
? filterTodayItems === null || filterTodayItems === void 0 ? void 0 : filterTodayItems.map(item => html `<notification-item
|
|
148
146
|
.notificaiton=${item}
|
|
149
|
-
?disabled=${item.resourceType ===
|
|
147
|
+
?disabled=${item.resourceType ===
|
|
150
148
|
NotificationGroups.INCIDENTS}
|
|
151
149
|
>
|
|
152
|
-
</notification-item> `)
|
|
150
|
+
</notification-item> `)
|
|
153
151
|
: this.renderNoResult()}
|
|
154
152
|
</div>
|
|
155
153
|
<div class="grow text-sm font-bold py-4 pl-2 align-top">Earlier</div>
|
|
156
154
|
<div>
|
|
157
|
-
${filterEarlierItems.length > 0
|
|
155
|
+
${filterEarlierItems.length > 0
|
|
158
156
|
? filterEarlierItems === null || filterEarlierItems === void 0 ? void 0 : filterEarlierItems.map(item => html `<notification-item
|
|
159
157
|
.notificaiton=${item}
|
|
160
|
-
?disabled=${item.resourceType ===
|
|
158
|
+
?disabled=${item.resourceType ===
|
|
161
159
|
NotificationGroups.INCIDENTS}
|
|
162
160
|
>
|
|
163
|
-
</notification-item> `)
|
|
161
|
+
</notification-item> `)
|
|
164
162
|
: this.renderNoResult()}
|
|
165
|
-
</div>`;
|
|
166
|
-
}
|
|
163
|
+
</div>`;
|
|
164
|
+
}
|
|
167
165
|
return html `<p class="m-0 pl-4 font-bold mr-4">
|
|
168
166
|
<small style="padding-left: 16px">No notifications yet.</small>
|
|
169
|
-
</p>`;
|
|
170
|
-
}
|
|
171
|
-
/* eslint-disable-next-line */
|
|
172
|
-
renderNoResult() {
|
|
167
|
+
</p>`;
|
|
168
|
+
}
|
|
169
|
+
/* eslint-disable-next-line */
|
|
170
|
+
renderNoResult() {
|
|
173
171
|
return html `<p class="m-0 pl-4 font-bold mr-4">
|
|
174
172
|
<small style="padding-left: 16px">No notifications yet.</small>
|
|
175
|
-
</p>`;
|
|
176
|
-
}
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
178
|
-
handleCloseClick(_e) {
|
|
179
|
-
this.showDateFilters = false;
|
|
180
|
-
this.showFilters = false;
|
|
181
|
-
}
|
|
182
|
-
render() {
|
|
173
|
+
</p>`;
|
|
174
|
+
}
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
176
|
+
handleCloseClick(_e) {
|
|
177
|
+
this.showDateFilters = false;
|
|
178
|
+
this.showFilters = false;
|
|
179
|
+
}
|
|
180
|
+
render() {
|
|
183
181
|
return html `
|
|
184
182
|
<div class="relative">
|
|
185
183
|
<ix-icon-button
|
|
@@ -192,8 +190,8 @@ export class IxNotifications extends MobxLitElement {
|
|
|
192
190
|
</div>
|
|
193
191
|
<confirmation-dialog
|
|
194
192
|
?open=${this.showMarkAllReadConfirmation}
|
|
195
|
-
@confirm-dialog-closed=${() => {
|
|
196
|
-
this.showMarkAllReadConfirmation = false;
|
|
193
|
+
@confirm-dialog-closed=${() => {
|
|
194
|
+
this.showMarkAllReadConfirmation = false;
|
|
197
195
|
}}
|
|
198
196
|
@on-confirm-selection=${this.confirmedMarkAllRead}
|
|
199
197
|
textMessage="Are you sure you want to mark all notifications as read?"
|
|
@@ -226,8 +224,8 @@ export class IxNotifications extends MobxLitElement {
|
|
|
226
224
|
class="blue-icon"
|
|
227
225
|
></ix-icon-button>
|
|
228
226
|
<div
|
|
229
|
-
class="filter-dropdown-content ${this.showFilters
|
|
230
|
-
? 'active z-50'
|
|
227
|
+
class="filter-dropdown-content ${this.showFilters
|
|
228
|
+
? 'active z-50'
|
|
231
229
|
: ''}"
|
|
232
230
|
>
|
|
233
231
|
<group-filters></group-filters>
|
|
@@ -238,8 +236,8 @@ export class IxNotifications extends MobxLitElement {
|
|
|
238
236
|
class="blue-icon"
|
|
239
237
|
></ix-icon-button>
|
|
240
238
|
<div
|
|
241
|
-
class="datefilter-dropdown-content ${this.showDateFilters
|
|
242
|
-
? 'active z-50'
|
|
239
|
+
class="datefilter-dropdown-content ${this.showDateFilters
|
|
240
|
+
? 'active z-50'
|
|
243
241
|
: ''}"
|
|
244
242
|
@on-selection=${this.handleCloseClick}
|
|
245
243
|
>
|
|
@@ -248,31 +246,31 @@ export class IxNotifications extends MobxLitElement {
|
|
|
248
246
|
</div>
|
|
249
247
|
</div>
|
|
250
248
|
<div slot="content">
|
|
251
|
-
${this.showGroupedView
|
|
252
|
-
? this.renderGroupedView()
|
|
249
|
+
${this.showGroupedView
|
|
250
|
+
? this.renderGroupedView()
|
|
253
251
|
: this.renderDefaultView()}
|
|
254
252
|
</div>
|
|
255
253
|
</ix-drawer>
|
|
256
|
-
`;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
IxNotifications.styles = [TWStyles, NotificationsStyle];
|
|
260
|
-
__decorate([
|
|
261
|
-
state()
|
|
262
|
-
], IxNotifications.prototype, "showDrawer", void 0);
|
|
263
|
-
__decorate([
|
|
264
|
-
state()
|
|
265
|
-
], IxNotifications.prototype, "showGroupedView", void 0);
|
|
266
|
-
__decorate([
|
|
267
|
-
state()
|
|
268
|
-
], IxNotifications.prototype, "showFilters", void 0);
|
|
269
|
-
__decorate([
|
|
270
|
-
state()
|
|
271
|
-
], IxNotifications.prototype, "showDateFilters", void 0);
|
|
272
|
-
__decorate([
|
|
273
|
-
state()
|
|
274
|
-
], IxNotifications.prototype, "showMarkAllReadConfirmation", void 0);
|
|
275
|
-
__decorate([
|
|
276
|
-
property({ type: String })
|
|
277
|
-
], IxNotifications.prototype, "baseApiUrl", void 0);
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
IxNotifications.styles = [TWStyles, NotificationsStyle];
|
|
258
|
+
__decorate([
|
|
259
|
+
state()
|
|
260
|
+
], IxNotifications.prototype, "showDrawer", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
state()
|
|
263
|
+
], IxNotifications.prototype, "showGroupedView", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
state()
|
|
266
|
+
], IxNotifications.prototype, "showFilters", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
state()
|
|
269
|
+
], IxNotifications.prototype, "showDateFilters", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
state()
|
|
272
|
+
], IxNotifications.prototype, "showMarkAllReadConfirmation", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
property({ type: String })
|
|
275
|
+
], IxNotifications.prototype, "baseApiUrl", void 0);
|
|
278
276
|
//# sourceMappingURL=IxNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxNotifications.js","sourceRoot":"","sources":["../src/IxNotifications.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,wCAAwC,CAAC;AAChD,OAAO,wCAAwC,CAAC;AAChD,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAMlE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,iDAAiD,CAAC;AACzD,OAAO,4CAA4C,CAAC;AACpD,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAAnD;;QAGmB,eAAU,GAAG,KAAK,CAAC;QAEnB,oBAAe,GAAG,KAAK,CAAC;QAExB,gBAAW,GAAG,KAAK,CAAC;QAEpB,oBAAe,GAAG,KAAK,CAAC;QAExB,gCAA2B,GAAG,KAAK,CAAC;QAEzB,eAAU,GAAG,EAAE,CAAC;IAmS9C,CAAC;IAjSC,KAAK,CAAC,YAAY;QAChB,2CAA2C;QAC3C,kBAAkB,CAAC,U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\nimport { property, state } from 'lit/decorators.js';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { differenceInDays, differenceInHours } from 'date-fns';\nimport { TWStyles } from './tw.js';\nimport '@digital-realty/ix-button/ix-button.js';\nimport '@digital-realty/ix-drawer/ix-drawer.js';\nimport '@digital-realty/ix-icon';\nimport '@material/web/icon/icon.js';\nimport { NotificationsState } from './state/NotificationState.js';\nimport { Notification } from './models/notification.js';\nimport {\n ConfirmationDialogEventDetail,\n FilterDialogEventDetail,\n} from './constants/notification-types.js';\nimport {\n NotificationGroups,\n NotificationStatus,\n} from './constants/notifications.js';\nimport './components/notifications/notification-item.js';\nimport './components/notifications/grouped-item.js';\nimport './components/notifications/group-filters.js';\nimport './components/notifications/date-filters.js';\nimport './components/notifications/confirmation-dialog.js';\nimport { NotificationsStyle } from './styles/notifications-style.js';\n\nexport class IxNotifications extends MobxLitElement {\n static styles = [TWStyles, NotificationsStyle];\n\n @state() private showDrawer = false;\n\n @state() private showGroupedView = false;\n\n @state() private showFilters = false;\n\n @state() private showDateFilters = false;\n\n @state() private showMarkAllReadConfirmation = false;\n\n @property({ type: String }) baseApiUrl = '';\n\n async firstUpdated() {\n // Construct ApiClient form baseApiUrl Prop\n NotificationsState.baseApiUrl = this.baseApiUrl;\n NotificationsState.ConstructApiClient();\n\n // Load the notifications\n await NotificationsState.getNotifications();\n }\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\n 'account-switched',\n NotificationsState.NewApiClient\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\n 'account-switched',\n NotificationsState.NewApiClient\n );\n }\n\n toggleDrawer() {\n this.showDrawer = !this.showDrawer;\n if (!this.showDrawer) {\n this.showFilters = false;\n this.showDateFilters = false;\n }\n }\n\n /* eslint-disable-next-line */\n renderUnReadCountText() {\n if (NotificationsState.unreadNotificationCount <= 0) {\n return html`${nothing}`;\n }\n\n let unreadCountText = '';\n if (NotificationsState.unreadNotificationCount > 99) {\n unreadCountText = '99+';\n } else {\n unreadCountText = NotificationsState.unreadNotificationCount.toString();\n }\n\n return html` <div\n class=\"px-1 bg-red-500 rounded-full text-center text-white text-sm absolute icon-position -start-0\"\n style=\"top:0.05rem ;left: 1.5rem;\"\n >\n ${unreadCountText}\n </div>`;\n }\n\n markAllread() {\n this.showMarkAllReadConfirmation = true;\n }\n\n private confirmedMarkAllRead(e: CustomEvent<ConfirmationDialogEventDetail>) {\n // Mark All read if Confirmed True\n if (e.detail.returnValue) {\n const filterNotification = this.applyNotificationFilters();\n\n filterNotification?.forEach(item => {\n if (item.status === NotificationStatus.UNREAD)\n NotificationsState.setNotificationReadStatus(item.id);\n });\n\n this.renderUnReadCountText();\n }\n\n this.showMarkAllReadConfirmation = false;\n }\n\n toggleGroupView() {\n this.showGroupedView = !this.showGroupedView;\n }\n\n displayFilters() {\n this.showFilters = !this.showFilters;\n }\n\n /* eslint-disable-next-line */\n applyNotificationFilters() {\n const filterredNotifications = NotificationsState.notifications?.filter(\n (x: Notification) =>\n (x.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&\n NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===\n true) ||\n (x.resourceType === NotificationGroups.SERVICE_TICKETS &&\n NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===\n true) ||\n (x.resourceType === NotificationGroups.DCIM_ALERTS &&\n NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||\n x.resourceType === NotificationGroups.INCIDENTS\n ); // Always display incidents\n\n if (\n NotificationsState.dateFilters.FROM_DATE === undefined ||\n NotificationsState.dateFilters.TO_DATE === undefined\n )\n return filterredNotifications;\n\n return filterredNotifications.filter(\n x =>\n differenceInHours(\n new Date(x.createdAt),\n NotificationsState.dateFilters.FROM_DATE!\n ) >= 0 &&\n differenceInDays(\n new Date(x.createdAt),\n NotificationsState.dateFilters.TO_DATE!\n ) <= 0\n );\n }\n\n displayDateFilters() {\n this.showDateFilters = !this.showDateFilters;\n }\n\n renderGroupedView() {\n const filteredNotifications = this.applyNotificationFilters();\n\n return html`<div>\n <grouped-item\n groupTitle=${NotificationGroups.PLANNED_MAINTENANCE}\n iconName=\"lab_profile\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.PLANNED_MAINTENANCE\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.INCIDENTS}\n iconName=\"emergency_home\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.INCIDENTS\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.SERVICE_TICKETS}\n iconName=\"dvr\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.SERVICE_TICKETS\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.DCIM_ALERTS}\n iconName=\"public\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.DCIM_ALERTS\n )}\n ></grouped-item>\n </div>`;\n }\n\n renderDefaultView() {\n const filterNotification = this.applyNotificationFilters();\n const filterTodayItems = filterNotification.filter(\n x => differenceInDays(x.createdAt, new Date()) === 0\n );\n const filterEarlierItems = filterNotification.filter(\n x => differenceInDays(x.createdAt, new Date()) !== 0\n );\n\n if (filterNotification?.length! > 0) {\n return html` <div class=\"grow text-sm font-bold py-4 pl-2 align-top\">\n Latest\n </div>\n <div class=\"m-0 p-0\">\n ${filterTodayItems.length > 0\n ? filterTodayItems?.map(\n item => html`<notification-item\n .notificaiton=${item}\n ?disabled=${item.resourceType ===\n NotificationGroups.INCIDENTS}\n >\n </notification-item> `\n )\n : this.renderNoResult()}\n </div>\n <div class=\"grow text-sm font-bold py-4 pl-2 align-top\">Earlier</div>\n <div>\n ${filterEarlierItems.length > 0\n ? filterEarlierItems?.map(\n item => html`<notification-item\n .notificaiton=${item}\n ?disabled=${item.resourceType ===\n NotificationGroups.INCIDENTS}\n >\n </notification-item> `\n )\n : this.renderNoResult()}\n </div>`;\n }\n\n return html`<p class=\"m-0 pl-4 font-bold mr-4\">\n <small style=\"padding-left: 16px\">No notifications yet.</small>\n </p>`;\n }\n\n /* eslint-disable-next-line */\n renderNoResult() {\n return html`<p class=\"m-0 pl-4 font-bold mr-4\">\n <small style=\"padding-left: 16px\">No notifications yet.</small>\n </p>`;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n handleCloseClick(_e: CustomEvent<FilterDialogEventDetail>) {\n this.showDateFilters = false;\n this.showFilters = false;\n }\n\n render() {\n return html`\n <div class=\"relative\">\n <ix-icon-button\n icon=\"circle_notifications\"\n class=\"blue-icon\"\n @click=${() => this.toggleDrawer()}\n >\n </ix-icon-button>\n ${this.renderUnReadCountText()}\n </div>\n <confirmation-dialog\n ?open=${this.showMarkAllReadConfirmation}\n @confirm-dialog-closed=${() => {\n this.showMarkAllReadConfirmation = false;\n }}\n @on-confirm-selection=${this.confirmedMarkAllRead}\n textMessage=\"Are you sure you want to mark all notifications as read?\"\n >\n </confirmation-dialog>\n <ix-drawer\n ?isVisible=${this.showDrawer}\n .onClosed=${() => this.toggleDrawer()}\n animate-vertical\n hide-close\n >\n <div class=\"flex flex-row justify-between grow py-2\" slot=\"header\">\n <div class=\"grow text-xl items-center font-bold py-4 pl-2 align-top\">\n Notifications\n </div>\n <div class=\"flex flex-row justify-end grow items-center \">\n <ix-icon-button\n @click=${this.markAllread}\n icon=\"fact_check\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <ix-icon-button\n @click=${this.toggleGroupView}\n icon=\"sort\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <ix-icon-button\n @click=${this.displayFilters}\n icon=\"menu\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <div\n class=\"filter-dropdown-content ${this.showFilters\n ? 'active z-50'\n : ''}\"\n >\n <group-filters></group-filters>\n </div>\n <ix-icon-button\n @click=${this.displayDateFilters}\n icon=\"calendar_month\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <div\n class=\"datefilter-dropdown-content ${this.showDateFilters\n ? 'active z-50'\n : ''}\"\n @on-selection=${this.handleCloseClick}\n >\n <date-filters></date-filters>\n </div>\n </div>\n </div>\n <div slot=\"content\">\n ${this.showGroupedView\n ? this.renderGroupedView()\n : this.renderDefaultView()}\n </div>\n </ix-drawer>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxNotifications.js","sourceRoot":"","sources":["../src/IxNotifications.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,wCAAwC,CAAC;AAChD,OAAO,wCAAwC,CAAC;AAChD,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAMlE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,iDAAiD,CAAC;AACzD,OAAO,4CAA4C,CAAC;AACpD,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAAnD;;QAGmB,eAAU,GAAG,KAAK,CAAC;QAEnB,oBAAe,GAAG,KAAK,CAAC;QAExB,gBAAW,GAAG,KAAK,CAAC;QAEpB,oBAAe,GAAG,KAAK,CAAC;QAExB,gCAA2B,GAAG,KAAK,CAAC;QAEzB,eAAU,GAAG,EAAE,CAAC;IAgS9C,CAAC;IA9RC,KAAK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from 'lit/decorators.js';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport { differenceInDays, differenceInHours } from 'date-fns';\nimport { TWStyles } from './tw.js';\nimport '@digital-realty/ix-button/ix-button.js';\nimport '@digital-realty/ix-drawer/ix-drawer.js';\nimport '@digital-realty/ix-icon';\nimport '@material/web/icon/icon.js';\nimport { NotificationsState } from './state/NotificationState.js';\nimport { Notification } from './models/notification.js';\nimport {\n ConfirmationDialogEventDetail,\n FilterDialogEventDetail,\n} from './constants/notification-types.js';\nimport {\n NotificationGroups,\n NotificationStatus,\n} from './constants/notifications.js';\nimport './components/notifications/notification-item.js';\nimport './components/notifications/grouped-item.js';\nimport './components/notifications/group-filters.js';\nimport './components/notifications/date-filters.js';\nimport './components/notifications/confirmation-dialog.js';\nimport { NotificationsStyle } from './styles/notifications-style.js';\n\nexport class IxNotifications extends MobxLitElement {\n static styles = [TWStyles, NotificationsStyle];\n\n @state() private showDrawer = false;\n\n @state() private showGroupedView = false;\n\n @state() private showFilters = false;\n\n @state() private showDateFilters = false;\n\n @state() private showMarkAllReadConfirmation = false;\n\n @property({ type: String }) baseApiUrl = '';\n\n async firstUpdated() {\n // Construct ApiClient form baseApiUrl Prop\n NotificationsState.baseApiUrl = this.baseApiUrl;\n NotificationsState.ConstructApiClient();\n }\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\n 'account-switched',\n NotificationsState.NewApiClient\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\n 'account-switched',\n NotificationsState.NewApiClient\n );\n }\n\n toggleDrawer() {\n this.showDrawer = !this.showDrawer;\n if (!this.showDrawer) {\n this.showFilters = false;\n this.showDateFilters = false;\n }\n }\n\n /* eslint-disable-next-line */\n renderUnReadCountText() {\n if (NotificationsState.unreadNotificationCount <= 0) {\n return html`${nothing}`;\n }\n\n let unreadCountText = '';\n if (NotificationsState.unreadNotificationCount > 99) {\n unreadCountText = '99+';\n } else {\n unreadCountText = NotificationsState.unreadNotificationCount.toString();\n }\n\n return html` <div\n class=\"px-1 bg-red-500 rounded-full text-center text-white text-sm absolute icon-position -start-0\"\n style=\"top:0.05rem ;left: 1.5rem;\"\n >\n ${unreadCountText}\n </div>`;\n }\n\n markAllread() {\n this.showMarkAllReadConfirmation = true;\n }\n\n private confirmedMarkAllRead(e: CustomEvent<ConfirmationDialogEventDetail>) {\n // Mark All read if Confirmed True\n if (e.detail.returnValue) {\n const filterNotification = this.applyNotificationFilters();\n\n filterNotification?.forEach(item => {\n if (item.status === NotificationStatus.UNREAD)\n NotificationsState.setNotificationReadStatus(item.id);\n });\n\n this.renderUnReadCountText();\n }\n\n this.showMarkAllReadConfirmation = false;\n }\n\n toggleGroupView() {\n this.showGroupedView = !this.showGroupedView;\n }\n\n displayFilters() {\n this.showFilters = !this.showFilters;\n }\n\n /* eslint-disable-next-line */\n applyNotificationFilters() {\n const filterredNotifications = NotificationsState.notifications?.filter(\n (x: Notification) =>\n (x.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&\n NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===\n true) ||\n (x.resourceType === NotificationGroups.SERVICE_TICKETS &&\n NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===\n true) ||\n (x.resourceType === NotificationGroups.DCIM_ALERTS &&\n NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||\n x.resourceType === NotificationGroups.INCIDENTS\n ); // Always display incidents\n\n if (\n NotificationsState.dateFilters.FROM_DATE === undefined ||\n NotificationsState.dateFilters.TO_DATE === undefined\n )\n return filterredNotifications;\n\n return filterredNotifications.filter(\n x =>\n differenceInHours(\n new Date(x.createdAt),\n NotificationsState.dateFilters.FROM_DATE!\n ) >= 0 &&\n differenceInDays(\n new Date(x.createdAt),\n NotificationsState.dateFilters.TO_DATE!\n ) <= 0\n );\n }\n\n displayDateFilters() {\n this.showDateFilters = !this.showDateFilters;\n }\n\n renderGroupedView() {\n const filteredNotifications = this.applyNotificationFilters();\n\n return html`<div>\n <grouped-item\n groupTitle=${NotificationGroups.PLANNED_MAINTENANCE}\n iconName=\"lab_profile\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.PLANNED_MAINTENANCE\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.INCIDENTS}\n iconName=\"emergency_home\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.INCIDENTS\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.SERVICE_TICKETS}\n iconName=\"dvr\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.SERVICE_TICKETS\n )}\n ></grouped-item>\n <grouped-item\n groupTitle=${NotificationGroups.DCIM_ALERTS}\n iconName=\"public\"\n .childItems=${filteredNotifications?.filter(\n item => item.resourceType === NotificationGroups.DCIM_ALERTS\n )}\n ></grouped-item>\n </div>`;\n }\n\n renderDefaultView() {\n const filterNotification = this.applyNotificationFilters();\n const filterTodayItems = filterNotification.filter(\n x => differenceInDays(x.createdAt, new Date()) === 0\n );\n const filterEarlierItems = filterNotification.filter(\n x => differenceInDays(x.createdAt, new Date()) !== 0\n );\n\n if (filterNotification?.length! > 0) {\n return html` <div class=\"grow text-sm font-bold py-4 pl-2 align-top\">\n Latest\n </div>\n <div class=\"m-0 p-0\">\n ${filterTodayItems.length > 0\n ? filterTodayItems?.map(\n item => html`<notification-item\n .notificaiton=${item}\n ?disabled=${item.resourceType ===\n NotificationGroups.INCIDENTS}\n >\n </notification-item> `\n )\n : this.renderNoResult()}\n </div>\n <div class=\"grow text-sm font-bold py-4 pl-2 align-top\">Earlier</div>\n <div>\n ${filterEarlierItems.length > 0\n ? filterEarlierItems?.map(\n item => html`<notification-item\n .notificaiton=${item}\n ?disabled=${item.resourceType ===\n NotificationGroups.INCIDENTS}\n >\n </notification-item> `\n )\n : this.renderNoResult()}\n </div>`;\n }\n\n return html`<p class=\"m-0 pl-4 font-bold mr-4\">\n <small style=\"padding-left: 16px\">No notifications yet.</small>\n </p>`;\n }\n\n /* eslint-disable-next-line */\n renderNoResult() {\n return html`<p class=\"m-0 pl-4 font-bold mr-4\">\n <small style=\"padding-left: 16px\">No notifications yet.</small>\n </p>`;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n handleCloseClick(_e: CustomEvent<FilterDialogEventDetail>) {\n this.showDateFilters = false;\n this.showFilters = false;\n }\n\n render() {\n return html`\n <div class=\"relative\">\n <ix-icon-button\n icon=\"circle_notifications\"\n class=\"blue-icon\"\n @click=${() => this.toggleDrawer()}\n >\n </ix-icon-button>\n ${this.renderUnReadCountText()}\n </div>\n <confirmation-dialog\n ?open=${this.showMarkAllReadConfirmation}\n @confirm-dialog-closed=${() => {\n this.showMarkAllReadConfirmation = false;\n }}\n @on-confirm-selection=${this.confirmedMarkAllRead}\n textMessage=\"Are you sure you want to mark all notifications as read?\"\n >\n </confirmation-dialog>\n <ix-drawer\n ?isVisible=${this.showDrawer}\n .onClosed=${() => this.toggleDrawer()}\n animate-vertical\n hide-close\n >\n <div class=\"flex flex-row justify-between grow py-2\" slot=\"header\">\n <div class=\"grow text-xl items-center font-bold py-4 pl-2 align-top\">\n Notifications\n </div>\n <div class=\"flex flex-row justify-end grow items-center \">\n <ix-icon-button\n @click=${this.markAllread}\n icon=\"fact_check\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <ix-icon-button\n @click=${this.toggleGroupView}\n icon=\"sort\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <ix-icon-button\n @click=${this.displayFilters}\n icon=\"menu\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <div\n class=\"filter-dropdown-content ${this.showFilters\n ? 'active z-50'\n : ''}\"\n >\n <group-filters></group-filters>\n </div>\n <ix-icon-button\n @click=${this.displayDateFilters}\n icon=\"calendar_month\"\n class=\"blue-icon\"\n ></ix-icon-button>\n <div\n class=\"datefilter-dropdown-content ${this.showDateFilters\n ? 'active z-50'\n : ''}\"\n @on-selection=${this.handleCloseClick}\n >\n <date-filters></date-filters>\n </div>\n </div>\n </div>\n <div slot=\"content\">\n ${this.showGroupedView\n ? this.renderGroupedView()\n : this.renderDefaultView()}\n </div>\n </ix-drawer>\n `;\n }\n}\n"]}
|