bug of AppMessengerResolver is fixed
This commit is contained in:
parent
c49e7e5931
commit
a198cf8ddf
@ -21,7 +21,7 @@ const routes: Routes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(routes)],
|
imports: [RouterModule.forRoot(routes, { enableTracing: true })],
|
||||||
exports: [RouterModule]
|
exports: [RouterModule]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {}
|
export class AppRoutingModule {}
|
||||||
|
@ -4,10 +4,10 @@ import {
|
|||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
RouterStateSnapshot
|
RouterStateSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, throwError } from 'rxjs';
|
||||||
import { take, map, catchError } from 'rxjs/operators';
|
import { map, tap, mergeMap, catchError, take } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
@ -19,9 +19,10 @@ import { LoginInfo, KEY_LOGIN_INFO } from '../types';
|
|||||||
import { InnerProtocolService } from '@ucap-webmessenger/protocol-inner';
|
import { InnerProtocolService } from '@ucap-webmessenger/protocol-inner';
|
||||||
import {
|
import {
|
||||||
AuthenticationProtocolService,
|
AuthenticationProtocolService,
|
||||||
SSOMode
|
SSOMode,
|
||||||
|
LoginResponse
|
||||||
} from '@ucap-webmessenger/protocol-authentication';
|
} from '@ucap-webmessenger/protocol-authentication';
|
||||||
import { LocaleCode } from '@ucap-webmessenger/core';
|
|
||||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -41,7 +42,8 @@ export class AppMessengerResolver implements Resolve<void> {
|
|||||||
): void | Observable<void> | Promise<void> {
|
): void | Observable<void> | Promise<void> {
|
||||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
||||||
|
|
||||||
return this.publicApiService
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
this.publicApiService
|
||||||
.versionInfo2({
|
.versionInfo2({
|
||||||
deviceType: loginInfo.deviceType,
|
deviceType: loginInfo.deviceType,
|
||||||
companyGroupType: 'C',
|
companyGroupType: 'C',
|
||||||
@ -50,19 +52,15 @@ export class AppMessengerResolver implements Resolve<void> {
|
|||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
take(1),
|
take(1),
|
||||||
map(res => {
|
tap(versionInfo2Res => {
|
||||||
this.store.dispatch(VersionInfoStore.fetchSuccess(res));
|
this.store.dispatch(VersionInfoStore.fetchSuccess(versionInfo2Res));
|
||||||
this.protocolService
|
}),
|
||||||
.connect(res.serverIp)
|
mergeMap(versionInfo2Res =>
|
||||||
.then(() => {
|
this.protocolService.connect(versionInfo2Res.serverIp)
|
||||||
this.innerProtocolService
|
),
|
||||||
.conn({})
|
mergeMap(() => this.innerProtocolService.conn({})),
|
||||||
.pipe(
|
mergeMap(connRres =>
|
||||||
take(1),
|
this.authenticationProtocolService.login({
|
||||||
map(connRes => {
|
|
||||||
console.log('connRes', connRes);
|
|
||||||
this.authenticationProtocolService
|
|
||||||
.login({
|
|
||||||
loginId: loginInfo.loginId,
|
loginId: loginInfo.loginId,
|
||||||
loginPw: loginInfo.loginPw,
|
loginPw: loginInfo.loginPw,
|
||||||
deviceType: loginInfo.deviceType,
|
deviceType: loginInfo.deviceType,
|
||||||
@ -81,8 +79,7 @@ export class AppMessengerResolver implements Resolve<void> {
|
|||||||
productId: 'PRO_000482',
|
productId: 'PRO_000482',
|
||||||
productName: 'EZMessenger'
|
productName: 'EZMessenger'
|
||||||
})
|
})
|
||||||
.pipe(
|
),
|
||||||
take(1),
|
|
||||||
map(loginRes => {
|
map(loginRes => {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
AuthenticationStore.loginSuccess({
|
AuthenticationStore.loginSuccess({
|
||||||
@ -91,18 +88,17 @@ export class AppMessengerResolver implements Resolve<void> {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
return of(
|
return throwError(err);
|
||||||
AuthenticationStore.loginFailure({ error: err })
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe(
|
||||||
})
|
() => {
|
||||||
)
|
resolve();
|
||||||
.subscribe();
|
},
|
||||||
})
|
err => {
|
||||||
.catch(reason => {});
|
reject();
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,14 @@ import { Router } from '@angular/router';
|
|||||||
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||||
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
|
import {
|
||||||
|
catchError,
|
||||||
|
exhaustMap,
|
||||||
|
map,
|
||||||
|
tap,
|
||||||
|
take,
|
||||||
|
switchMap
|
||||||
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PiService,
|
PiService,
|
||||||
@ -68,11 +75,8 @@ export class Effects {
|
|||||||
() =>
|
() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(webLoginSuccess),
|
ofType(webLoginSuccess),
|
||||||
tap(params => {
|
switchMap(params =>
|
||||||
this.nativeService
|
this.nativeService.checkForUpdates().pipe(
|
||||||
.checkForUpdates()
|
|
||||||
.pipe(
|
|
||||||
take(1),
|
|
||||||
map((update: boolean) => {
|
map((update: boolean) => {
|
||||||
if (!update) {
|
if (!update) {
|
||||||
this.appAuthenticationService.login(
|
this.appAuthenticationService.login(
|
||||||
@ -84,8 +88,7 @@ export class Effects {
|
|||||||
}),
|
}),
|
||||||
catchError(error => of(error))
|
catchError(error => of(error))
|
||||||
)
|
)
|
||||||
.subscribe();
|
)
|
||||||
})
|
|
||||||
),
|
),
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
@ -54,14 +54,15 @@ export class ProtocolService {
|
|||||||
.pipe(share());
|
.pipe(share());
|
||||||
}
|
}
|
||||||
|
|
||||||
public connect(serverIp: string | null = null): Promise<void> {
|
public connect(serverIp: string | null = null): Observable<void> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Observable<void>(subscriber => {
|
||||||
|
try {
|
||||||
this.socket$ = makeWebSocketObservable(
|
this.socket$ = makeWebSocketObservable(
|
||||||
`${this.moduleConfig.urls.base}${serverIp ? serverIp : ''}`
|
`${this.moduleConfig.urls.base}${serverIp ? serverIp : ''}`
|
||||||
);
|
);
|
||||||
this.messages$ = this.socket$.pipe(
|
this.messages$ = this.socket$.pipe(
|
||||||
switchMap(getResponses => {
|
switchMap(getResponses => {
|
||||||
resolve();
|
subscriber.next();
|
||||||
return getResponses(this.input$);
|
return getResponses(this.input$);
|
||||||
}),
|
}),
|
||||||
retryWhen(errors =>
|
retryWhen(errors =>
|
||||||
@ -117,6 +118,9 @@ export class ProtocolService {
|
|||||||
console.log('the connection was closed in response to the user');
|
console.log('the connection was closed in response to the user');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
subscriber.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{ data.message }}
|
{{ data.message }}
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
<mat-card-actions class="button-farm flex-row">
|
<mat-card-actions *ngIf="!hideAction" class="button-farm flex-row">
|
||||||
<button
|
<button
|
||||||
mat-stroked-button
|
mat-stroked-button
|
||||||
(click)="onClickChoice(false)"
|
(click)="onClickChoice(false)"
|
||||||
|
@ -11,6 +11,7 @@ export interface ConfirmDialogData {
|
|||||||
title: string;
|
title: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
html?: string;
|
html?: string;
|
||||||
|
hideAction?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfirmDialogResult {
|
export interface ConfirmDialogResult {
|
||||||
@ -26,6 +27,8 @@ export class ConfirmDialogComponent implements OnInit {
|
|||||||
@ViewChild('messageContainer', { static: true })
|
@ViewChild('messageContainer', { static: true })
|
||||||
messageContainer: ElementRef;
|
messageContainer: ElementRef;
|
||||||
|
|
||||||
|
hideAction = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<ConfirmDialogComponent, ConfirmDialogResult>,
|
public dialogRef: MatDialogRef<ConfirmDialogComponent, ConfirmDialogResult>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
||||||
@ -35,6 +38,9 @@ export class ConfirmDialogComponent implements OnInit {
|
|||||||
if (!!this.data.html) {
|
if (!!this.data.html) {
|
||||||
this.messageContainer.nativeElement.innerHTML = this.data.html;
|
this.messageContainer.nativeElement.innerHTML = this.data.html;
|
||||||
}
|
}
|
||||||
|
if (!!this.data.hideAction) {
|
||||||
|
this.hideAction = this.data.hideAction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickChoice(choice: boolean): void {
|
onClickChoice(choice: boolean): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user