@posiwise/dashboard-module 0.0.84 → 0.0.86

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.
Files changed (89) hide show
  1. package/.eslintrc.json +21 -0
  2. package/ng-package.json +15 -0
  3. package/package.json +10 -23
  4. package/project.json +72 -0
  5. package/{index.d.ts → src/index.ts} +1 -0
  6. package/src/lib/customizer/customizer.component.html +184 -0
  7. package/src/lib/customizer/customizer.component.scss +101 -0
  8. package/src/lib/customizer/customizer.component.ts +13 -0
  9. package/src/lib/dashboard.module.ts +63 -0
  10. package/src/lib/faq/faq.component.html +110 -0
  11. package/src/lib/faq/faq.component.scss +58 -0
  12. package/src/lib/faq/faq.component.spec.ts +143 -0
  13. package/src/lib/faq/faq.component.ts +144 -0
  14. package/src/lib/faq-details/faq-details.component.html +21 -0
  15. package/src/lib/faq-details/faq-details.component.scss +3 -0
  16. package/src/lib/faq-details/faq-details.component.spec.ts +69 -0
  17. package/src/lib/faq-details/faq-details.component.ts +38 -0
  18. package/src/lib/footer/footer.component.html +14 -0
  19. package/src/lib/footer/footer.component.spec.ts +42 -0
  20. package/src/lib/footer/footer.component.ts +24 -0
  21. package/src/lib/home/home.component.html +93 -0
  22. package/src/lib/home/home.component.scss +0 -0
  23. package/src/lib/home/home.component.spec.ts +69 -0
  24. package/src/lib/home/home.component.ts +88 -0
  25. package/src/lib/navbar/navbar.component.html +189 -0
  26. package/src/lib/navbar/navbar.component.scss +92 -0
  27. package/src/lib/navbar/navbar.component.spec.ts +76 -0
  28. package/src/lib/navbar/navbar.component.ts +198 -0
  29. package/src/lib/notifications-page/current-notifications/current-notifications.component.html +61 -0
  30. package/src/lib/notifications-page/current-notifications/current-notifications.component.spec.ts +57 -0
  31. package/src/lib/notifications-page/current-notifications/current-notifications.component.ts +63 -0
  32. package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.html +65 -0
  33. package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.spec.ts +71 -0
  34. package/src/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.ts +79 -0
  35. package/src/lib/notifications-page/notifications-page.component.html +24 -0
  36. package/src/lib/notifications-page/notifications-page.component.scss +28 -0
  37. package/src/lib/notifications-page/notifications-page.component.spec.ts +26 -0
  38. package/src/lib/notifications-page/notifications-page.component.ts +8 -0
  39. package/src/lib/search/search.component.html +215 -0
  40. package/src/lib/search/search.component.scss +98 -0
  41. package/src/lib/search/search.component.spec.ts +64 -0
  42. package/src/lib/search/search.component.ts +50 -0
  43. package/src/lib/sidebar/sidebar-routes.config.ts +355 -0
  44. package/{lib/sidebar/sidebar.metadata.d.ts → src/lib/sidebar/sidebar.metadata.ts} +1 -0
  45. package/src/lib/user-feedback/user-feedback.component.html +53 -0
  46. package/src/lib/user-feedback/user-feedback.component.scss +18 -0
  47. package/src/lib/user-feedback/user-feedback.component.spec.ts +54 -0
  48. package/src/lib/user-feedback/user-feedback.component.ts +83 -0
  49. package/src/lib/user-notifications/user-notifications.component.html +21 -0
  50. package/src/lib/user-notifications/user-notifications.component.scss +21 -0
  51. package/src/lib/user-notifications/user-notifications.component.spec.ts +47 -0
  52. package/src/lib/user-notifications/user-notifications.component.ts +74 -0
  53. package/tsconfig.json +30 -0
  54. package/tsconfig.lib.json +19 -0
  55. package/tsconfig.lib.prod.json +9 -0
  56. package/tsconfig.spec.json +11 -0
  57. package/esm2022/index.mjs +0 -16
  58. package/esm2022/lib/customizer/customizer.component.mjs +0 -17
  59. package/esm2022/lib/dashboard.module.mjs +0 -101
  60. package/esm2022/lib/faq/faq.component.mjs +0 -108
  61. package/esm2022/lib/faq-details/faq-details.component.mjs +0 -38
  62. package/esm2022/lib/footer/footer.component.mjs +0 -22
  63. package/esm2022/lib/home/home.component.mjs +0 -79
  64. package/esm2022/lib/navbar/navbar.component.mjs +0 -162
  65. package/esm2022/lib/notifications-page/current-notifications/current-notifications.component.mjs +0 -58
  66. package/esm2022/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.mjs +0 -73
  67. package/esm2022/lib/notifications-page/notifications-page.component.mjs +0 -14
  68. package/esm2022/lib/search/search.component.mjs +0 -47
  69. package/esm2022/lib/sidebar/sidebar-routes.config.mjs +0 -338
  70. package/esm2022/lib/sidebar/sidebar.metadata.mjs +0 -2
  71. package/esm2022/lib/user-feedback/user-feedback.component.mjs +0 -73
  72. package/esm2022/lib/user-notifications/user-notifications.component.mjs +0 -65
  73. package/esm2022/posiwise-dashboard-module.mjs +0 -5
  74. package/fesm2022/posiwise-dashboard-module.mjs +0 -1106
  75. package/fesm2022/posiwise-dashboard-module.mjs.map +0 -1
  76. package/lib/customizer/customizer.component.d.ts +0 -7
  77. package/lib/dashboard.module.d.ts +0 -28
  78. package/lib/faq/faq.component.d.ts +0 -37
  79. package/lib/faq-details/faq-details.component.d.ts +0 -16
  80. package/lib/footer/footer.component.d.ts +0 -12
  81. package/lib/home/home.component.d.ts +0 -18
  82. package/lib/navbar/navbar.component.d.ts +0 -35
  83. package/lib/notifications-page/current-notifications/current-notifications.component.d.ts +0 -17
  84. package/lib/notifications-page/dismissed-notifications/dismissed-notifications.component.d.ts +0 -18
  85. package/lib/notifications-page/notifications-page.component.d.ts +0 -5
  86. package/lib/search/search.component.d.ts +0 -24
  87. package/lib/sidebar/sidebar-routes.config.d.ts +0 -64
  88. package/lib/user-feedback/user-feedback.component.d.ts +0 -24
  89. package/lib/user-notifications/user-notifications.component.d.ts +0 -20
@@ -0,0 +1,61 @@
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>
@@ -0,0 +1,57 @@
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
+ });
@@ -0,0 +1,63 @@
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
+ }
@@ -0,0 +1,65 @@
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>
@@ -0,0 +1,71 @@
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
+ });
@@ -0,0 +1,79 @@
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
+ }
@@ -0,0 +1,24 @@
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>
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ });
@@ -0,0 +1,8 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'pw-notifications-page',
5
+ templateUrl: './notifications-page.component.html',
6
+ styleUrls: ['./notifications-page.component.scss']
7
+ })
8
+ export class NotificationsPageComponent {}