@tech4good/angular-schematics 17.0.3 → 18.0.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 (220) hide show
  1. package/README.md +8 -0
  2. package/package.json +4 -4
  3. package/src/collection.json +0 -16
  4. package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +22 -8
  5. package/src/component/index.js +2 -45
  6. package/src/component/index.js.map +1 -1
  7. package/src/component/schema.json +0 -5
  8. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +12 -0
  9. package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +1 -0
  10. package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +41 -0
  11. package/src/entity/index.js +29 -50
  12. package/src/entity/index.js.map +1 -1
  13. package/src/init/files/.firebaserc.template +8 -0
  14. package/src/init/files/README.md.template +6 -6
  15. package/src/init/files/angular.json.template +18 -11
  16. package/src/init/files/package.json.template +28 -29
  17. package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
  18. package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
  19. package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
  20. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
  21. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
  22. package/src/init/files/src/app/app.component.html.template +1 -0
  23. package/src/init/files/src/app/app.component.ts.template +14 -8
  24. package/src/init/files/src/app/app.config.ts.template +63 -0
  25. package/src/init/files/src/app/app.routes.ts.template +32 -0
  26. package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
  27. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
  28. package/src/init/files/src/app/core/auth/auth.guard.ts.template +25 -22
  29. package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
  30. package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
  31. package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
  32. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
  33. package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
  34. package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
  35. package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
  36. package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
  37. package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
  38. package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
  39. package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
  40. package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
  41. package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
  42. package/src/init/files/src/app/core/store/user/user.model.ts.template +1 -1
  43. package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
  44. package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
  45. package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
  46. package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
  47. package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
  48. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +8 -13
  49. package/src/init/files/src/app/first-time/consent/consent.component.ts.template +90 -0
  50. package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
  51. package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +69 -0
  52. package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +1 -1
  53. package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
  54. package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +194 -0
  55. package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
  56. package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
  57. package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
  58. package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
  59. package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
  60. package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
  61. package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
  62. package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
  63. package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
  64. package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
  65. package/src/init/files/src/app/main/home/home.component.html.template +5 -0
  66. package/src/init/files/src/app/main/home/home.component.ts.template +51 -0
  67. package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
  68. package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +43 -0
  69. package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
  70. package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
  71. package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
  72. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
  73. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
  74. package/src/init/files/src/assets/images/close-x.svg +3 -0
  75. package/src/init/files/src/environments/environment.ts.template +1 -0
  76. package/src/init/files/src/index.html.template +1 -1
  77. package/src/init/files/tsconfig.json.template +0 -1
  78. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
  79. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
  80. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
  81. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
  82. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
  83. package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
  84. package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
  85. package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
  86. package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
  87. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
  88. package/src/container/index.d.ts +0 -2
  89. package/src/container/index.js +0 -127
  90. package/src/container/index.js.map +0 -1
  91. package/src/container/index_spec.d.ts +0 -1
  92. package/src/container/index_spec.js +0 -23
  93. package/src/container/index_spec.js.map +0 -1
  94. package/src/container/schema.json +0 -50
  95. package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
  96. package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  97. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  98. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  99. package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  100. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
  101. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  102. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
  103. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  104. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  105. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  106. package/src/entity-in-example/index.d.ts +0 -2
  107. package/src/entity-in-example/index.js +0 -141
  108. package/src/entity-in-example/index.js.map +0 -1
  109. package/src/entity-in-example/index_spec.d.ts +0 -1
  110. package/src/entity-in-example/index_spec.js +0 -23
  111. package/src/entity-in-example/index_spec.js.map +0 -1
  112. package/src/entity-in-example/schema.json +0 -45
  113. package/src/init/files/CHANGELOG.md.template +0 -10
  114. package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
  115. package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
  116. package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
  117. package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
  118. package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
  119. package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
  120. package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
  121. package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
  122. package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
  123. package/src/init/files/src/app/app-routing.module.ts.template +0 -26
  124. package/src/init/files/src/app/app.module.ts.template +0 -34
  125. package/src/init/files/src/app/core/core.module.ts.template +0 -75
  126. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
  127. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
  128. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
  129. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
  130. package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
  131. package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
  132. package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
  133. package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
  134. package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
  135. package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
  136. package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
  137. package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
  138. package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
  139. package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
  140. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
  141. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
  142. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
  143. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
  144. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
  145. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
  146. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
  147. package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
  148. package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
  149. package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -149
  150. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
  151. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
  152. package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
  153. package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
  154. package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
  155. package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
  156. package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
  157. package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
  158. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
  159. package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
  160. package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
  161. package/src/init/files/src/app/general/general.module.ts.template +0 -36
  162. package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
  163. package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
  164. package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
  165. package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +0 -20
  166. package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
  167. package/src/init/files/src/app/general/home/home.component.html.template +0 -5
  168. package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
  169. package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
  170. package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
  171. package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
  172. package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +0 -20
  173. package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
  174. package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
  175. package/src/init/files/src/app/general/login/login.component.html.template +0 -11
  176. package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
  177. package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
  178. package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
  179. package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
  180. package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +0 -20
  181. package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
  182. package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
  183. package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
  184. package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
  185. package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
  186. package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
  187. package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
  188. package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
  189. package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
  190. package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
  191. package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
  192. package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
  193. package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
  194. package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
  195. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
  196. package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
  197. package/src/init/files/src/main.ts.template +0 -12
  198. package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
  199. package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
  200. package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
  201. package/src/module/index.d.ts +0 -2
  202. package/src/module/index.js +0 -97
  203. package/src/module/index.js.map +0 -1
  204. package/src/module/index_spec.d.ts +0 -1
  205. package/src/module/index_spec.js +0 -23
  206. package/src/module/index_spec.js.map +0 -1
  207. package/src/module/schema.json +0 -38
  208. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
  209. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +0 -0
  210. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
  211. /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
  212. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
  213. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
  214. /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
  215. /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
  216. /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
  217. /package/src/init/files/src/app/{general → main}/home/home.component.scss.template +0 -0
  218. /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
  219. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
  220. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
