@tech4good/angular-schematics 13.5.0 → 13.7.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 (115) hide show
  1. package/package.json +1 -1
  2. package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +8 -8
  3. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +3 -2
  4. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +6 -5
  5. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +2 -2
  6. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +25 -14
  7. package/src/container/index.js +13 -2
  8. package/src/container/index.js.map +1 -1
  9. package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +9 -30
  10. package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +23 -24
  11. package/src/init/files/.github/workflows/angular-github-ci.yml.template +1 -2
  12. package/src/init/files/package.json.template +3 -1
  13. package/src/init/files/src/app/admin/admin-routing.module.ts.template +17 -0
  14. package/src/init/files/src/app/admin/admin.module.spec.ts.template +13 -0
  15. package/src/init/files/src/app/admin/admin.module.ts.template +28 -0
  16. package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +23 -0
  17. package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +50 -0
  18. package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +39 -0
  19. package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +13 -0
  20. package/src/init/files/src/app/admin/waitlist/waitlist.animations.ts.template +4 -0
  21. package/src/init/files/src/app/admin/waitlist/waitlist.component.html.template +30 -0
  22. package/src/init/files/src/app/admin/waitlist/waitlist.component.scss.template +14 -0
  23. package/src/init/files/src/app/admin/waitlist/waitlist.component.spec.ts.template +25 -0
  24. package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +136 -0
  25. package/src/init/files/src/app/app-routing.module.ts.template +13 -5
  26. package/src/init/files/src/app/app.component.html.template +1 -0
  27. package/src/init/files/src/app/app.component.scss.template +7 -0
  28. package/src/init/files/src/app/app.component.ts.template +5 -0
  29. package/src/init/files/src/app/core/analytics/log.service.ts.template +89 -4
  30. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +204 -69
  31. package/src/init/files/src/app/core/auth/auth.guard.ts.template +85 -0
  32. package/src/init/files/src/app/core/core.module.ts.template +4 -0
  33. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +4 -4
  34. package/src/init/files/src/app/core/local-storage/local-storage.service.ts.template +47 -0
  35. package/src/init/files/src/app/core/local-storage/session-local-storage.service.ts.template +67 -0
  36. package/src/init/files/src/app/core/local-storage/session.service.ts.template +48 -0
  37. package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +270 -0
  38. package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +131 -0
  39. package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +8 -0
  40. package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +13 -0
  41. package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +51 -0
  42. package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +50 -0
  43. package/src/init/files/src/app/core/store/app.effects.ts.template +10 -2
  44. package/src/init/files/src/app/core/store/app.reducer.ts.template +6 -0
  45. package/src/init/files/src/app/core/store/app.selectors.ts.template +12 -0
  46. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +3 -1
  47. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +27 -31
  48. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +1 -1
  49. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +5 -1
  50. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +9 -8
  51. package/src/init/files/src/app/core/store/user/user.model.ts.template +14 -0
  52. package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +270 -0
  53. package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +131 -0
  54. package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +13 -0
  55. package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +13 -0
  56. package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +51 -0
  57. package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +50 -0
  58. package/src/init/files/src/app/general/general-routing.module.ts.template +6 -2
  59. package/src/init/files/src/app/general/general.module.ts.template +8 -2
  60. package/src/init/files/src/app/general/home/+state/home.actions.ts.template +26 -0
  61. package/src/init/files/src/app/general/home/+state/home.effects.ts.template +48 -0
  62. package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
  63. package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +20 -0
  64. package/src/init/files/src/app/general/home/+state/home.state.ts.template +13 -0
  65. package/src/init/files/src/app/general/home/home.animations.ts.template +4 -0
  66. package/src/init/files/src/app/general/home/home.component.html.template +5 -0
  67. package/src/init/files/src/app/general/home/home.component.scss.template +5 -0
  68. package/src/init/files/src/app/general/{e404/e404.component.spec.ts.template → home/home.component.spec.ts.template} +6 -6
  69. package/src/init/files/src/app/general/home/home.component.ts.template +88 -0
  70. package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +26 -0
  71. package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +48 -0
  72. package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
  73. package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +20 -0
  74. package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +13 -0
  75. package/src/init/files/src/app/general/landing/landing.animations.ts.template +4 -0
  76. package/src/init/files/src/app/general/landing/landing.component.html.template +3 -0
  77. package/src/init/files/src/app/general/landing/landing.component.scss.template +13 -0
  78. package/src/init/files/src/app/general/landing/landing.component.spec.ts.template +25 -0
  79. package/src/init/files/src/app/general/landing/landing.component.ts.template +98 -0
  80. package/src/init/files/src/app/general/login/login.component.html.template +5 -5
  81. package/src/init/files/src/app/general/login/login.component.ts.template +12 -4
  82. package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +23 -0
  83. package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +47 -0
  84. package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
  85. package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +20 -0
  86. package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +13 -0
  87. package/src/init/files/src/app/onboarding/consent/consent.animations.ts.template +4 -0
  88. package/src/init/files/src/app/onboarding/consent/consent.component.html.template +61 -0
  89. package/src/init/files/src/app/onboarding/consent/consent.component.scss.template +77 -0
  90. package/src/init/files/src/app/onboarding/consent/consent.component.spec.ts.template +25 -0
  91. package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +152 -0
  92. package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +19 -0
  93. package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +13 -0
  94. package/src/init/files/src/app/onboarding/onboarding.module.ts.template +32 -0
  95. package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +26 -0
  96. package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +52 -0
  97. package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +9 -0
  98. package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +42 -0
  99. package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +13 -0
  100. package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +4 -0
  101. package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +57 -0
  102. package/src/init/files/src/app/onboarding/waiting/waiting.component.scss.template +99 -0
  103. package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +25 -0
  104. package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +279 -0
  105. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +10 -0
  106. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.scss.template +46 -0
  107. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.spec.ts.template +24 -0
  108. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.ts.template +29 -0
  109. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.service.ts.template +63 -0
  110. package/src/init/files/src/app/shared/shared.module.ts.template +6 -0
  111. package/src/init/files/src/index.html.template +0 -3
  112. package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +2 -0
  113. package/src/init/files/src/app/general/e404/e404.component.html.template +0 -1
  114. package/src/init/files/src/app/general/e404/e404.component.ts.template +0 -28
  115. /package/src/init/files/src/app/{general/e404/e404.component.scss.template → admin/waitlist/+state/waitlist.model.ts.template} +0 -0
