@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.
- package/README.md +8 -0
- package/package.json +4 -4
- package/src/collection.json +0 -16
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +22 -8
- package/src/component/index.js +2 -45
- package/src/component/index.js.map +1 -1
- package/src/component/schema.json +0 -5
- package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +12 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +1 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +41 -0
- package/src/entity/index.js +29 -50
- package/src/entity/index.js.map +1 -1
- package/src/init/files/.firebaserc.template +8 -0
- package/src/init/files/README.md.template +6 -6
- package/src/init/files/angular.json.template +18 -11
- package/src/init/files/package.json.template +28 -29
- package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
- package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
- package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
- package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
- package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
- package/src/init/files/src/app/app.component.html.template +1 -0
- package/src/init/files/src/app/app.component.ts.template +14 -8
- package/src/init/files/src/app/app.config.ts.template +63 -0
- package/src/init/files/src/app/app.routes.ts.template +32 -0
- package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
- package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
- package/src/init/files/src/app/core/auth/auth.guard.ts.template +25 -22
- package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
- package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
- package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
- package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
- package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
- package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
- package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
- package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
- package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
- package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
- package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
- package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
- package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
- package/src/init/files/src/app/core/store/user/user.model.ts.template +1 -1
- package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
- package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
- package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
- package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
- package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
- package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +8 -13
- package/src/init/files/src/app/first-time/consent/consent.component.ts.template +90 -0
- package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
- package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +69 -0
- package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +1 -1
- package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
- package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +194 -0
- package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
- package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
- package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
- package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
- package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
- package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
- package/src/init/files/src/app/main/home/home.component.html.template +5 -0
- package/src/init/files/src/app/main/home/home.component.ts.template +51 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +43 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
- package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
- package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
- package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
- package/src/init/files/src/assets/images/close-x.svg +3 -0
- package/src/init/files/src/environments/environment.ts.template +1 -0
- package/src/init/files/src/index.html.template +1 -1
- package/src/init/files/tsconfig.json.template +0 -1
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
- package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
- package/src/container/index.d.ts +0 -2
- package/src/container/index.js +0 -127
- package/src/container/index.js.map +0 -1
- package/src/container/index_spec.d.ts +0 -1
- package/src/container/index_spec.js +0 -23
- package/src/container/index_spec.js.map +0 -1
- package/src/container/schema.json +0 -50
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
- package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
- package/src/entity-in-example/index.d.ts +0 -2
- package/src/entity-in-example/index.js +0 -141
- package/src/entity-in-example/index.js.map +0 -1
- package/src/entity-in-example/index_spec.d.ts +0 -1
- package/src/entity-in-example/index_spec.js +0 -23
- package/src/entity-in-example/index_spec.js.map +0 -1
- package/src/entity-in-example/schema.json +0 -45
- package/src/init/files/CHANGELOG.md.template +0 -10
- package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
- package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
- package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
- package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
- package/src/init/files/src/app/app-routing.module.ts.template +0 -26
- package/src/init/files/src/app/app.module.ts.template +0 -34
- package/src/init/files/src/app/core/core.module.ts.template +0 -75
- package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
- package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
- package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
- package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
- package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
- package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
- package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
- package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
- package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
- package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
- package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
- package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
- package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
- package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
- package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
- package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
- package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
- package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
- package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
- package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
- package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -149
- package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
- package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
- package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
- package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
- package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
- package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
- package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
- package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
- package/src/init/files/src/app/general/general.module.ts.template +0 -36
- package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
- package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
- 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 +0 -20
- package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
- package/src/init/files/src/app/general/home/home.component.html.template +0 -5
- package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
- package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
- package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
- 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 +0 -20
- package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
- package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
- package/src/init/files/src/app/general/login/login.component.html.template +0 -11
- package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
- package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
- package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
- 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 +0 -20
- package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
- package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
- package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
- package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
- package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
- package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
- package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
- package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
- package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
- package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
- package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
- package/src/init/files/src/main.ts.template +0 -12
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
- package/src/module/index.d.ts +0 -2
- package/src/module/index.js +0 -97
- package/src/module/index.js.map +0 -1
- package/src/module/index_spec.d.ts +0 -1
- package/src/module/index_spec.js +0 -23
- package/src/module/index_spec.js.map +0 -1
- package/src/module/schema.json +0 -38
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +0 -0
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
- /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
|
|
2
|
-
import { UserContext } from './user-context.model';
|
|
3
|
-
import { UserContextActions, UserContextActionTypes } from './user-context.actions';
|
|
4
|
-
import { createFeatureSelector } from '@ngrx/store';
|
|
5
|
-
|
|
6
|
-
export interface State extends EntityState<UserContext> {
|
|
7
|
-
// additional entities state properties
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const adapter: EntityAdapter<UserContext> = createEntityAdapter<UserContext>({
|
|
11
|
-
selectId: (userContext: UserContext) => userContext.__id,
|
|
12
|
-
sortComparer: false,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const initialState: State = adapter.getInitialState({
|
|
16
|
-
// additional entity state properties
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export function reducer(
|
|
20
|
-
state: State = initialState,
|
|
21
|
-
action: UserContextActions,
|
|
22
|
-
) {
|
|
23
|
-
switch (action.type) {
|
|
24
|
-
case UserContextActionTypes.ADDED:
|
|
25
|
-
return adapter.upsertOne(action.payload, state);
|
|
26
|
-
|
|
27
|
-
case UserContextActionTypes.LOADED:
|
|
28
|
-
return adapter.upsertMany(action.payload, state);
|
|
29
|
-
|
|
30
|
-
case UserContextActionTypes.MODIFIED:
|
|
31
|
-
return adapter.updateOne({
|
|
32
|
-
id: action.payload.__id,
|
|
33
|
-
changes: action.payload,
|
|
34
|
-
}, state);
|
|
35
|
-
|
|
36
|
-
case UserContextActionTypes.REMOVED:
|
|
37
|
-
return adapter.removeOne(action.payload.__id, state);
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
return state;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const getUserContextState = createFeatureSelector<State>('userContext');
|
|
45
|
-
|
|
46
|
-
export const {
|
|
47
|
-
selectIds,
|
|
48
|
-
selectEntities,
|
|
49
|
-
selectAll,
|
|
50
|
-
selectTotal,
|
|
51
|
-
} = adapter.getSelectors(getUserContextState);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { CachedSelectorsService } from '../cached-selectors.service';
|
|
4
|
-
import { FirebaseService } from '../../firebase/firebase.service';
|
|
5
|
-
import { UserContext } from './user-context.model';
|
|
6
|
-
|
|
7
|
-
@Injectable({
|
|
8
|
-
providedIn: 'root',
|
|
9
|
-
})
|
|
10
|
-
export class UserContextService {
|
|
11
|
-
constructor(
|
|
12
|
-
private cs: CachedSelectorsService,
|
|
13
|
-
private db: FirebaseService,
|
|
14
|
-
) { }
|
|
15
|
-
|
|
16
|
-
/** Select a userContext from the store. */
|
|
17
|
-
public selectUserContext = <T extends UserContext>(
|
|
18
|
-
id: string,
|
|
19
|
-
correlationId: string,
|
|
20
|
-
childrenFn?: (e: UserContext) => { [index: string]: Observable<any> },
|
|
21
|
-
): Observable<T> => {
|
|
22
|
-
return this.cs.selectEntityObj<UserContext, T>('userContext', id, correlationId, childrenFn);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** Select userContexts from the store. */
|
|
26
|
-
public selectUserContexts = <T extends UserContext>(
|
|
27
|
-
queryParams: [string, string, any][],
|
|
28
|
-
correlationId: string,
|
|
29
|
-
childrenFn?: (e: UserContext) => { [index: string]: Observable<any> },
|
|
30
|
-
): Observable<Array<T>> => {
|
|
31
|
-
return this.cs.selectEntityList<UserContext, T>('userContext', queryParams, correlationId, childrenFn);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** Get a userContext directly from the database. */
|
|
35
|
-
public getUserContext = <T extends UserContext>(
|
|
36
|
-
id: string,
|
|
37
|
-
childrenFn?: (e: UserContext) => { [index: string]: Observable<any> },
|
|
38
|
-
): Observable<T> => {
|
|
39
|
-
return this.db.queryObjOnce<UserContext, T>('userContexts', id, childrenFn);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Get userContexts directly from the database. */
|
|
43
|
-
public getUserContexts = <T extends UserContext>(
|
|
44
|
-
queryParams: [string, string, any][],
|
|
45
|
-
queryOptions?: { [index: string]: any },
|
|
46
|
-
childrenFn?: (e: UserContext) => { [index: string]: Observable<any> },
|
|
47
|
-
): Observable<Array<T>> => {
|
|
48
|
-
return this.db.queryListOnce<UserContext, T>('userContexts', queryParams, queryOptions, childrenFn);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
export function kebabCase(str: string) {
|
|
2
|
-
let result = str;
|
|
3
|
-
|
|
4
|
-
// Convert existing camelCase to space.
|
|
5
|
-
result = result.replace(/([a-z][A-Z])/g, (match) => {
|
|
6
|
-
return match.substr(0, 1) + ' ' + match.substr(1, 1).toLowerCase();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// Replace dashes with space
|
|
10
|
-
result = result.replace(/-/g, ' ');
|
|
11
|
-
|
|
12
|
-
// Remove non-alphanumeric characters
|
|
13
|
-
result = result.replace(/[^\sa-zA-Z0-9]+/g, '');
|
|
14
|
-
|
|
15
|
-
result = result.replace(/^[0-9]+/, '');
|
|
16
|
-
|
|
17
|
-
// Convert spaces to dash and then change any remaining capitals to lowercase
|
|
18
|
-
result = result.replace(/s+/g, '-').toLowerCase();
|
|
19
|
-
|
|
20
|
-
// Remove hyphens from both ends
|
|
21
|
-
result = result.replace(/^-+/, '').replace(/-$/, '');
|
|
22
|
-
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function camelCase(str: string) {
|
|
27
|
-
let result = str;
|
|
28
|
-
|
|
29
|
-
// Convert existing camelCase to space.
|
|
30
|
-
result = result.replace(/([a-z][A-Z])/g, (match) => {
|
|
31
|
-
return match.substr(0, 1) + ' ' + match.substr(1, 1).toLowerCase();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Replace dashes with space
|
|
35
|
-
result = result.replace(/-/g, ' ');
|
|
36
|
-
|
|
37
|
-
// Remove non-alphanumeric characters
|
|
38
|
-
result = result.replace(/[^\sa-zA-Z0-9]+/g, '');
|
|
39
|
-
|
|
40
|
-
result = result.replace(/^[0-9]+/, '');
|
|
41
|
-
|
|
42
|
-
// Change to camel case
|
|
43
|
-
result = result.split(' ').map((word) => {
|
|
44
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
45
|
-
}).join('');
|
|
46
|
-
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function normalCaps(str: string) {
|
|
51
|
-
let result = str;
|
|
52
|
-
|
|
53
|
-
// Convert existing camelCase to space.
|
|
54
|
-
result = result.replace(/([a-z][A-Z])/g, (match) => {
|
|
55
|
-
return match.substr(0, 1) + ' ' + match.substr(1, 1).toLowerCase();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Replace dashes with space
|
|
59
|
-
result = result.replace(/-/g, ' ');
|
|
60
|
-
|
|
61
|
-
// Remove non-alphanumeric characters
|
|
62
|
-
result = result.replace(/[^\sa-zA-Z0-9]+/g, '');
|
|
63
|
-
|
|
64
|
-
result = result.replace(/^[0-9]+/, '');
|
|
65
|
-
|
|
66
|
-
// Change to camel case
|
|
67
|
-
result = result.split(' ').map((word) => {
|
|
68
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
69
|
-
}).join(' ');
|
|
70
|
-
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function lowerCamelCase(str: string) {
|
|
75
|
-
let result = str;
|
|
76
|
-
|
|
77
|
-
// Convert existing camelCase to space.
|
|
78
|
-
result = result.replace(/([a-z][A-Z])/g, (match) => {
|
|
79
|
-
return match.substr(0, 1) + ' ' + match.substr(1, 1).toLowerCase();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// Replace dashes with space
|
|
83
|
-
result = result.replace(/-/g, ' ');
|
|
84
|
-
|
|
85
|
-
// Remove non-alphanumeric characters
|
|
86
|
-
result = result.replace(/[^\sa-zA-Z0-9]+/g, '');
|
|
87
|
-
|
|
88
|
-
result = result.replace(/^[0-9]+/, '');
|
|
89
|
-
|
|
90
|
-
// Change to camel case
|
|
91
|
-
result = result.split(' ').map((word) => {
|
|
92
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
93
|
-
}).join('');
|
|
94
|
-
|
|
95
|
-
return result.charAt(0).toLowerCase() + result.slice(1);
|
|
96
|
-
}
|
|
@@ -1,25 +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 { HomeComponent } from './home/home.component';
|
|
7
|
-
import { LandingComponent } from './landing/landing.component';
|
|
8
|
-
import { LoginComponent } from './login/login.component';
|
|
9
|
-
|
|
10
|
-
const routes: Routes = [
|
|
11
|
-
{ path: 'home', component: HomeComponent, canActivate: [AuthGuard] },
|
|
12
|
-
{ path: 'landing', component: LandingComponent, canActivate: [AuthGuard] },
|
|
13
|
-
// We intentionally do not add an AuthGuard here so you can always navigate there
|
|
14
|
-
{ path: 'login', component: LoginComponent },
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
@NgModule({
|
|
18
|
-
imports: [
|
|
19
|
-
RouterModule.forChild(routes),
|
|
20
|
-
],
|
|
21
|
-
exports: [
|
|
22
|
-
RouterModule,
|
|
23
|
-
],
|
|
24
|
-
})
|
|
25
|
-
export class GeneralRoutingModule { }
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GeneralModule } from './general.module';
|
|
2
|
-
|
|
3
|
-
describe('GeneralModule', () => {
|
|
4
|
-
let generalModule: GeneralModule;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
generalModule = new GeneralModule();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should create an instance', () => {
|
|
11
|
-
expect(generalModule).toBeTruthy();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,36 +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 { GeneralRoutingModule } from './general-routing.module';
|
|
6
|
-
|
|
7
|
-
// Containers
|
|
8
|
-
import { HomeComponent } from './home/home.component';
|
|
9
|
-
import { HomeEffects } from './home/+state/home.effects';
|
|
10
|
-
import { LandingComponent } from './landing/landing.component';
|
|
11
|
-
import { LandingEffects } from './landing/+state/landing.effects';
|
|
12
|
-
import { LoginComponent } from './login/login.component';
|
|
13
|
-
|
|
14
|
-
// Components
|
|
15
|
-
|
|
16
|
-
@NgModule({
|
|
17
|
-
imports: [
|
|
18
|
-
CommonModule,
|
|
19
|
-
SharedModule,
|
|
20
|
-
GeneralRoutingModule,
|
|
21
|
-
EffectsModule.forFeature([
|
|
22
|
-
HomeEffects,
|
|
23
|
-
LandingEffects,
|
|
24
|
-
]),
|
|
25
|
-
],
|
|
26
|
-
declarations: [
|
|
27
|
-
// Containers
|
|
28
|
-
HomeComponent,
|
|
29
|
-
LandingComponent,
|
|
30
|
-
LoginComponent,
|
|
31
|
-
// Components
|
|
32
|
-
],
|
|
33
|
-
exports: [
|
|
34
|
-
],
|
|
35
|
-
})
|
|
36
|
-
export class GeneralModule { }
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { User } from '../../../core/store/user/user.model';
|
|
3
|
-
|
|
4
|
-
export enum HomeActionTypes {
|
|
5
|
-
LOAD_DATA = '[Home] load data',
|
|
6
|
-
CLEANUP = '[Home] cleanup',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** Action for loading required DB data. */
|
|
10
|
-
export class LoadData implements Action {
|
|
11
|
-
readonly type = HomeActionTypes.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 = HomeActionTypes.CLEANUP;
|
|
21
|
-
constructor(public correlationId: string) { }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type HomeActions =
|
|
25
|
-
LoadData |
|
|
26
|
-
Cleanup;
|
|
@@ -1,48 +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 { HomeState } from './home.state';
|
|
13
|
-
|
|
14
|
-
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
|
|
15
|
-
import { HomeActionTypes, Cleanup, LoadData } from './home.actions';
|
|
16
|
-
|
|
17
|
-
@Injectable()
|
|
18
|
-
export class HomeEffects {
|
|
19
|
-
/** Load data from Firebase. */
|
|
20
|
-
loadData$: Observable<Action> = createEffect(
|
|
21
|
-
() => this.actions$.pipe(
|
|
22
|
-
ofType<LoadData>(HomeActionTypes.LOAD_DATA),
|
|
23
|
-
mergeMap((action: LoadData) => {
|
|
24
|
-
const loadId = action.correlationId;
|
|
25
|
-
const currentUser = action.payload.currentUser;
|
|
26
|
-
|
|
27
|
-
return [
|
|
28
|
-
];
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
/** Unsubscribe connections from Firebase. */
|
|
34
|
-
cleanup$: Observable<Action> = createEffect(
|
|
35
|
-
() => this.actions$.pipe(
|
|
36
|
-
ofType<Cleanup>(HomeActionTypes.CLEANUP),
|
|
37
|
-
map((action: Cleanup) => new Unsubscribe(action.correlationId)),
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
constructor(
|
|
42
|
-
private actions$: Actions,
|
|
43
|
-
private store: Store<fromStore.State>,
|
|
44
|
-
private state: HomeState,
|
|
45
|
-
private db: FirebaseService,
|
|
46
|
-
private eh: EffectsHelpers,
|
|
47
|
-
) {}
|
|
48
|
-
}
|
|
File without changes
|
|
@@ -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 HomeSelectors {
|
|
13
|
-
constructor(
|
|
14
|
-
private slRx: EntitySelectorService,
|
|
15
|
-
) { }
|
|
16
|
-
|
|
17
|
-
cleanup(cId: string) {
|
|
18
|
-
this.slRx.release(cId);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
-
import { HomeAnimations } from './home.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 { HomeState } from './+state/home.state';
|
|
12
|
-
import { HomeSelectors } from './+state/home.selectors';
|
|
13
|
-
|
|
14
|
-
import { LoadData, Cleanup } from './+state/home.actions';
|
|
15
|
-
import { RouterNavigate } from '../../core/store/app.actions';
|
|
16
|
-
|
|
17
|
-
import { User } from '../../core/store/user/user.model';
|
|
18
|
-
|
|
19
|
-
@Component({
|
|
20
|
-
selector: 'app-home',
|
|
21
|
-
templateUrl: './home.component.html',
|
|
22
|
-
styleUrls: ['./home.component.scss'],
|
|
23
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
|
-
animations: HomeAnimations,
|
|
25
|
-
})
|
|
26
|
-
export class HomeComponent implements OnInit, OnDestroy {
|
|
27
|
-
// --------------- ROUTE PARAMS & CURRENT USER ---------
|
|
28
|
-
|
|
29
|
-
/** The currently signed in user. */
|
|
30
|
-
currentUser$: Observable<User> = this.store.pipe(
|
|
31
|
-
select(fromAuth.selectUser),
|
|
32
|
-
filter((user) => user !== null), // null indicates LoadAuth hasn't been processed
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
// --------------- LOCAL AND GLOBAL STATE --------------
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// --------------- DB ENTITY DATA ----------------------
|
|
39
|
-
|
|
40
|
-
/** Container id for selectors and loading. */
|
|
41
|
-
containerId: string = this.db.createId();
|
|
42
|
-
|
|
43
|
-
// --------------- DATA BINDING ------------------------
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// --------------- EVENT BINDING -----------------------
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// --------------- HELPER FUNCTIONS AND OTHER ----------
|
|
50
|
-
|
|
51
|
-
/** Unsubscribe observable for subscriptions. */
|
|
52
|
-
unsubscribe$: Subject<void> = new Subject();
|
|
53
|
-
|
|
54
|
-
constructor(
|
|
55
|
-
private state: HomeState,
|
|
56
|
-
private route: ActivatedRoute,
|
|
57
|
-
private selectors: HomeSelectors,
|
|
58
|
-
private store: Store<fromStore.State>,
|
|
59
|
-
private db: FirebaseService,
|
|
60
|
-
) {
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ngOnInit() {
|
|
64
|
-
// --------------- EVENT HANDLING ----------------------
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// --------------- LOAD DATA ---------------------------
|
|
68
|
-
|
|
69
|
-
// Once everything is set up, load the data for the role.
|
|
70
|
-
this.currentUser$.pipe(
|
|
71
|
-
takeUntil(this.unsubscribe$),
|
|
72
|
-
).subscribe((currentUser) => {
|
|
73
|
-
this.store.dispatch( new LoadData({
|
|
74
|
-
currentUser,
|
|
75
|
-
}, this.containerId) );
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
ngOnDestroy() {
|
|
80
|
-
// Unsubscribe subscriptions.
|
|
81
|
-
this.unsubscribe$.next();
|
|
82
|
-
this.unsubscribe$.complete();
|
|
83
|
-
|
|
84
|
-
// Unsubscribe from firebase connection from load and free up memoized selector values.
|
|
85
|
-
this.store.dispatch( new Cleanup(this.containerId) );
|
|
86
|
-
this.selectors.cleanup(this.containerId);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { User } from '../../../core/store/user/user.model';
|
|
3
|
-
|
|
4
|
-
export enum LandingActionTypes {
|
|
5
|
-
LOAD_DATA = '[Landing] load data',
|
|
6
|
-
CLEANUP = '[Landing] cleanup',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** Action for loading required DB data. */
|
|
10
|
-
export class LoadData implements Action {
|
|
11
|
-
readonly type = LandingActionTypes.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 = LandingActionTypes.CLEANUP;
|
|
21
|
-
constructor(public correlationId: string) { }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type LandingActions =
|
|
25
|
-
LoadData |
|
|
26
|
-
Cleanup;
|
|
@@ -1,48 +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 { LandingState } from './landing.state';
|
|
13
|
-
|
|
14
|
-
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
|
|
15
|
-
import { LandingActionTypes, Cleanup, LoadData } from './landing.actions';
|
|
16
|
-
|
|
17
|
-
@Injectable()
|
|
18
|
-
export class LandingEffects {
|
|
19
|
-
/** Load data from Firebase. */
|
|
20
|
-
loadData$: Observable<Action> = createEffect(
|
|
21
|
-
() => this.actions$.pipe(
|
|
22
|
-
ofType<LoadData>(LandingActionTypes.LOAD_DATA),
|
|
23
|
-
mergeMap((action: LoadData) => {
|
|
24
|
-
const loadId = action.correlationId;
|
|
25
|
-
const currentUser = action.payload.currentUser;
|
|
26
|
-
|
|
27
|
-
return [
|
|
28
|
-
];
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
/** Unsubscribe connections from Firebase. */
|
|
34
|
-
cleanup$: Observable<Action> = createEffect(
|
|
35
|
-
() => this.actions$.pipe(
|
|
36
|
-
ofType<Cleanup>(LandingActionTypes.CLEANUP),
|
|
37
|
-
map((action: Cleanup) => new Unsubscribe(action.correlationId)),
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
constructor(
|
|
42
|
-
private actions$: Actions,
|
|
43
|
-
private store: Store<fromStore.State>,
|
|
44
|
-
private state: LandingState,
|
|
45
|
-
private db: FirebaseService,
|
|
46
|
-
private eh: EffectsHelpers,
|
|
47
|
-
) {}
|
|
48
|
-
}
|
|
File without changes
|
|
@@ -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 LandingSelectors {
|
|
13
|
-
constructor(
|
|
14
|
-
private slRx: EntitySelectorService,
|
|
15
|
-
) { }
|
|
16
|
-
|
|
17
|
-
cleanup(cId: string) {
|
|
18
|
-
this.slRx.release(cId);
|
|
19
|
-
}
|
|
20
|
-
}
|