@@ -1,98 +0,0 @@
1
- import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
- import { LandingAnimations } from './landing.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 { LandingState } from './+state/landing.state';
12
- import { LandingSelectors } from './+state/landing.selectors';
13
-
14
- import { LoadData, Cleanup } from './+state/landing.actions';
15
- import { RouterNavigate } from '../../core/store/app.actions';
16
-
17
- import { User } from '../../core/store/user/user.model';
18
- import { Login } from '../../core/store/auth/auth.actions';
19
-
20
- @Component({
21
- selector: 'app-landing',
22
- templateUrl: './landing.component.html',
23
- styleUrls: ['./landing.component.scss'],
24
- changeDetection: ChangeDetectionStrategy.OnPush,
25
- animations: LandingAnimations,
26
- })
27
- export class LandingComponent implements OnInit, OnDestroy {
28
- // --------------- ROUTE PARAMS & CURRENT USER ---------
29
-
30
- /** The currently signed in user. */
31
- currentUser$: Observable<User> = this.store.pipe(
32
- select(fromAuth.selectUser),
33
- filter((user) => user !== null), // null indicates LoadAuth hasn't been processed
34
- );
35
-
36
- // --------------- LOCAL AND GLOBAL STATE --------------
37
-
38
-
39
- // --------------- DB ENTITY DATA ----------------------
40
-
41
- /** Container id for selectors and loading. */
42
- containerId: string = this.db.createId();
43
-
44
- // --------------- DATA BINDING ------------------------
45
-
46
-
47
- // --------------- EVENT BINDING -----------------------
48
-
49
- /** Login click events. */
50
- login$: Subject<void> = new Subject<void>();
51
-
52
-
53
- // --------------- HELPER FUNCTIONS AND OTHER ----------
54
-
55
- /** Unsubscribe observable for subscriptions. */
56
- unsubscribe$: Subject<void> = new Subject();
57
-
58
- constructor(
59
- private state: LandingState,
60
- private route: ActivatedRoute,
61
- private selectors: LandingSelectors,
62
- private store: Store<fromStore.State>,
63
- private db: FirebaseService,
64
- ) {
65
- }
66
-
67
- ngOnInit() {
68
- // --------------- EVENT HANDLING ----------------------
69
-
70
- /** Handle login events. */
71
- this.login$.pipe(
72
- takeUntil(this.unsubscribe$),
73
- ).subscribe(() => {
74
- this.store.dispatch(new Login({ provider: 'google.com' }));
75
- });
76
-
77
- // --------------- LOAD DATA ---------------------------
78
-
79
- // Once everything is set up, load the data for the role.
80
- this.currentUser$.pipe(
81
- takeUntil(this.unsubscribe$),
82
- ).subscribe((currentUser) => {
83
- this.store.dispatch( new LoadData({
84
- currentUser,
85
- }, this.containerId) );
86
- });
87
- }
88
-
89
- ngOnDestroy() {
90
- // Unsubscribe subscriptions.
91
- this.unsubscribe$.next();
92
- this.unsubscribe$.complete();
93
-
94
- // Unsubscribe from firebase connection from load and free up memoized selector values.
95
- this.store.dispatch( new Cleanup(this.containerId) );
96
- this.selectors.cleanup(this.containerId);
97
- }
98
- }
@@ -1,11 +0,0 @@
1
- <div class="login-container" *ngIf="{ user: currentUser$ | async } as data">
2
- <ng-container *ngIf="data.user">
3
- <img class="profile" [src]="data.user.photoURL" referrerpolicy="no-referrer"/>
4
- <h2>Hello {{data.user.name}}!</h2>
5
- <input type="submit" value="Logout" (click)="logout$.next()">
6
- </ng-container>
7
- <ng-container *ngIf="!data.user">
8
- <h2>Hello!</h2>
9
- <input type="submit" value="Login" (click)="login$.next()">
10
- </ng-container>
11
- </div>
@@ -1,80 +0,0 @@
1
- import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
- import { Observable, Subject } from 'rxjs';
3
- import { takeUntil, filter } from 'rxjs/operators';
4
- import { select, Store } from '@ngrx/store';
5
- import * as fromStore from '../../core/store/app.reducer';
6
- import * as fromAuth from '../../core/store/auth/auth.reducer';
7
- import { Login, Logout } from '../../core/store/auth/auth.actions';
8
- import { User } from '../../core/store/user/user.model';
9
-
10
- @Component({
11
- selector: 'app-login',
12
- templateUrl: './login.component.html',
13
- styleUrls: ['./login.component.scss'],
14
- changeDetection: ChangeDetectionStrategy.OnPush,
15
- })
16
- export class LoginComponent implements OnInit, OnDestroy {
17
- // --------------- ROUTE PARAMS & CURRENT USER ---------
18
-
19
- /** The currently signed in user. */
20
- currentUser$: Observable<User> = this.store.pipe(
21
- select(fromAuth.selectUser),
22
- filter((user) => user !== null),
23
- );
24
-
25
- // --------------- LOCAL UI STATE ----------------------
26
-
27
-
28
- // --------------- DATA BINDING STREAMS ----------------
29
-
30
-
31
- // --------------- EVENT BINDING STREAMS: RAW ------
32
-
33
- /** Login click events. */
34
- login$: Subject<void> = new Subject<void>();
35
-
36
- /** Logout click events. */
37
- logout$: Subject<void> = new Subject<void>();
38
-
39
- // --------------- EVENT BINDING STREAMS: COMPUTED -----
40
-
41
-
42
- // --------------- OTHER -------------------------------
43
-
44
- /** Unsubscribe observable for subscriptions. */
45
- unsubscribe$: Subject<void> = new Subject();
46
-
47
- constructor(
48
- private store: Store<fromStore.State>,
49
- ) {
50
- // --------------- EVENT HANDLING ----------------------
51
-
52
- /** Handle login events. */
53
- this.login$.pipe(
54
- takeUntil(this.unsubscribe$),
55
- ).subscribe(() => {
56
- this.store.dispatch(new Login({
57
- provider: 'google.com',
58
- doNotRoute: true,
59
- }));
60
- });
61
-
62
- /** Handle logout events. */
63
- this.logout$.pipe(
64
- takeUntil(this.unsubscribe$),
65
- ).subscribe(() => {
66
- this.store.dispatch(new Logout({
67
- doNotRoute: true,
68
- }));
69
- });
70
- }
71
-
72
- ngOnInit() {
73
- }
74
-
75
- ngOnDestroy() {
76
- // Unsubscribe subscriptions.
77
- this.unsubscribe$.next();
78
- this.unsubscribe$.complete();
79
- }
80
- }
@@ -1,23 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
-
3
- export enum ConsentActionTypes {
4
- LOAD_DATA = '[Consent] load data',
5
- CLEANUP = '[Consent] cleanup',
6
- }
7
-
8
- /** Action for loading required DB data. */
9
- export class LoadData implements Action {
10
- readonly type = ConsentActionTypes.LOAD_DATA;
11
-
12
- constructor(public correlationId: string) { }
13
- }
14
-
15
- /** Action for cleaning up loading subscriptions. */
16
- export class Cleanup implements Action {
17
- readonly type = ConsentActionTypes.CLEANUP;
18
- constructor(public correlationId: string) { }
19
- }
20
-
21
- export type ConsentActions =
22
- LoadData |
23
- Cleanup;
@@ -1,47 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Action } from '@ngrx/store';
3
- import { Actions, createEffect, ofType } from '@ngrx/effects';
4
-
5
- import { of, Observable } from 'rxjs';
6
- import { mergeMap, tap, map } from 'rxjs/operators';
7
-
8
- import { select, Store } from '@ngrx/store';
9
- import * as fromStore from '../../../core/store/app.reducer';
10
- import { FirebaseService } from '../../../core/firebase/firebase.service';
11
- import { EffectsHelpers } from '../../../core/store/effects.helpers';
12
- import { ConsentState } from './consent.state';
13
-
14
- import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
15
- import { ConsentActionTypes, Cleanup, LoadData } from './consent.actions';
16
-
17
- @Injectable()
18
- export class ConsentEffects {
19
- /** Load data from Firebase. */
20
- loadData$: Observable<Action> = createEffect(
21
- () => this.actions$.pipe(
22
- ofType<LoadData>(ConsentActionTypes.LOAD_DATA),
23
- mergeMap((action: LoadData) => {
24
- const loadId = action.correlationId;
25
-
26
- return [
27
- ];
28
- }),
29
- ),
30
- );
31
-
32
- /** Unsubscribe connections from Firebase. */
33
- cleanup$: Observable<Action> = createEffect(
34
- () => this.actions$.pipe(
35
- ofType<Cleanup>(ConsentActionTypes.CLEANUP),
36
- map((action: Cleanup) => new Unsubscribe(action.correlationId)),
37
- ),
38
- );
39
-
40
- constructor(
41
- private actions$: Actions,
42
- private store: Store<fromStore.State>,
43
- private state: ConsentState,
44
- private db: FirebaseService,
45
- private eh: EffectsHelpers,
46
- ) {}
47
- }
@@ -1,20 +0,0 @@
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
-
9
- @Injectable({
10
- providedIn: 'root',
11
- })
12
- export class ConsentSelectors {
13
- constructor(
14
- private slRx: EntitySelectorService,
15
- ) { }
16
-
17
- cleanup(cId: string) {
18
- this.slRx.release(cId);
19
- }
20
- }
@@ -1,13 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- import { BehaviorSubject } from 'rxjs';
4
-
5
- @Injectable({
6
- providedIn: 'root',
7
- })
8
- export class ConsentState {
9
- // --------------- LOCAL UI STATE ----------------------
10
-
11
- constructor(
12
- ) { }
13
- }
@@ -1,151 +0,0 @@
1
- import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
- import { ConsentAnimations } from './consent.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 { ConsentState } from './+state/consent.state';
12
- import { ConsentSelectors } from './+state/consent.selectors';
13
-
14
- import { LoadData, Cleanup } from './+state/consent.actions';
15
- import { ActionFlow, RouterNavigate } from '../../core/store/app.actions';
16
- import { ShowSnackbar } from '../../core/snackbar/snackbar.actions';
17
-
18
- import { User, AccessState } from '../../core/store/user/user.model';
19
- import { UpdateUser, UserActionTypes } from '../../core/store/user/user.actions';
20
- import { Location, PlatformLocation } from '@angular/common';
21
-
22
- @Component({
23
- selector: 'app-consent',
24
- templateUrl: './consent.component.html',
25
- styleUrls: ['./consent.component.scss'],
26
- changeDetection: ChangeDetectionStrategy.OnPush,
27
- animations: ConsentAnimations,
28
- })
29
- export class ConsentComponent implements OnInit, OnDestroy {
30
- // --------------- ROUTE PARAMS & CURRENT USER ---------
31
-
32
- /** The currently signed in user. */
33
- currentUser$: Observable<User> = this.store.pipe(
34
- select(fromAuth.selectUser),
35
- filter((user) => user !== null),
36
- );
37
-
38
- // --------------- LOCAL AND GLOBAL STATE --------------
39
-
40
- /** String constants. */
41
- appName = 'APP_NAME [Causeway]';
42
- shortProdDesc = 'PROD_DESC [provides users with opportunities to learn coding in real-world settings while contributing to non-profit causes]';
43
- shortResearchDesc = 'RESEARCH_DESC [how to scale opportunities for experiential learning and support collaboration around social causes]';
44
- authAppName = 'AUTH_APP_NAME [Google]';
45
- protocolNumber = 'PROTOCOL_NO [HS-FY2022-254]';
46
- protocolTitle = 'PROTOCOL_TITLE [Scaling Experiential Learning of Web Development]';
47
- usageDataProductDesc = 'USAGE_DATA_PROD [help users learn and contribute to projects they are participating in. When you participate in a project, your task information, status, and code will be shared with the project team]';
48
- usageDataResearchDesc = 'USAGE_DATA_RESEARCH [how to better support experiential learning online]';
49
- studyDoingDesc = 'STUDY_DOING [When you participate in our study, you will use our platform to learn web development and contribute code to a platform. You will also fill out a survey on your experience, and optionally, participate in a follow-up interview]';
50
- benefitsDesc = 'STUDY_BENEFITS [to learn web development and contribute to a project you care about]';
51
- investigatorInfo = 'INVESTIGATOR_INFO [FirstName LastName, co-Principal Investigator, email@ucsc.edu]';
52
- facultyInfo = 'FACULTY_INFO [David T. Lee, dlee105@ucsc.edu]';
53
-
54
- /** Checkbox state used in form. */
55
- checked: boolean;
56
-
57
- /** Consent url. */
58
- consentUrl;
59
-
60
- // --------------- DB ENTITY DATA ----------------------
61
-
62
- /** Container id for selectors and loading. */
63
- containerId: string = this.db.createId();
64
-
65
- // --------------- DATA BINDING ------------------------
66
-
67
-
68
- // --------------- EVENT BINDING -----------------------
69
-
70
- /** Event stream for submission events. */
71
- submit$: Subject<void> = new Subject<void>();
72
-
73
- // --------------- HELPER FUNCTIONS AND OTHER ----------
74
-
75
- /** Loading indicator. */
76
- loading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
77
-
78
- /** Unsubscribe observable for subscriptions. */
79
- unsubscribe$: Subject<void> = new Subject();
80
-
81
- constructor(
82
- private state: ConsentState,
83
- private route: ActivatedRoute,
84
- private selectors: ConsentSelectors,
85
- private store: Store<fromStore.State>,
86
- private db: FirebaseService,
87
- private platform: PlatformLocation,
88
- private location: Location,
89
- ) {
90
- }
91
-
92
- ngOnInit() {
93
- this.consentUrl = location.origin + '/' + this.location.prepareExternalUrl('consent');
94
-
95
- // --------------- EVENT HANDLING ----------------------
96
-
97
-
98
- // Handle submitting the form
99
- this.submit$.pipe(
100
- withLatestFrom(this.currentUser$),
101
- takeUntil(this.unsubscribe$),
102
- ).subscribe(([_, currentUser]) => {
103
- const actionSets = [{
104
- action: new UpdateUser(currentUser.__id, {
105
- accessState: AccessState.SUBMIT_INTEREST,
106
- consented: true,
107
- }, this.containerId),
108
- responseActionTypes: {
109
- success: UserActionTypes.UPDATE_SUCCESS,
110
- failure: UserActionTypes.UPDATE_FAIL,
111
- },
112
- }];
113
-
114
- this.store.dispatch(
115
- new ActionFlow({
116
- actionSets,
117
- loading$: this.loading$,
118
- successActionFn: (actionSetResponses) => {
119
- return [
120
- new RouterNavigate(['/onboarding/waiting']),
121
- ];
122
- },
123
- failActionFn: (actionSetResponses) => {
124
- return [
125
- new ShowSnackbar({
126
- message: 'Failed to update consent status',
127
- config: { duration: 3000 },
128
- }),
129
- ];
130
- },
131
- }),
132
- );
133
- });
134
-
135
-
136
- // --------------- LOAD DATA ---------------------------
137
-
138
- // Once everything is set up, load the data for the role.
139
- this.store.dispatch( new LoadData(this.containerId) );
140
- }
141
-
142
- ngOnDestroy() {
143
- // Unsubscribe subscriptions.
144
- this.unsubscribe$.next();
145
- this.unsubscribe$.complete();
146
-
147
- // Unsubscribe from firebase connection from load and free up memoized selector values.
148
- this.store.dispatch( new Cleanup(this.containerId) );
149
- this.selectors.cleanup(this.containerId);
150
- }
151
- }
@@ -1,19 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { Routes, RouterModule } from '@angular/router';
3
- import { AuthGuard } from '../core/auth/auth.guard';
4
-
5
- // Containers
6
- import { WaitingComponent } from './waiting/waiting.component';
7
- import { ConsentComponent } from './consent/consent.component';
8
-
9
- const routes: Routes = [
10
- { path: '', redirectTo: '/landing', pathMatch: 'full' },
11
- { path: 'waiting', component: WaitingComponent, canActivate: [AuthGuard] },
12
- { path: 'consent', component: ConsentComponent, canActivate: [AuthGuard] },
13
- ];
14
-
15
- @NgModule({
16
- imports: [RouterModule.forChild(routes)],
17
- exports: [RouterModule],
18
- })
19
- export class OnboardingRoutingModule { }
@@ -1,13 +0,0 @@
1
- import { OnboardingModule } from './onboarding.module';
2
-
3
- describe('OnboardingModule', () => {
4
- let onboardingModule: OnboardingModule;
5
-
6
- beforeEach(() => {
7
- onboardingModule = new OnboardingModule();
8
- });
9
-
10
- it('should create an instance', () => {
11
- expect(onboardingModule).toBeTruthy();
12
- });
13
- });
@@ -1,32 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { EffectsModule } from '@ngrx/effects';
4
- import { SharedModule } from '../shared/shared.module';
5
- import { OnboardingRoutingModule } from './onboarding-routing.module';
6
-
7
- // Containers
8
- import { WaitingComponent } from './waiting/waiting.component';
9
- import { WaitingEffects } from './waiting/+state/waiting.effects';
10
- import { ConsentComponent } from './consent/consent.component';
11
- import { ConsentEffects } from './consent/+state/consent.effects';
12
-
13
- // Components
14
-
15
- @NgModule({
16
- imports: [
17
- CommonModule,
18
- SharedModule,
19
- OnboardingRoutingModule,
20
- EffectsModule.forFeature([
21
- WaitingEffects,
22
- ConsentEffects,
23
- ]),
24
- ],
25
- declarations: [
26
- // Containers
27
- WaitingComponent,
28
- ConsentComponent,
29
- // Components
30
- ],
31
- })
32
- export class OnboardingModule { }
@@ -1,26 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
- import { User } from '../../../core/store/user/user.model';
3
-
4
- export enum WaitingActionTypes {
5
- LOAD_DATA = '[Waiting] load data',
6
- CLEANUP = '[Waiting] cleanup',
7
- }
8
-
9
- /** Action for loading required DB data. */
10
- export class LoadData implements Action {
11
- readonly type = WaitingActionTypes.LOAD_DATA;
12
-
13
- constructor(public payload: {
14
- currentUser: User,
15
- }, public correlationId: string) { }
16
- }
17
-
18
- /** Action for cleaning up loading subscriptions. */
19
- export class Cleanup implements Action {
20
- readonly type = WaitingActionTypes.CLEANUP;
21
- constructor(public correlationId: string) { }
22
- }
23
-
24
- export type WaitingActions =
25
- LoadData |
26
- Cleanup;
@@ -1,52 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Action } from '@ngrx/store';
3
- import { Actions, createEffect, ofType } from '@ngrx/effects';
4
-
5
- import { of, Observable } from 'rxjs';
6
- import { mergeMap, tap, map } from 'rxjs/operators';
7
-
8
- import { select, Store } from '@ngrx/store';
9
- import * as fromStore from '../../../core/store/app.reducer';
10
- import { FirebaseService } from '../../../core/firebase/firebase.service';
11
- import { EffectsHelpers } from '../../../core/store/effects.helpers';
12
- import { WaitingState } from './waiting.state';
13
-
14
- import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
15
- import { WaitingActionTypes, Cleanup, LoadData } from './waiting.actions';
16
- import { StreamUserContext } from '../../../core/store/user-context/user-context.actions';
17
- import { StreamAppState } from '../../../core/store/app-state/app-state.actions';
18
-
19
- @Injectable()
20
- export class WaitingEffects {
21
- /** Load data from Firebase. */
22
- loadData$: Observable<Action> = createEffect(
23
- () => this.actions$.pipe(
24
- ofType<LoadData>(WaitingActionTypes.LOAD_DATA),
25
- mergeMap((action: LoadData) => {
26
- const loadId = action.correlationId;
27
- const currentUser = action.payload.currentUser;
28
-
29
- return [
30
- new StreamUserContext([['__userId', '==', currentUser.__id]], {}, loadId),
31
- new StreamAppState([['__id', '==', 'app']], {}, loadId),
32
- ];
33
- }),
34
- ),
35
- );
36
-
37
- /** Unsubscribe connections from Firebase. */
38
- cleanup$: Observable<Action> = createEffect(
39
- () => this.actions$.pipe(
40
- ofType<Cleanup>(WaitingActionTypes.CLEANUP),
41
- map((action: Cleanup) => new Unsubscribe(action.correlationId)),
42
- ),
43
- );
44
-
45
- constructor(
46
- private actions$: Actions,
47
- private store: Store<fromStore.State>,
48
- private state: WaitingState,
49
- private db: FirebaseService,
50
- private eh: EffectsHelpers,
51
- ) {}
52
- }
@@ -1,9 +0,0 @@
1
- import { User } from '../../../core/store/user/user.model';
2
- import { UserContext } from '../../../core/store/user-context/user-context.model';
3
- import { AppState } from '../../../core/store/app-state/app-state.model';
4
-
5
- export interface WaitlistData {
6
- currentUser: User;
7
- userContext: UserContext;
8
- appState: AppState;
9
- }
@@ -1,42 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
-
3
- export const WaitingAnimations = [
4
- ];