@@ -0,0 +1,42 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Store, select } from '@ngrx/store';
3
+ import * as fromStore from '../../../core/store/app.reducer';
4
+ import { EntitySelectorService } from '../../../core/store/app.selectors';
5
+
6
+ import { Observable, of, combineLatest } from 'rxjs';
7
+ import { bufferTime, distinctUntilChanged, shareReplay, mergeMap, filter, switchMap, map } from 'rxjs/operators';
8
+ import { User, AccessState } from '../../../core/store/user/user.model';
9
+ import { WaitlistData } from './waiting.model';
10
+
11
+ @Injectable({
12
+ providedIn: 'root',
13
+ })
14
+ export class WaitingSelectors {
15
+ constructor(
16
+ private slRx: EntitySelectorService,
17
+ ) { }
18
+
19
+ /** Get waitlist data from store. */
20
+ getWaitlistData(currentUser$: Observable<User>, cId: string): Observable<WaitlistData> {
21
+ return combineLatest([
22
+ this.slRx.selectAppStates([['__id', '==', 'app']], cId).pipe(map((x) => x.length > 0 ? x[0] : undefined)),
23
+ currentUser$,
24
+ ]).pipe(
25
+ switchMap(([appState, currentUser]) => {
26
+ return this.slRx.selectUserContexts([['__userId', '==', currentUser.__id]], cId).pipe(
27
+ map((userContexts) => {
28
+ if (userContexts.length > 0) {
29
+ return { currentUser, userContext: userContexts[0], appState };
30
+ } else {
31
+ return { currentUser, userContext: undefined, appState };
32
+ }
33
+ }),
34
+ );
35
+ }),
36
+ );
37
+ }
38
+
39
+ cleanup(cId: string) {
40
+ this.slRx.release(cId);
41
+ }
42
+ }
@@ -0,0 +1,13 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ import { BehaviorSubject } from 'rxjs';
4
+
5
+ @Injectable({
6
+ providedIn: 'root',
7
+ })
8
+ export class WaitingState {
9
+ // --------------- LOCAL UI STATE ----------------------
10
+
11
+ constructor(
12
+ ) { }
13
+ }
@@ -0,0 +1,4 @@
1
+ import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
+
3
+ export const WaitingAnimations = [
4
+ ];
@@ -0,0 +1,57 @@
1
+ <div class="waiting-container" *ngIf="waitlistData$ | async as data">
2
+ <ng-container *ngIf="{ loading: loading$ | async } as state">
3
+ <!-- Core questions on motivation and desired value -->
4
+ <ng-container *ngIf="data.currentUser.accessState === AccessState.SUBMIT_INTEREST && !state.loading">
5
+ <h1>Hello and Welcome!</h1>
6
+ <form #checkForm="ngForm" (ngSubmit)="submitInterest$.next()">
7
+ <div class="form-field-group">
8
+ <mat-label class="question">Which of the following best describe your background and interest in {{ appName }}?</mat-label>
9
+ <div class="checkbox-group" [formGroup]="backgroundSelections">
10
+ <mat-checkbox [formControlName]="option.fieldName" [aria-label]="option.ariaLabel" *ngFor="let option of backgroundAndInterestsOptions">{{ option.label }}</mat-checkbox>
11
+ </div>
12
+ </div>
13
+ <div class="form-field-group" [formGroup]="backgroundSelections" *ngIf="backgroundSelections.value.other">
14
+ <mat-label class="question">How would you describe your background and interest in {{ appName }}?</mat-label>
15
+ <mat-form-field class="background-other" appearance="fill">
16
+ <mat-label>Your background and interest</mat-label>
17
+ <input matInput [(ngModel)]="backgroundOther" name="backgroundOther" required [ngModelOptions]="{standalone: true}">
18
+ </mat-form-field>
19
+ </div>
20
+ <div class="form-field-group">
21
+ <mat-label class="question">What do you hope to experience or get out of an application for {{ appArea }}?</mat-label>
22
+ <mat-form-field class="desired-value" appearance="fill">
23
+ <mat-label>Your ideal experience or outcomes</mat-label>
24
+ <textarea #text matInput [(ngModel)]="desiredValue" name="desiredValue" required></textarea>
25
+ <mat-hint *ngIf="text.value?.length < 100">You've shared {{text.value?.length || 0}} characters. If you could say a little more and explain why, that'd be helpful! 🙏</mat-hint>
26
+ </mat-form-field>
27
+ </div>
28
+ <button type="submit" class="btn continue-btn" [disabled]="!checkForm.form.valid">
29
+ Submit and Continue
30
+ <img src="https://icongr.am/feather/arrow-right.svg?size=20&color=B2B6C7">
31
+ </button>
32
+ </form>
33
+ </ng-container>
34
+ <!-- Questions to develop a richer understanding of context: goals and needs, barriers, partial solutions, motivators, influencers, environmental context -->
35
+ <ng-container *ngIf="data.currentUser.accessState === AccessState.SUBMIT_DETAILED && !state.loading">
36
+ <h1>Help us understand your unique context and needs</h1>
37
+ <form #checkForm2="ngForm" (ngSubmit)="submitDetailed$.next()">
38
+ <div class="form-field-group">
39
+ <mat-label class="question">[Insert some questions that can help develop a richer understanding of context, e.g. around goals and needs, barriers, partial solutions, motivators, influencers, environmental context, etc.]</mat-label>
40
+ </div>
41
+ <button type="submit" class="btn continue-btn" [disabled]="!checkForm2.form.valid">
42
+ Submit and Continue
43
+ <img src="https://icongr.am/feather/arrow-right.svg?size=20&color=B2B6C7">
44
+ </button>
45
+ </form>
46
+ </ng-container>
47
+ <!-- Waiting list position and path for going getting access early -->
48
+ <ng-container *ngIf="data.currentUser.accessState === AccessState.WAITING && !state.loading">
49
+ <h1>You are <span class="your-position">{{ nth(data.currentUser.positionNumber) }}</span> on the waitlist</h1>
50
+ <p>Thanks for signing up! We're hand-reviewing your response and personally onboarding our first 100 users to ensure that we can give you a delightful experience. We'll be in touch soon 😊</p>
51
+ <p>Also, we haven't had the chance to implement a formal referral system yet, but if you would love to get off the waitlist faster and can help us reach others, email {{ outreachLeadName }} at <a [href]="'mailto:' + outreachLeadEmail">{{ outreachLeadEmail }}</a> and let's talk about getting you early access!</p>
52
+ </ng-container>
53
+ <div class="loading-container" *ngIf="state.loading">
54
+ Submitting... <mat-spinner [diameter]="20" [strokeWidth]="2"></mat-spinner>
55
+ </div>
56
+ </ng-container>
57
+ </div>
@@ -0,0 +1,99 @@
1
+ .waiting-container {
2
+ align-items: stretch;
3
+ width: 100%;
4
+ height: 100%;
5
+ padding: 50px 100px;
6
+ overflow-y: auto;
7
+ color: #303030;
8
+
9
+ .agree-container {
10
+ display: flex;
11
+ align-items: flex-start;
12
+ margin-bottom: 10px;
13
+ input {
14
+ width: auto;
15
+ height: auto;
16
+ margin: 0 10px 0 0;
17
+ }
18
+ .permission-text {
19
+ margin-left: 10px;
20
+ display: inline-block;
21
+ }
22
+ }
23
+ .loading-container {
24
+ display: flex;
25
+ margin-top: 100px;
26
+ margin-bottom: 25px;
27
+
28
+ mat-spinner {
29
+ margin-left: 10px;
30
+ }
31
+ }
32
+ .continue-btn {
33
+ margin: 18px 15px 15px 0;
34
+ border: 1px solid #8c9fff;
35
+ background-color: #6e84f8;
36
+ color: #f1f3ff;
37
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
38
+ border-radius: 6px;
39
+ font-weight: 200;
40
+ display: flex;
41
+ align-items: center;
42
+ font-size: 1.1em;
43
+ padding: 10px 22px 10px;
44
+ transition: color 0.8s ease, border 0.8s ease;
45
+ >img {
46
+ margin: 0 3px 0 2px;
47
+ transition: margin 0.2s ease;
48
+ }
49
+ &[disabled] {
50
+ background-color: white;
51
+ border: 1px solid #d8d8d8;
52
+ color: #b2b6c7;
53
+ box-shadow: none;
54
+ }
55
+ &:hover {
56
+ >img {
57
+ margin: 0 0 0 5px;
58
+ }
59
+ &[disabled] {
60
+ >img {
61
+ margin: 0 3px 0 2px;
62
+ }
63
+ }
64
+ }
65
+ &:focus {
66
+ outline: 0;
67
+ }
68
+ }
69
+
70
+ form {
71
+ margin-top: 2em;
72
+ display: flex;
73
+ flex-direction: column;
74
+ align-items: flex-start;
75
+
76
+ .form-field-group {
77
+ display: flex;
78
+ flex-direction: column;
79
+ .checkbox-group {
80
+ display: flex;
81
+ flex-direction: column;
82
+ margin-bottom: 20px;
83
+ }
84
+
85
+ .question {
86
+ margin-bottom: 10px;
87
+ font-weight: 600;
88
+ }
89
+ }
90
+
91
+ button {
92
+ cursor: pointer;
93
+ }
94
+ }
95
+
96
+ .your-position {
97
+ color: #6ea6fb;
98
+ }
99
+ }
@@ -0,0 +1,25 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { WaitingComponent } from './waiting.component';
4
+
5
+ describe('WaitingComponent', () => {
6
+ let component: WaitingComponent;
7
+ let fixture: ComponentFixture<WaitingComponent>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [WaitingComponent],
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(WaitingComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,279 @@
1
+ import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
+ import { WaitingAnimations } from './waiting.animations';
3
+ import { ParamMap, ActivatedRoute } from '@angular/router';
4
+ import { Store, select } from '@ngrx/store';
5
+ import * as fromStore from '../../core/store/app.reducer';
6
+ import * as fromAuth from '../../core/store/auth/auth.reducer';
7
+ import { FirebaseService } from '../../core/firebase/firebase.service';
8
+ import { Observable, Subject, BehaviorSubject, combineLatest } from 'rxjs';
9
+ import { withLatestFrom, filter, take, takeUntil } from 'rxjs/operators';
10
+
11
+ import { WaitingState } from './+state/waiting.state';
12
+ import { WaitlistData } from './+state/waiting.model';
13
+ import { WaitingSelectors } from './+state/waiting.selectors';
14
+
15
+ import { LoadData, Cleanup } from './+state/waiting.actions';
16
+ import { ActionFlow, RouterNavigate, ActionSet } from '../../core/store/app.actions';
17
+ import { ShowSnackbar } from '../../core/snackbar/snackbar.actions';
18
+
19
+ import { User, AccessState } from '../../core/store/user/user.model';
20
+ import { UpdateUser, UserActionTypes } from '../../core/store/user/user.actions';
21
+ import { UserContext } from '../../core/store/user-context/user-context.model';
22
+ import { UpdateUserContext, AddUserContext, UserContextActionTypes } from '../../core/store/user-context/user-context.actions';
23
+ import { AppState } from '../../core/store/app-state/app-state.model';
24
+ import { UpdateAppState, AddAppState, AppStateActionTypes } from '../../core/store/app-state/app-state.actions';
25
+
26
+ import { Timestamp } from 'firebase/firestore';
27
+ import { FormBuilder } from '@angular/forms';
28
+
29
+ @Component({
30
+ selector: 'app-waiting',
31
+ templateUrl: './waiting.component.html',
32
+ styleUrls: ['./waiting.component.scss'],
33
+ changeDetection: ChangeDetectionStrategy.OnPush,
34
+ animations: WaitingAnimations,
35
+ })
36
+ export class WaitingComponent implements OnInit, OnDestroy {
37
+ // --------------- ROUTE PARAMS & CURRENT USER ---------
38
+
39
+ /** The currently signed in user. */
40
+ currentUser$: Observable<User> = this.store.pipe(
41
+ select(fromAuth.selectUser),
42
+ filter((user) => user !== null), // null indicates LoadAuth hasn't been processed
43
+ );
44
+
45
+ // --------------- LOCAL AND GLOBAL STATE --------------
46
+
47
+ // this allows the template to use the enum
48
+ AccessState = AccessState;
49
+
50
+ // Template constants
51
+ appName = 'APP_NAME [Causeway]';
52
+ appArea = 'APP_AREA [learning web development]';
53
+ backgroundAndInterestsOptions = [
54
+ { fieldName: 'option1', label: 'OPTION_1 [Student trying to get hands-on experience]', ariaLabel: 'OPTION_1_ARIA' },
55
+ { fieldName: 'option2', label: 'OPTION_2 [Educator exploring new ways to teach]', ariaLabel: 'OPTION_2_ARIA' },
56
+ { fieldName: 'option3', label: 'OPTION_3 [Professional wanting to contribute to a cause]', ariaLabel: 'OPTION_3_ARIA' },
57
+ { fieldName: 'other', label: 'Other (none are a perfect fit)', ariaLabel: 'Other' },
58
+ ];
59
+ outreachLeadName = 'OUTREACH_LEAD_NAME [FirstName LastName]';
60
+ outreachLeadEmail = 'OUTREACH_LEAD_EMAIL [email@ucsc.edu]';
61
+
62
+ // Form variables
63
+ desiredValue = '';
64
+ backgroundOther = '';
65
+ backgroundSelections = this.form.group(this.backgroundAndInterestsOptions.reduce((obj, option) => {
66
+ obj[option.fieldName] = false;
67
+ return obj;
68
+ }, {}));
69
+
70
+ // --------------- DB ENTITY DATA ----------------------
71
+
72
+ /** Container id for selectors and loading. */
73
+ containerId: string = this.db.createId();
74
+
75
+ /** Waitlist data from app-state, user, and user-context. */
76
+ waitlistData$: Observable<WaitlistData> = this.selectors.getWaitlistData(this.currentUser$, this.containerId);
77
+
78
+ // --------------- DATA BINDING ------------------------
79
+
80
+
81
+ // --------------- EVENT BINDING -----------------------
82
+
83
+ /** Event stream for submitting interest. */
84
+ submitInterest$: Subject<void> = new Subject<void>();
85
+
86
+ /** Event stream for submitting detailed context. */
87
+ submitDetailed$: Subject<void> = new Subject<void>();
88
+
89
+ // --------------- HELPER FUNCTIONS AND OTHER ----------
90
+
91
+ /** Function for adding the appropriate suffix. */
92
+ nth(n: number) {
93
+ switch (n % 10) {
94
+ case 1: return `${n}st`;
95
+ case 2: return `${n}nd`;
96
+ case 3: return `${n}rd`;
97
+ default: return `${n}th`;
98
+ }
99
+ }
100
+
101
+ /** Get all options that were selected. */
102
+ getSelections(): string[] {
103
+ return Object.keys(this.backgroundSelections.value).filter((key) => this.backgroundSelections.value[key]);
104
+ }
105
+
106
+ /** Loading indicator. */
107
+ loading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
108
+
109
+ /** Unsubscribe observable for subscriptions. */
110
+ unsubscribe$: Subject<void> = new Subject();
111
+
112
+ constructor(
113
+ private state: WaitingState,
114
+ private route: ActivatedRoute,
115
+ private selectors: WaitingSelectors,
116
+ private store: Store<fromStore.State>,
117
+ private db: FirebaseService,
118
+ private form: FormBuilder,
119
+ ) {
120
+ }
121
+
122
+ ngOnInit() {
123
+ // --------------- EVENT HANDLING ----------------------
124
+
125
+ this.submitInterest$.pipe(
126
+ withLatestFrom(this.waitlistData$),
127
+ takeUntil(this.unsubscribe$),
128
+ ).subscribe(([_, waitlistData]) => {
129
+ const actionSets: ActionSet[] = [{
130
+ action: new UpdateUser(waitlistData.currentUser.__id, {
131
+ accessState: AccessState.SUBMIT_DETAILED,
132
+ }, this.containerId),
133
+ responseActionTypes: {
134
+ success: UserActionTypes.UPDATE_SUCCESS,
135
+ failure: UserActionTypes.UPDATE_FAIL,
136
+ },
137
+ }];
138
+
139
+ if (waitlistData.userContext) {
140
+ actionSets.push({
141
+ action: new UpdateUserContext(waitlistData.userContext.__id, {
142
+ background: {
143
+ selections: this.getSelections(),
144
+ ...(this.backgroundOther ? { other: this.backgroundOther } : { }),
145
+ },
146
+ desiredValue: this.desiredValue,
147
+ }, this.containerId),
148
+ responseActionTypes: {
149
+ success: UserContextActionTypes.UPDATE_SUCCESS,
150
+ failure: UserContextActionTypes.UPDATE_FAIL,
151
+ },
152
+ });
153
+ } else {
154
+ actionSets.push({
155
+ action: new AddUserContext({
156
+ __id: this.db.createId(),
157
+ __userId: waitlistData.currentUser.__id,
158
+ background: {
159
+ selections: this.getSelections(),
160
+ ...(this.backgroundOther ? { other: this.backgroundOther } : { }),
161
+ },
162
+ desiredValue: this.desiredValue,
163
+ }, this.containerId),
164
+ responseActionTypes: {
165
+ success: UserContextActionTypes.UPDATE_SUCCESS,
166
+ failure: UserContextActionTypes.UPDATE_FAIL,
167
+ },
168
+ });
169
+ }
170
+
171
+ this.store.dispatch(
172
+ new ActionFlow({
173
+ actionSets,
174
+ loading$: this.loading$,
175
+ successActionFn: (actionSetResponses) => {
176
+ return [];
177
+ },
178
+ failActionFn: (actionSetResponses) => {
179
+ return [
180
+ new ShowSnackbar({
181
+ message: 'Failed to submit response',
182
+ config: { duration: 3000 },
183
+ }),
184
+ ];
185
+ },
186
+ }),
187
+ );
188
+ });
189
+
190
+ this.submitDetailed$.pipe(
191
+ withLatestFrom(this.waitlistData$),
192
+ takeUntil(this.unsubscribe$),
193
+ ).subscribe(([_, waitlistData]) => {
194
+ // TODO: Need to implement a cloud function to update all position numbers
195
+ // when we take someone off the waitlist (decrement everyone who joined after them)
196
+ const actionSets: ActionSet[] = [{
197
+ action: new UpdateUser(waitlistData.currentUser.__id, {
198
+ accessState: AccessState.WAITING,
199
+ positionNumber: waitlistData.appState ? waitlistData.appState._totalWaiting + 1 : 1,
200
+ joinedWaitlistAt: Timestamp.fromDate(new Date()),
201
+ }, this.containerId),
202
+ responseActionTypes: {
203
+ success: UserActionTypes.UPDATE_SUCCESS,
204
+ failure: UserActionTypes.UPDATE_FAIL,
205
+ },
206
+ }, {
207
+ action: new UpdateUserContext(waitlistData.userContext.__id, {
208
+ // Add relevant fields from detailed responses
209
+ }, this.containerId),
210
+ responseActionTypes: {
211
+ success: UserContextActionTypes.UPDATE_SUCCESS,
212
+ failure: UserContextActionTypes.UPDATE_FAIL,
213
+ },
214
+ }];
215
+
216
+ if (waitlistData.appState) {
217
+ actionSets.push({
218
+ action: new UpdateAppState(waitlistData.appState.__id, {
219
+ _totalWaiting: waitlistData.appState._totalWaiting + 1,
220
+ }, this.containerId),
221
+ responseActionTypes: {
222
+ success: UserContextActionTypes.UPDATE_SUCCESS,
223
+ failure: UserContextActionTypes.UPDATE_FAIL,
224
+ },
225
+ });
226
+ } else {
227
+ actionSets.push({
228
+ action: new AddAppState({
229
+ __id: 'app',
230
+ _totalWaiting: 1,
231
+ }, this.containerId),
232
+ responseActionTypes: {
233
+ success: UserContextActionTypes.ADD_SUCCESS,
234
+ failure: UserContextActionTypes.ADD_FAIL,
235
+ },
236
+ });
237
+ }
238
+
239
+ this.store.dispatch(
240
+ new ActionFlow({
241
+ actionSets,
242
+ loading$: this.loading$,
243
+ successActionFn: (actionSetResponses) => {
244
+ return [];
245
+ },
246
+ failActionFn: (actionSetResponses) => {
247
+ return [
248
+ new ShowSnackbar({
249
+ message: 'Failed to submit response',
250
+ config: { duration: 3000 },
251
+ }),
252
+ ];
253
+ },
254
+ }),
255
+ );
256
+ });
257
+
258
+ // --------------- LOAD DATA ---------------------------
259
+
260
+ // Once everything is set up, load the data for the role.
261
+ this.currentUser$.pipe(
262
+ takeUntil(this.unsubscribe$),
263
+ ).subscribe((currentUser) => {
264
+ this.store.dispatch(
265
+ new LoadData({ currentUser }, this.containerId),
266
+ );
267
+ });
268
+ }
269
+
270
+ ngOnDestroy() {
271
+ // Unsubscribe subscriptions.
272
+ this.unsubscribe$.next();
273
+ this.unsubscribe$.complete();
274
+
275
+ // Unsubscribe from firebase connection from load and free up memoized selector values.
276
+ this.store.dispatch( new Cleanup(this.containerId) );
277
+ this.selectors.cleanup(this.containerId);
278
+ }
279
+ }
@@ -0,0 +1,10 @@
1
+ <div
2
+ class="warning-container"
3
+ *ngIf="showRedeploymentWarning"
4
+ >
5
+ <div class="header">
6
+ <div class="title">This version is out of date!</div>
7
+ <img (click)="close()" src="/assets/img/close-x.svg" />
8
+ </div>
9
+ <button (click)="update()" class="update">Update Now</button>
10
+ </div>
@@ -0,0 +1,46 @@
1
+ :host {
2
+ z-index: 100;
3
+
4
+ .warning-container {
5
+ padding: 10px 13px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ width: 350px;
9
+ height: 63px;
10
+ background: #fff;
11
+ border-radius: 5px;
12
+ border: 1px solid #999;
13
+ box-shadow: 0px 1px 4px #999;
14
+
15
+ .header {
16
+ display: flex;
17
+ width: 100%;
18
+
19
+ .title {
20
+ text-transform: uppercase;
21
+ color: #283262;
22
+ font-weight: bold;
23
+ font-size: 13px;
24
+ }
25
+
26
+ img {
27
+ cursor: pointer;
28
+ margin-left: auto;
29
+ }
30
+ }
31
+
32
+ button {
33
+ margin-top: auto;
34
+ border: none;
35
+ padding: 0;
36
+ width: fit-content;
37
+ outline: 0;
38
+ font-weight: bold;
39
+ font-size: 13px;
40
+ text-decoration-line: underline;
41
+ background: none;
42
+ text-transform: capitalize;
43
+ cursor: pointer;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,24 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { RedeploymentWarningComponent } from './redeployment-warning.component';
4
+
5
+ describe('RedeploymentWarningComponent', () => {
6
+ let component: RedeploymentWarningComponent;
7
+ let fixture: ComponentFixture<RedeploymentWarningComponent>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [RedeploymentWarningComponent],
12
+ }).compileComponents();
13
+ }));
14
+
15
+ beforeEach(() => {
16
+ fixture = TestBed.createComponent(RedeploymentWarningComponent);
17
+ component = fixture.componentInstance;
18
+ fixture.detectChanges();
19
+ });
20
+
21
+ it('should create', () => {
22
+ expect(component).toBeTruthy();
23
+ });
24
+ });
@@ -0,0 +1,29 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { DetectRedeploymentService } from './redeployment-warning.service';
3
+
4
+ @Component({
5
+ selector: 'app-redeployment-warning',
6
+ templateUrl: './redeployment-warning.component.html',
7
+ styleUrls: ['./redeployment-warning.component.scss'],
8
+ })
9
+ export class RedeploymentWarningComponent implements OnInit {
10
+ showRedeploymentWarning: boolean = false;
11
+
12
+ constructor(public detectRedeployment: DetectRedeploymentService) {}
13
+
14
+ ngOnInit() {
15
+ this.detectRedeployment.redeployed().subscribe(() => {
16
+ this.showRedeploymentWarning = true;
17
+ });
18
+ }
19
+
20
+ /** Triggers a refresh. */
21
+ update() {
22
+ this.detectRedeployment.refresh();
23
+ }
24
+
25
+ /** Ignores the warning. */
26
+ close() {
27
+ this.showRedeploymentWarning = false;
28
+ }
29
+ }