@tech4good/angular-schematics 17.0.4 → 18.0.1
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/.eslintrc.json.template +1 -1
- package/src/init/files/.firebaserc.template +8 -0
- package/src/init/files/.github/workflows/angular-github-ci.yml.template +1 -1
- package/src/init/files/README.md.template +13 -10
- package/src/init/files/angular.json.template +18 -11
- package/src/init/files/package.json.template +29 -30
- 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.ts.template +12 -8
- package/src/init/files/src/app/app.config.ts.template +65 -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 +26 -23
- 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 +3 -6
- 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 +10 -14
- package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +2 -2
- package/src/init/files/src/app/first-time/consent/consent.component.ts.template +95 -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 +65 -0
- package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +10 -3
- 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 +254 -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 +6 -0
- package/src/init/files/src/app/{general → main}/home/home.component.scss.template +1 -0
- package/src/init/files/src/app/main/home/home.component.ts.template +55 -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 +41 -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.prod.ts.template +6 -2
- package/src/init/files/src/environments/environment.ts.template +4 -2
- package/src/init/files/src/index.html.template +1 -1
- package/src/init/files/src/styles.scss.template +4 -0
- 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 -148
- 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.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.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,75 +0,0 @@
|
|
|
1
|
-
import { NgModule, Optional, SkipSelf, NgZone, PLATFORM_ID } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { RouterModule } from '@angular/router';
|
|
4
|
-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
5
|
-
import { throwIfAlreadyLoaded } from './setup/module-import-guard';
|
|
6
|
-
|
|
7
|
-
import { environment } from '../../environments/environment';
|
|
8
|
-
|
|
9
|
-
// Firebase
|
|
10
|
-
import { AngularFireModule } from '@angular/fire/compat';
|
|
11
|
-
import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
|
|
12
|
-
import { AngularFireAuthModule } from '@angular/fire/compat/auth';
|
|
13
|
-
import { MainAngularFirestore, LoggingAngularFirestore, MainAngularFirestoreFactory, LoggingAngularFirestoreFactory } from './setup/firebase-setup';
|
|
14
|
-
|
|
15
|
-
// NgRx
|
|
16
|
-
import { StoreModule } from '@ngrx/store';
|
|
17
|
-
import { reducers, metaReducers } from './store/app.reducer';
|
|
18
|
-
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
|
|
19
|
-
import { StoreRouterConnectingModule, RouterState } from '@ngrx/router-store';
|
|
20
|
-
import { EffectsModule } from '@ngrx/effects';
|
|
21
|
-
import { AppEffects } from './store/app.effects';
|
|
22
|
-
|
|
23
|
-
// Auth
|
|
24
|
-
import { AuthEffects } from './store/auth/auth.effects';
|
|
25
|
-
|
|
26
|
-
// Entity Effects
|
|
27
|
-
import { AppStateEffects } from './store/app-state/app-state.effects';
|
|
28
|
-
import { UserContextEffects } from './store/user-context/user-context.effects';
|
|
29
|
-
import { UserEffects } from './store/user/user.effects';
|
|
30
|
-
|
|
31
|
-
// Service Effects
|
|
32
|
-
import { SnackbarEffects } from './snackbar/snackbar.effects';
|
|
33
|
-
|
|
34
|
-
@NgModule({
|
|
35
|
-
imports: [
|
|
36
|
-
CommonModule,
|
|
37
|
-
RouterModule,
|
|
38
|
-
BrowserAnimationsModule,
|
|
39
|
-
AngularFireModule.initializeApp(environment.firebase),
|
|
40
|
-
AngularFirestoreModule,
|
|
41
|
-
AngularFireAuthModule,
|
|
42
|
-
StoreModule.forRoot(reducers, {
|
|
43
|
-
metaReducers,
|
|
44
|
-
runtimeChecks: {
|
|
45
|
-
strictActionImmutability: false,
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
StoreRouterConnectingModule.forRoot({ routerState: RouterState.Minimal }),
|
|
49
|
-
StoreDevtoolsModule.instrument({
|
|
50
|
-
maxAge: 25, // Retains last 25 states
|
|
51
|
-
logOnly: environment.production, // Restrict extension to log-only mode
|
|
52
|
-
}),
|
|
53
|
-
EffectsModule.forRoot([
|
|
54
|
-
AppEffects,
|
|
55
|
-
AuthEffects,
|
|
56
|
-
// Service Effects
|
|
57
|
-
SnackbarEffects,
|
|
58
|
-
// Entity Effects
|
|
59
|
-
AppStateEffects,
|
|
60
|
-
UserContextEffects,
|
|
61
|
-
UserEffects,
|
|
62
|
-
]),
|
|
63
|
-
],
|
|
64
|
-
declarations: [],
|
|
65
|
-
exports: [],
|
|
66
|
-
providers: [
|
|
67
|
-
{ provide: MainAngularFirestore, deps: [PLATFORM_ID, NgZone], useFactory: MainAngularFirestoreFactory },
|
|
68
|
-
{ provide: LoggingAngularFirestore, deps: [PLATFORM_ID, NgZone], useFactory: LoggingAngularFirestoreFactory },
|
|
69
|
-
],
|
|
70
|
-
})
|
|
71
|
-
export class CoreModule {
|
|
72
|
-
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
|
|
73
|
-
throwIfAlreadyLoaded(parentModule, 'CoreModule');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Injectable, NgZone } from '@angular/core';
|
|
2
|
-
import { AngularFirestore } from '@angular/fire/compat/firestore';
|
|
3
|
-
import { ɵAngularFireSchedulers } from '@angular/fire';
|
|
4
|
-
import { AppCheckInstances } from '@angular/fire/app-check';
|
|
5
|
-
import { AngularFireAuth } from '@angular/fire/compat/auth';
|
|
6
|
-
import { environment } from '../../../environments/environment';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class MainAngularFirestore extends AngularFirestore { }
|
|
10
|
-
|
|
11
|
-
@Injectable()
|
|
12
|
-
export class LoggingAngularFirestore extends AngularFirestore { }
|
|
13
|
-
|
|
14
|
-
export function MainAngularFirestoreFactory(platformId: Record<string, unknown>, zone: NgZone): MainAngularFirestore {
|
|
15
|
-
const schedulers = new ɵAngularFireSchedulers(zone);
|
|
16
|
-
const auth = new AngularFireAuth(environment.firebase, 'mainAuth', platformId, zone, schedulers, null, null, null, null, null, null, new AppCheckInstances());
|
|
17
|
-
|
|
18
|
-
return new MainAngularFirestore(environment.firebase, 'main', true, {}, platformId, zone, schedulers, {}, null, auth, null, null, null, null, null, null, new AppCheckInstances());
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function LoggingAngularFirestoreFactory(platformId: Record<string, unknown>, zone: NgZone): LoggingAngularFirestore {
|
|
22
|
-
const schedulers = new ɵAngularFireSchedulers(zone);
|
|
23
|
-
const auth = new AngularFireAuth(environment.firebase, 'loggingAuth', platformId, zone, schedulers, null, null, null, null, null, null, new AppCheckInstances());
|
|
24
|
-
return new LoggingAngularFirestore(environment.firebaseLogs, 'logging', true, {}, platformId, zone, schedulers, {}, null, auth, null, null, null, null, null, null, new AppCheckInstances());
|
|
25
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { MatSnackBarConfig, MatSnackBarRef } from '@angular/material/snack-bar';
|
|
3
|
-
|
|
4
|
-
export enum SnackbarActionTypes {
|
|
5
|
-
SHOW_MESSAGE = '[Snackbar] show snackbar message',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** If there is a component, will use openFromComponent. Otherwise, will use message. At least one of component or message needs to be provided. */
|
|
9
|
-
export class ShowSnackbar implements Action {
|
|
10
|
-
readonly type = SnackbarActionTypes.SHOW_MESSAGE;
|
|
11
|
-
constructor(
|
|
12
|
-
public payload: {
|
|
13
|
-
component?: any,
|
|
14
|
-
message?: string,
|
|
15
|
-
action?: string,
|
|
16
|
-
config?: MatSnackBarConfig<any>,
|
|
17
|
-
onAction?: (snackBarRef: MatSnackBarRef<any>) => any,
|
|
18
|
-
},
|
|
19
|
-
public correlationId?: string,
|
|
20
|
-
) {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type SnackbarActions =
|
|
24
|
-
ShowSnackbar;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Action } from '@ngrx/store';
|
|
3
|
-
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
4
|
-
import { of, Observable } from 'rxjs';
|
|
5
|
-
import { tap, take } from 'rxjs/operators';
|
|
6
|
-
import { SnackbarActionTypes, ShowSnackbar } from './snackbar.actions';
|
|
7
|
-
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
8
|
-
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class SnackbarEffects {
|
|
11
|
-
|
|
12
|
-
/** Process the snackbar action. */
|
|
13
|
-
showSnackbar$: Observable<Action> = createEffect(
|
|
14
|
-
() => this.actions$.pipe(
|
|
15
|
-
ofType<ShowSnackbar>(SnackbarActionTypes.SHOW_MESSAGE),
|
|
16
|
-
tap((action: ShowSnackbar) => {
|
|
17
|
-
|
|
18
|
-
let snackBarRef;
|
|
19
|
-
const config = action.payload.config;
|
|
20
|
-
|
|
21
|
-
if (action.payload.component) {
|
|
22
|
-
snackBarRef = this.snackBar.openFromComponent(action.payload.component, config);
|
|
23
|
-
} else if (action.payload.message) {
|
|
24
|
-
snackBarRef = this.snackBar.open(action.payload.message, action.payload.action || '', config);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (action.payload.onAction) {
|
|
28
|
-
snackBarRef.onAction().pipe(take(1)).subscribe(() => {
|
|
29
|
-
action.payload.onAction(snackBarRef);
|
|
30
|
-
snackBarRef.dismiss();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}),
|
|
34
|
-
), { dispatch: false },
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
private actions$: Actions,
|
|
39
|
-
private snackBar: MatSnackBar,
|
|
40
|
-
) {}
|
|
41
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { LoadAction } from '../app.actions';
|
|
3
|
-
import { AppState } from './app-state.model';
|
|
4
|
-
|
|
5
|
-
export enum AppStateActionTypes {
|
|
6
|
-
STREAM = '[AppState] stream appState',
|
|
7
|
-
STREAM_SUCCESS = '[AppState] stream appState success',
|
|
8
|
-
STREAM_FAIL = '[AppState] stream appState fail',
|
|
9
|
-
LOAD = '[AppState] load appState',
|
|
10
|
-
LOAD_SUCCESS = '[AppState] load appState success',
|
|
11
|
-
LOAD_FAIL = '[AppState] load appState fail',
|
|
12
|
-
ADD = '[AppState] add appState',
|
|
13
|
-
ADD_SUCCESS = '[AppState] add appState success',
|
|
14
|
-
ADD_FAIL = '[AppState] add appState fail',
|
|
15
|
-
UPDATE = '[AppState] update appState',
|
|
16
|
-
UPDATE_SUCCESS = '[AppState] update appState success',
|
|
17
|
-
UPDATE_FAIL = '[AppState] update appState fail',
|
|
18
|
-
REMOVE = '[AppState] remove appState',
|
|
19
|
-
REMOVE_SUCCESS = '[AppState] remove appState success',
|
|
20
|
-
REMOVE_FAIL = '[AppState] remove appState fail',
|
|
21
|
-
LOADED = '[AppState] loaded',
|
|
22
|
-
ADDED = '[AppState] added',
|
|
23
|
-
MODIFIED = '[AppState] modified',
|
|
24
|
-
REMOVED = '[AppState] removed',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// See Firebase Docs for current constraints on valid queries
|
|
28
|
-
export class StreamAppState implements Action {
|
|
29
|
-
readonly type = AppStateActionTypes.STREAM;
|
|
30
|
-
constructor(
|
|
31
|
-
// property, comparator, value
|
|
32
|
-
public queryParams: [string, string, any][],
|
|
33
|
-
public queryOptions: {
|
|
34
|
-
orderBy?: string | [string, string],
|
|
35
|
-
limit?: number,
|
|
36
|
-
startAt?: string,
|
|
37
|
-
startAfter?: string,
|
|
38
|
-
endAt?: string,
|
|
39
|
-
endBefore?: string,
|
|
40
|
-
},
|
|
41
|
-
public correlationId: string,
|
|
42
|
-
public followupActions?: (appState: AppState) => LoadAction[],
|
|
43
|
-
) {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class StreamAppStateSuccess implements Action {
|
|
47
|
-
readonly type = AppStateActionTypes.STREAM_SUCCESS;
|
|
48
|
-
constructor(
|
|
49
|
-
public queryParams: [string, string, any][],
|
|
50
|
-
public queryOptions: {
|
|
51
|
-
orderBy?: string | [string, string],
|
|
52
|
-
limit?: number,
|
|
53
|
-
startAt?: string,
|
|
54
|
-
startAfter?: string,
|
|
55
|
-
endAt?: string,
|
|
56
|
-
endBefore?: string,
|
|
57
|
-
},
|
|
58
|
-
public correlationId: string,
|
|
59
|
-
public followupActions?: (appState: AppState) => LoadAction[],
|
|
60
|
-
) {}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class StreamAppStateFail implements Action {
|
|
64
|
-
readonly type = AppStateActionTypes.STREAM_FAIL;
|
|
65
|
-
constructor(
|
|
66
|
-
public error: any,
|
|
67
|
-
public correlationId?: string,
|
|
68
|
-
) {}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export class LoadAppState implements Action {
|
|
73
|
-
readonly type = AppStateActionTypes.LOAD;
|
|
74
|
-
constructor(
|
|
75
|
-
// property, comparator, value
|
|
76
|
-
public queryParams: [string, string, any][],
|
|
77
|
-
public queryOptions: {
|
|
78
|
-
orderBy?: string | [string, string],
|
|
79
|
-
limit?: number,
|
|
80
|
-
startAt?: string,
|
|
81
|
-
startAfter?: string,
|
|
82
|
-
endAt?: string,
|
|
83
|
-
endBefore?: string,
|
|
84
|
-
},
|
|
85
|
-
public correlationId: string,
|
|
86
|
-
public followupActions?: (appState: AppState) => LoadAction[],
|
|
87
|
-
) {}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export class LoadAppStateSuccess implements Action {
|
|
91
|
-
readonly type = AppStateActionTypes.LOAD_SUCCESS;
|
|
92
|
-
constructor(
|
|
93
|
-
public queryParams: [string, string, any][],
|
|
94
|
-
public queryOptions: {
|
|
95
|
-
orderBy?: string | [string, string],
|
|
96
|
-
limit?: number,
|
|
97
|
-
startAt?: string,
|
|
98
|
-
startAfter?: string,
|
|
99
|
-
endAt?: string,
|
|
100
|
-
endBefore?: string,
|
|
101
|
-
},
|
|
102
|
-
public correlationId: string,
|
|
103
|
-
public followupActions?: (appState: AppState) => LoadAction[],
|
|
104
|
-
) {}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export class LoadAppStateFail implements Action {
|
|
108
|
-
readonly type = AppStateActionTypes.LOAD_FAIL;
|
|
109
|
-
constructor(
|
|
110
|
-
public error: any,
|
|
111
|
-
public correlationId?: string,
|
|
112
|
-
) {}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export class AddAppState implements Action {
|
|
116
|
-
readonly type = AppStateActionTypes.ADD;
|
|
117
|
-
constructor(
|
|
118
|
-
public appState: AppState,
|
|
119
|
-
public correlationId?: string,
|
|
120
|
-
public options?: {
|
|
121
|
-
optimistic?: boolean,
|
|
122
|
-
},
|
|
123
|
-
) {}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export class AddAppStateSuccess implements Action {
|
|
127
|
-
readonly type = AppStateActionTypes.ADD_SUCCESS;
|
|
128
|
-
constructor(
|
|
129
|
-
public appState: AppState,
|
|
130
|
-
public correlationId?: string,
|
|
131
|
-
public options?: {
|
|
132
|
-
optimistic?: boolean,
|
|
133
|
-
},
|
|
134
|
-
) {}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export class AddAppStateFail implements Action {
|
|
138
|
-
readonly type = AppStateActionTypes.ADD_FAIL;
|
|
139
|
-
constructor(
|
|
140
|
-
public error: any,
|
|
141
|
-
public correlationId?: string,
|
|
142
|
-
public options?: {
|
|
143
|
-
optimistic?: boolean,
|
|
144
|
-
},
|
|
145
|
-
) {}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export class UpdateAppState implements Action {
|
|
149
|
-
readonly type = AppStateActionTypes.UPDATE;
|
|
150
|
-
constructor(
|
|
151
|
-
public __id: string,
|
|
152
|
-
public changes: Partial<AppState>,
|
|
153
|
-
public correlationId?: string,
|
|
154
|
-
) { }
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export class UpdateAppStateSuccess implements Action {
|
|
158
|
-
readonly type = AppStateActionTypes.UPDATE_SUCCESS;
|
|
159
|
-
constructor(
|
|
160
|
-
public __id: string,
|
|
161
|
-
public changes: Partial<AppState>,
|
|
162
|
-
public correlationId?: string,
|
|
163
|
-
) {}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export class UpdateAppStateFail implements Action {
|
|
167
|
-
readonly type = AppStateActionTypes.UPDATE_FAIL;
|
|
168
|
-
constructor(
|
|
169
|
-
public error: any,
|
|
170
|
-
public correlationId?: string,
|
|
171
|
-
) {}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export class RemoveAppState implements Action {
|
|
175
|
-
readonly type = AppStateActionTypes.REMOVE;
|
|
176
|
-
constructor(
|
|
177
|
-
public __id: string,
|
|
178
|
-
public correlationId?: string,
|
|
179
|
-
) { }
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export class RemoveAppStateSuccess implements Action {
|
|
183
|
-
readonly type = AppStateActionTypes.REMOVE_SUCCESS;
|
|
184
|
-
constructor(
|
|
185
|
-
public __id: string,
|
|
186
|
-
public correlationId?: string,
|
|
187
|
-
) {}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export class RemoveAppStateFail implements Action {
|
|
191
|
-
readonly type = AppStateActionTypes.REMOVE_FAIL;
|
|
192
|
-
constructor(
|
|
193
|
-
public error: any,
|
|
194
|
-
public correlationId?: string,
|
|
195
|
-
) {}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export class LoadedAppState implements Action {
|
|
199
|
-
readonly type = AppStateActionTypes.LOADED;
|
|
200
|
-
constructor(
|
|
201
|
-
public payload: AppState[],
|
|
202
|
-
public correlationId?: string,
|
|
203
|
-
) {}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export class AddedAppState implements Action {
|
|
207
|
-
readonly type = AppStateActionTypes.ADDED;
|
|
208
|
-
constructor(
|
|
209
|
-
public payload: AppState,
|
|
210
|
-
public correlationId?: string,
|
|
211
|
-
) {}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export class ModifiedAppState implements Action {
|
|
215
|
-
readonly type = AppStateActionTypes.MODIFIED;
|
|
216
|
-
constructor(
|
|
217
|
-
public payload: AppState,
|
|
218
|
-
public correlationId?: string,
|
|
219
|
-
) {}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export class RemovedAppState implements Action {
|
|
223
|
-
readonly type = AppStateActionTypes.REMOVED;
|
|
224
|
-
constructor(
|
|
225
|
-
public payload: AppState,
|
|
226
|
-
public correlationId?: string,
|
|
227
|
-
) {}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export type AppStateActions =
|
|
231
|
-
StreamAppState |
|
|
232
|
-
StreamAppStateSuccess |
|
|
233
|
-
StreamAppStateFail |
|
|
234
|
-
LoadAppState |
|
|
235
|
-
LoadAppStateSuccess |
|
|
236
|
-
LoadAppStateFail |
|
|
237
|
-
AddAppState |
|
|
238
|
-
AddAppStateSuccess |
|
|
239
|
-
AddAppStateFail |
|
|
240
|
-
UpdateAppState |
|
|
241
|
-
UpdateAppStateSuccess |
|
|
242
|
-
UpdateAppStateFail |
|
|
243
|
-
RemoveAppState |
|
|
244
|
-
RemoveAppStateSuccess |
|
|
245
|
-
RemoveAppStateFail |
|
|
246
|
-
LoadedAppState |
|
|
247
|
-
AddedAppState |
|
|
248
|
-
ModifiedAppState |
|
|
249
|
-
RemovedAppState;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Action } from '@ngrx/store';
|
|
3
|
-
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
4
|
-
import { EMPTY, of, Observable, throwError, forkJoin, from, pipe, merge } from 'rxjs';
|
|
5
|
-
import { switchMap, flatMap, mergeMap, map, catchError, tap, take } from 'rxjs/operators';
|
|
6
|
-
import { FirebaseService } from '../../firebase/firebase.service';
|
|
7
|
-
import { CachedLoadConnectionsService } from '../cached-load-connections.service';
|
|
8
|
-
|
|
9
|
-
import { AppState } from './app-state.model';
|
|
10
|
-
import { AppStateActionTypes, AppStateActions,
|
|
11
|
-
AddedAppState, RemovedAppState,
|
|
12
|
-
StreamAppState, StreamAppStateSuccess, StreamAppStateFail,
|
|
13
|
-
LoadAppState, LoadAppStateSuccess, LoadAppStateFail,
|
|
14
|
-
AddAppState, AddAppStateSuccess, AddAppStateFail,
|
|
15
|
-
UpdateAppState, UpdateAppStateSuccess, UpdateAppStateFail,
|
|
16
|
-
RemoveAppState, RemoveAppStateSuccess, RemoveAppStateFail } from './app-state.actions';
|
|
17
|
-
|
|
18
|
-
@Injectable()
|
|
19
|
-
export class AppStateEffects {
|
|
20
|
-
/** Process the stream action to create firebase connections. */
|
|
21
|
-
stream$: Observable<Action> = createEffect(
|
|
22
|
-
() => this.actions$.pipe(
|
|
23
|
-
ofType<StreamAppState>(AppStateActionTypes.STREAM),
|
|
24
|
-
mergeMap((action: StreamAppState) => {
|
|
25
|
-
const connection = this.clc.processLoadAction(action);
|
|
26
|
-
return connection.loadStream.pipe(
|
|
27
|
-
take(1),
|
|
28
|
-
map(() => new StreamAppStateSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
|
|
29
|
-
catchError((error) => of(new StreamAppStateFail(error, action.correlationId))),
|
|
30
|
-
);
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
/** Process the load action to create firebase connections. */
|
|
36
|
-
load$: Observable<Action> = createEffect(
|
|
37
|
-
() => this.actions$.pipe(
|
|
38
|
-
ofType<LoadAppState>(AppStateActionTypes.LOAD),
|
|
39
|
-
mergeMap((action: LoadAppState) => {
|
|
40
|
-
const connection = this.clc.processLoadAction(action);
|
|
41
|
-
return connection.loadStream.pipe(
|
|
42
|
-
take(1),
|
|
43
|
-
map(() => new LoadAppStateSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
|
|
44
|
-
catchError((error) => of(new LoadAppStateFail(error, action.correlationId))),
|
|
45
|
-
);
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
/** Process the add action to update database and initiate callbacks. */
|
|
51
|
-
add$: Observable<Action> = createEffect(
|
|
52
|
-
() => this.actions$.pipe(
|
|
53
|
-
ofType<AddAppState>(AppStateActionTypes.ADD),
|
|
54
|
-
mergeMap((action: AddAppState) => {
|
|
55
|
-
if (action.options && action.options.optimistic) {
|
|
56
|
-
return merge(
|
|
57
|
-
of(new AddedAppState(action.appState, action.correlationId)),
|
|
58
|
-
this.db.addEntity('appStates', action.appState).pipe(
|
|
59
|
-
mergeMap(() => merge(
|
|
60
|
-
of(new AddAppStateSuccess(action.appState, action.correlationId)),
|
|
61
|
-
this.actionsOnAdd(action),
|
|
62
|
-
)),
|
|
63
|
-
catchError((error) => merge(
|
|
64
|
-
of(new AddAppStateFail(error, action.correlationId)),
|
|
65
|
-
of(new RemovedAppState(action.appState, action.correlationId)),
|
|
66
|
-
)),
|
|
67
|
-
),
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
return this.db.addEntity('appStates', action.appState).pipe(
|
|
71
|
-
mergeMap(() => merge(
|
|
72
|
-
of(new AddAppStateSuccess(action.appState, action.correlationId)),
|
|
73
|
-
this.actionsOnAdd(action),
|
|
74
|
-
)),
|
|
75
|
-
catchError((error) => of(new AddAppStateFail(error, action.correlationId))),
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
/** Process the update action to update database and initiate callbacks. */
|
|
83
|
-
update$: Observable<Action> = createEffect(
|
|
84
|
-
() => this.actions$.pipe(
|
|
85
|
-
ofType<UpdateAppState>(AppStateActionTypes.UPDATE),
|
|
86
|
-
mergeMap((action: UpdateAppState) => {
|
|
87
|
-
return this.db.updateEntity('appStates', action.__id, action.changes).pipe(
|
|
88
|
-
mergeMap(() => merge(
|
|
89
|
-
of(new UpdateAppStateSuccess(action.__id, action.changes, action.correlationId)),
|
|
90
|
-
this.actionsOnUpdate(action),
|
|
91
|
-
)),
|
|
92
|
-
catchError((error) => of(new UpdateAppStateFail(error, action.correlationId))),
|
|
93
|
-
);
|
|
94
|
-
}),
|
|
95
|
-
),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
/** Process the remove action to update database and initiate callbacks. */
|
|
99
|
-
remove$: Observable<Action> = createEffect(
|
|
100
|
-
() => this.actions$.pipe(
|
|
101
|
-
ofType<RemoveAppState>(AppStateActionTypes.REMOVE),
|
|
102
|
-
mergeMap((action: RemoveAppState) => {
|
|
103
|
-
return this.db.removeEntity('appStates', action.__id).pipe(
|
|
104
|
-
mergeMap(() => merge(
|
|
105
|
-
of(new RemoveAppStateSuccess(action.__id, action.correlationId)),
|
|
106
|
-
this.actionsOnRemove(action),
|
|
107
|
-
)),
|
|
108
|
-
catchError((error) => of(new RemoveAppStateFail(error, action.correlationId))),
|
|
109
|
-
);
|
|
110
|
-
}),
|
|
111
|
-
),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
actionsOnAdd(action: AddAppState): Observable<Action> {
|
|
115
|
-
return EMPTY;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
actionsOnUpdate(action: UpdateAppState): Observable<Action> {
|
|
119
|
-
return EMPTY;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
actionsOnRemove(action: RemoveAppState): Observable<Action> {
|
|
123
|
-
return EMPTY;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
constructor(
|
|
127
|
-
private actions$: Actions,
|
|
128
|
-
private db: FirebaseService,
|
|
129
|
-
private clc: CachedLoadConnectionsService,
|
|
130
|
-
) {}
|
|
131
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { reducer, initialState } from './app-state.reducer';
|
|
2
|
-
|
|
3
|
-
describe('AppState Reducer', () => {
|
|
4
|
-
describe('unknown action', () => {
|
|
5
|
-
it('should return the initial state', () => {
|
|
6
|
-
const action = {} as any;
|
|
7
|
-
|
|
8
|
-
const result = reducer(initialState, action);
|
|
9
|
-
|
|
10
|
-
expect(result).toBe(initialState);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
|
|
2
|
-
import { AppState } from './app-state.model';
|
|
3
|
-
import { AppStateActions, AppStateActionTypes } from './app-state.actions';
|
|
4
|
-
import { createFeatureSelector } from '@ngrx/store';
|
|
5
|
-
|
|
6
|
-
export interface State extends EntityState<AppState> {
|
|
7
|
-
// additional entities state properties
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const adapter: EntityAdapter<AppState> = createEntityAdapter<AppState>({
|
|
11
|
-
selectId: (appState: AppState) => appState.__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: AppStateActions,
|
|
22
|
-
) {
|
|
23
|
-
switch (action.type) {
|
|
24
|
-
case AppStateActionTypes.ADDED:
|
|
25
|
-
return adapter.upsertOne(action.payload, state);
|
|
26
|
-
|
|
27
|
-
case AppStateActionTypes.LOADED:
|
|
28
|
-
return adapter.upsertMany(action.payload, state);
|
|
29
|
-
|
|
30
|
-
case AppStateActionTypes.MODIFIED:
|
|
31
|
-
return adapter.updateOne({
|
|
32
|
-
id: action.payload.__id,
|
|
33
|
-
changes: action.payload,
|
|
34
|
-
}, state);
|
|
35
|
-
|
|
36
|
-
case AppStateActionTypes.REMOVED:
|
|
37
|
-
return adapter.removeOne(action.payload.__id, state);
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
return state;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const getAppStateState = createFeatureSelector<State>('appState');
|
|
45
|
-
|
|
46
|
-
export const {
|
|
47
|
-
selectIds,
|
|
48
|
-
selectEntities,
|
|
49
|
-
selectAll,
|
|
50
|
-
selectTotal,
|
|
51
|
-
} = adapter.getSelectors(getAppStateState);
|
|
@@ -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 { AppState } from './app-state.model';
|
|
6
|
-
|
|
7
|
-
@Injectable({
|
|
8
|
-
providedIn: 'root',
|
|
9
|
-
})
|
|
10
|
-
export class AppStateService {
|
|
11
|
-
constructor(
|
|
12
|
-
private cs: CachedSelectorsService,
|
|
13
|
-
private db: FirebaseService,
|
|
14
|
-
) { }
|
|
15
|
-
|
|
16
|
-
/** Select a appState from the store. */
|
|
17
|
-
public selectAppState = <T extends AppState>(
|
|
18
|
-
id: string,
|
|
19
|
-
correlationId: string,
|
|
20
|
-
childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
|
|
21
|
-
): Observable<T> => {
|
|
22
|
-
return this.cs.selectEntityObj<AppState, T>('appState', id, correlationId, childrenFn);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** Select appStates from the store. */
|
|
26
|
-
public selectAppStates = <T extends AppState>(
|
|
27
|
-
queryParams: [string, string, any][],
|
|
28
|
-
correlationId: string,
|
|
29
|
-
childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
|
|
30
|
-
): Observable<Array<T>> => {
|
|
31
|
-
return this.cs.selectEntityList<AppState, T>('appState', queryParams, correlationId, childrenFn);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** Get a appState directly from the database. */
|
|
35
|
-
public getAppState = <T extends AppState>(
|
|
36
|
-
id: string,
|
|
37
|
-
childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
|
|
38
|
-
): Observable<T> => {
|
|
39
|
-
return this.db.queryObjOnce<AppState, T>('appStates', id, childrenFn);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Get appStates directly from the database. */
|
|
43
|
-
public getAppStates = <T extends AppState>(
|
|
44
|
-
queryParams: [string, string, any][],
|
|
45
|
-
queryOptions?: { [index: string]: any },
|
|
46
|
-
childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
|
|
47
|
-
): Observable<Array<T>> => {
|
|
48
|
-
return this.db.queryListOnce<AppState, T>('appStates', queryParams, queryOptions, childrenFn);
|
|
49
|
-
};
|
|
50
|
-
}
|