Skip to content

Commit b1aae1b

Browse files
committed
feat(dashboard): added profile and settings pages
also added app.state
1 parent 5aaa29c commit b1aae1b

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

apps/webapp/src/environments/base.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default {
1010
sessionId: 'sumodemo',
1111
},
1212
webPush: {
13-
publicVapidKey: 'BAJq-yHlSNjUqKW9iMY0hG96X9WdVwetUFDa5rQIGRPqOHKAL_fkKUe_gUTAKnn9IPAltqmlNO2OkJrjdQ_MXNg'
13+
publicVapidKey: 'BAJq-yHlSNjUqKW9iMY0hG96X9WdVwetUFDa5rQIGRPqOHKAL_fkKUe_gUTAKnn9IPAltqmlNO2OkJrjdQ_MXNg',
1414
},
1515
versions: {
1616
app: packageJson.version,
@@ -20,7 +20,6 @@ export default {
2020
flexLayout: packageJson.dependencies['@angular/flex-layout'],
2121
rxjs: packageJson.dependencies.rxjs,
2222
angularCli: packageJson.devDependencies['@angular/cli'],
23-
// typescript: packageJson.devDependencies['typescript'],
24-
typescript: packageJson.dependencies['typescript'],
23+
typescript: packageJson.devDependencies['typescript'],
2524
},
2625
};

libs/auth/src/lib/oauth.init.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ export function initializeAuth(oauthService: OAuthService, store: Store) {
2121
if (oauthService.hasValidAccessToken()) {
2222
// This is called when using ImplicitFlow or page reload, no effect for ROPC Flow
2323
console.log('hasValidAccessToken');
24-
// const profile: any = oauthService.getIdentityClaims();
25-
const profile: any = await oauthService.loadUserProfile();
24+
const profile: any = oauthService.getIdentityClaims();
2625
store.dispatch(new LoginSuccess(profile));
2726
}
2827
return true; // need to return.

libs/core/src/lib/services/push-notification.service.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Injectable} from '@angular/core';
2-
import {SwPush} from '@angular/service-worker';
3-
import {from as fromPromise, Observable, of} from 'rxjs';
1+
import { Injectable } from '@angular/core';
2+
import { SwPush } from '@angular/service-worker';
3+
import { from as fromPromise, Observable, of } from 'rxjs';
44
import { environment } from '@env/environment';
55
// import {ApiService} from './api.service';
66

77
@Injectable({
8-
providedIn: 'root'
8+
providedIn: 'root',
99
})
1010
export class PushNotificationService {
1111
private pushSubscription: PushSubscription;
@@ -14,8 +14,7 @@ export class PushNotificationService {
1414
return this.swPush.isEnabled;
1515
}
1616

17-
constructor(private readonly swPush: SwPush, /*private readonly apiService: ApiService*/) {
18-
}
17+
constructor(private readonly swPush: SwPush /*private readonly apiService: ApiService*/) {}
1918

2019
async register() {
2120
if (!this.swPush.isEnabled) {
@@ -24,7 +23,7 @@ export class PushNotificationService {
2423

2524
// Key generation: https://web-push-codelab.glitch.me
2625
const subscription = await this.swPush.requestSubscription({ serverPublicKey: environment.webPush.publicVapidKey });
27-
console.log('Push subscription endpoint: ', subscription.endpoint);
26+
console.log('Push subscription', subscription);
2827
this.pushSubscription = subscription;
2928
// return this.apiService.post('push/register', subscription).subscribe();
3029
}

libs/core/src/lib/state/eventbus.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@ export class EventBus {
4343
this.renderer.listen(this.window, 'beforeinstallprompt', event => {
4444
event.preventDefault(); // Prevent default for older Chrome versions to prevent double install prompt
4545
this.analytics.emitEvent(EventCategory.Install, 'available');
46+
// this.snackBar.open('You can add this PWA to your homescreen', '', {duration: 3000});
4647
this.store.dispatch(new SetInstallPrompt(event));
4748
});
4849
this.renderer.listen(this.window, 'appinstalled', event => {
4950
event.preventDefault(); // Prevent default for older Chrome versions to prevent double install prompt
50-
ga('send', 'event', 'install', 'installed');
5151
this.analytics.emitEvent(EventCategory.Install, 'installed');
5252
this.store.dispatch(new ChangeInstallStatus(true));
5353
});
5454

5555
this.actions$.pipe(ofActionSuccessful(SetInstallPrompt)).subscribe(async (action: SetInstallPrompt) => {
5656
try {
5757
console.log('platforms', action.payload.platforms);
58-
// TODO: prompt user with MatSnackBar and call below if clicked.
58+
// TODO: const sb = this.snackBar.open('Do you want to install this app?', 'Install', {duration: 5000})
59+
// sb.onAction().subscribe(() => { //prompt here }
5960
action.payload.prompt();
6061
const choiceResult = await action.payload.userChoice;
6162
console.log('choiceResult', choiceResult);

libs/dashboard/src/lib/containers/settings/settings.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import {
66
ChangeLanguage,
77
ChangeTheme,
88
DisableNotifications,
9-
EnableNotifications, Language,
9+
EnableNotifications,
10+
Language,
1011
PreferenceState,
11-
PreferenceStateModel, PushNotificationService, ThemeName,
12+
PreferenceStateModel,
13+
PushNotificationService,
14+
ThemeName,
1215
} from '@ngx-starter-kit/core';
1316
import { untilDestroy } from '@ngx-starter-kit/ngx-utils';
1417

@@ -22,7 +25,12 @@ export class SettingsComponent implements OnInit, OnDestroy {
2225
preferences: PreferenceStateModel;
2326
settingsForm: FormGroup;
2427
languages: Language[] = ['en', 'es', 'de', 'fr', 'cn'];
25-
themes: ThemeName[] = [ThemeName.DEEPPURPLE_AMBER, ThemeName.INDIGO_PINK, ThemeName.PINK_BLUEGREY, ThemeName.PURPLE_GREEN];
28+
themes: ThemeName[] = [
29+
ThemeName.DEEPPURPLE_AMBER,
30+
ThemeName.INDIGO_PINK,
31+
ThemeName.PINK_BLUEGREY,
32+
ThemeName.PURPLE_GREEN,
33+
];
2634

2735
constructor(private fb: FormBuilder, private store: Store, private pnServ: PushNotificationService) {}
2836

@@ -44,7 +52,6 @@ export class SettingsComponent implements OnInit, OnDestroy {
4452
.get('enableNotifications')
4553
.valueChanges.pipe(untilDestroy(this))
4654
.subscribe(enableNotifications => {
47-
console.log('pnServ.available', this.pnServ.available);
4855
if (enableNotifications) {
4956
this.pnServ.register();
5057
this.store.dispatch(new EnableNotifications());

0 commit comments

Comments
 (0)