@posiwise/dashboard-module 0.0.86 → 0.0.88
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/esm2022/index.mjs +16 -0
- package/esm2022/lib/customizer/customizer.component.mjs +17 -0
- package/esm2022/lib/dashboard.module.mjs +101 -0
- package/esm2022/lib/faq/faq.component.mjs +108 -0
- package/esm2022/lib/faq-details/faq-details.component.mjs +38 -0
- package/esm2022/lib/footer/footer.component.mjs +22 -0
- package/esm2022/lib/home/home.component.mjs +79 -0
- package/esm2022/lib/navbar/navbar.component.mjs +162 -0
- package/esm2022/lib/notifications-page/current-notifications/current-notifications.component.mjs +58 -0
- package/esm2022/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.mjs +73 -0
- package/esm2022/lib/notifications-page/notifications-page.component.mjs +14 -0
- package/esm2022/lib/search/search.component.mjs +48 -0
- package/esm2022/lib/sidebar/sidebar-routes.config.mjs +350 -0
- package/esm2022/lib/sidebar/sidebar.metadata.mjs +2 -0
- package/esm2022/lib/user-feedback/user-feedback.component.mjs +73 -0
- package/esm2022/lib/user-notifications/user-notifications.component.mjs +65 -0
- package/esm2022/posiwise-dashboard-module.mjs +5 -0
- package/fesm2022/posiwise-dashboard-module.mjs +1118 -0
- package/fesm2022/posiwise-dashboard-module.mjs.map +1 -0
- package/{src/index.ts → index.d.ts} +0 -1
- package/lib/customizer/customizer.component.d.ts +7 -0
- package/lib/dashboard.module.d.ts +28 -0
- package/lib/faq/faq.component.d.ts +37 -0
- package/lib/faq-details/faq-details.component.d.ts +16 -0
- package/lib/footer/footer.component.d.ts +12 -0
- package/lib/home/home.component.d.ts +18 -0
- package/lib/navbar/navbar.component.d.ts +35 -0
- package/lib/notifications-page/current-notifications/current-notifications.component.d.ts +17 -0
- package/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.d.ts +18 -0
- package/lib/notifications-page/notifications-page.component.d.ts +5 -0
- package/lib/search/search.component.d.ts +24 -0
- package/lib/sidebar/sidebar-routes.config.d.ts +64 -0
- package/{src/lib/sidebar/sidebar.metadata.ts → lib/sidebar/sidebar.metadata.d.ts} +0 -1
- package/lib/user-feedback/user-feedback.component.d.ts +24 -0
- package/lib/user-notifications/user-notifications.component.d.ts +20 -0
- package/package.json +23 -10
- package/.eslintrc.json +0 -21
- package/ng-package.json +0 -15
- package/project.json +0 -72
- package/src/lib/customizer/customizer.component.html +0 -184
- package/src/lib/customizer/customizer.component.scss +0 -101
- package/src/lib/customizer/customizer.component.ts +0 -13
- package/src/lib/dashboard.module.ts +0 -63
- package/src/lib/faq/faq.component.html +0 -110
- package/src/lib/faq/faq.component.scss +0 -58
- package/src/lib/faq/faq.component.spec.ts +0 -143
- package/src/lib/faq/faq.component.ts +0 -144
- package/src/lib/faq-details/faq-details.component.html +0 -21
- package/src/lib/faq-details/faq-details.component.scss +0 -3
- package/src/lib/faq-details/faq-details.component.spec.ts +0 -69
- package/src/lib/faq-details/faq-details.component.ts +0 -38
- package/src/lib/footer/footer.component.html +0 -14
- package/src/lib/footer/footer.component.spec.ts +0 -42
- package/src/lib/footer/footer.component.ts +0 -24
- package/src/lib/home/home.component.html +0 -93
- package/src/lib/home/home.component.scss +0 -0
- package/src/lib/home/home.component.spec.ts +0 -69
- package/src/lib/home/home.component.ts +0 -88
- package/src/lib/navbar/navbar.component.html +0 -189
- package/src/lib/navbar/navbar.component.scss +0 -92
- package/src/lib/navbar/navbar.component.spec.ts +0 -76
- package/src/lib/navbar/navbar.component.ts +0 -198
- package/src/lib/notifications-page/current-notifications/current-notifications.component.html +0 -61
- package/src/lib/notifications-page/current-notifications/current-notifications.component.spec.ts +0 -57
- package/src/lib/notifications-page/current-notifications/current-notifications.component.ts +0 -63
- package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.html +0 -65
- package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.spec.ts +0 -71
- package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.ts +0 -79
- package/src/lib/notifications-page/notifications-page.component.html +0 -24
- package/src/lib/notifications-page/notifications-page.component.scss +0 -28
- package/src/lib/notifications-page/notifications-page.component.spec.ts +0 -26
- package/src/lib/notifications-page/notifications-page.component.ts +0 -8
- package/src/lib/search/search.component.html +0 -215
- package/src/lib/search/search.component.scss +0 -98
- package/src/lib/search/search.component.spec.ts +0 -64
- package/src/lib/search/search.component.ts +0 -50
- package/src/lib/sidebar/sidebar-routes.config.ts +0 -355
- package/src/lib/user-feedback/user-feedback.component.html +0 -53
- package/src/lib/user-feedback/user-feedback.component.scss +0 -18
- package/src/lib/user-feedback/user-feedback.component.spec.ts +0 -54
- package/src/lib/user-feedback/user-feedback.component.ts +0 -83
- package/src/lib/user-notifications/user-notifications.component.html +0 -21
- package/src/lib/user-notifications/user-notifications.component.scss +0 -21
- package/src/lib/user-notifications/user-notifications.component.spec.ts +0 -47
- package/src/lib/user-notifications/user-notifications.component.ts +0 -74
- package/tsconfig.json +0 -30
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -11
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { Component, Injector, Input, OnDestroy, ViewChild } from '@angular/core';
|
|
2
|
-
import { NgbDropdown, NgbDropdownConfig } from '@ng-bootstrap/ng-bootstrap';
|
|
3
|
-
import { Store } from '@ngrx/store';
|
|
4
|
-
import { AppState, getUser } from '@posiwise/app-store';
|
|
5
|
-
import { orderBy } from 'lodash';
|
|
6
|
-
|
|
7
|
-
import { AppBaseComponent } from '@posiwise/app-base-component';
|
|
8
|
-
import {
|
|
9
|
-
PermissionService,
|
|
10
|
-
ScriptLoaderService,
|
|
11
|
-
NotificationService
|
|
12
|
-
} from '@posiwise/common-services';
|
|
13
|
-
|
|
14
|
-
@Component({
|
|
15
|
-
selector: 'pw-navbar',
|
|
16
|
-
templateUrl: './navbar.component.html',
|
|
17
|
-
styleUrls: ['./navbar.component.scss'],
|
|
18
|
-
providers: [NgbDropdownConfig]
|
|
19
|
-
})
|
|
20
|
-
export class NavbarComponent extends AppBaseComponent implements OnDestroy, OnDestroy {
|
|
21
|
-
@Input() logo: any;
|
|
22
|
-
|
|
23
|
-
@ViewChild('notiDrop', { static: true })
|
|
24
|
-
notiDrop: NgbDropdown;
|
|
25
|
-
|
|
26
|
-
notificationCount = 0;
|
|
27
|
-
|
|
28
|
-
noNoti = true;
|
|
29
|
-
|
|
30
|
-
notifications = [];
|
|
31
|
-
|
|
32
|
-
private notiInterval: number;
|
|
33
|
-
|
|
34
|
-
slug: string;
|
|
35
|
-
|
|
36
|
-
constructor(
|
|
37
|
-
injector: Injector,
|
|
38
|
-
private notificationService: NotificationService,
|
|
39
|
-
config: NgbDropdownConfig,
|
|
40
|
-
private scriptLoader: ScriptLoaderService,
|
|
41
|
-
private store: Store<AppState>
|
|
42
|
-
) {
|
|
43
|
-
super(injector);
|
|
44
|
-
this.loadExternalScripts();
|
|
45
|
-
config.autoClose = false;
|
|
46
|
-
this.store.select(getUser).subscribe(res => {
|
|
47
|
-
this.slug = res.currentUser ? res.currentUser.slug : '';
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
this.getNotifications();
|
|
51
|
-
this.updateNotifications();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override ngOnDestroy() {
|
|
55
|
-
clearInterval(this.notiInterval);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get isSupportMenu() {
|
|
59
|
-
return PermissionService.selectedProduct?.gitlab_service_desk_email;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private loadExternalScripts() {
|
|
63
|
-
this.scriptLoader.loadScripts(
|
|
64
|
-
'head',
|
|
65
|
-
[
|
|
66
|
-
'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.11/jstree.min.js',
|
|
67
|
-
'https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.7/quill.min.js',
|
|
68
|
-
'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js'
|
|
69
|
-
],
|
|
70
|
-
true
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
this.scriptLoader.loadStyle(
|
|
74
|
-
'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.11/themes/default/style.min.css'
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private getNotifications() {
|
|
79
|
-
this.notificationService.getNotifications().subscribe((data: any[]) => {
|
|
80
|
-
this.notificationsCount(data);
|
|
81
|
-
|
|
82
|
-
this.notificationService.notiWebSocket().subscribe(res => {
|
|
83
|
-
if (res) {
|
|
84
|
-
this.notificationsCount([res]);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (data.length > 0) {
|
|
89
|
-
this.notificationService.showNotifications(this.notifications);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private notificationsCount(noti: any[]) {
|
|
95
|
-
for (let i = 0; i < noti.length; i++) {
|
|
96
|
-
if (!noti[i]?.dismissed && noti[i].show_on_dashboard) {
|
|
97
|
-
this.notifications.push(noti[i]);
|
|
98
|
-
}
|
|
99
|
-
if (noti[i].unread === true) {
|
|
100
|
-
this.notificationCount++;
|
|
101
|
-
}
|
|
102
|
-
if (noti[i].dismissed === false) {
|
|
103
|
-
this.noNoti = false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.sortNotifications();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private sortNotifications() {
|
|
111
|
-
this.notifications = orderBy(this.notifications, ['id'], ['desc']);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private updateNotifications() {
|
|
115
|
-
this.notificationService.getNotifications().subscribe(data => {
|
|
116
|
-
const val = data;
|
|
117
|
-
if (val.length > 0) {
|
|
118
|
-
val.forEach(element => {
|
|
119
|
-
const existNotification = this.notifications.find(
|
|
120
|
-
({ id }) => element.id === id
|
|
121
|
-
);
|
|
122
|
-
if (!existNotification) {
|
|
123
|
-
if (!element.dismissed && element.show_on_dashboard) {
|
|
124
|
-
this.notifications.push(element);
|
|
125
|
-
}
|
|
126
|
-
if (element.unread === true) {
|
|
127
|
-
this.notificationCount++;
|
|
128
|
-
}
|
|
129
|
-
if (element.dismissed === false) {
|
|
130
|
-
this.noNoti = false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
this.sortNotifications();
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
checkNoti() {
|
|
140
|
-
if (this.notiDrop.isOpen()) {
|
|
141
|
-
// Mark all Notifications as read
|
|
142
|
-
this.notificationService.readNotifications().subscribe(() => {
|
|
143
|
-
this.notificationCount = 0;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
dismiss(id: number, _e) {
|
|
149
|
-
this.notificationService.dismissNotification(id).subscribe(data => {
|
|
150
|
-
// Remove notification from notification array
|
|
151
|
-
// TODO: Add animation while removing
|
|
152
|
-
const index = this.notifications.findIndex(x => x.id === id);
|
|
153
|
-
this.notifications.splice(index, 1);
|
|
154
|
-
|
|
155
|
-
if (data) {
|
|
156
|
-
const val = JSON.parse(data);
|
|
157
|
-
if (val.length > 0) {
|
|
158
|
-
val.forEach(element => {
|
|
159
|
-
const existNotification = this.notifications.find(
|
|
160
|
-
({ key }) => element.id === key
|
|
161
|
-
);
|
|
162
|
-
if (!existNotification) {
|
|
163
|
-
this.notifications.push(element);
|
|
164
|
-
if (element.unread === true) {
|
|
165
|
-
this.notificationCount++;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (this.notifications.length === 0) {
|
|
173
|
-
this.noNoti = true;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
this.sortNotifications();
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
onLangChange(lang: string) {
|
|
181
|
-
this.translation.setActiveLang(lang);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
logout() {
|
|
185
|
-
this.router.navigate(['logout']);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
redirectToNotification() {
|
|
189
|
-
this.notiDrop.close();
|
|
190
|
-
this.router.navigate(['/notifications']);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
onSearch(search) {
|
|
194
|
-
if (search.value) {
|
|
195
|
-
this.router.navigate(['search'], { queryParams: { keyword: search.value } });
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
package/src/lib/notifications-page/current-notifications/current-notifications.component.html
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<div class="row main-div">
|
|
2
|
-
<div class="w-100 text-center mt-3">
|
|
3
|
-
<ng-template [ngIf]="!isLoaded">
|
|
4
|
-
<p-progressSpinner strokeWidth="2"> </p-progressSpinner>
|
|
5
|
-
</ng-template>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="col-12 col-sm-12 col-md-12 mb-5"
|
|
8
|
-
*ngIf="notifications?.length && isLoaded">
|
|
9
|
-
<div class="card">
|
|
10
|
-
<div class="card-body">
|
|
11
|
-
<ul class="noti-list">
|
|
12
|
-
<li *ngFor="let item of notifications; trackBy: trackByNotification"
|
|
13
|
-
class="p-3 border-bottom border-bottom-blue-grey border-bottom-lighten-4 d-flex align-items-center">
|
|
14
|
-
<span class="btn btn-circle me-2"
|
|
15
|
-
[ngClass]="{
|
|
16
|
-
'btn-danger': item.note_type === 'administrative',
|
|
17
|
-
'btn-secondary': item.note_type === 'object_event',
|
|
18
|
-
'btn-primary': item.note_type === 'user_generated'
|
|
19
|
-
}">
|
|
20
|
-
<i
|
|
21
|
-
class="fal float-start"
|
|
22
|
-
[ngClass]="{
|
|
23
|
-
'fa-bell': item.note_type === 'administrative',
|
|
24
|
-
'fa-share-alt': item.note_type === 'object_event',
|
|
25
|
-
'fa-bells': item.note_type === 'user_generated'
|
|
26
|
-
}"
|
|
27
|
-
aria-hidden="true"
|
|
28
|
-
></i>
|
|
29
|
-
</span>
|
|
30
|
-
<span class="d-inline-block noty-body">
|
|
31
|
-
<span class="noti-title line-height-1p5 d-block text-bold-400">{{
|
|
32
|
-
item.content
|
|
33
|
-
}}</span>
|
|
34
|
-
<span class="noti-text"><span class="fal fa-clock"></span>
|
|
35
|
-
{{ item?.created_at | sinceAgo }}</span>
|
|
36
|
-
</span>
|
|
37
|
-
<span class="noti-buttons">
|
|
38
|
-
<button class="btn float-end">
|
|
39
|
-
<i
|
|
40
|
-
class="far fa-trash-alt"
|
|
41
|
-
(click)="dismiss(item.id, item)"
|
|
42
|
-
aria-hidden="true"
|
|
43
|
-
></i>
|
|
44
|
-
</button>
|
|
45
|
-
</span>
|
|
46
|
-
</li>
|
|
47
|
-
</ul>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<div class="col-12 col-sm-12 col-md-12"
|
|
53
|
-
*ngIf="noNoti && isLoaded">
|
|
54
|
-
<div class="text-center">
|
|
55
|
-
<h3 class="noti-title line-height-1p5 d-block text-bold-400 primary">
|
|
56
|
-
You are all caught up.
|
|
57
|
-
</h3>
|
|
58
|
-
<p class="text-secondary">You currently do not have any notifications.</p>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
package/src/lib/notifications-page/current-notifications/current-notifications.component.spec.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { CommonServicesModule, NotificationService, PermissionService } from "@posiwise/common-services";
|
|
2
|
-
import { SharedModule } from "@posiwise/shared-module";
|
|
3
|
-
import { DashboardLibModule } from "../../dashboard.module";
|
|
4
|
-
import { TestBed } from "@angular/core/testing";
|
|
5
|
-
import { TestHelper } from "@posiwise/test-helpers";
|
|
6
|
-
import { MockProvider } from "ng-mocks";
|
|
7
|
-
import { of } from "rxjs";
|
|
8
|
-
import { CurrentNotificationsComponent } from "./current-notifications.component";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
describe('CurrentNotificationsComponent', () => {
|
|
12
|
-
const createComponent = TestHelper.createComponentFactory({
|
|
13
|
-
component: CurrentNotificationsComponent,
|
|
14
|
-
imports: [SharedModule,CommonServicesModule,DashboardLibModule],
|
|
15
|
-
providers: [
|
|
16
|
-
...TestHelper.TEST_PROVIDERS,
|
|
17
|
-
MockProvider(PermissionService, {
|
|
18
|
-
evaluatePermissions: () => {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
MockProvider(NotificationService, {
|
|
23
|
-
dismissNotification: () => of('test'),
|
|
24
|
-
getNotifications: () =>
|
|
25
|
-
of([
|
|
26
|
-
{
|
|
27
|
-
id: 1,
|
|
28
|
-
note_type: 'administrative',
|
|
29
|
-
content: 'test',
|
|
30
|
-
created_at: '2021-11-26T10:13:10.687+00:00',
|
|
31
|
-
updated_at: '2021-11-26T10:13:10.687+00:00',
|
|
32
|
-
show_on_dashboard: true,
|
|
33
|
-
dismissed: false
|
|
34
|
-
}
|
|
35
|
-
])
|
|
36
|
-
})
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
TestHelper.setUpPermissionsAndUser();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should create', async () => {
|
|
45
|
-
const spectator = await createComponent();
|
|
46
|
-
expect(spectator.component).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should delete notification', async () => {
|
|
50
|
-
const spectator = await createComponent();
|
|
51
|
-
expect(spectator.component).toBeTruthy();
|
|
52
|
-
const service = TestBed.inject(NotificationService);
|
|
53
|
-
const spy = spyOn(service, 'dismissNotification').and.callThrough();
|
|
54
|
-
spectator.click('.noti-list li:first-of-type .fa-trash-alt');
|
|
55
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
import { NotificationService } from '@posiwise/common-services';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'pw-current-notifications',
|
|
7
|
-
templateUrl: './current-notifications.component.html',
|
|
8
|
-
styleUrls: ['../notifications-page.component.scss']
|
|
9
|
-
})
|
|
10
|
-
export class CurrentNotificationsComponent implements OnInit {
|
|
11
|
-
notificationCount = 0;
|
|
12
|
-
|
|
13
|
-
noNoti = true;
|
|
14
|
-
|
|
15
|
-
notifications = [];
|
|
16
|
-
|
|
17
|
-
isLoaded = false;
|
|
18
|
-
|
|
19
|
-
constructor(private notificationService: NotificationService) {}
|
|
20
|
-
|
|
21
|
-
ngOnInit() {
|
|
22
|
-
this.getNotifications();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private getNotifications() {
|
|
26
|
-
this.notificationService
|
|
27
|
-
.getNotifications()
|
|
28
|
-
.subscribe(data => {
|
|
29
|
-
if (data.length > 0) {
|
|
30
|
-
this.notifications = data.filter(
|
|
31
|
-
note => !note.dismissed && note.show_on_dashboard
|
|
32
|
-
);
|
|
33
|
-
this.noNoti = true;
|
|
34
|
-
if (this.notifications?.length) {
|
|
35
|
-
this.noNoti = false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
.add(() => {
|
|
40
|
-
this.isLoaded = true;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
dismiss(id: number, e) {
|
|
45
|
-
this.notificationService.dismissNotification(id).subscribe(() => {
|
|
46
|
-
// Remove notification from notification array
|
|
47
|
-
const index = this.notifications.indexOf(e);
|
|
48
|
-
this.notifications.splice(index, 1);
|
|
49
|
-
|
|
50
|
-
if (this.notifications.length === 0) {
|
|
51
|
-
this.noNoti = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
$('#noty').slideUp('slow', () => {
|
|
55
|
-
$('#noty').remove();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
trackByNotification(_index: number, item: any) {
|
|
61
|
-
return item.id;
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.html
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
<div class="row main-div">
|
|
2
|
-
<div class="w-100 text-center mt-3">
|
|
3
|
-
<ng-template [ngIf]="!isLoaded">
|
|
4
|
-
<p-progressSpinner strokeWidth="2"> </p-progressSpinner>
|
|
5
|
-
</ng-template>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="col-12 col-sm-12 col-md-12 mb-5"
|
|
8
|
-
*ngIf="dismissedNotifications?.length && isLoaded">
|
|
9
|
-
<div class="card">
|
|
10
|
-
<div class="card-body">
|
|
11
|
-
<ul class="noti-list">
|
|
12
|
-
<li *ngFor="let item of dismissedNotifications; trackBy: trackByNotification"
|
|
13
|
-
class="p-3 border-bottom border-bottom-blue-grey border-bottom-lighten-4 d-flex align-items-center">
|
|
14
|
-
<span class="btn btn-circle me-2"
|
|
15
|
-
[ngClass]="{
|
|
16
|
-
'btn-danger': item.note_type === 'administrative',
|
|
17
|
-
'btn-secondary': item.note_type === 'object_event',
|
|
18
|
-
'btn-primary': item.note_type === 'user_generated'
|
|
19
|
-
}">
|
|
20
|
-
<i
|
|
21
|
-
class="fal float-start"
|
|
22
|
-
[ngClass]="{
|
|
23
|
-
'fa-bell': item.note_type === 'administrative',
|
|
24
|
-
'fa-share-alt': item.note_type === 'object_event',
|
|
25
|
-
'fa-bells': item.note_type === 'user_generated'
|
|
26
|
-
}"
|
|
27
|
-
aria-hidden="true"
|
|
28
|
-
></i>
|
|
29
|
-
</span>
|
|
30
|
-
<span class="d-inline-block noty-body">
|
|
31
|
-
<span class="noti-title line-height-1p5 d-block text-bold-400">{{
|
|
32
|
-
item.content
|
|
33
|
-
}}</span>
|
|
34
|
-
<span class="noti-text"><span class="fal fa-clock"></span>
|
|
35
|
-
{{ item?.created_at | sinceAgo }}</span>
|
|
36
|
-
</span>
|
|
37
|
-
<span class="noti-buttons">
|
|
38
|
-
<button class="btn float-end">
|
|
39
|
-
<i
|
|
40
|
-
class="far fa-trash-alt"
|
|
41
|
-
(click)="dismiss(item.id, item)"
|
|
42
|
-
aria-hidden="true"
|
|
43
|
-
></i>
|
|
44
|
-
</button>
|
|
45
|
-
<button class="btn float-end">
|
|
46
|
-
<i
|
|
47
|
-
class="fas fa-trash-restore-alt"
|
|
48
|
-
(click)="restoreNotification(item.id, item)"
|
|
49
|
-
aria-hidden="true"
|
|
50
|
-
></i>
|
|
51
|
-
</button>
|
|
52
|
-
</span>
|
|
53
|
-
</li>
|
|
54
|
-
</ul>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div class="col-12 col-sm-12 col-md-12"
|
|
60
|
-
*ngIf="noNoti && isLoaded">
|
|
61
|
-
<div class="text-center">
|
|
62
|
-
<p class="text-secondary">You currently do not have any dismissed notifications.</p>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.spec.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { CommonServicesModule, NotificationService, PermissionService } from "@posiwise/common-services";
|
|
2
|
-
import { SharedModule } from "@posiwise/shared-module";
|
|
3
|
-
import { DashboardLibModule } from "../../dashboard.module";
|
|
4
|
-
import { TestBed } from "@angular/core/testing";
|
|
5
|
-
import { TestHelper } from "@posiwise/test-helpers";
|
|
6
|
-
import { MockProvider } from "ng-mocks";
|
|
7
|
-
import { of } from "rxjs";
|
|
8
|
-
import Swal from "sweetalert2";
|
|
9
|
-
import { DismissedNotificationsComponent } from "./dismissed-notifications.component";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
describe('DismissedNotificationsComponent', () => {
|
|
13
|
-
const createComponent = TestHelper.createComponentFactory({
|
|
14
|
-
component: DismissedNotificationsComponent,
|
|
15
|
-
imports: [SharedModule,CommonServicesModule,DashboardLibModule],
|
|
16
|
-
providers: [
|
|
17
|
-
...TestHelper.TEST_PROVIDERS,
|
|
18
|
-
MockProvider(PermissionService, {
|
|
19
|
-
evaluatePermissions: () => {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}),
|
|
23
|
-
MockProvider(NotificationService, {
|
|
24
|
-
deleteNotifications: () => of({}),
|
|
25
|
-
reinstateNotification: () => of({}),
|
|
26
|
-
getDismissedNotifications: () =>
|
|
27
|
-
of([
|
|
28
|
-
{
|
|
29
|
-
id: 1,
|
|
30
|
-
note_type: 'administrative',
|
|
31
|
-
content: 'test',
|
|
32
|
-
created_at: '2021-11-26T10:13:10.687+00:00',
|
|
33
|
-
updated_at: '2021-11-26T10:13:10.687+00:00',
|
|
34
|
-
show_on_dashboard: true,
|
|
35
|
-
dismissed: false
|
|
36
|
-
}
|
|
37
|
-
])
|
|
38
|
-
})
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
TestHelper.setUpPermissionsAndUser();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should create', async () => {
|
|
47
|
-
const spectator = await createComponent();
|
|
48
|
-
expect(spectator.component).toBeTruthy();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should delete notification', async () => {
|
|
52
|
-
const spectator = await createComponent();
|
|
53
|
-
expect(spectator.component).toBeTruthy();
|
|
54
|
-
const service = TestBed.inject(NotificationService);
|
|
55
|
-
const spy = spyOn(service, 'deleteNotifications').and.callThrough();
|
|
56
|
-
spectator.click('.noti-list li:first-of-type .fa-trash-alt');
|
|
57
|
-
expect(Swal.isVisible()).toBeTruthy();
|
|
58
|
-
Swal.clickConfirm();
|
|
59
|
-
await TestHelper.stabilize(spectator);
|
|
60
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should restore notification', async () => {
|
|
64
|
-
const spectator = await createComponent();
|
|
65
|
-
expect(spectator.component).toBeTruthy();
|
|
66
|
-
const service = TestBed.inject(NotificationService);
|
|
67
|
-
const spy = spyOn(service, 'reinstateNotification').and.callThrough();
|
|
68
|
-
spectator.click('.noti-list li:first-of-type .fa-trash-restore-alt');
|
|
69
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
70
|
-
});
|
|
71
|
-
});
|
package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
import { HelperService } from '@posiwise/helper-service';
|
|
4
|
-
import { NotificationService } from '@posiwise/common-services';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'pw-dismissed-notifications',
|
|
8
|
-
templateUrl: './dismissed-notifications.component.html',
|
|
9
|
-
styleUrls: ['../notifications-page.component.scss']
|
|
10
|
-
})
|
|
11
|
-
export class DismissedNotificationsComponent implements OnInit {
|
|
12
|
-
notificationCount = 0;
|
|
13
|
-
|
|
14
|
-
noNoti = true;
|
|
15
|
-
|
|
16
|
-
dismissedNotifications = [];
|
|
17
|
-
|
|
18
|
-
isLoaded = false;
|
|
19
|
-
|
|
20
|
-
constructor(private notificationService: NotificationService) {}
|
|
21
|
-
|
|
22
|
-
ngOnInit() {
|
|
23
|
-
this.getNotifications();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private getNotifications() {
|
|
27
|
-
this.notificationService
|
|
28
|
-
.getDismissedNotifications()
|
|
29
|
-
.subscribe(data => {
|
|
30
|
-
if (data.length > 0) {
|
|
31
|
-
this.noNoti = false;
|
|
32
|
-
this.dismissedNotifications = data;
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
.add(() => {
|
|
36
|
-
this.isLoaded = true;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
dismiss(id: number, e) {
|
|
41
|
-
HelperService.raiseDeletePopup().then(res => {
|
|
42
|
-
if (res.value) {
|
|
43
|
-
this.notificationService.deleteNotifications(id).subscribe(() => {
|
|
44
|
-
// Remove notification from notification array
|
|
45
|
-
const index = this.dismissedNotifications.indexOf(e);
|
|
46
|
-
this.dismissedNotifications.splice(index, 1);
|
|
47
|
-
|
|
48
|
-
if (this.dismissedNotifications.length === 0) {
|
|
49
|
-
this.noNoti = true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
$('#noty').slideUp('slow', () => {
|
|
53
|
-
$('#noty').remove();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
restoreNotification(id: number, e) {
|
|
61
|
-
this.notificationService.reinstateNotification(id).subscribe(() => {
|
|
62
|
-
// Remove notification from dismissed notification array
|
|
63
|
-
const index = this.dismissedNotifications.indexOf(e);
|
|
64
|
-
this.dismissedNotifications.splice(index, 1);
|
|
65
|
-
|
|
66
|
-
if (this.dismissedNotifications.length === 0) {
|
|
67
|
-
this.noNoti = true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
$('#noty').slideUp('slow', () => {
|
|
71
|
-
$('#noty').remove();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
trackByNotification(_index: number, item: any) {
|
|
77
|
-
return item.id;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<div class="row">
|
|
2
|
-
<div class="col-12 col-sm-12 col-md-12">
|
|
3
|
-
<h2 class="p-2">Notifications</h2>
|
|
4
|
-
</div>
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<ul ngbNav
|
|
8
|
-
#nav="ngbNav"
|
|
9
|
-
class="nav-tabs">
|
|
10
|
-
<li [ngbNavItem]="1">
|
|
11
|
-
<a ngbNavLink>Current Notifications</a>
|
|
12
|
-
<ng-template ngbNavContent>
|
|
13
|
-
<pw-current-notifications></pw-current-notifications>
|
|
14
|
-
</ng-template>
|
|
15
|
-
</li>
|
|
16
|
-
<li [ngbNavItem]="2">
|
|
17
|
-
<a ngbNavLink>Dismissed Notifications</a>
|
|
18
|
-
<ng-template ngbNavContent>
|
|
19
|
-
<pw-dismissed-notifications></pw-dismissed-notifications>
|
|
20
|
-
</ng-template>
|
|
21
|
-
</li>
|
|
22
|
-
</ul>
|
|
23
|
-
|
|
24
|
-
<div [ngbNavOutlet]="nav"></div>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.icon-dismiss {
|
|
2
|
-
position: relative;
|
|
3
|
-
right: 15px;
|
|
4
|
-
top: 30px;
|
|
5
|
-
z-index: 9;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.noti-list {
|
|
9
|
-
overflow-x: hidden !important;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.noti-buttons {
|
|
13
|
-
flex: auto;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.main-div {
|
|
17
|
-
padding: 0 20px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.card {
|
|
21
|
-
padding-bottom: 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@media screen and (max-width: 480px) {
|
|
25
|
-
.noty-body {
|
|
26
|
-
width: 240px;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CommonServicesModule, NotificationService } from "@posiwise/common-services";
|
|
2
|
-
import { TestHelper } from "@posiwise/test-helpers";
|
|
3
|
-
import { MockProvider } from "ng-mocks";
|
|
4
|
-
import { of } from "rxjs";
|
|
5
|
-
import { NotificationsPageComponent } from "./notifications-page.component";
|
|
6
|
-
import { SharedModule } from "@posiwise/shared-module";
|
|
7
|
-
import { DashboardLibModule } from "../dashboard.module";
|
|
8
|
-
|
|
9
|
-
describe('NotificationsPageComponent', () => {
|
|
10
|
-
const createComponent = TestHelper.createComponentFactory({
|
|
11
|
-
component: NotificationsPageComponent,
|
|
12
|
-
imports: [ SharedModule,CommonServicesModule,DashboardLibModule],
|
|
13
|
-
providers: [
|
|
14
|
-
...TestHelper.TEST_PROVIDERS,
|
|
15
|
-
MockProvider(NotificationService, {
|
|
16
|
-
getDismissedNotifications: () => of([]),
|
|
17
|
-
getNotifications: () => of([])
|
|
18
|
-
})
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', async () => {
|
|
23
|
-
const spectator = await createComponent();
|
|
24
|
-
expect(spectator.component).toBeTruthy();
|
|
25
|
-
});
|
|
26
|
-
});
|