Skip to content

Commit

Permalink
fix: display error message after sesseion timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
holdan-8 committed May 29, 2024
1 parent 91338a2 commit 5d5e4fd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions frontend/src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
import { shareReplay } from 'rxjs/operators';
import { environment } from 'src/environments/environment';
import { TokenService } from './services/token.service';
import { ToastrService } from 'ngx-toastr';
import { catchError } from 'rxjs/operators';
import { NEVER, throwError } from 'rxjs';


@Injectable({
Expand All @@ -20,7 +23,7 @@ export class DataService {
.get<Metric[]>('assets/options.json')
.pipe(shareReplay(1));

constructor(private http: HttpClient, private tokenService: TokenService) {}
constructor(private http: HttpClient, private tokenService: TokenService, private toastr: ToastrService) {}
private institutionData = null;
private TodoInstitutions = null;

Expand Down Expand Up @@ -52,10 +55,17 @@ export class DataService {
}

async LoadTodoInstitutions() {
this.TodoInstitutions = await this.http
return this.http
.get<TodoInstitution>(`${environment.api}api/institution`)
.pipe(
catchError(error => {
if (error.status === 401) {
this.toastr.error("Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.", "Login timeout", {disableTimeOut: true});
}
return throwError(error);
})
)
.toPromise();
return this.TodoInstitutions;
}

async loadSingleInstitution(config: { name: string }): Promise<Institution> {
Expand Down

0 comments on commit 5d5e4fd

Please sign in to comment.