@tech4good/angular-schematics 13.3.0 → 13.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +2 -4
  3. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +1 -1
  4. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +2 -4
  5. package/src/init/files/src/app/app-routing.module.ts.template +19 -0
  6. package/src/init/files/src/app/{app.component.html → app.component.html.template} +0 -0
  7. package/src/init/files/src/app/{app.component.scss → app.component.scss.template} +0 -0
  8. package/src/init/files/src/app/app.component.ts.template +41 -0
  9. package/src/init/files/src/app/app.module.ts.template +34 -0
  10. package/src/init/files/src/app/core/analytics/log.service.ts.template +35 -0
  11. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +223 -0
  12. package/src/init/files/src/app/core/core.module.ts.template +71 -0
  13. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +284 -0
  14. package/src/init/files/src/app/core/router/routing-state.service.ts.template +28 -0
  15. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +25 -0
  16. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +5 -0
  17. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +24 -0
  18. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +41 -0
  19. package/src/init/files/src/app/core/store/app.actions.ts.template +92 -0
  20. package/src/init/files/src/app/core/store/app.effects.ts.template +167 -0
  21. package/src/init/files/src/app/core/store/app.reducer.ts.template +30 -0
  22. package/src/init/files/src/app/core/store/app.selectors.ts.template +30 -0
  23. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +75 -0
  24. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +164 -0
  25. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +13 -0
  26. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +26 -0
  27. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +21 -0
  28. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +404 -0
  29. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +376 -0
  30. package/src/init/files/src/app/core/store/effects.helpers.ts.template +66 -0
  31. package/src/init/files/src/app/core/store/user/user.actions.ts.template +269 -0
  32. package/src/init/files/src/app/core/store/user/user.effects.ts.template +131 -0
  33. package/src/init/files/src/app/core/store/user/user.model.ts.template +15 -0
  34. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +13 -0
  35. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +50 -0
  36. package/src/init/files/src/app/core/store/user/user.service.ts.template +50 -0
  37. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +96 -0
  38. package/src/init/files/src/app/general/e404/{e404.component.html → e404.component.html.template} +0 -0
  39. package/src/init/files/src/app/general/e404/{e404.component.scss → e404.component.scss.template} +0 -0
  40. package/src/init/files/src/app/general/e404/e404.component.spec.ts.template +25 -0
  41. package/src/init/files/src/app/general/e404/e404.component.ts.template +28 -0
  42. package/src/init/files/src/app/general/general-routing.module.ts.template +21 -0
  43. package/src/init/files/src/app/general/general.module.spec.ts.template +13 -0
  44. package/src/init/files/src/app/general/general.module.ts.template +30 -0
  45. package/src/init/files/src/app/general/login/{login.component.html → login.component.html.template} +0 -0
  46. package/src/init/files/src/app/general/login/{login.component.scss → login.component.scss.template} +0 -0
  47. package/src/init/files/src/app/general/login/login.component.spec.ts.template +25 -0
  48. package/src/init/files/src/app/general/login/login.component.ts.template +72 -0
  49. package/src/init/files/src/app/shared/shared.module.ts.template +81 -0
  50. package/src/init/files/src/environments/environment.prod.ts.template +5 -0
  51. package/src/init/files/src/environments/environment.ts.template +18 -0
  52. /package/src/init/files/src/styles/{_variables.scss → _variables.scss.template} +0 -0
  53. /package/src/init/files/src/{styles.scss → styles.scss.template} +0 -0
