@tech4good/angular-schematics 20.1.0 → 20.3.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.
Files changed (90) hide show
  1. package/.agents/skills/publish-npm/SKILL.md +37 -0
  2. package/.agents/skills/publish-npm/eval.yaml +17 -0
  3. package/.t4g/agent-memory.db +0 -0
  4. package/CHANGELOG.md +66 -0
  5. package/README.md +16 -7
  6. package/changelog.config.json +19 -0
  7. package/contributing-docs/branches-and-releases.md +57 -0
  8. package/contributing-docs/commit-message.md +117 -0
  9. package/package.json +10 -2
  10. package/src/component/files/__name@dasherize__/__name@dasherize__.component.scss.template +1 -0
  11. package/src/component/schema.json +1 -0
  12. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +1 -1
  13. package/src/entity/schema.json +1 -0
  14. package/src/ng-add/files/.gitignore.template +3 -0
  15. package/src/ng-add/files/package.json.template +3 -2
  16. package/src/ng-add/files/public/images/abstract.png +0 -0
  17. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.html.template +27 -22
  18. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.scss.template +35 -4
  19. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.ts.template +31 -75
  20. package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.html.template +25 -0
  21. package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.scss.template +67 -0
  22. package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.ts.template +74 -0
  23. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-count-pill/admin-count-pill.animations.ts.template +4 -0
  24. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-count-pill/admin-count-pill.component.html.template +4 -0
  25. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-count-pill/admin-count-pill.component.scss.template +22 -0
  26. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-count-pill/admin-count-pill.component.spec.ts.template +37 -0
  27. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-count-pill/admin-count-pill.component.ts.template +36 -0
  28. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-user-counts.animations.ts.template +4 -0
  29. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-user-counts.component.html.template +11 -0
  30. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-user-counts.component.scss.template +22 -0
  31. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-user-counts.component.spec.ts.template +37 -0
  32. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-counts/admin-user-counts.component.ts.template +47 -0
  33. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.html.template +52 -0
  34. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.scss.template +66 -0
  35. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.ts.template +220 -0
  36. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.animations.ts.template +4 -0
  37. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.html.template +81 -0
  38. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.scss.template +136 -0
  39. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.spec.ts.template +37 -0
  40. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.ts.template +118 -0
  41. package/src/ng-add/files/src/app/app.component.html.template +2 -0
  42. package/src/ng-add/files/src/app/app.component.ts.template +2 -0
  43. package/src/ng-add/files/src/app/app.routes.ts.template +14 -18
  44. package/src/ng-add/files/src/app/core/auth/auth.service.ts.template +58 -0
  45. package/src/ng-add/files/src/app/core/auth/guards/admin-override.ts.template +9 -0
  46. package/src/ng-add/files/src/app/core/auth/guards/index.ts.template +11 -0
  47. package/src/ng-add/files/src/app/core/auth/guards/redirect-if-authenticated.guard.ts.template +42 -0
  48. package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.ts.template +39 -0
  49. package/src/ng-add/files/src/app/core/auth/guards/require-auth-and-consent.guard.ts.template +69 -0
  50. package/src/ng-add/files/src/app/core/auth/guards/require-auth.guard.ts.template +35 -0
  51. package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +2 -17
  52. package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +1 -1
  53. package/src/ng-add/files/src/app/core/firebase/firebase.service.ts.template +7 -1
  54. package/src/ng-add/files/src/app/core/store/app.model.ts.template +1 -1
  55. package/src/ng-add/files/src/app/core/store/app.store.ts.template +71 -6
  56. package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +94 -53
  57. package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +5 -5
  58. package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +5 -7
  59. package/src/ng-add/files/src/app/core/store/user-context/user-context.mock.ts.template +3 -5
  60. package/src/ng-add/files/src/app/core/store/user-context/user-context.model.ts.template +2 -5
  61. package/src/ng-add/files/src/app/first-time/consent/consent.component.ts.template +4 -3
  62. package/src/ng-add/files/src/app/first-time/consent/consent.guard.ts.template +54 -0
  63. package/src/ng-add/files/src/app/first-time/early-access/early-access.animations.ts.template +6 -0
  64. package/src/ng-add/files/src/app/first-time/early-access/early-access.component.html.template +70 -52
  65. package/src/ng-add/files/src/app/first-time/early-access/early-access.component.scss.template +73 -6
  66. package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +59 -111
  67. package/src/ng-add/files/src/app/first-time/early-access/early-access.guard.ts.template +44 -0
  68. package/src/ng-add/files/src/app/first-time/landing/hero/hero.animations.ts.template +15 -0
  69. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.html.template +12 -0
  70. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.scss.template +79 -0
  71. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +20 -0
  72. package/src/ng-add/files/src/app/first-time/landing/landing.component.html.template +1 -1
  73. package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +11 -8
  74. package/src/ng-add/files/src/app/first-time/landing/landing.component.ts.template +2 -0
  75. package/src/ng-add/files/src/app/first-time/landing/rotating-quotes/rotating-quotes.component.html.template +3 -0
  76. package/src/ng-add/files/src/app/first-time/landing/rotating-quotes/rotating-quotes.component.scss.template +26 -0
  77. package/src/ng-add/files/src/app/first-time/landing/rotating-quotes/rotating-quotes.component.ts.template +52 -0
  78. package/src/ng-add/files/src/app/shared/dev-status-bar/dev-status-bar.component.html.template +21 -0
  79. package/src/ng-add/files/src/app/shared/dev-status-bar/dev-status-bar.component.scss.template +71 -0
  80. package/src/ng-add/files/src/app/shared/dev-status-bar/dev-status-bar.component.ts.template +70 -0
  81. package/src/ng-add/files/src/app/shared/hint-visibility/hint-visibility.directive.ts.template +131 -0
  82. package/src/ng-add/files/src/app/shared/navbar/navbar.component.html.template +1 -1
  83. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.ts.template +1 -1
  84. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +2 -2
  85. package/src/ng-add/files/src/environments/environment.ts.template +1 -1
  86. package/src/ng-add/files/src/index.html.template +3 -2
  87. package/src/ng-add/files/src/styles/_variables.scss.template +1 -0
  88. package/src/ng-add/files/src/styles.scss.template +4 -2
  89. package/src/ng-add/schema.json +1 -0
  90. package/src/ng-add/files/src/app/core/auth/auth.guard.ts.template +0 -96
