@digital-realty/ix-notifications 1.0.31 → 1.0.33-alpha.0
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 +46 -46
- package/dist/IxNotifications.js +269 -269
- package/dist/api/notifications-api/apis/NotificationsApi.d.ts +83 -83
- package/dist/api/notifications-api/apis/NotificationsApi.js +202 -202
- 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/assets/iconset.d.ts +6 -6
- package/dist/assets/iconset.js +7 -7
- 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 +121 -121
- 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 +57 -57
- package/dist/components/notifications/notification-item.d.ts +22 -22
- package/dist/components/notifications/notification-item.js +145 -145
- package/dist/components/notifications/notification-tooltip.d.ts +15 -15
- package/dist/components/notifications/notification-tooltip.js +78 -78
- package/dist/components/notifications/view-item-dialog.d.ts +13 -13
- package/dist/components/notifications/view-item-dialog.js +81 -81
- 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 +27 -27
- package/dist/constants/notifications.js +32 -32
- package/dist/helper/common.d.ts +1 -1
- package/dist/helper/common.js +9 -9
- 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/models/notification.d.ts +17 -17
- 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 +5 -5
- package/dist/services/notifications-service.d.ts +11 -11
- package/dist/services/notifications-service.js +64 -64
- package/dist/state/NotificationState.d.ts +35 -35
- package/dist/state/NotificationState.js +191 -191
- 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 +11 -11
package/dist/IxNotifications.js
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { html, nothing } from 'lit';
|
|
3
|
-
import { property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
5
|
-
import { differenceInDays, differenceInHours } from 'date-fns';
|
|
6
|
-
import { plannedMaintenance, viewList, dcim, sortCheck, } from './assets/iconset.js';
|
|
7
|
-
import { TWStyles } from './tw.js';
|
|
8
|
-
import '@digital-realty/ix-button/ix-button.js';
|
|
9
|
-
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
10
|
-
import '@digital-realty/ix-icon';
|
|
11
|
-
import '@material/web/icon/icon.js';
|
|
12
|
-
import { NotificationsState } from './state/NotificationState.js';
|
|
13
|
-
import { ApiCallState, NotificationGroups, NotificationStatus, } from './constants/notifications.js';
|
|
14
|
-
import './components/notifications/notification-item.js';
|
|
15
|
-
import './components/notifications/grouped-item.js';
|
|
16
|
-
import './components/notifications/group-filters.js';
|
|
17
|
-
import './components/notifications/date-filters.js';
|
|
18
|
-
import './components/notifications/confirmation-dialog.js';
|
|
19
|
-
import { NotificationsStyle } from './styles/notifications-style.js';
|
|
20
|
-
import './components/notifications/notification-tooltip.js';
|
|
21
|
-
export class IxNotifications extends MobxLitElement {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
this.showGroupedView = false;
|
|
25
|
-
this.showFilters = false;
|
|
26
|
-
this.showDateFilters = false;
|
|
27
|
-
this.showMarkAllReadConfirmation = false;
|
|
28
|
-
this.baseApiUrl = '';
|
|
29
|
-
this.localStorageKey = '';
|
|
30
|
-
}
|
|
31
|
-
async firstUpdated() {
|
|
32
|
-
// Construct ApiClient form baseApiUrl and localStorageKey
|
|
33
|
-
NotificationsState.baseApiUrl = this.baseApiUrl;
|
|
34
|
-
NotificationsState.localStorageKey = this.localStorageKey;
|
|
35
|
-
NotificationsState.ConstructApiClient();
|
|
36
|
-
}
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
super.connectedCallback();
|
|
39
|
-
window.addEventListener('account-switched', NotificationsState.NewApiClient);
|
|
40
|
-
window.addEventListener('beforeunload', this.handleOnbeforeunload);
|
|
41
|
-
}
|
|
42
|
-
disconnectedCallback() {
|
|
43
|
-
window.removeEventListener('account-switched', NotificationsState.NewApiClient);
|
|
44
|
-
window.removeEventListener('beforeunload', this.handleOnbeforeunload);
|
|
45
|
-
super.disconnectedCallback();
|
|
46
|
-
}
|
|
47
|
-
// Handle browser refresh event
|
|
48
|
-
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
49
|
-
handleOnbeforeunload(event) {
|
|
50
|
-
NotificationsState.clearStoredNotificationsData();
|
|
51
|
-
}
|
|
52
|
-
toggleDrawer() {
|
|
53
|
-
NotificationsState.showDrawer = !NotificationsState.showDrawer;
|
|
54
|
-
if (!NotificationsState.showDrawer) {
|
|
55
|
-
this.showFilters = false;
|
|
56
|
-
this.showDateFilters = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/* eslint-disable-next-line */
|
|
60
|
-
renderUnReadCountText() {
|
|
61
|
-
if (NotificationsState.unreadNotificationCount <= 0) {
|
|
62
|
-
return html `${nothing}`;
|
|
63
|
-
}
|
|
64
|
-
let unreadCountText = '';
|
|
65
|
-
if (NotificationsState.unreadNotificationCount > 99) {
|
|
66
|
-
unreadCountText = '99+';
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
unreadCountText = NotificationsState.unreadNotificationCount.toString();
|
|
70
|
-
}
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
5
|
+
import { differenceInDays, differenceInHours } from 'date-fns';
|
|
6
|
+
import { plannedMaintenance, viewList, dcim, sortCheck, } from './assets/iconset.js';
|
|
7
|
+
import { TWStyles } from './tw.js';
|
|
8
|
+
import '@digital-realty/ix-button/ix-button.js';
|
|
9
|
+
import '@digital-realty/ix-drawer/ix-drawer.js';
|
|
10
|
+
import '@digital-realty/ix-icon';
|
|
11
|
+
import '@material/web/icon/icon.js';
|
|
12
|
+
import { NotificationsState } from './state/NotificationState.js';
|
|
13
|
+
import { ApiCallState, NotificationGroups, NotificationStatus, } from './constants/notifications.js';
|
|
14
|
+
import './components/notifications/notification-item.js';
|
|
15
|
+
import './components/notifications/grouped-item.js';
|
|
16
|
+
import './components/notifications/group-filters.js';
|
|
17
|
+
import './components/notifications/date-filters.js';
|
|
18
|
+
import './components/notifications/confirmation-dialog.js';
|
|
19
|
+
import { NotificationsStyle } from './styles/notifications-style.js';
|
|
20
|
+
import './components/notifications/notification-tooltip.js';
|
|
21
|
+
export class IxNotifications extends MobxLitElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.showGroupedView = false;
|
|
25
|
+
this.showFilters = false;
|
|
26
|
+
this.showDateFilters = false;
|
|
27
|
+
this.showMarkAllReadConfirmation = false;
|
|
28
|
+
this.baseApiUrl = '';
|
|
29
|
+
this.localStorageKey = '';
|
|
30
|
+
}
|
|
31
|
+
async firstUpdated() {
|
|
32
|
+
// Construct ApiClient form baseApiUrl and localStorageKey
|
|
33
|
+
NotificationsState.baseApiUrl = this.baseApiUrl;
|
|
34
|
+
NotificationsState.localStorageKey = this.localStorageKey;
|
|
35
|
+
NotificationsState.ConstructApiClient();
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
window.addEventListener('account-switched', NotificationsState.NewApiClient);
|
|
40
|
+
window.addEventListener('beforeunload', this.handleOnbeforeunload);
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
window.removeEventListener('account-switched', NotificationsState.NewApiClient);
|
|
44
|
+
window.removeEventListener('beforeunload', this.handleOnbeforeunload);
|
|
45
|
+
super.disconnectedCallback();
|
|
46
|
+
}
|
|
47
|
+
// Handle browser refresh event
|
|
48
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
49
|
+
handleOnbeforeunload(event) {
|
|
50
|
+
NotificationsState.clearStoredNotificationsData();
|
|
51
|
+
}
|
|
52
|
+
toggleDrawer() {
|
|
53
|
+
NotificationsState.showDrawer = !NotificationsState.showDrawer;
|
|
54
|
+
if (!NotificationsState.showDrawer) {
|
|
55
|
+
this.showFilters = false;
|
|
56
|
+
this.showDateFilters = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/* eslint-disable-next-line */
|
|
60
|
+
renderUnReadCountText() {
|
|
61
|
+
if (NotificationsState.unreadNotificationCount <= 0) {
|
|
62
|
+
return html `${nothing}`;
|
|
63
|
+
}
|
|
64
|
+
let unreadCountText = '';
|
|
65
|
+
if (NotificationsState.unreadNotificationCount > 99) {
|
|
66
|
+
unreadCountText = '99+';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
unreadCountText = NotificationsState.unreadNotificationCount.toString();
|
|
70
|
+
}
|
|
71
71
|
return html ` <div
|
|
72
72
|
class="unread rounded-full text-center text-white text-sm absolute icon-position -start-0"
|
|
73
73
|
>
|
|
74
74
|
${unreadCountText}
|
|
75
|
-
</div>`;
|
|
76
|
-
}
|
|
77
|
-
markAllread() {
|
|
78
|
-
if (NotificationsState.unreadNotificationCount > 0) {
|
|
79
|
-
this.showMarkAllReadConfirmation = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
confirmedMarkAllRead(e) {
|
|
83
|
-
// Mark All read if Confirmed True
|
|
84
|
-
if (e.detail.returnValue) {
|
|
85
|
-
const filterNotification = this.applyNotificationFilters();
|
|
86
|
-
const unreadItems = filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.filter(item => item.status === NotificationStatus.UNREAD);
|
|
87
|
-
if (unreadItems.length > 0) {
|
|
88
|
-
let allResultSuccesful = true;
|
|
89
|
-
filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.forEach(item => {
|
|
90
|
-
NotificationsState.setNotificationReadStatus(item.id).then((result) => {
|
|
91
|
-
if (allResultSuccesful)
|
|
92
|
-
allResultSuccesful = result;
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
const apiResult = {
|
|
96
|
-
State: allResultSuccesful === true
|
|
97
|
-
? ApiCallState.SUCCESS
|
|
98
|
-
: ApiCallState.ERROR,
|
|
99
|
-
Message: allResultSuccesful === true
|
|
100
|
-
? 'Successfully marked all the notificaions as read'
|
|
101
|
-
: 'Error while marking the notifications read, Please try again',
|
|
102
|
-
};
|
|
103
|
-
this.showResultMessage(apiResult, unreadItems[0].id);
|
|
104
|
-
this.renderUnReadCountText();
|
|
105
|
-
this.requestUpdate();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
this.showMarkAllReadConfirmation = false;
|
|
109
|
-
}
|
|
110
|
-
// eslint-disable-next-line class-methods-use-this
|
|
111
|
-
showResultMessage(result, id) {
|
|
112
|
-
window.dispatchEvent(new CustomEvent('add-toast', {
|
|
113
|
-
detail: {
|
|
114
|
-
id,
|
|
75
|
+
</div>`;
|
|
76
|
+
}
|
|
77
|
+
markAllread() {
|
|
78
|
+
if (NotificationsState.unreadNotificationCount > 0) {
|
|
79
|
+
this.showMarkAllReadConfirmation = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
confirmedMarkAllRead(e) {
|
|
83
|
+
// Mark All read if Confirmed True
|
|
84
|
+
if (e.detail.returnValue) {
|
|
85
|
+
const filterNotification = this.applyNotificationFilters();
|
|
86
|
+
const unreadItems = filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.filter(item => item.status === NotificationStatus.UNREAD);
|
|
87
|
+
if (unreadItems.length > 0) {
|
|
88
|
+
let allResultSuccesful = true;
|
|
89
|
+
filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.forEach(item => {
|
|
90
|
+
NotificationsState.setNotificationReadStatus(item.id).then((result) => {
|
|
91
|
+
if (allResultSuccesful)
|
|
92
|
+
allResultSuccesful = result;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
const apiResult = {
|
|
96
|
+
State: allResultSuccesful === true
|
|
97
|
+
? ApiCallState.SUCCESS
|
|
98
|
+
: ApiCallState.ERROR,
|
|
99
|
+
Message: allResultSuccesful === true
|
|
100
|
+
? 'Successfully marked all the notificaions as read'
|
|
101
|
+
: 'Error while marking the notifications read, Please try again',
|
|
102
|
+
};
|
|
103
|
+
this.showResultMessage(apiResult, unreadItems[0].id);
|
|
104
|
+
this.renderUnReadCountText();
|
|
105
|
+
this.requestUpdate();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this.showMarkAllReadConfirmation = false;
|
|
109
|
+
}
|
|
110
|
+
// eslint-disable-next-line class-methods-use-this
|
|
111
|
+
showResultMessage(result, id) {
|
|
112
|
+
window.dispatchEvent(new CustomEvent('add-toast', {
|
|
113
|
+
detail: {
|
|
114
|
+
id,
|
|
115
115
|
content: html ` <ix-message-toast
|
|
116
116
|
toastId=${id}
|
|
117
117
|
.TMessageToast=${result.State.toLowerCase()}
|
|
118
118
|
forceClose
|
|
119
119
|
>
|
|
120
120
|
${result.Message}
|
|
121
|
-
</ix-message-toast>`,
|
|
122
|
-
autoClose: 3000,
|
|
123
|
-
durationOut: 3000,
|
|
124
|
-
vertical: 'bottom',
|
|
125
|
-
horizontal: 'center',
|
|
126
|
-
animated: true,
|
|
127
|
-
above: false,
|
|
128
|
-
},
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
toggleGroupView() {
|
|
132
|
-
this.showGroupedView = !this.showGroupedView;
|
|
133
|
-
}
|
|
134
|
-
displayFilters() {
|
|
135
|
-
this.showFilters = !this.showFilters;
|
|
136
|
-
}
|
|
137
|
-
/* eslint-disable-next-line */
|
|
138
|
-
applyNotificationFilters() {
|
|
139
|
-
var _a;
|
|
140
|
-
const filteredNotifications = (_a = NotificationsState.notifications) === null || _a === void 0 ? void 0 : _a.filter((notification) => (notification.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&
|
|
141
|
-
NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===
|
|
142
|
-
true) ||
|
|
143
|
-
(notification.resourceType === NotificationGroups.SERVICE_TICKETS &&
|
|
144
|
-
NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===
|
|
145
|
-
true) ||
|
|
146
|
-
(notification.resourceType === NotificationGroups.DCIM_ALERTS &&
|
|
147
|
-
NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||
|
|
148
|
-
notification.resourceType === NotificationGroups.INCIDENTS); // Always display incidents
|
|
149
|
-
// both dates are defined, search within the window
|
|
150
|
-
if (NotificationsState.dateFilters.FROM_DATE !== undefined &&
|
|
151
|
-
NotificationsState.dateFilters.TO_DATE !== undefined)
|
|
152
|
-
return filteredNotifications.filter(notification => differenceInHours(new Date(notification.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0 &&
|
|
153
|
-
differenceInDays(new Date(notification.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
154
|
-
// FROM_DATE is defined, TO_DATE is undefined, return notifications after FROM_DATE
|
|
155
|
-
if (NotificationsState.dateFilters.FROM_DATE !== undefined &&
|
|
156
|
-
NotificationsState.dateFilters.TO_DATE === undefined)
|
|
157
|
-
return filteredNotifications.filter(notification => differenceInHours(new Date(notification.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0);
|
|
158
|
-
// TO_DATE is defined, FROM_DATE is undefined, return notifications before TO_DATE
|
|
159
|
-
if (NotificationsState.dateFilters.FROM_DATE === undefined &&
|
|
160
|
-
NotificationsState.dateFilters.TO_DATE !== undefined)
|
|
161
|
-
return filteredNotifications.filter(notification => differenceInDays(new Date(notification.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
162
|
-
return filteredNotifications;
|
|
163
|
-
}
|
|
164
|
-
displayDateFilters() {
|
|
165
|
-
this.showDateFilters = !this.showDateFilters;
|
|
166
|
-
}
|
|
167
|
-
renderGroupedView() {
|
|
168
|
-
const filteredNotifications = this.applyNotificationFilters();
|
|
121
|
+
</ix-message-toast>`,
|
|
122
|
+
autoClose: 3000,
|
|
123
|
+
durationOut: 3000,
|
|
124
|
+
vertical: 'bottom',
|
|
125
|
+
horizontal: 'center',
|
|
126
|
+
animated: true,
|
|
127
|
+
above: false,
|
|
128
|
+
},
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
toggleGroupView() {
|
|
132
|
+
this.showGroupedView = !this.showGroupedView;
|
|
133
|
+
}
|
|
134
|
+
displayFilters() {
|
|
135
|
+
this.showFilters = !this.showFilters;
|
|
136
|
+
}
|
|
137
|
+
/* eslint-disable-next-line */
|
|
138
|
+
applyNotificationFilters() {
|
|
139
|
+
var _a;
|
|
140
|
+
const filteredNotifications = (_a = NotificationsState.notifications) === null || _a === void 0 ? void 0 : _a.filter((notification) => (notification.resourceType === NotificationGroups.PLANNED_MAINTENANCE &&
|
|
141
|
+
NotificationsState.notificationFilters.SHOW_PLANNED_MAINTENANCE ===
|
|
142
|
+
true) ||
|
|
143
|
+
(notification.resourceType === NotificationGroups.SERVICE_TICKETS &&
|
|
144
|
+
NotificationsState.notificationFilters.SHOW_SERVICE_TICKETS ===
|
|
145
|
+
true) ||
|
|
146
|
+
(notification.resourceType === NotificationGroups.DCIM_ALERTS &&
|
|
147
|
+
NotificationsState.notificationFilters.SHOW_DCIM_ALERTS === true) ||
|
|
148
|
+
notification.resourceType === NotificationGroups.INCIDENTS); // Always display incidents
|
|
149
|
+
// both dates are defined, search within the window
|
|
150
|
+
if (NotificationsState.dateFilters.FROM_DATE !== undefined &&
|
|
151
|
+
NotificationsState.dateFilters.TO_DATE !== undefined)
|
|
152
|
+
return filteredNotifications.filter(notification => differenceInHours(new Date(notification.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0 &&
|
|
153
|
+
differenceInDays(new Date(notification.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
154
|
+
// FROM_DATE is defined, TO_DATE is undefined, return notifications after FROM_DATE
|
|
155
|
+
if (NotificationsState.dateFilters.FROM_DATE !== undefined &&
|
|
156
|
+
NotificationsState.dateFilters.TO_DATE === undefined)
|
|
157
|
+
return filteredNotifications.filter(notification => differenceInHours(new Date(notification.createdAt), NotificationsState.dateFilters.FROM_DATE) >= 0);
|
|
158
|
+
// TO_DATE is defined, FROM_DATE is undefined, return notifications before TO_DATE
|
|
159
|
+
if (NotificationsState.dateFilters.FROM_DATE === undefined &&
|
|
160
|
+
NotificationsState.dateFilters.TO_DATE !== undefined)
|
|
161
|
+
return filteredNotifications.filter(notification => differenceInDays(new Date(notification.createdAt), NotificationsState.dateFilters.TO_DATE) <= 0);
|
|
162
|
+
return filteredNotifications;
|
|
163
|
+
}
|
|
164
|
+
displayDateFilters() {
|
|
165
|
+
this.showDateFilters = !this.showDateFilters;
|
|
166
|
+
}
|
|
167
|
+
renderGroupedView() {
|
|
168
|
+
const filteredNotifications = this.applyNotificationFilters();
|
|
169
169
|
return html `<div style="margin:0px">
|
|
170
170
|
<grouped-item
|
|
171
171
|
groupTitle="Planned Site Maintenance"
|
|
@@ -187,69 +187,69 @@ export class IxNotifications extends MobxLitElement {
|
|
|
187
187
|
groupIcon="${dcim.strings[0]}"
|
|
188
188
|
.childItems=${filteredNotifications === null || filteredNotifications === void 0 ? void 0 : filteredNotifications.filter(item => item.resourceType === NotificationGroups.DCIM_ALERTS)}
|
|
189
189
|
></grouped-item>
|
|
190
|
-
</div>`;
|
|
191
|
-
}
|
|
192
|
-
renderDefaultView() {
|
|
193
|
-
const filterNotification = this.applyNotificationFilters();
|
|
194
|
-
const filterTodayItems = filterNotification.filter(notification => differenceInDays(notification.createdAt, new Date()) === 0);
|
|
195
|
-
const filterEarlierItems = filterNotification.filter(notification => differenceInDays(notification.createdAt, new Date()) !== 0);
|
|
196
|
-
if ((filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.length) > 0) {
|
|
190
|
+
</div>`;
|
|
191
|
+
}
|
|
192
|
+
renderDefaultView() {
|
|
193
|
+
const filterNotification = this.applyNotificationFilters();
|
|
194
|
+
const filterTodayItems = filterNotification.filter(notification => differenceInDays(notification.createdAt, new Date()) === 0);
|
|
195
|
+
const filterEarlierItems = filterNotification.filter(notification => differenceInDays(notification.createdAt, new Date()) !== 0);
|
|
196
|
+
if ((filterNotification === null || filterNotification === void 0 ? void 0 : filterNotification.length) > 0) {
|
|
197
197
|
return html ` <h3 class="grow">Today</h3>
|
|
198
198
|
<div class="m-0 p-0">
|
|
199
|
-
${filterTodayItems.length > 0
|
|
199
|
+
${filterTodayItems.length > 0
|
|
200
200
|
? filterTodayItems === null || filterTodayItems === void 0 ? void 0 : filterTodayItems.map(item => html `<notification-item
|
|
201
201
|
.notification=${item}
|
|
202
|
-
?disabled=${item.resourceType ===
|
|
202
|
+
?disabled=${item.resourceType ===
|
|
203
203
|
NotificationGroups.INCIDENTS}
|
|
204
204
|
>
|
|
205
|
-
</notification-item> `)
|
|
205
|
+
</notification-item> `)
|
|
206
206
|
: this.renderNoResult()}
|
|
207
207
|
</div>
|
|
208
208
|
<h3 class="grow">Earlier</h3>
|
|
209
209
|
<div>
|
|
210
|
-
${filterEarlierItems.length > 0
|
|
210
|
+
${filterEarlierItems.length > 0
|
|
211
211
|
? filterEarlierItems === null || filterEarlierItems === void 0 ? void 0 : filterEarlierItems.map(item => html `<notification-item
|
|
212
212
|
.notification=${item}
|
|
213
|
-
?disabled=${item.resourceType ===
|
|
213
|
+
?disabled=${item.resourceType ===
|
|
214
214
|
NotificationGroups.INCIDENTS}
|
|
215
215
|
>
|
|
216
|
-
</notification-item> `)
|
|
216
|
+
</notification-item> `)
|
|
217
217
|
: this.renderNoResult()}
|
|
218
|
-
</div>`;
|
|
219
|
-
}
|
|
220
|
-
return html `<p class="empty"><strong>No notifications yet.</strong></p>`;
|
|
221
|
-
}
|
|
222
|
-
/* eslint-disable-next-line */
|
|
223
|
-
renderNoResult() {
|
|
224
|
-
return html `<p class="empty"><strong>No notifications yet.</strong></p>`;
|
|
225
|
-
}
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
227
|
-
handleCloseClick(_e) {
|
|
228
|
-
this.showDateFilters = false;
|
|
229
|
-
this.showFilters = false;
|
|
230
|
-
}
|
|
231
|
-
// eslint-disable-next-line
|
|
232
|
-
handleContentScroll(e) {
|
|
233
|
-
// when scrollbar at the end, retrieve next page
|
|
234
|
-
if (e !== null &&
|
|
235
|
-
e.detail.scrollTop + e.detail.clientHeight >= e.detail.scrollHeight) {
|
|
236
|
-
NotificationsState.getNotifications();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
manageFilterVisibility(e) {
|
|
240
|
-
const path = e.composedPath();
|
|
241
|
-
if (this.showFilters &&
|
|
242
|
-
!path.includes(this.groupFilters) &&
|
|
243
|
-
!path.includes(this.groupFiltersButton)) {
|
|
244
|
-
this.showFilters = false;
|
|
245
|
-
}
|
|
246
|
-
if (this.showDateFilters &&
|
|
247
|
-
!path.includes(this.dateFilters) &&
|
|
248
|
-
!path.includes(this.dateFiltersButton)) {
|
|
249
|
-
this.showDateFilters = false;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
render() {
|
|
218
|
+
</div>`;
|
|
219
|
+
}
|
|
220
|
+
return html `<p class="empty"><strong>No notifications yet.</strong></p>`;
|
|
221
|
+
}
|
|
222
|
+
/* eslint-disable-next-line */
|
|
223
|
+
renderNoResult() {
|
|
224
|
+
return html `<p class="empty"><strong>No notifications yet.</strong></p>`;
|
|
225
|
+
}
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
227
|
+
handleCloseClick(_e) {
|
|
228
|
+
this.showDateFilters = false;
|
|
229
|
+
this.showFilters = false;
|
|
230
|
+
}
|
|
231
|
+
// eslint-disable-next-line
|
|
232
|
+
handleContentScroll(e) {
|
|
233
|
+
// when scrollbar at the end, retrieve next page
|
|
234
|
+
if (e !== null &&
|
|
235
|
+
e.detail.scrollTop + e.detail.clientHeight >= e.detail.scrollHeight) {
|
|
236
|
+
NotificationsState.getNotifications();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
manageFilterVisibility(e) {
|
|
240
|
+
const path = e.composedPath();
|
|
241
|
+
if (this.showFilters &&
|
|
242
|
+
!path.includes(this.groupFilters) &&
|
|
243
|
+
!path.includes(this.groupFiltersButton)) {
|
|
244
|
+
this.showFilters = false;
|
|
245
|
+
}
|
|
246
|
+
if (this.showDateFilters &&
|
|
247
|
+
!path.includes(this.dateFilters) &&
|
|
248
|
+
!path.includes(this.dateFiltersButton)) {
|
|
249
|
+
this.showDateFilters = false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
render() {
|
|
253
253
|
return html `
|
|
254
254
|
<notification-tooltip> </notification-tooltip>
|
|
255
255
|
<div class="relative">
|
|
@@ -260,8 +260,8 @@ export class IxNotifications extends MobxLitElement {
|
|
|
260
260
|
</div>
|
|
261
261
|
<confirmation-dialog
|
|
262
262
|
?open=${this.showMarkAllReadConfirmation}
|
|
263
|
-
@confirm-dialog-closed=${() => {
|
|
264
|
-
this.showMarkAllReadConfirmation = false;
|
|
263
|
+
@confirm-dialog-closed=${() => {
|
|
264
|
+
this.showMarkAllReadConfirmation = false;
|
|
265
265
|
}}
|
|
266
266
|
@on-confirm-selection=${this.confirmedMarkAllRead}
|
|
267
267
|
textMessage="Are you sure you want to mark all notifications as read?"
|
|
@@ -280,28 +280,28 @@ export class IxNotifications extends MobxLitElement {
|
|
|
280
280
|
<div class="flex flex-row justify-end grow items-center options">
|
|
281
281
|
<ix-icon-button
|
|
282
282
|
@click=${this.markAllread}
|
|
283
|
-
@mouseover=${(e) => {
|
|
284
|
-
// only show the tooltip if the button is active
|
|
285
|
-
if (NotificationsState.unreadNotificationCount > 0) {
|
|
286
|
-
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
287
|
-
detail: { label: 'Mark All Read', target: e.target },
|
|
288
|
-
}));
|
|
289
|
-
}
|
|
283
|
+
@mouseover=${(e) => {
|
|
284
|
+
// only show the tooltip if the button is active
|
|
285
|
+
if (NotificationsState.unreadNotificationCount > 0) {
|
|
286
|
+
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
287
|
+
detail: { label: 'Mark All Read', target: e.target },
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
290
|
}}
|
|
291
291
|
@mouseout=${() => window.dispatchEvent(new CustomEvent('hide-notification-tooltip'))}
|
|
292
292
|
icon="markunread_mailbox"
|
|
293
|
-
class="${NotificationsState.unreadNotificationCount <= 0
|
|
294
|
-
? 'inactive-icon'
|
|
293
|
+
class="${NotificationsState.unreadNotificationCount <= 0
|
|
294
|
+
? 'inactive-icon'
|
|
295
295
|
: 'active-icon'}"
|
|
296
296
|
.disabled="${NotificationsState.unreadNotificationCount <= 0}"
|
|
297
297
|
filledIcon="true"
|
|
298
298
|
></ix-icon-button>
|
|
299
299
|
<ix-icon-button
|
|
300
300
|
@click=${this.toggleGroupView}
|
|
301
|
-
@mouseover=${(e) => {
|
|
302
|
-
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
303
|
-
detail: { label: 'Sort by Type', target: e.target },
|
|
304
|
-
}));
|
|
301
|
+
@mouseover=${(e) => {
|
|
302
|
+
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
303
|
+
detail: { label: 'Sort by Type', target: e.target },
|
|
304
|
+
}));
|
|
305
305
|
}}
|
|
306
306
|
@mouseout=${() => window.dispatchEvent(new CustomEvent('hide-notification-tooltip'))}
|
|
307
307
|
class="active-icon"
|
|
@@ -313,10 +313,10 @@ export class IxNotifications extends MobxLitElement {
|
|
|
313
313
|
</ix-icon-button>
|
|
314
314
|
<ix-icon-button
|
|
315
315
|
@click=${this.displayFilters}
|
|
316
|
-
@mouseover=${(e) => {
|
|
317
|
-
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
318
|
-
detail: { label: 'Filter by Type', target: e.target },
|
|
319
|
-
}));
|
|
316
|
+
@mouseover=${(e) => {
|
|
317
|
+
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
318
|
+
detail: { label: 'Filter by Type', target: e.target },
|
|
319
|
+
}));
|
|
320
320
|
}}
|
|
321
321
|
@mouseout=${() => window.dispatchEvent(new CustomEvent('hide-notification-tooltip'))}
|
|
322
322
|
class="active-icon"
|
|
@@ -326,18 +326,18 @@ export class IxNotifications extends MobxLitElement {
|
|
|
326
326
|
<ix-icon slot="default"> ${viewList} </ix-icon>
|
|
327
327
|
</ix-icon-button>
|
|
328
328
|
<div
|
|
329
|
-
class="filter-dropdown-content ${this.showFilters
|
|
330
|
-
? 'active z-50'
|
|
329
|
+
class="filter-dropdown-content ${this.showFilters
|
|
330
|
+
? 'active z-50'
|
|
331
331
|
: ''}"
|
|
332
332
|
>
|
|
333
333
|
<group-filters></group-filters>
|
|
334
334
|
</div>
|
|
335
335
|
<ix-icon-button
|
|
336
336
|
@click=${this.displayDateFilters}
|
|
337
|
-
@mouseover=${(e) => {
|
|
338
|
-
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
339
|
-
detail: { label: 'Filter by Date', target: e.target },
|
|
340
|
-
}));
|
|
337
|
+
@mouseover=${(e) => {
|
|
338
|
+
window.dispatchEvent(new CustomEvent('show-notification-tooltip', {
|
|
339
|
+
detail: { label: 'Filter by Date', target: e.target },
|
|
340
|
+
}));
|
|
341
341
|
}}
|
|
342
342
|
@mouseout=${() => window.dispatchEvent(new CustomEvent('hide-notification-tooltip'))}
|
|
343
343
|
icon="date_range"
|
|
@@ -347,8 +347,8 @@ export class IxNotifications extends MobxLitElement {
|
|
|
347
347
|
label="Filter by Date"
|
|
348
348
|
></ix-icon-button>
|
|
349
349
|
<div
|
|
350
|
-
class="datefilter-dropdown-content ${this.showDateFilters
|
|
351
|
-
? 'active z-50'
|
|
350
|
+
class="datefilter-dropdown-content ${this.showDateFilters
|
|
351
|
+
? 'active z-50'
|
|
352
352
|
: ''}"
|
|
353
353
|
@on-selection=${this.handleCloseClick}
|
|
354
354
|
>
|
|
@@ -357,43 +357,43 @@ export class IxNotifications extends MobxLitElement {
|
|
|
357
357
|
</div>
|
|
358
358
|
</div>
|
|
359
359
|
<div slot="content">
|
|
360
|
-
${this.showGroupedView
|
|
361
|
-
? this.renderGroupedView()
|
|
360
|
+
${this.showGroupedView
|
|
361
|
+
? this.renderGroupedView()
|
|
362
362
|
: this.renderDefaultView()}
|
|
363
363
|
</div>
|
|
364
364
|
</ix-drawer>
|
|
365
|
-
`;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
IxNotifications.styles = [TWStyles, NotificationsStyle];
|
|
369
|
-
__decorate([
|
|
370
|
-
query('group-filters')
|
|
371
|
-
], IxNotifications.prototype, "groupFilters", void 0);
|
|
372
|
-
__decorate([
|
|
373
|
-
query('ix-icon-button#group-filter-button')
|
|
374
|
-
], IxNotifications.prototype, "groupFiltersButton", void 0);
|
|
375
|
-
__decorate([
|
|
376
|
-
query('date-filters')
|
|
377
|
-
], IxNotifications.prototype, "dateFilters", void 0);
|
|
378
|
-
__decorate([
|
|
379
|
-
query('ix-icon-button#date-filters-button')
|
|
380
|
-
], IxNotifications.prototype, "dateFiltersButton", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
state()
|
|
383
|
-
], IxNotifications.prototype, "showGroupedView", void 0);
|
|
384
|
-
__decorate([
|
|
385
|
-
state()
|
|
386
|
-
], IxNotifications.prototype, "showFilters", void 0);
|
|
387
|
-
__decorate([
|
|
388
|
-
state()
|
|
389
|
-
], IxNotifications.prototype, "showDateFilters", void 0);
|
|
390
|
-
__decorate([
|
|
391
|
-
state()
|
|
392
|
-
], IxNotifications.prototype, "showMarkAllReadConfirmation", void 0);
|
|
393
|
-
__decorate([
|
|
394
|
-
property({ type: String })
|
|
395
|
-
], IxNotifications.prototype, "baseApiUrl", void 0);
|
|
396
|
-
__decorate([
|
|
397
|
-
property({ type: String })
|
|
398
|
-
], IxNotifications.prototype, "localStorageKey", void 0);
|
|
365
|
+
`;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
IxNotifications.styles = [TWStyles, NotificationsStyle];
|
|
369
|
+
__decorate([
|
|
370
|
+
query('group-filters')
|
|
371
|
+
], IxNotifications.prototype, "groupFilters", void 0);
|
|
372
|
+
__decorate([
|
|
373
|
+
query('ix-icon-button#group-filter-button')
|
|
374
|
+
], IxNotifications.prototype, "groupFiltersButton", void 0);
|
|
375
|
+
__decorate([
|
|
376
|
+
query('date-filters')
|
|
377
|
+
], IxNotifications.prototype, "dateFilters", void 0);
|
|
378
|
+
__decorate([
|
|
379
|
+
query('ix-icon-button#date-filters-button')
|
|
380
|
+
], IxNotifications.prototype, "dateFiltersButton", void 0);
|
|
381
|
+
__decorate([
|
|
382
|
+
state()
|
|
383
|
+
], IxNotifications.prototype, "showGroupedView", void 0);
|
|
384
|
+
__decorate([
|
|
385
|
+
state()
|
|
386
|
+
], IxNotifications.prototype, "showFilters", void 0);
|
|
387
|
+
__decorate([
|
|
388
|
+
state()
|
|
389
|
+
], IxNotifications.prototype, "showDateFilters", void 0);
|
|
390
|
+
__decorate([
|
|
391
|
+
state()
|
|
392
|
+
], IxNotifications.prototype, "showMarkAllReadConfirmation", void 0);
|
|
393
|
+
__decorate([
|
|
394
|
+
property({ type: String })
|
|
395
|
+
], IxNotifications.prototype, "baseApiUrl", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
property({ type: String })
|
|
398
|
+
], IxNotifications.prototype, "localStorageKey", void 0);
|
|
399
399
|
//# sourceMappingURL=IxNotifications.js.map
|