SUPPORT-9164 add progress bar

This commit is contained in:
kochetkov 2025-05-12 11:07:17 +03:00
parent 17a6344a83
commit 9a2fdef3dc

View file

@ -2,7 +2,7 @@ import {Injectable} from "@angular/core";
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from "@angular/router"; import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from "@angular/router";
import {Observable} from "rxjs"; import {Observable} from "rxjs";
import {HttpClient, HttpParams} from "@angular/common/http"; import {HttpClient, HttpParams} from "@angular/common/http";
import {MessagesService} from "@webbpm/base-package"; import {MessagesService, ProgressIndicationService} from "@webbpm/base-package";
import {AuthenticationService} from "../authentication.service"; import {AuthenticationService} from "../authentication.service";
import {EsiaErrorDetail} from "../EsiaErrorDetail"; import {EsiaErrorDetail} from "../EsiaErrorDetail";
@ -13,6 +13,7 @@ export abstract class AuthGuard implements CanActivate {
protected router: Router, protected router: Router,
private httpClient: HttpClient, private httpClient: HttpClient,
private authenticationService: AuthenticationService, private authenticationService: AuthenticationService,
private progressIndicationService: ProgressIndicationService,
private messageService: MessagesService private messageService: MessagesService
) { ) {
} }
@ -44,6 +45,7 @@ export abstract class AuthGuard implements CanActivate {
return false; return false;
} }
if (code && state) { if (code && state) {
this.progressIndicationService.showProgressBar();
const params = new HttpParams().set('code', code).set('state', state); const params = new HttpParams().set('code', code).set('state', state);
this.httpClient.get("esia/auth", this.httpClient.get("esia/auth",
{ {
@ -57,6 +59,7 @@ export abstract class AuthGuard implements CanActivate {
.toPromise() .toPromise()
.then( .then(
() => { () => {
this.progressIndicationService.hideProgressBar();
window.open(url.origin + url.pathname, "_self"); window.open(url.origin + url.pathname, "_self");
}) })
.catch(reason => { .catch(reason => {
@ -64,7 +67,8 @@ export abstract class AuthGuard implements CanActivate {
json.messages.forEach((errorMessage) => { json.messages.forEach((errorMessage) => {
this.messageService.error(errorMessage, json); this.messageService.error(errorMessage, json);
}) })
}); })
.finally(() => this.progressIndicationService.hideProgressBar());
return false; return false;
} }
else { else {