@@ -0,0 +1,131 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Action } from '@ngrx/store';
3
+ import { Actions, createEffect, Effect, 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 { User } from './user.model';
10
+ import { UserActionTypes, UserActions,
11
+ StreamUser, StreamUserSuccess, StreamUserFail,
12
+ LoadUser, LoadUserSuccess, LoadUserFail,
13
+ AddUser, AddUserSuccess, AddUserFail,
14
+ UpdateUser, UpdateUserSuccess, UpdateUserFail,
15
+ UpsertUser, UpsertUserSuccess, UpsertUserFail,
16
+ RemoveUser, RemoveUserSuccess, RemoveUserFail } from './user.actions';
17
+
18
+ @Injectable()
19
+ export class UserEffects {
20
+ /** Process the stream action to create firebase connections. */
21
+ stream$: Observable<Action> = createEffect(
22
+ () => this.actions$.pipe(
23
+ ofType<StreamUser>(UserActionTypes.STREAM),
24
+ mergeMap((action: StreamUser) => {
25
+ const connection = this.clc.processLoadAction(action);
26
+ return connection.loadStream.pipe(
27
+ take(1),
28
+ map(() => new StreamUserSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
29
+ catchError((error) => of(new StreamUserFail(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<LoadUser>(UserActionTypes.LOAD),
39
+ mergeMap((action: LoadUser) => {
40
+ const connection = this.clc.processLoadAction(action);
41
+ return connection.loadStream.pipe(
42
+ take(1),
43
+ map(() => new LoadUserSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
44
+ catchError((error) => of(new LoadUserFail(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<AddUser>(UserActionTypes.ADD),
54
+ mergeMap((action: AddUser) => {
55
+ return this.db.addEntity('users', action.user).pipe(
56
+ mergeMap(() => merge(
57
+ of(new AddUserSuccess(action.user, action.correlationId)),
58
+ this.actionsOnAdd(action),
59
+ )),
60
+ catchError((error) => of(new AddUserFail(error, action.correlationId))),
61
+ );
62
+ }),
63
+ ),
64
+ );
65
+
66
+ /** Process the update action to update database and initiate callbacks. */
67
+ update$: Observable<Action> = createEffect(
68
+ () => this.actions$.pipe(
69
+ ofType<UpdateUser>(UserActionTypes.UPDATE),
70
+ mergeMap((action: UpdateUser) => {
71
+ return this.db.updateEntity('users', action.__id, action.changes).pipe(
72
+ mergeMap(() => merge(
73
+ of(new UpdateUserSuccess(action.__id, action.changes, action.correlationId)),
74
+ this.actionsOnUpdate(action),
75
+ )),
76
+ catchError((error) => of(new UpdateUserFail(error, action.correlationId))),
77
+ );
78
+ }),
79
+ ),
80
+ );
81
+
82
+ /** Process the upsert action to update database and initiate callbacks. */
83
+ upsert$: Observable<Action> = createEffect(
84
+ () => this.actions$.pipe(
85
+ ofType<UpsertUser>(UserActionTypes.UPSERT),
86
+ mergeMap((action: UpsertUser) => {
87
+ return this.db.upsertEntity('users', action.user).pipe(
88
+ mergeMap((results) => merge(
89
+ of(new UpsertUserSuccess(action.user, action.correlationId)),
90
+ results.type === 'add' ? this.actionsOnAdd(new AddUser(action.user, action.correlationId)) : this.actionsOnUpdate(new UpdateUser(action.user.__id, action.user, action.correlationId)),
91
+ )),
92
+ catchError((error) => of(new UpsertUserFail(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<RemoveUser>(UserActionTypes.REMOVE),
102
+ mergeMap((action: RemoveUser) => {
103
+ return this.db.removeEntity('users', action.__id).pipe(
104
+ mergeMap(() => merge(
105
+ of(new RemoveUserSuccess(action.__id, action.correlationId)),
106
+ this.actionsOnRemove(action),
107
+ )),
108
+ catchError((error) => of(new RemoveUserFail(error, action.correlationId))),
109
+ );
110
+ }),
111
+ ),
112
+ );
113
+
114
+ actionsOnAdd(action: AddUser): Observable<Action> {
115
+ return EMPTY;
116
+ }
117
+
118
+ actionsOnUpdate(action: UpdateUser): Observable<Action> {
119
+ return EMPTY;
120
+ }
121
+
122
+ actionsOnRemove(action: RemoveUser): Observable<Action> {
123
+ return EMPTY;
124
+ }
125
+
126
+ constructor(
127
+ private actions$: Actions,
128
+ private db: FirebaseService,
129
+ private clc: CachedLoadConnectionsService,
130
+ ) {}
131
+ }
@@ -0,0 +1,15 @@
1
+ import { Timestamp } from '@angular/fire/firestore';
2
+
3
+ /** user data */
4
+ export interface User {
5
+ __id: string;
6
+ _createdAt?: Timestamp;
7
+ _updatedAt?: Timestamp;
8
+ name: string;
9
+ email: string;
10
+ photoURL?: string;
11
+ tokens?: {
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ [index: string]: any;
14
+ };
15
+ }
@@ -0,0 +1,13 @@
1
+ import { reducer, initialState } from './user.reducer';
2
+
3
+ describe('User 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
+ });
@@ -0,0 +1,50 @@
1
+ import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
2
+ import { User } from './user.model';
3
+ import { UserActions, UserActionTypes } from './user.actions';
4
+ import { createFeatureSelector } from '@ngrx/store';
5
+
6
+ export interface State extends EntityState<User> {
7
+ // additional entities state properties
8
+ }
9
+
10
+ export const adapter: EntityAdapter<User> = createEntityAdapter<User>({
11
+ selectId: (user: User) => user.__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: UserActions) {
22
+ switch (action.type) {
23
+ case UserActionTypes.ADDED:
24
+ return adapter.upsertOne(action.payload, state);
25
+
26
+ case UserActionTypes.LOADED:
27
+ return adapter.upsertMany(action.payload, state);
28
+
29
+ case UserActionTypes.MODIFIED:
30
+ return adapter.updateOne({
31
+ id: action.payload.__id,
32
+ changes: action.payload,
33
+ }, state);
34
+
35
+ case UserActionTypes.REMOVED:
36
+ return adapter.removeOne(action.payload.__id, state);
37
+
38
+ default:
39
+ return state;
40
+ }
41
+ }
42
+
43
+ export const getUserState = createFeatureSelector<State>('user');
44
+
45
+ export const {
46
+ selectIds,
47
+ selectEntities,
48
+ selectAll,
49
+ selectTotal,
50
+ } = adapter.getSelectors(getUserState);
@@ -0,0 +1,50 @@
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 { User } from './user.model';
6
+
7
+ @Injectable({
8
+ providedIn: 'root',
9
+ })
10
+ export class UserService {
11
+ constructor(
12
+ private cs: CachedSelectorsService,
13
+ private db: FirebaseService,
14
+ ) { }
15
+
16
+ /** Select a user from the store. */
17
+ public selectUser = <T extends User>(
18
+ id: string,
19
+ correlationId: string,
20
+ childrenFn?: (e: User) => { [index: string]: Observable<any> },
21
+ ): Observable<T> => {
22
+ return this.cs.selectEntityObj<User, T>('user', id, correlationId, childrenFn);
23
+ };
24
+
25
+ /** Select users from the store. */
26
+ public selectUsers = <T extends User>(
27
+ queryParams: [string, string, any][],
28
+ correlationId: string,
29
+ childrenFn?: (e: User) => { [index: string]: Observable<any> },
30
+ ): Observable<Array<T>> => {
31
+ return this.cs.selectEntityList<User, T>('user', queryParams, correlationId, childrenFn);
32
+ };
33
+
34
+ /** Get a user directly from the database. */
35
+ public getUser = <T extends User>(
36
+ id: string,
37
+ childrenFn?: (e: User) => { [index: string]: Observable<any> },
38
+ ): Observable<T> => {
39
+ return this.db.queryObjOnce<User, T>('users', id, childrenFn);
40
+ };
41
+
42
+ /** Get users directly from the database. */
43
+ public getUsers = <T extends User>(
44
+ queryParams: [string, string, any][],
45
+ queryOptions?: { [index: string]: any },
46
+ childrenFn?: (e: User) => { [index: string]: Observable<any> },
47
+ ): Observable<Array<T>> => {
48
+ return this.db.queryListOnce<User, T>('users', queryParams, queryOptions, childrenFn);
49
+ };
50
+ }
@@ -0,0 +1,96 @@
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
+ }
@@ -0,0 +1,25 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { E404Component } from './e404.component';
4
+
5
+ describe('E404Component', () => {
6
+ let component: E404Component;
7
+ let fixture: ComponentFixture<E404Component>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [E404Component],
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(E404Component);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,28 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'app-e404',
5
+ templateUrl: './e404.component.html',
6
+ styleUrls: ['./e404.component.scss'],
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ })
9
+ export class E404Component implements OnInit {
10
+ // --------------- INPUTS AND OUTPUTS ------------------
11
+
12
+ constructor() {
13
+ }
14
+
15
+ ngOnInit() {
16
+ }
17
+
18
+ // --------------- LOCAL UI STATE ----------------------
19
+
20
+
21
+ // --------------- DATA BINDING FUNCTIONS --------------
22
+
23
+
24
+ // --------------- EVENT BINDING FUNCTIONS -------------
25
+
26
+
27
+ // --------------- OTHER -------------------------------
28
+ }
@@ -0,0 +1,21 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { Routes, RouterModule } from '@angular/router';
3
+
4
+ // Containers
5
+ import { E404Component } from './e404/e404.component';
6
+ import { LoginComponent } from './login/login.component';
7
+
8
+ const routes: Routes = [
9
+ { path: '404', component: E404Component },
10
+ { path: 'login', component: LoginComponent },
11
+ ];
12
+
13
+ @NgModule({
14
+ imports: [
15
+ RouterModule.forChild(routes),
16
+ ],
17
+ exports: [
18
+ RouterModule,
19
+ ],
20
+ })
21
+ export class GeneralRoutingModule { }
@@ -0,0 +1,13 @@
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
+ });
@@ -0,0 +1,30 @@
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 { E404Component } from './e404/e404.component';
9
+ import { LoginComponent } from './login/login.component';
10
+
11
+ // Components
12
+
13
+ @NgModule({
14
+ imports: [
15
+ CommonModule,
16
+ SharedModule,
17
+ GeneralRoutingModule,
18
+ EffectsModule.forFeature([
19
+ ]),
20
+ ],
21
+ declarations: [
22
+ // Containers
23
+ E404Component,
24
+ LoginComponent,
25
+ // Components
26
+ ],
27
+ exports: [
28
+ ],
29
+ })
30
+ export class GeneralModule { }
@@ -0,0 +1,25 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { LoginComponent } from './login.component';
4
+
5
+ describe('LoginComponent', () => {
6
+ let component: LoginComponent;
7
+ let fixture: ComponentFixture<LoginComponent>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [LoginComponent],
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(LoginComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,72 @@
1
+ import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
+ import { Observable, Subject } from 'rxjs';
3
+ import { takeUntil } from 'rxjs/operators';
4
+ import { select, Store } from '@ngrx/store';
5
+ import * as fromStore from '../../core/store/app.reducer';
6
+ import * as fromAuth from '../../core/store/auth/auth.reducer';
7
+ import { Login, Logout } from '../../core/store/auth/auth.actions';
8
+ import { User } from '../../core/store/user/user.model';
9
+
10
+ @Component({
11
+ selector: 'app-login',
12
+ templateUrl: './login.component.html',
13
+ styleUrls: ['./login.component.scss'],
14
+ changeDetection: ChangeDetectionStrategy.OnPush,
15
+ })
16
+ export class LoginComponent implements OnInit, OnDestroy {
17
+ // --------------- ROUTE PARAMS & CURRENT USER ---------
18
+
19
+ /** The currently signed in user. */
20
+ currentUser$: Observable<User> = this.store.pipe(select(fromAuth.selectUser));
21
+
22
+ // --------------- LOCAL UI STATE ----------------------
23
+
24
+
25
+ // --------------- DATA BINDING STREAMS ----------------
26
+
27
+
28
+ // --------------- EVENT BINDING STREAMS: RAW ------
29
+
30
+ /** Login click events. */
31
+ login$: Subject<void> = new Subject<void>();
32
+
33
+ /** Logout click events. */
34
+ logout$: Subject<void> = new Subject<void>();
35
+
36
+ // --------------- EVENT BINDING STREAMS: COMPUTED -----
37
+
38
+
39
+ // --------------- OTHER -------------------------------
40
+
41
+ /** Unsubscribe observable for subscriptions. */
42
+ unsubscribe$: Subject<void> = new Subject();
43
+
44
+ constructor(
45
+ private store: Store<fromStore.State>,
46
+ ) {
47
+ // --------------- EVENT HANDLING ----------------------
48
+
49
+ /** Handle login events. */
50
+ this.login$.pipe(
51
+ takeUntil(this.unsubscribe$),
52
+ ).subscribe(() => {
53
+ this.store.dispatch(new Login({ provider: 'google.com' }));
54
+ });
55
+
56
+ /** Handle logout events. */
57
+ this.logout$.pipe(
58
+ takeUntil(this.unsubscribe$),
59
+ ).subscribe(() => {
60
+ this.store.dispatch(new Logout());
61
+ });
62
+ }
63
+
64
+ ngOnInit() {
65
+ }
66
+
67
+ ngOnDestroy() {
68
+ // Unsubscribe subscriptions.
69
+ this.unsubscribe$.next();
70
+ this.unsubscribe$.complete();
71
+ }
72
+ }
@@ -0,0 +1,81 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { RouterModule } from '@angular/router';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { EffectsModule } from '@ngrx/effects';
6
+
7
+ // External Modules
8
+ import { MatMenuModule } from '@angular/material/menu';
9
+ import { MatTabsModule } from '@angular/material/tabs';
10
+ import { MatInputModule } from '@angular/material/input';
11
+ import { MatButtonModule } from '@angular/material/button';
12
+ import { MatFormFieldModule } from '@angular/material/form-field';
13
+ import { MatSelectModule } from '@angular/material/select';
14
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
15
+ import { MatRadioModule } from '@angular/material/radio';
16
+ import { MatCheckboxModule } from '@angular/material/checkbox';
17
+ import { MatDialogModule } from '@angular/material/dialog';
18
+ import { MatTooltipModule } from '@angular/material/tooltip';
19
+ import { MatExpansionModule } from '@angular/material/expansion';
20
+ import { MatTableModule } from '@angular/material/table';
21
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
22
+
23
+ // Containers
24
+
25
+ // Components
26
+
27
+ // Pipes
28
+
29
+
30
+ @NgModule({
31
+ imports: [
32
+ CommonModule,
33
+ RouterModule,
34
+ FormsModule,
35
+ // External Modules
36
+ MatMenuModule,
37
+ MatTabsModule,
38
+ MatInputModule,
39
+ MatFormFieldModule,
40
+ MatSelectModule,
41
+ MatSnackBarModule,
42
+ MatButtonModule,
43
+ MatCheckboxModule,
44
+ MatTableModule,
45
+ MatDialogModule,
46
+ MatTooltipModule,
47
+ MatExpansionModule,
48
+ MatProgressSpinnerModule,
49
+ MatRadioModule,
50
+ EffectsModule.forFeature([
51
+ ]),
52
+ ],
53
+ declarations: [
54
+ // Containers
55
+ // Components
56
+ // Pipes
57
+ ],
58
+ exports: [
59
+ RouterModule,
60
+ FormsModule,
61
+ // External Modules
62
+ MatMenuModule,
63
+ MatTabsModule,
64
+ MatInputModule,
65
+ MatFormFieldModule,
66
+ MatSelectModule,
67
+ MatSnackBarModule,
68
+ MatCheckboxModule,
69
+ MatTableModule,
70
+ MatDialogModule,
71
+ MatTooltipModule,
72
+ MatButtonModule,
73
+ MatExpansionModule,
74
+ MatProgressSpinnerModule,
75
+ MatRadioModule,
76
+ // Containers
77
+ // Components
78
+ // Pipes
79
+ ],
80
+ })
81
+ export class SharedModule { }
@@ -0,0 +1,5 @@
1
+ export const environment = {
2
+ production: true,
3
+ firebase: {}, // REPLACE WITH CONFIG
4
+ firebaseLogs: {}, // REPLACE WITH CONFIG
5
+ };