@tech4good/angular-schematics 13.6.0 → 13.7.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/package.json +1 -1
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +8 -8
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +3 -2
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +6 -5
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +2 -2
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +25 -14
- package/src/container/index.js +13 -2
- package/src/container/index.js.map +1 -1
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +9 -30
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +23 -24
- package/src/init/files/package.json.template +3 -1
- package/src/init/files/src/app/admin/admin-routing.module.ts.template +17 -0
- package/src/init/files/src/app/admin/admin.module.spec.ts.template +13 -0
- package/src/init/files/src/app/admin/admin.module.ts.template +28 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +23 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +50 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +39 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +13 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.animations.ts.template +4 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.html.template +30 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.scss.template +14 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.spec.ts.template +25 -0
- package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +136 -0
- package/src/init/files/src/app/app-routing.module.ts.template +13 -5
- package/src/init/files/src/app/core/analytics/log.service.ts.template +89 -4
- package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +204 -69
- package/src/init/files/src/app/core/auth/auth.guard.ts.template +85 -0
- package/src/init/files/src/app/core/core.module.ts.template +4 -0
- package/src/init/files/src/app/core/firebase/firebase.service.ts.template +4 -4
- package/src/init/files/src/app/core/local-storage/local-storage.service.ts.template +47 -0
- package/src/init/files/src/app/core/local-storage/session-local-storage.service.ts.template +67 -0
- package/src/init/files/src/app/core/local-storage/session.service.ts.template +48 -0
- package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +270 -0
- package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +131 -0
- package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +8 -0
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +13 -0
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +51 -0
- package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +50 -0
- package/src/init/files/src/app/core/store/app.effects.ts.template +10 -2
- package/src/init/files/src/app/core/store/app.reducer.ts.template +6 -0
- package/src/init/files/src/app/core/store/app.selectors.ts.template +12 -0
- package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +3 -1
- package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +27 -31
- package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +1 -1
- package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +5 -1
- package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +9 -8
- package/src/init/files/src/app/core/store/user/user.model.ts.template +14 -0
- package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +270 -0
- package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +131 -0
- package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +13 -0
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +13 -0
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +51 -0
- package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +50 -0
- package/src/init/files/src/app/general/general-routing.module.ts.template +6 -2
- package/src/init/files/src/app/general/general.module.ts.template +8 -2
- package/src/init/files/src/app/general/home/+state/home.actions.ts.template +26 -0
- package/src/init/files/src/app/general/home/+state/home.effects.ts.template +48 -0
- package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
- package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +20 -0
- package/src/init/files/src/app/general/home/+state/home.state.ts.template +13 -0
- package/src/init/files/src/app/general/home/home.animations.ts.template +4 -0
- package/src/init/files/src/app/general/home/home.component.html.template +5 -0
- package/src/init/files/src/app/general/home/home.component.scss.template +5 -0
- package/src/init/files/src/app/general/{e404/e404.component.spec.ts.template → home/home.component.spec.ts.template} +6 -6
- package/src/init/files/src/app/general/home/home.component.ts.template +88 -0
- package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +26 -0
- package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +48 -0
- package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
- package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +20 -0
- package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +13 -0
- package/src/init/files/src/app/general/landing/landing.animations.ts.template +4 -0
- package/src/init/files/src/app/general/landing/landing.component.html.template +3 -0
- package/src/init/files/src/app/general/landing/landing.component.scss.template +13 -0
- package/src/init/files/src/app/general/landing/landing.component.spec.ts.template +25 -0
- package/src/init/files/src/app/general/landing/landing.component.ts.template +98 -0
- package/src/init/files/src/app/general/login/login.component.html.template +5 -5
- package/src/init/files/src/app/general/login/login.component.ts.template +12 -4
- package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +23 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +47 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +20 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +13 -0
- package/src/init/files/src/app/onboarding/consent/consent.animations.ts.template +4 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.html.template +61 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.scss.template +77 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.spec.ts.template +25 -0
- package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +152 -0
- package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +19 -0
- package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +13 -0
- package/src/init/files/src/app/onboarding/onboarding.module.ts.template +32 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +26 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +52 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +9 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +42 -0
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +13 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +4 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +57 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.scss.template +99 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +25 -0
- package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +279 -0
- package/src/init/files/src/app/shared/shared.module.ts.template +3 -0
- package/src/init/files/src/index.html.template +0 -3
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +2 -0
- package/src/init/files/src/app/general/e404/e404.component.html.template +0 -1
- package/src/init/files/src/app/general/e404/e404.component.ts.template +0 -28
- /package/src/init/files/src/app/{general/e404/e404.component.scss.template → admin/waitlist/+state/waitlist.model.ts.template} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { WaitlistComponent } from './waitlist.component';
|
|
4
|
+
|
|
5
|
+
describe('WaitlistComponent', () => {
|
|
6
|
+
let component: WaitlistComponent;
|
|
7
|
+
let fixture: ComponentFixture<WaitlistComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(waitForAsync(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [WaitlistComponent],
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(WaitlistComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
import { WaitlistAnimations } from './waitlist.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, take, takeUntil } from 'rxjs/operators';
|
|
10
|
+
|
|
11
|
+
import { WaitlistState } from './+state/waitlist.state';
|
|
12
|
+
import { WaitlistSelectors } from './+state/waitlist.selectors';
|
|
13
|
+
|
|
14
|
+
import { LoadData, Cleanup } from './+state/waitlist.actions';
|
|
15
|
+
import { ActionFlow, RouterNavigate, ActionSet } from '../../core/store/app.actions';
|
|
16
|
+
|
|
17
|
+
import { User, AccessState } from '../../core/store/user/user.model';
|
|
18
|
+
import { ShowSnackbar } from '../../core/snackbar/snackbar.actions';
|
|
19
|
+
import { UpdateUser, UserActionTypes } from '../../core/store/user/user.actions';
|
|
20
|
+
|
|
21
|
+
@Component({
|
|
22
|
+
selector: 'app-waitlist',
|
|
23
|
+
templateUrl: './waitlist.component.html',
|
|
24
|
+
styleUrls: ['./waitlist.component.scss'],
|
|
25
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
+
animations: WaitlistAnimations,
|
|
27
|
+
})
|
|
28
|
+
export class WaitlistComponent implements OnInit, OnDestroy {
|
|
29
|
+
// --------------- ROUTE PARAMS & CURRENT USER ---------
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// --------------- LOCAL AND GLOBAL STATE --------------
|
|
33
|
+
|
|
34
|
+
/** Access options for menu sorted alphabetically. */
|
|
35
|
+
accessOptions = Object.keys(AccessState)
|
|
36
|
+
.map((k) => AccessState[k])
|
|
37
|
+
.sort((a, b) => {
|
|
38
|
+
if (a > b) {
|
|
39
|
+
return 1;
|
|
40
|
+
} else if (a < b) {
|
|
41
|
+
return -1;
|
|
42
|
+
} else {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** Columns to display in the table */
|
|
48
|
+
displayedColumns = ['userName', 'accessState', 'update'];
|
|
49
|
+
|
|
50
|
+
// --------------- DB ENTITY DATA ----------------------
|
|
51
|
+
|
|
52
|
+
/** Container id for selectors and loading. */
|
|
53
|
+
containerId: string = this.db.createId();
|
|
54
|
+
|
|
55
|
+
/** Get array of all waiting users. */
|
|
56
|
+
waitingUsers$: Observable<User[]> = this.selectors.selectWaitingUsers(this.containerId);
|
|
57
|
+
|
|
58
|
+
// --------------- DATA BINDING ------------------------
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// --------------- EVENT BINDING -----------------------
|
|
62
|
+
|
|
63
|
+
/** Event stream for updating user accessState. */
|
|
64
|
+
updateState$: Subject<{ user: User, state: AccessState }> = new Subject<{ user: User, state: AccessState }>();
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// --------------- HELPER FUNCTIONS AND OTHER ----------
|
|
68
|
+
|
|
69
|
+
/** Unsubscribe observable for subscriptions. */
|
|
70
|
+
unsubscribe$: Subject<void> = new Subject();
|
|
71
|
+
|
|
72
|
+
constructor(
|
|
73
|
+
private state: WaitlistState,
|
|
74
|
+
private route: ActivatedRoute,
|
|
75
|
+
private selectors: WaitlistSelectors,
|
|
76
|
+
private store: Store<fromStore.State>,
|
|
77
|
+
private db: FirebaseService,
|
|
78
|
+
) {
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
ngOnInit() {
|
|
82
|
+
// --------------- EVENT HANDLING ----------------------
|
|
83
|
+
|
|
84
|
+
this.updateState$.pipe(
|
|
85
|
+
takeUntil(this.unsubscribe$),
|
|
86
|
+
).subscribe(({ user, state }) => {
|
|
87
|
+
const actionSets: ActionSet[] = [{
|
|
88
|
+
action: new UpdateUser(user.__id, {
|
|
89
|
+
accessState: state,
|
|
90
|
+
}, this.containerId),
|
|
91
|
+
responseActionTypes: {
|
|
92
|
+
success: UserActionTypes.UPDATE_SUCCESS,
|
|
93
|
+
failure: UserActionTypes.UPDATE_FAIL,
|
|
94
|
+
},
|
|
95
|
+
}];
|
|
96
|
+
|
|
97
|
+
this.store.dispatch(
|
|
98
|
+
new ActionFlow({
|
|
99
|
+
actionSets,
|
|
100
|
+
successActionFn: (actionSetResponses) => {
|
|
101
|
+
return [
|
|
102
|
+
new ShowSnackbar({
|
|
103
|
+
message: `Updated ${user.name}'s accessState to ${state}`,
|
|
104
|
+
config: { duration: 3000 },
|
|
105
|
+
}),
|
|
106
|
+
];
|
|
107
|
+
},
|
|
108
|
+
failActionFn: (actionSetResponses) => {
|
|
109
|
+
return [
|
|
110
|
+
new ShowSnackbar({
|
|
111
|
+
message: 'Failed to submit response',
|
|
112
|
+
config: { duration: 3000 },
|
|
113
|
+
}),
|
|
114
|
+
];
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// --------------- LOAD DATA ---------------------------
|
|
122
|
+
|
|
123
|
+
// Once everything is set up, load the data for the role.
|
|
124
|
+
this.store.dispatch( new LoadData(this.containerId) );
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ngOnDestroy() {
|
|
128
|
+
// Unsubscribe subscriptions.
|
|
129
|
+
this.unsubscribe$.next();
|
|
130
|
+
this.unsubscribe$.complete();
|
|
131
|
+
|
|
132
|
+
// Unsubscribe from firebase connection from load and free up memoized selector values.
|
|
133
|
+
this.store.dispatch( new Cleanup(this.containerId) );
|
|
134
|
+
this.selectors.cleanup(this.containerId);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
|
-
import { Routes, RouterModule } from '@angular/router';
|
|
2
|
+
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
|
|
3
|
+
import { AuthGuard } from './core/auth/auth.guard';
|
|
3
4
|
|
|
4
5
|
// Containers
|
|
5
6
|
import { LoginComponent } from './general/login/login.component';
|
|
7
|
+
import { LandingComponent } from './general/landing/landing.component';
|
|
6
8
|
|
|
9
|
+
// Our general approach is to load the GeneralModule eagerly and everything lazily (but with preloading)
|
|
7
10
|
const appRoutes: Routes = [
|
|
8
|
-
|
|
9
|
-
{ path: '',
|
|
10
|
-
{ path: '
|
|
11
|
+
{ path: 'admin', loadChildren: () => import('./admin/admin.module').then((mod) => mod.AdminModule) },
|
|
12
|
+
{ path: 'onboarding', loadChildren: () => import('./onboarding/onboarding.module').then((mod) => mod.OnboardingModule) },
|
|
13
|
+
{ path: '', component: LandingComponent, canActivate: [AuthGuard] },
|
|
14
|
+
{ path: '**', redirectTo: '', pathMatch: 'full' },
|
|
11
15
|
];
|
|
12
16
|
|
|
13
17
|
@NgModule({
|
|
14
18
|
imports: [
|
|
15
|
-
RouterModule.forRoot(appRoutes, {
|
|
19
|
+
RouterModule.forRoot(appRoutes, {
|
|
20
|
+
useHash: true,
|
|
21
|
+
relativeLinkResolution: 'legacy',
|
|
22
|
+
preloadingStrategy: PreloadAllModules,
|
|
23
|
+
}),
|
|
16
24
|
],
|
|
17
25
|
exports: [RouterModule],
|
|
18
26
|
})
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
import { LoggingAngularFirestore } from '../setup/firebase-setup';
|
|
3
3
|
import { isDevMode } from '@angular/core';
|
|
4
|
+
import { environment } from '../../../environments/environment';
|
|
4
5
|
|
|
5
6
|
interface LogData {
|
|
6
|
-
__userId
|
|
7
|
+
__userId?: string;
|
|
8
|
+
__sessionId?: string;
|
|
9
|
+
__deviceId?: string;
|
|
7
10
|
route: string;
|
|
8
11
|
startTime: number;
|
|
9
12
|
time: Array<{
|
|
@@ -25,11 +28,93 @@ export class LogService {
|
|
|
25
28
|
) {
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
rawLog(data: LogData, logType: string = 'logs') {
|
|
31
|
+
rawLog(data: LogData, logType: string = 'logs', logId?: string) {
|
|
32
|
+
// If no logId supplied, then create one
|
|
33
|
+
if (!logId) {
|
|
34
|
+
logId = this.log.createId();
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
if (!isDevMode()) {
|
|
30
|
-
|
|
38
|
+
// Note that we are intentionally overriding logs with same id.
|
|
39
|
+
// This allows for making sure the same log doesn't get stored twice,
|
|
40
|
+
// e.g. for storing things in localStorage and saving next time we load
|
|
41
|
+
// the browser
|
|
42
|
+
this.log.doc(`/${logType}/${logId}`).set(data);
|
|
31
43
|
} else if (this.LOG_IN_DEV) {
|
|
32
|
-
console.log(data);
|
|
44
|
+
console.log('LOGGING', logId, data);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
rawLogOnBeaconEvent(data: LogData, logType: string = 'logs', logId?: string) {
|
|
49
|
+
// If no logId supplied, then create one
|
|
50
|
+
if (!logId) {
|
|
51
|
+
logId = this.log.createId();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (data !== null) {
|
|
55
|
+
if (!isDevMode()) {
|
|
56
|
+
navigator.sendBeacon(
|
|
57
|
+
`https://firestore.googleapis.com/v1/projects/${environment.firebaseLogs.projectId}/databases/(default)/documents:commit`,
|
|
58
|
+
this.reformatLogForBeacon(data, logType, logId),
|
|
59
|
+
);
|
|
60
|
+
} else if (this.LOG_IN_DEV) {
|
|
61
|
+
console.log('BEACON LOGGING', logId, data);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
reformatLogForBeacon(data: LogData, logType, logId) {
|
|
67
|
+
// Converts JSON objects to Firestore's REST API Document format
|
|
68
|
+
// from: https://stackoverflow.com/questions/62246410/how-to-convert-a-firestore-document-to-plain-json-and-vice-versa/62304377#62304377
|
|
69
|
+
const jsonToDocument = (value) => {
|
|
70
|
+
if (!value) {
|
|
71
|
+
return { 'nullValue': null };
|
|
72
|
+
} else if (!isNaN(value) && !(value && value.constructor === Array)) { // edit, checking if not an array since empty arrays pass the isNan test
|
|
73
|
+
if (value.toString().indexOf('.') != -1) {
|
|
74
|
+
return { 'doubleValue': value };
|
|
75
|
+
} else {
|
|
76
|
+
return { 'integerValue': value };
|
|
77
|
+
}
|
|
78
|
+
} else if (value === 'true' || value === 'false' || typeof value === 'boolean') {
|
|
79
|
+
return { 'booleanValue': value };
|
|
80
|
+
} else if (typeof value === 'string') { // edit: removed check for Date that was before String check (see below)
|
|
81
|
+
return { 'stringValue': value };
|
|
82
|
+
} else if (value && value.constructor === Array) {
|
|
83
|
+
return { 'arrayValue': { values: value.map((v) => jsonToDocument(v)) } };
|
|
84
|
+
} else if (typeof value === 'object') {
|
|
85
|
+
const obj = {};
|
|
86
|
+
for (const o in value) {
|
|
87
|
+
if (Object.prototype.hasOwnProperty.call(value, o)) {
|
|
88
|
+
obj[o] = jsonToDocument(value[o]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { 'mapValue': { fields: obj } };
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
if (data !== null) {
|
|
96
|
+
const wrappedData = {
|
|
97
|
+
writes: [
|
|
98
|
+
{
|
|
99
|
+
update: {
|
|
100
|
+
name: `projects/${environment.firebaseLogs.projectId}/databases/(default)/documents/${logType}/${logId}`,
|
|
101
|
+
fields: {
|
|
102
|
+
...jsonToDocument(data).mapValue.fields,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// console.log('WRAPPED_DATA', wrappedData);
|
|
110
|
+
|
|
111
|
+
const preparedData = new Blob([JSON.stringify(wrappedData, null, 2)], {
|
|
112
|
+
type: 'application/json',
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return preparedData;
|
|
116
|
+
} else {
|
|
117
|
+
return null;
|
|
33
118
|
}
|
|
34
119
|
}
|
|
35
120
|
}
|