@tech4good/angular-schematics 13.6.0 → 13.8.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.
- package/README.md +3 -2
- package/package.json +1 -1
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +8 -8
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +3 -2
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +6 -5
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +2 -2
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +25 -14
- package/src/container/index.js +13 -2
- package/src/container/index.js.map +1 -1
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +9 -30
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +23 -24
- package/src/init/files/CHANGELOG.md.template +10 -0
- package/src/init/files/README.md.template +24 -0
- package/src/init/files/package.json.template +4 -2
- package/src/init/files/src/app/admin/admin-routing.module.ts.template +17 -0
- package/src/init/files/src/app/admin/admin.module.spec.ts.template +13 -0
- package/src/init/files/src/app/admin/admin.module.ts.template +28 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +23 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +50 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +39 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +13 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.animations.ts.template +4 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.html.template +30 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.scss.template +14 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.spec.ts.template +25 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +136 -0
- package/src/init/files/src/app/app-routing.module.ts.template +13 -5
- package/src/init/files/src/app/core/analytics/log.service.ts.template +89 -4
- package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +204 -69
- package/src/init/files/src/app/core/auth/auth.guard.ts.template +85 -0
- package/src/init/files/src/app/core/core.module.ts.template +4 -0
- package/src/init/files/src/app/core/firebase/firebase.service.ts.template +4 -4
- package/src/init/files/src/app/core/local-storage/local-storage.service.ts.template +47 -0
- package/src/init/files/src/app/core/local-storage/session-local-storage.service.ts.template +67 -0
- package/src/init/files/src/app/core/local-storage/session.service.ts.template +48 -0
- package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +270 -0
- package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +131 -0
- package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +8 -0
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +13 -0
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +51 -0
- package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +50 -0
- package/src/init/files/src/app/core/store/app.effects.ts.template +10 -2
- package/src/init/files/src/app/core/store/app.reducer.ts.template +6 -0
- package/src/init/files/src/app/core/store/app.selectors.ts.template +12 -0
- package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +3 -1
- package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +27 -31
- package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +1 -1
- package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +5 -1
- package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +9 -8
- package/src/init/files/src/app/core/store/user/user.model.ts.template +14 -0
- package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +270 -0
- package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +131 -0
- package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +13 -0
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +13 -0
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +51 -0
- package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +50 -0
- package/src/init/files/src/app/general/general-routing.module.ts.template +6 -2
- package/src/init/files/src/app/general/general.module.ts.template +8 -2
- package/src/init/files/src/app/general/home/+state/home.actions.ts.template +26 -0
- package/src/init/files/src/app/general/home/+state/home.effects.ts.template +48 -0
- package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
- package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +20 -0
- package/src/init/files/src/app/general/home/+state/home.state.ts.template +13 -0
- package/src/init/files/src/app/general/home/home.animations.ts.template +4 -0
- package/src/init/files/src/app/general/home/home.component.html.template +5 -0
- package/src/init/files/src/app/general/home/home.component.scss.template +5 -0
- package/src/init/files/src/app/general/{e404/e404.component.spec.ts.template → home/home.component.spec.ts.template} +6 -6
- package/src/init/files/src/app/general/home/home.component.ts.template +88 -0
- package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +26 -0
- package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +48 -0
- package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
- package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +20 -0
- package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +13 -0
- package/src/init/files/src/app/general/landing/landing.animations.ts.template +4 -0
- package/src/init/files/src/app/general/landing/landing.component.html.template +3 -0
- package/src/init/files/src/app/general/landing/landing.component.scss.template +13 -0
- package/src/init/files/src/app/general/landing/landing.component.spec.ts.template +25 -0
- package/src/init/files/src/app/general/landing/landing.component.ts.template +98 -0
- package/src/init/files/src/app/general/login/login.component.html.template +5 -5
- package/src/init/files/src/app/general/login/login.component.ts.template +12 -4
- package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +23 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +47 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +20 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +13 -0
- package/src/init/files/src/app/onboarding/consent/consent.animations.ts.template +4 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.html.template +61 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.scss.template +77 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.spec.ts.template +25 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +152 -0
- package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +19 -0
- package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +13 -0
- package/src/init/files/src/app/onboarding/onboarding.module.ts.template +32 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +26 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +52 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +9 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +42 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +13 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +4 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +57 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.scss.template +99 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +25 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +279 -0
- package/src/init/files/src/app/shared/shared.module.ts.template +3 -0
- package/src/init/files/src/index.html.template +0 -3
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +2 -0
- package/src/init/files/src/app/general/e404/e404.component.html.template +0 -1
- package/src/init/files/src/app/general/e404/e404.component.ts.template +0 -28
- /package/src/init/files/src/app/{general/e404/e404.component.scss.template → admin/waitlist/+state/waitlist.model.ts.template} +0 -0
package/README.md
CHANGED
|
@@ -37,10 +37,11 @@ To publish, simply do:
|
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
npm run build
|
|
40
|
-
npm publish
|
|
40
|
+
npm publish # will ask for a OTP (see Google Authenticator: npm)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
That's it!
|
|
44
44
|
|
|
45
45
|
You can also use `npm version <version>` to update the version before publishing.
|
|
46
|
-
|
|
46
|
+
* Don't forget to also update `src/init/files/package.json.template` so that the latest version of `@tech4good/anguar-schematics` is being used in the dependencies.
|
|
47
|
+
* If we are making a major update for a new angular version, we also need to update the version number in `package.json.template`.
|
package/package.json
CHANGED
|
@@ -9,22 +9,22 @@ import { <%= classify(name) %>Animations } from './<%= dasherize(name) %>.animat
|
|
|
9
9
|
animations: <%= classify(name) %>Animations,
|
|
10
10
|
})
|
|
11
11
|
export class <%= classify(name) %>Component implements OnInit {
|
|
12
|
-
// --------------- INPUTS AND OUTPUTS
|
|
12
|
+
// --------------- INPUTS AND OUTPUTS ------------------
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
// --------------- LOCAL
|
|
15
|
+
// --------------- LOCAL AND GLOBAL STATE --------------
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// --------------- DATA BINDING ------------------------
|
|
19
19
|
|
|
20
|
-
ngOnInit(): void {
|
|
21
|
-
}
|
|
22
20
|
|
|
23
|
-
// ---------------
|
|
21
|
+
// --------------- EVENT BINDING -----------------------
|
|
24
22
|
|
|
25
23
|
|
|
26
|
-
// ---------------
|
|
24
|
+
// --------------- HELPER FUNCTIONS AND OTHER ----------
|
|
27
25
|
|
|
26
|
+
constructor() { }
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
ngOnInit(): void {
|
|
29
|
+
}
|
|
30
30
|
}
|
package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@ngrx/store';
|
|
2
|
+
import { User } from '../<%= containerToCorePath %>/store/user/user.model';
|
|
2
3
|
|
|
3
4
|
export enum <%= classify(name) %>ActionTypes {
|
|
4
5
|
LOAD_DATA = '[<%= classify(name) %>] load data',
|
|
@@ -10,14 +11,14 @@ export class LoadData implements Action {
|
|
|
10
11
|
readonly type = <%= classify(name) %>ActionTypes.LOAD_DATA;
|
|
11
12
|
|
|
12
13
|
constructor(public payload: {
|
|
14
|
+
currentUser: User,
|
|
13
15
|
}, public correlationId: string) { }
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/** Action for cleaning up loading subscriptions. */
|
|
17
19
|
export class Cleanup implements Action {
|
|
18
20
|
readonly type = <%= classify(name) %>ActionTypes.CLEANUP;
|
|
19
|
-
constructor(public
|
|
20
|
-
}, public correlationId: string) { }
|
|
21
|
+
constructor(public correlationId: string) { }
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export type <%= classify(name) %>Actions =
|
package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template
CHANGED
|
@@ -6,12 +6,12 @@ import { of, Observable } from 'rxjs';
|
|
|
6
6
|
import { mergeMap, tap, map } from 'rxjs/operators';
|
|
7
7
|
|
|
8
8
|
import { select, Store } from '@ngrx/store';
|
|
9
|
-
import * as fromStore from '
|
|
10
|
-
import { FirebaseService } from '
|
|
11
|
-
import { EffectsHelpers } from '
|
|
9
|
+
import * as fromStore from '../<%= containerToCorePath %>/store/app.reducer';
|
|
10
|
+
import { FirebaseService } from '../<%= containerToCorePath %>/firebase/firebase.service';
|
|
11
|
+
import { EffectsHelpers } from '../<%= containerToCorePath %>/store/effects.helpers';
|
|
12
12
|
import { <%= classify(name) %>State } from './<%= dasherize(name) %>.state';
|
|
13
13
|
|
|
14
|
-
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '
|
|
14
|
+
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../<%= containerToCorePath %>/store/app.actions';
|
|
15
15
|
import { <%= classify(name) %>ActionTypes, Cleanup, LoadData } from './<%= dasherize(name) %>.actions';
|
|
16
16
|
|
|
17
17
|
@Injectable()
|
|
@@ -22,6 +22,7 @@ export class <%= classify(name) %>Effects {
|
|
|
22
22
|
ofType<LoadData>(<%= classify(name) %>ActionTypes.LOAD_DATA),
|
|
23
23
|
mergeMap((action: LoadData) => {
|
|
24
24
|
const loadId = action.correlationId;
|
|
25
|
+
const currentUser = action.payload.currentUser;
|
|
25
26
|
|
|
26
27
|
return [
|
|
27
28
|
];
|
|
@@ -33,7 +34,7 @@ export class <%= classify(name) %>Effects {
|
|
|
33
34
|
cleanup$: Observable<Action> = createEffect(
|
|
34
35
|
() => this.actions$.pipe(
|
|
35
36
|
ofType<Cleanup>(<%= classify(name) %>ActionTypes.CLEANUP),
|
|
36
|
-
map((action: Cleanup) => new Unsubscribe(action.
|
|
37
|
+
map((action: Cleanup) => new Unsubscribe(action.correlationId)),
|
|
37
38
|
),
|
|
38
39
|
);
|
|
39
40
|
|
package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
import { Store, select } from '@ngrx/store';
|
|
3
|
-
import * as fromStore from '
|
|
4
|
-
import { EntitySelectorService } from '
|
|
3
|
+
import * as fromStore from '../<%= containerToCorePath %>/store/app.reducer';
|
|
4
|
+
import { EntitySelectorService } from '../<%= containerToCorePath %>/store/app.selectors';
|
|
5
5
|
|
|
6
6
|
import { Observable, of, combineLatest } from 'rxjs';
|
|
7
7
|
import { bufferTime, distinctUntilChanged, shareReplay, mergeMap, filter, switchMap, map } from 'rxjs/operators';
|
|
@@ -2,19 +2,19 @@ import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/
|
|
|
2
2
|
import { <%= classify(name) %>Animations } from './<%= dasherize(name) %>.animations';
|
|
3
3
|
import { ParamMap, ActivatedRoute } from '@angular/router';
|
|
4
4
|
import { Store, select } from '@ngrx/store';
|
|
5
|
-
import * as fromStore from '
|
|
6
|
-
import * as fromAuth from '
|
|
7
|
-
import { FirebaseService } from '
|
|
5
|
+
import * as fromStore from '<%= containerToCorePath %>/store/app.reducer';
|
|
6
|
+
import * as fromAuth from '<%= containerToCorePath %>/store/auth/auth.reducer';
|
|
7
|
+
import { FirebaseService } from '<%= containerToCorePath %>/firebase/firebase.service';
|
|
8
8
|
import { Observable, Subject, BehaviorSubject, combineLatest } from 'rxjs';
|
|
9
|
-
import { withLatestFrom, take, takeUntil } from 'rxjs/operators';
|
|
9
|
+
import { withLatestFrom, filter, take, takeUntil } from 'rxjs/operators';
|
|
10
10
|
|
|
11
11
|
import { <%= classify(name) %>State } from './+state/<%= dasherize(name) %>.state';
|
|
12
12
|
import { <%= classify(name) %>Selectors } from './+state/<%= dasherize(name) %>.selectors';
|
|
13
13
|
|
|
14
14
|
import { LoadData, Cleanup } from './+state/<%= dasherize(name) %>.actions';
|
|
15
|
-
import { RouterNavigate } from '
|
|
15
|
+
import { RouterNavigate } from '<%= containerToCorePath %>/store/app.actions';
|
|
16
16
|
|
|
17
|
-
import { User } from '
|
|
17
|
+
import { User } from '<%= containerToCorePath %>/store/user/user.model';
|
|
18
18
|
|
|
19
19
|
@Component({
|
|
20
20
|
selector: 'app-<%= dasherize(name) %>',
|
|
@@ -26,8 +26,15 @@ import { User } from '../../core/store/user/user.model';
|
|
|
26
26
|
export class <%= classify(name) %>Component implements OnInit, OnDestroy {
|
|
27
27
|
// --------------- ROUTE PARAMS & CURRENT USER ---------
|
|
28
28
|
|
|
29
|
+
// TODO: Delete this block of code if you don't need the currentUser (and make sure
|
|
30
|
+
// to remove it from LoadData too
|
|
31
|
+
/** The currently signed in user. */
|
|
32
|
+
currentUser$: Observable<User> = this.store.pipe(
|
|
33
|
+
select(fromAuth.selectUser),
|
|
34
|
+
filter((user) => user !== null), // null indicates LoadAuth hasn't been processed
|
|
35
|
+
);
|
|
29
36
|
|
|
30
|
-
// --------------- LOCAL
|
|
37
|
+
// --------------- LOCAL AND GLOBAL STATE --------------
|
|
31
38
|
|
|
32
39
|
|
|
33
40
|
// --------------- DB ENTITY DATA ----------------------
|
|
@@ -35,13 +42,13 @@ export class <%= classify(name) %>Component implements OnInit, OnDestroy {
|
|
|
35
42
|
/** Container id for selectors and loading. */
|
|
36
43
|
containerId: string = this.db.createId();
|
|
37
44
|
|
|
38
|
-
// --------------- DATA BINDING
|
|
45
|
+
// --------------- DATA BINDING ------------------------
|
|
39
46
|
|
|
40
47
|
|
|
41
|
-
// --------------- EVENT BINDING
|
|
48
|
+
// --------------- EVENT BINDING -----------------------
|
|
42
49
|
|
|
43
50
|
|
|
44
|
-
// --------------- OTHER
|
|
51
|
+
// --------------- HELPER FUNCTIONS AND OTHER ----------
|
|
45
52
|
|
|
46
53
|
/** Unsubscribe observable for subscriptions. */
|
|
47
54
|
unsubscribe$: Subject<void> = new Subject();
|
|
@@ -62,8 +69,13 @@ export class <%= classify(name) %>Component implements OnInit, OnDestroy {
|
|
|
62
69
|
// --------------- LOAD DATA ---------------------------
|
|
63
70
|
|
|
64
71
|
// Once everything is set up, load the data for the role.
|
|
65
|
-
this.
|
|
66
|
-
|
|
72
|
+
this.currentUser$.pipe(
|
|
73
|
+
takeUntil(this.unsubscribe$),
|
|
74
|
+
).subscribe((currentUser) => {
|
|
75
|
+
this.store.dispatch( new LoadData({
|
|
76
|
+
currentUser,
|
|
77
|
+
}, this.containerId) );
|
|
78
|
+
});
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
ngOnDestroy() {
|
|
@@ -72,8 +84,7 @@ export class <%= classify(name) %>Component implements OnInit, OnDestroy {
|
|
|
72
84
|
this.unsubscribe$.complete();
|
|
73
85
|
|
|
74
86
|
// Unsubscribe from firebase connection from load and free up memoized selector values.
|
|
75
|
-
this.store.dispatch( new Cleanup(
|
|
76
|
-
}, this.containerId) );
|
|
87
|
+
this.store.dispatch( new Cleanup(this.containerId) );
|
|
77
88
|
this.selectors.cleanup(this.containerId);
|
|
78
89
|
}
|
|
79
90
|
}
|
package/src/container/index.js
CHANGED
|
@@ -60,7 +60,7 @@ function addInserts(options) {
|
|
|
60
60
|
'const routes: Routes = ['
|
|
61
61
|
], [
|
|
62
62
|
`import { ${classifiedName}Component } from '${moduleRoutingToContainerPath}';`,
|
|
63
|
-
` { path: '${dasherizedName}', component: ${classifiedName}Component },`
|
|
63
|
+
` { path: '${dasherizedName}', component: ${classifiedName}Component, canActivate: [AuthGuard] },`
|
|
64
64
|
]);
|
|
65
65
|
context.logger.info(`about to start committing`);
|
|
66
66
|
// For each of the files and corresponding set of changes, commit to the tree
|
|
@@ -102,8 +102,19 @@ function container(options) {
|
|
|
102
102
|
options.name = parsedPath.name;
|
|
103
103
|
options.path = parsedPath.path;
|
|
104
104
|
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
105
|
+
// Define relative path parameters
|
|
106
|
+
const containerPath = `/${options.path}/` +
|
|
107
|
+
core_1.strings.dasherize(options.name) + '/' +
|
|
108
|
+
core_1.strings.dasherize(options.name) + '.component';
|
|
109
|
+
const moduleDir = (0, core_1.normalize)(options.module).split('/').slice(0, -1).join('/');
|
|
110
|
+
context.logger.info(`moduleDir: ${moduleDir}`);
|
|
111
|
+
const moduleToContainerPath = (0, find_module_1.buildRelativePath)(options.module, containerPath);
|
|
112
|
+
context.logger.info(`moduleToContainer: ${moduleToContainerPath}`);
|
|
113
|
+
// This is just a hacky way of figuring how many ../ we need to get to core
|
|
114
|
+
const containerToCorePath = moduleToContainerPath.split('/')
|
|
115
|
+
.slice(0, -1).map(() => '..').join('/') + '/core';
|
|
105
116
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
106
|
-
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
117
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { containerToCorePath })),
|
|
107
118
|
(0, schematics_1.move)(parsedPath.path),
|
|
108
119
|
]);
|
|
109
120
|
return (0, schematics_1.chain)([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mapp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AqB,CAAC,KAAK,CAAC,GAAG,CAAC;aACzD,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAEnD,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,IAAA,2BAAc,gDACT,cAAO,GACP,OAAO,KACV,mBAAmB,IACnB;YACF,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,UAAU,CAAC,OAAO,CAAC;YACnB,IAAA,sBAAS,EAAC,cAAc,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AA7DD,8BA6DC"}
|
|
@@ -15,9 +15,6 @@ export enum <%= classify(name) %>ActionTypes {
|
|
|
15
15
|
UPDATE = '[<%= classify(name) %>] update <%= camelize(name) %>',
|
|
16
16
|
UPDATE_SUCCESS = '[<%= classify(name) %>] update <%= camelize(name) %> success',
|
|
17
17
|
UPDATE_FAIL = '[<%= classify(name) %>] update <%= camelize(name) %> fail',
|
|
18
|
-
UPSERT = '[<%= classify(name) %>] upsert <%= camelize(name) %>',
|
|
19
|
-
UPSERT_SUCCESS = '[<%= classify(name) %>] upsert <%= camelize(name) %> success',
|
|
20
|
-
UPSERT_FAIL = '[<%= classify(name) %>] upsert <%= camelize(name) %> fail',
|
|
21
18
|
REMOVE = '[<%= classify(name) %>] remove <%= camelize(name) %>',
|
|
22
19
|
REMOVE_SUCCESS = '[<%= classify(name) %>] remove <%= camelize(name) %> success',
|
|
23
20
|
REMOVE_FAIL = '[<%= classify(name) %>] remove <%= camelize(name) %> fail',
|
|
@@ -120,6 +117,9 @@ export class Add<%= classify(name) %> implements Action {
|
|
|
120
117
|
constructor(
|
|
121
118
|
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
122
119
|
public correlationId?: string,
|
|
120
|
+
public options?: {
|
|
121
|
+
optimistic?: boolean,
|
|
122
|
+
},
|
|
123
123
|
) {}
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -128,6 +128,9 @@ export class Add<%= classify(name) %>Success implements Action {
|
|
|
128
128
|
constructor(
|
|
129
129
|
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
130
130
|
public correlationId?: string,
|
|
131
|
+
public options?: {
|
|
132
|
+
optimistic?: boolean,
|
|
133
|
+
},
|
|
131
134
|
) {}
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -136,6 +139,9 @@ export class Add<%= classify(name) %>Fail implements Action {
|
|
|
136
139
|
constructor(
|
|
137
140
|
public error: any,
|
|
138
141
|
public correlationId?: string,
|
|
142
|
+
public options?: {
|
|
143
|
+
optimistic?: boolean,
|
|
144
|
+
},
|
|
139
145
|
) {}
|
|
140
146
|
}
|
|
141
147
|
|
|
@@ -165,30 +171,6 @@ export class Update<%= classify(name) %>Fail implements Action {
|
|
|
165
171
|
) {}
|
|
166
172
|
}
|
|
167
173
|
|
|
168
|
-
export class Upsert<%= classify(name) %> implements Action {
|
|
169
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT;
|
|
170
|
-
constructor(
|
|
171
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
172
|
-
public correlationId?: string,
|
|
173
|
-
) {}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export class Upsert<%= classify(name) %>Success implements Action {
|
|
177
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT_SUCCESS;
|
|
178
|
-
constructor(
|
|
179
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
180
|
-
public correlationId?: string,
|
|
181
|
-
) {}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export class Upsert<%= classify(name) %>Fail implements Action {
|
|
185
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT_FAIL;
|
|
186
|
-
constructor(
|
|
187
|
-
public error: any,
|
|
188
|
-
public correlationId?: string,
|
|
189
|
-
) {}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
174
|
export class Remove<%= classify(name) %> implements Action {
|
|
193
175
|
readonly type = <%= classify(name) %>ActionTypes.REMOVE;
|
|
194
176
|
constructor(
|
|
@@ -258,9 +240,6 @@ export type <%= classify(name) %>Actions =
|
|
|
258
240
|
Update<%= classify(name) %> |
|
|
259
241
|
Update<%= classify(name) %>Success |
|
|
260
242
|
Update<%= classify(name) %>Fail |
|
|
261
|
-
Upsert<%= classify(name) %> |
|
|
262
|
-
Upsert<%= classify(name) %>Success |
|
|
263
|
-
Upsert<%= classify(name) %>Fail |
|
|
264
243
|
Remove<%= classify(name) %> |
|
|
265
244
|
Remove<%= classify(name) %>Success |
|
|
266
245
|
Remove<%= classify(name) %>Fail |
|
|
@@ -12,7 +12,6 @@ import { <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions,
|
|
|
12
12
|
Load<%= classify(name) %>, Load<%= classify(name) %>Success, Load<%= classify(name) %>Fail,
|
|
13
13
|
Add<%= classify(name) %>, Add<%= classify(name) %>Success, Add<%= classify(name) %>Fail,
|
|
14
14
|
Update<%= classify(name) %>, Update<%= classify(name) %>Success, Update<%= classify(name) %>Fail,
|
|
15
|
-
Upsert<%= classify(name) %>, Upsert<%= classify(name) %>Success, Upsert<%= classify(name) %>Fail,
|
|
16
15
|
Remove<%= classify(name) %>, Remove<%= classify(name) %>Success, Remove<%= classify(name) %>Fail } from './<%= dasherize(name) %>.actions';
|
|
17
16
|
|
|
18
17
|
@Injectable()
|
|
@@ -52,13 +51,29 @@ export class <%= classify(name) %>Effects {
|
|
|
52
51
|
() => this.actions$.pipe(
|
|
53
52
|
ofType<Add<%= classify(name) %>>(<%= classify(name) %>ActionTypes.ADD),
|
|
54
53
|
mergeMap((action: Add<%= classify(name) %>) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
of(new
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
if (action.options && action.options.optimistic) {
|
|
55
|
+
return merge(
|
|
56
|
+
of(new Added<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)),
|
|
57
|
+
this.db.addEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
|
|
58
|
+
mergeMap(() => merge(
|
|
59
|
+
of(new Add<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
|
|
60
|
+
this.actionsOnAdd(action),
|
|
61
|
+
)),
|
|
62
|
+
catchError((error) => merge(
|
|
63
|
+
of(new Add<%= classify(name) %>Fail(error, action.correlationId)),
|
|
64
|
+
of(new Removed<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)),
|
|
65
|
+
)),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
return this.db.addEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
|
|
70
|
+
mergeMap(() => merge(
|
|
71
|
+
of(new Add<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
|
|
72
|
+
this.actionsOnAdd(action),
|
|
73
|
+
)),
|
|
74
|
+
catchError((error) => of(new Add<%= classify(name) %>Fail(error, action.correlationId))),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
62
77
|
}),
|
|
63
78
|
),
|
|
64
79
|
);
|
|
@@ -79,22 +94,6 @@ export class <%= classify(name) %>Effects {
|
|
|
79
94
|
),
|
|
80
95
|
);
|
|
81
96
|
|
|
82
|
-
/** Process the upsert action to update database and initiate callbacks. */
|
|
83
|
-
upsert$: Observable<Action> = createEffect(
|
|
84
|
-
() => this.actions$.pipe(
|
|
85
|
-
ofType<Upsert<%= classify(name) %>>(<%= classify(name) %>ActionTypes.UPSERT),
|
|
86
|
-
mergeMap((action: Upsert<%= classify(name) %>) => {
|
|
87
|
-
return this.db.upsertEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
|
|
88
|
-
mergeMap((results) => merge(
|
|
89
|
-
of(new Upsert<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
|
|
90
|
-
results.type === 'add' ? this.actionsOnAdd(new Add<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)) : this.actionsOnUpdate(new Update<%= classify(name) %>(action.<%= camelize(name) %>.__id, action.<%= camelize(name) %>, action.correlationId)),
|
|
91
|
-
)),
|
|
92
|
-
catchError((error) => of(new Upsert<%= classify(name) %>Fail(error, action.correlationId))),
|
|
93
|
-
);
|
|
94
|
-
}),
|
|
95
|
-
),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
97
|
/** Process the remove action to update database and initiate callbacks. */
|
|
99
98
|
remove$: Observable<Action> = createEffect(
|
|
100
99
|
() => this.actions$.pipe(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Update this manually once the project is generated and update it as changes are made to the repository.
|
|
2
|
+
|
|
3
|
+
<a name="13.0.0-0"></a>
|
|
4
|
+
# 13.0.0-0 (YYYY-MM-DD)
|
|
5
|
+
### <%= classify(project) %>
|
|
6
|
+
| Commit | Type | Description |
|
|
7
|
+
| -- | -- | -- |
|
|
8
|
+
| [commit-hash](commit-url) | fix | **module:** commit message ([#pr](pr-url)) |
|
|
9
|
+
|
|
10
|
+
<!-- CHANGELOG SPLIT MARKER -->
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# <%= classify(project) %>
|
|
2
|
+
|
|
3
|
+
This project was initialized by using [Tech4Good's Angular Schematics](https://github.com/tech4good-lab/angular-schematics) after a base project repository was generated with [Angular CLI](https://github.com/angular/angular-cli). You can check the early commits of package.json to determine the versions used to generate it.
|
|
4
|
+
|
|
5
|
+
## Development server
|
|
6
|
+
|
|
7
|
+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
|
8
|
+
Run `ng serve --configuration production` to run a prod server locally. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
|
9
|
+
|
|
10
|
+
## Code scaffolding
|
|
11
|
+
|
|
12
|
+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate container|module|entity`.
|
|
13
|
+
|
|
14
|
+
## Build
|
|
15
|
+
|
|
16
|
+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
17
|
+
|
|
18
|
+
## Version number
|
|
19
|
+
|
|
20
|
+
We use the syntax `ANGULAR_MAJOR.MAJOR.MINOR-PATCH` for versioning, where
|
|
21
|
+
* `ANGULAR_MAJOR` corresponds to angular's major version,
|
|
22
|
+
* `MAJOR` contains significant new features, with some developer assistance needed, e.g. to write scripts that update the database for existing users.
|
|
23
|
+
* `MINOR` contains new smaller features. Minor releases are fully backward-compatible in that we can immediately deploy to production without needing to make any updates to the database for existing users,
|
|
24
|
+
* `PATCH` contains low risk bug fixes that do not require any updates to the database.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "<%= dasherize(project) %>",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"ng": "ng",
|
|
6
6
|
"start": "ng serve",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@ngrx/router-store": "^13.1.0",
|
|
29
29
|
"@ngrx/store": "^13.1.0",
|
|
30
30
|
"@ngrx/store-devtools": "^13.1.0",
|
|
31
|
-
"@tech4good/angular-schematics": "^13.
|
|
31
|
+
"@tech4good/angular-schematics": "^13.8.0",
|
|
32
|
+
"crypto-es": "^1.2.7",
|
|
32
33
|
"rxjs": "~7.5.0",
|
|
33
34
|
"tslib": "^2.3.0",
|
|
34
35
|
"zone.js": "~0.11.4"
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"@ngrx/schematics": "^13.1.0",
|
|
46
47
|
"@types/jasmine": "~3.10.0",
|
|
47
48
|
"@types/node": "^12.11.1",
|
|
49
|
+
"@types/estree": "^1.0.0",
|
|
48
50
|
"@typescript-eslint/eslint-plugin": "5.17.0",
|
|
49
51
|
"@typescript-eslint/parser": "5.17.0",
|
|
50
52
|
"eslint": "^8.12.0",
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { WaitlistComponent } from './waitlist/waitlist.component';
|
|
7
|
+
|
|
8
|
+
const routes: Routes = [
|
|
9
|
+
{ path: '', redirectTo: '/landing', pathMatch: 'full' },
|
|
10
|
+
{ path: 'waitlist', component: WaitlistComponent, canActivate: [AuthGuard] },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
imports: [RouterModule.forChild(routes)],
|
|
15
|
+
exports: [RouterModule],
|
|
16
|
+
})
|
|
17
|
+
export class AdminRoutingModule { }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminModule } from './admin.module';
|
|
2
|
+
|
|
3
|
+
describe('AdminModule', () => {
|
|
4
|
+
let adminModule: AdminModule;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
adminModule = new AdminModule();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should create an instance', () => {
|
|
11
|
+
expect(adminModule).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { AdminRoutingModule } from './admin-routing.module';
|
|
6
|
+
|
|
7
|
+
// Containers
|
|
8
|
+
import { WaitlistComponent } from './waitlist/waitlist.component';
|
|
9
|
+
import { WaitlistEffects } from './waitlist/+state/waitlist.effects';
|
|
10
|
+
|
|
11
|
+
// Components
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
imports: [
|
|
15
|
+
CommonModule,
|
|
16
|
+
SharedModule,
|
|
17
|
+
AdminRoutingModule,
|
|
18
|
+
EffectsModule.forFeature([
|
|
19
|
+
WaitlistEffects,
|
|
20
|
+
]),
|
|
21
|
+
],
|
|
22
|
+
declarations: [
|
|
23
|
+
// Containers
|
|
24
|
+
WaitlistComponent,
|
|
25
|
+
// Components
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
export class AdminModule { }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
|
|
3
|
+
export enum WaitlistActionTypes {
|
|
4
|
+
LOAD_DATA = '[Waitlist] load data',
|
|
5
|
+
CLEANUP = '[Waitlist] cleanup',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Action for loading required DB data. */
|
|
9
|
+
export class LoadData implements Action {
|
|
10
|
+
readonly type = WaitlistActionTypes.LOAD_DATA;
|
|
11
|
+
|
|
12
|
+
constructor(public containerId: string) { }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Action for cleaning up loading subscriptions. */
|
|
16
|
+
export class Cleanup implements Action {
|
|
17
|
+
readonly type = WaitlistActionTypes.CLEANUP;
|
|
18
|
+
constructor(public containerId: string) { }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type WaitlistActions =
|
|
22
|
+
LoadData |
|
|
23
|
+
Cleanup;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { WaitlistState } from './waitlist.state';
|
|
13
|
+
|
|
14
|
+
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
|
|
15
|
+
import { WaitlistActionTypes, Cleanup, LoadData } from './waitlist.actions';
|
|
16
|
+
import { AccessState } from '../../../core/store/user/user.model';
|
|
17
|
+
import { StreamUser } from '../../../core/store/user/user.actions';
|
|
18
|
+
|
|
19
|
+
@Injectable()
|
|
20
|
+
export class WaitlistEffects {
|
|
21
|
+
/** Load data from Firebase. */
|
|
22
|
+
loadData$: Observable<Action> = createEffect(
|
|
23
|
+
() => this.actions$.pipe(
|
|
24
|
+
ofType<LoadData>(WaitlistActionTypes.LOAD_DATA),
|
|
25
|
+
mergeMap((action: LoadData) => {
|
|
26
|
+
const loadId = action.containerId;
|
|
27
|
+
|
|
28
|
+
return [
|
|
29
|
+
new StreamUser([], {}, loadId),
|
|
30
|
+
];
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/** Unsubscribe connections from Firebase. */
|
|
36
|
+
cleanup$: Observable<Action> = createEffect(
|
|
37
|
+
() => this.actions$.pipe(
|
|
38
|
+
ofType<Cleanup>(WaitlistActionTypes.CLEANUP),
|
|
39
|
+
map((action: Cleanup) => new Unsubscribe(action.containerId)),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
constructor(
|
|
44
|
+
private actions$: Actions,
|
|
45
|
+
private store: Store<fromStore.State>,
|
|
46
|
+
private state: WaitlistState,
|
|
47
|
+
private db: FirebaseService,
|
|
48
|
+
private eh: EffectsHelpers,
|
|
49
|
+
) {}
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
10
|
+
@Injectable({
|
|
11
|
+
providedIn: 'root',
|
|
12
|
+
})
|
|
13
|
+
export class WaitlistSelectors {
|
|
14
|
+
constructor(
|
|
15
|
+
private slRx: EntitySelectorService,
|
|
16
|
+
) { }
|
|
17
|
+
|
|
18
|
+
/** selector for getting waiting users. */
|
|
19
|
+
selectWaitingUsers(cId: string): Observable<User[]> {
|
|
20
|
+
return this.slRx.selectUsers([], cId).pipe(
|
|
21
|
+
map((users) => {
|
|
22
|
+
users.sort((a, b) => {
|
|
23
|
+
if (a.accessState > b.accessState) {
|
|
24
|
+
return 1;
|
|
25
|
+
} else if (a.accessState < b.accessState) {
|
|
26
|
+
return -1;
|
|
27
|
+
} else {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return users;
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
cleanup(cId: string) {
|
|
37
|
+
this.slRx.release(cId);
|
|
38
|
+
}
|
|
39
|
+
}
|