@@ -1,18 +1,17 @@
1
- import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
1
+ import { Component, ChangeDetectionStrategy, inject, input, linkedSignal } from '@angular/core';
2
+ import { ActivatedRoute, Router } from '@angular/router';
2
3
  import { AdminPanelAnimations } from './admin-panel.animations';
3
- import { User, AccessState } from '../../core/store/user/user.model';
4
- import { AuthStore } from '../../core/store/auth/auth.store';
5
- import { UserStore } from '../../core/store/user/user.store';
6
- import { MatSnackBar } from '@angular/material/snack-bar';
7
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
- import { NgFor } from '@angular/common';
9
- import { MatMenuTrigger, MatMenu, MatMenuItem } from '@angular/material/menu';
10
- import { MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow } from '@angular/material/table';
11
- import { BatchWriteService, BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
4
+ import { MatIcon } from '@angular/material/icon';
5
+ import { AdminUserListComponent } from './admin-user-list/admin-user-list.component';
6
+ import { AdminSettingsComponent } from './admin-settings/admin-settings.component';
12
7
 
13
- // If you add other columns, update this, e.g. AccessState | string | boolean;
14
- type UpdateValueTypes = AccessState;
8
+ /** The available tabs in the admin panel. */
9
+ type AdminTab = 'users' | 'settings';
15
10
 
11
+ /**
12
+ * Parent admin panel component that provides tab-based navigation
13
+ * between the user management list and admin settings.
14
+ */
16
15
  @Component({
17
16
  selector: 'app-admin-panel',
18
17
  templateUrl: './admin-panel.component.html',
@@ -20,79 +19,36 @@ type UpdateValueTypes = AccessState;
20
19
  changeDetection: ChangeDetectionStrategy.OnPush,
21
20
  animations: AdminPanelAnimations,
22
21
  imports: [
23
- MatTable,
24
- MatColumnDef,
25
- MatHeaderCellDef,
26
- MatHeaderCell,
27
- MatCellDef,
28
- MatCell,
29
- MatMenuTrigger,
30
- MatMenu,
31
- NgFor,
32
- MatMenuItem,
33
- MatHeaderRowDef,
34
- MatHeaderRow,
35
- MatRowDef,
36
- MatRow,
22
+ MatIcon,
23
+ AdminUserListComponent,
24
+ AdminSettingsComponent,
37
25
  ],
38
26
  })
39
- export class AdminPanelComponent implements OnInit {
40
- readonly authStore = inject(AuthStore);
41
- readonly userStore = inject(UserStore);
27
+ export class AdminPanelComponent {
28
+ private readonly route = inject(ActivatedRoute);
29
+ private readonly router = inject(Router);
42
30
 
43
31
  // --------------- INPUTS AND OUTPUTS ------------------
44
32
 
45
- // --------------- LOCAL UI STATE ----------------------
46
-
47
- /** Access options for menu sorted alphabetically. */
48
- accessOptions: AccessState[] = Object.keys(AccessState)
49
- .map((k) => AccessState[k] as AccessState)
50
- .sort((a, b) => {
51
- if (a > b) {
52
- return 1;
53
- } else if (a < b) {
54
- return -1;
55
- } else {
56
- return 0;
57
- }
58
- });
59
-
60
- /** Columns to display in the table */
61
- displayedColumns = ['userName', 'accessState'];
33
+ /** The tab query parameter. */
34
+ tab = input<AdminTab>();
62
35
 
63
36
  // --------------- COMPUTED DATA -----------------------
64
37
 
65
- /** Get array of all waiting users. */
66
- waitingUsers: Signal<User[]> = computed(() => this.userStore.selectEntities([], { orderBy: 'accessState' }));
38
+ /** The currently active tab. */
39
+ activeTab = linkedSignal<AdminTab>(() => {
40
+ const tabParam = this.tab();
41
+ return (tabParam === 'settings' || tabParam === 'users') ? tabParam : 'users';
42
+ });
67
43
 
68
44
  // --------------- EVENT HANDLING ----------------------
69
45
 
70
- /** Event stream for updating user accessState. */
71
- async updateState(user: User, key: string, value: UpdateValueTypes) {
72
- const data = {};
73
- data[key] = value;
74
-
75
- try {
76
- await this.userStore.update(user.__id, { ...data });
77
- this.snackBar.open(`Set ${user.name}'s ${key} to ${value}`, '', { duration: 3000 });
78
- } catch (e) {
79
- console.error(e);
80
- this.snackBar.open('Failed to submit response', '', { duration: 3000 });
81
- }
82
- }
83
-
84
- // --------------- OTHER -------------------------------
85
-
86
- constructor(
87
- private snackBar: MatSnackBar,
88
- private injector: Injector,
89
- @Inject(BATCH_WRITE_SERVICE) private batch: BatchWriteService,
90
- ) {
91
- }
92
-
93
- // --------------- LOAD AND CLEANUP --------------------
94
-
95
- ngOnInit() {
96
- this.userStore.load([], {});
46
+ setTab(tab: AdminTab) {
47
+ this.activeTab.set(tab);
48
+ this.router.navigate([], {
49
+ relativeTo: this.route,
50
+ queryParams: { tab },
51
+ queryParamsHandling: 'merge',
52
+ });
97
53
  }
98
54
  }
@@ -0,0 +1,25 @@
1
+ <div class="settings-container">
2
+ <div class="override-section">
3
+ <h3>Route Override</h3>
4
+ <p class="override-description">
5
+ Toggle routes to bypass auth guards. When a route is enabled, you can
6
+ view that page regardless of your access state. An orange notification
7
+ bar will appear when you're browsing with overridden permissions.
8
+ </p>
9
+ <div class="override-routes">
10
+ @for (route of availableOverrideRoutes; track route.path) {
11
+ <div class="override-route-item">
12
+ <mat-icon
13
+ class="override-toggle"
14
+ [class.active]="isRouteOverridden(route.path)"
15
+ (click)="toggleOverridePath(route.path)"
16
+ >
17
+ {{ isRouteOverridden(route.path) ? 'toggle_on' : 'toggle_off' }}
18
+ </mat-icon>
19
+ <span class="route-path">{{ route.path }}</span>
20
+ <span class="route-label">{{ route.label }}</span>
21
+ </div>
22
+ }
23
+ </div>
24
+ </div>
25
+ </div>
@@ -0,0 +1,67 @@
1
+ :host {
2
+ display: block;
3
+
4
+ .settings-container {
5
+ .override-section {
6
+ padding: 20px;
7
+ border: 1px solid #e0e0e0;
8
+ border-radius: 8px;
9
+ background: #fafafa;
10
+
11
+ h3 {
12
+ margin: 0 0 8px 0;
13
+ font-size: 16px;
14
+ font-weight: 600;
15
+ color: #333;
16
+ }
17
+
18
+ .override-description {
19
+ margin: 0 0 16px 0;
20
+ font-size: 13px;
21
+ color: #666;
22
+ line-height: 1.4;
23
+ }
24
+
25
+ .override-routes {
26
+ display: flex;
27
+ flex-direction: column;
28
+ gap: 8px;
29
+
30
+ .override-route-item {
31
+ display: flex;
32
+ align-items: center;
33
+ gap: 12px;
34
+ padding: 8px 12px;
35
+ border-radius: 6px;
36
+ background: #fff;
37
+ border: 1px solid #e0e0e0;
38
+
39
+ .override-toggle {
40
+ cursor: pointer;
41
+ font-size: 28px;
42
+ width: 28px;
43
+ height: 28px;
44
+ color: #999;
45
+ transition: color 0.2s ease;
46
+
47
+ &.active {
48
+ color: #f57c00;
49
+ }
50
+ }
51
+
52
+ .route-path {
53
+ font-family: monospace;
54
+ font-size: 13px;
55
+ color: #333;
56
+ min-width: 120px;
57
+ }
58
+
59
+ .route-label {
60
+ font-size: 13px;
61
+ color: #888;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,74 @@
1
+ import { Component, ChangeDetectionStrategy, inject } from '@angular/core';
2
+ import { AuthStore } from '../../../core/store/auth/auth.store';
3
+ import { UserStore } from '../../../core/store/user/user.store';
4
+ import { MatSnackBar } from '@angular/material/snack-bar';
5
+ import { MatIcon } from '@angular/material/icon';
6
+
7
+ /**
8
+ * Admin settings panel for managing route override permissions.
9
+ * Allows the current admin to toggle which routes bypass auth guards,
10
+ * enabling them to view pages as if they were at a different access state.
11
+ */
12
+ @Component({
13
+ selector: 'app-admin-settings',
14
+ templateUrl: './admin-settings.component.html',
15
+ styleUrls: ['./admin-settings.component.scss'],
16
+ changeDetection: ChangeDetectionStrategy.OnPush,
17
+ imports: [MatIcon],
18
+ })
19
+ export class AdminSettingsComponent {
20
+ readonly authStore = inject(AuthStore);
21
+ private readonly userStore = inject(UserStore);
22
+
23
+ // --------------- LOCAL UI STATE ----------------------
24
+
25
+ /**
26
+ * Routes available for admin override. These are the guarded routes
27
+ * that an admin might want to view regardless of their access state.
28
+ */
29
+ readonly availableOverrideRoutes = [
30
+ { path: '/early-access', label: 'Waitlist / Early Access' },
31
+ { path: '/consent', label: 'Consent Form' },
32
+ { path: '/onboarding', label: 'Onboarding' },
33
+ { path: '/home', label: 'Home' },
34
+ ];
35
+
36
+ // --------------- ROUTE OVERRIDE MANAGEMENT -----------
37
+
38
+ /** Returns whether the given route path is in the current admin's override list. */
39
+ isRouteOverridden(path: string): boolean {
40
+ const user = this.authStore.user();
41
+ return user?.adminOverridePaths?.includes(path) ?? false;
42
+ }
43
+
44
+ /**
45
+ * Toggles a route path in the current admin's `adminOverridePaths`.
46
+ * Adds it if not present, removes it if already present.
47
+ * Updates both the AuthStore and Firestore.
48
+ */
49
+ async toggleOverridePath(path: string) {
50
+ const user = this.authStore.user();
51
+ if (!user) return;
52
+
53
+ const current = user.adminOverridePaths ?? [];
54
+ const updated = current.includes(path) ?
55
+ current.filter((p) => p !== path) :
56
+ [...current, path];
57
+
58
+ try {
59
+ await this.userStore.update(user.__id, { adminOverridePaths: updated });
60
+ const action = updated.includes(path) ? 'Enabled' : 'Disabled';
61
+ this.snackBar.open(`${action} override for ${path}`, '', { duration: 3000 });
62
+ } catch (e) {
63
+ console.error(e);
64
+ this.snackBar.open('Failed to update route override', '', { duration: 3000 });
65
+ }
66
+ }
67
+
68
+ // --------------- OTHER -------------------------------
69
+
70
+ constructor(
71
+ private snackBar: MatSnackBar,
72
+ ) {
73
+ }
74
+ }
@@ -0,0 +1,4 @@
1
+ import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
+
3
+ export const AdminCountPillAnimations = [
4
+ ];
@@ -0,0 +1,4 @@
1
+ <div class="count-item">
2
+ <span class="label">{{ label() }}:</span>
3
+ <span class="value">{{ value() }}</span>
4
+ </div>
@@ -0,0 +1,22 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .count-item {
6
+ display: flex;
7
+ align-items: center;
8
+ gap: 6px;
9
+ background: #f5f5f5;
10
+ padding: 6px 12px;
11
+ border-radius: 6px;
12
+ font-size: 13px;
13
+
14
+ .label {
15
+ color: #666;
16
+ }
17
+
18
+ .value {
19
+ font-weight: 600;
20
+ color: #1976d2;
21
+ }
22
+ }
@@ -0,0 +1,37 @@
1
+ import { render } from '@testing-library/angular';
2
+ import userEvent from '@testing-library/user-event';
3
+
4
+ import { AdminCountPillComponent } from './admin-count-pill.component';
5
+ import { DATABASE_SERVICE } from 'src/app/core/firebase/database.service';
6
+ import { FirebaseMockService } from 'src/app/core/firebase/firebase.mock.service';
7
+ import { BatchWriteMockService } from 'src/app/core/store/batch-write.mock.service';
8
+ import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
9
+
10
+ /** Sets up the testing environment for AdminCountPillComponent using render.*/
11
+ async function setup() {
12
+ const user = userEvent.setup();
13
+ const checkedSpy = jest.fn();
14
+
15
+ const view = await render(AdminCountPillComponent, {
16
+ imports: [],
17
+ providers: [
18
+ { provide: DATABASE_SERVICE, useClass: FirebaseMockService },
19
+ { provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
20
+ ],
21
+ componentInputs: {},
22
+ on: {},
23
+ });
24
+
25
+ return {
26
+ user,
27
+ fixture: view.fixture,
28
+ rerender: () => view.rerender(), // add component inputs if needed
29
+ };
30
+ }
31
+
32
+ describe('AdminCountPillComponent', () => {
33
+ it('should create', async () => {
34
+ const { fixture } = await setup();
35
+ expect(fixture.componentInstance).toBeTruthy();
36
+ });
37
+ });
@@ -0,0 +1,36 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
2
+ import { AdminCountPillAnimations } from './admin-count-pill.animations';
3
+
4
+ @Component({
5
+ selector: 'app-admin-count-pill',
6
+ templateUrl: './admin-count-pill.component.html',
7
+ styleUrls: ['./admin-count-pill.component.scss'],
8
+ changeDetection: ChangeDetectionStrategy.OnPush,
9
+ animations: AdminCountPillAnimations,
10
+ imports: [
11
+ ],
12
+ })
13
+ export class AdminCountPillComponent implements OnInit {
14
+ // --------------- INPUTS AND OUTPUTS ------------------
15
+
16
+ /** The text label to display on the pill. */
17
+ label = input.required<string>();
18
+
19
+ /** The numerical value to display. */
20
+ value = input.required<number>();
21
+
22
+ // --------------- LOCAL UI STATE ----------------------
23
+
24
+ // --------------- COMPUTED DATA -----------------------
25
+
26
+ // --------------- EVENT HANDLING ----------------------
27
+
28
+ // --------------- OTHER -------------------------------
29
+
30
+ constructor() { }
31
+
32
+ // --------------- LOAD AND CLEANUP --------------------
33
+
34
+ ngOnInit(): void {
35
+ }
36
+ }
@@ -0,0 +1,4 @@
1
+ import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
+
3
+ export const AdminUserCountsAnimations = [
4
+ ];
@@ -0,0 +1,11 @@
1
+ <div class="list-header">
2
+ <div class="counts">
3
+ <app-admin-count-pill label="Interested" [value]="counts().submitInterest"></app-admin-count-pill>
4
+ <app-admin-count-pill label="Waitlist" [value]="counts().waiting"></app-admin-count-pill>
5
+ <app-admin-count-pill label="Consent" [value]="counts().consent"></app-admin-count-pill>
6
+ <app-admin-count-pill label="Done" [value]="counts().done"></app-admin-count-pill>
7
+ </div>
8
+ <button mat-button class="refresh-btn" (click)="refresh.emit()">
9
+ <mat-icon>refresh</mat-icon> Refresh Counts
10
+ </button>
11
+ </div>
@@ -0,0 +1,22 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .list-header {
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ flex-wrap: wrap;
10
+ gap: 10px;
11
+ margin-bottom: 16px;
12
+
13
+ .counts {
14
+ display: flex;
15
+ flex-wrap: wrap;
16
+ gap: 16px;
17
+ }
18
+
19
+ .refresh-btn {
20
+ color: #1976d2;
21
+ }
22
+ }
@@ -0,0 +1,37 @@
1
+ import { render } from '@testing-library/angular';
2
+ import userEvent from '@testing-library/user-event';
3
+
4
+ import { AdminUserCountsComponent } from './admin-user-counts.component';
5
+ import { DATABASE_SERVICE } from 'src/app/core/firebase/database.service';
6
+ import { FirebaseMockService } from 'src/app/core/firebase/firebase.mock.service';
7
+ import { BatchWriteMockService } from 'src/app/core/store/batch-write.mock.service';
8
+ import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
9
+
10
+ /** Sets up the testing environment for AdminUserCountsComponent using render.*/
11
+ async function setup() {
12
+ const user = userEvent.setup();
13
+ const checkedSpy = jest.fn();
14
+
15
+ const view = await render(AdminUserCountsComponent, {
16
+ imports: [],
17
+ providers: [
18
+ { provide: DATABASE_SERVICE, useClass: FirebaseMockService },
19
+ { provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
20
+ ],
21
+ componentInputs: {},
22
+ on: {},
23
+ });
24
+
25
+ return {
26
+ user,
27
+ fixture: view.fixture,
28
+ rerender: () => view.rerender(), // add component inputs if needed
29
+ };
30
+ }
31
+
32
+ describe('AdminUserCountsComponent', () => {
33
+ it('should create', async () => {
34
+ const { fixture } = await setup();
35
+ expect(fixture.componentInstance).toBeTruthy();
36
+ });
37
+ });
@@ -0,0 +1,47 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
2
+ import { AdminUserCountsAnimations } from './admin-user-counts.animations';
3
+ import { MatButton } from '@angular/material/button';
4
+ import { MatIcon } from '@angular/material/icon';
5
+ import { AdminCountPillComponent } from './admin-count-pill/admin-count-pill.component';
6
+
7
+ export interface AdminCounts {
8
+ submitInterest: number;
9
+ waiting: number;
10
+ consent: number;
11
+ done: number;
12
+ }
13
+
14
+ @Component({
15
+ selector: 'app-admin-user-counts',
16
+ templateUrl: './admin-user-counts.component.html',
17
+ styleUrls: ['./admin-user-counts.component.scss'],
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
19
+ animations: AdminUserCountsAnimations,
20
+ imports: [
21
+ MatButton, MatIcon, AdminCountPillComponent
22
+ ],
23
+ })
24
+ export class AdminUserCountsComponent implements OnInit {
25
+ // --------------- INPUTS AND OUTPUTS ------------------
26
+
27
+ /** The counts for each user state. */
28
+ counts = input.required<AdminCounts>();
29
+
30
+ /** Emitted when the user clicks the refresh button. */
31
+ refresh = output<void>();
32
+
33
+ // --------------- LOCAL UI STATE ----------------------
34
+
35
+ // --------------- COMPUTED DATA -----------------------
36
+
37
+ // --------------- EVENT HANDLING ----------------------
38
+
39
+ // --------------- OTHER -------------------------------
40
+
41
+ constructor() { }
42
+
43
+ // --------------- LOAD AND CLEANUP --------------------
44
+
45
+ ngOnInit(): void {
46
+ }
47
+ }
@@ -0,0 +1,52 @@
1
+ <app-admin-user-counts [counts]="counts()" (refresh)="refreshCounts()"></app-admin-user-counts>
2
+
3
+ <div class="table-section">
4
+ <div class="section-header">
5
+ <h3>
6
+ Waitlist
7
+ <mat-icon matTooltip="Displays users currently on the waitlist. Sorted by time waiting.">info_outline</mat-icon>
8
+ </h3>
9
+ </div>
10
+
11
+ <app-admin-user-table
12
+ [dataSource]="waitingUsers()"
13
+ [displayedColumns]="displayedColumns"
14
+ [accessOptions]="accessOptions"
15
+ (updateState)="updateState($event.user, $event.key, $event.value)">
16
+ </app-admin-user-table>
17
+
18
+ @if (waitingUsers().length < counts().waiting) {
19
+ <div class="load-more-container">
20
+ <button mat-button class="load-more-btn" (click)="loadMore()">Load More (Showing {{limitState()}})</button>
21
+ </div>
22
+ }
23
+ </div>
24
+
25
+ <div class="table-section">
26
+ <div class="section-header">
27
+ <h3>
28
+ Other Users
29
+ <mat-icon matTooltip="Displays all other users. Sorted by most recently updated.">info_outline</mat-icon>
30
+ </h3>
31
+ </div>
32
+
33
+ <app-admin-user-table
34
+ [dataSource]="otherUsers()"
35
+ [displayedColumns]="displayedColumns"
36
+ [accessOptions]="accessOptions"
37
+ [sortable]="true"
38
+ [sortActive]="otherSortState().active"
39
+ [sortDirection]="otherSortState().direction"
40
+ [showFilter]="true"
41
+ [filterState]="filterState()"
42
+ (sortChange)="onOtherSortChange($event)"
43
+ (updateState)="updateState($event.user, $event.key, $event.value)"
44
+ (filterChange)="filterState.set($event)">
45
+ </app-admin-user-table>
46
+
47
+ @if (otherUsersFetchedCount() < (counts().submitInterest + counts().consent + counts().done)) {
48
+ <div class="load-more-container">
49
+ <button mat-button class="load-more-btn" (click)="loadMoreOther()">Load More (Showing {{otherLimitState()}})</button>
50
+ </div>
51
+ }
52
+ </div>
@@ -0,0 +1,66 @@
1
+ :host {
2
+ display: block;
3
+
4
+ .note {
5
+ display: flex;
6
+ align-items: center;
7
+ gap: 6px;
8
+ font-size: 13px;
9
+ color: #666;
10
+ background: #e3f2fd;
11
+ padding: 8px 12px;
12
+ border-radius: 6px;
13
+ margin-bottom: 16px;
14
+
15
+ .info-icon {
16
+ font-size: 18px;
17
+ width: 18px;
18
+ height: 18px;
19
+ color: #1976d2;
20
+ }
21
+ }
22
+
23
+ .table-section {
24
+ margin-bottom: 40px;
25
+
26
+ .section-header {
27
+ margin-bottom: 16px;
28
+
29
+ h3 {
30
+ display: flex;
31
+ align-items: center;
32
+ gap: 8px;
33
+ margin: 0;
34
+ font-size: 18px;
35
+ font-weight: 500;
36
+ color: #333;
37
+
38
+ mat-icon {
39
+ font-size: 18px;
40
+ width: 18px;
41
+ height: 18px;
42
+ color: #888;
43
+ cursor: help;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+
50
+
51
+ .load-more-container {
52
+ display: flex;
53
+ justify-content: center;
54
+ margin-top: 16px;
55
+
56
+ .load-more-btn {
57
+ color: #1976d2;
58
+ }
59
+ }
60
+ }
61
+
62
+ // Highlight the active filter option in the dropdown
63
+ ::ng-deep .mat-mdc-menu-item.selected {
64
+ background: #e3f2fd;
65
+ font-weight: 600;
66
+ }