Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SBOLCanvasFrontend/src/app/error/error.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1 mat-dialog-title>An error has occurred.</h1>
<mat-expansion-panel>
<mat-expansion-panel [expanded]="true">
<mat-expansion-panel-header>

<mat-panel-description>
Click to view more details.
Click to see less Details.
</mat-panel-description>
</mat-expansion-panel-header>

Expand Down
26 changes: 17 additions & 9 deletions SBOLCanvasFrontend/src/app/http.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Observable, of, throwError } from "rxjs";
import { tap, catchError } from "rxjs/operators";
import { MatDialog } from '@angular/material/dialog';
import { ErrorComponent } from './error/error.component';
import { UploadGraphComponent } from './upload-graph/upload-graph.component';
import { CollectionCreationComponent } from './collection-creation/collection-creation.component';
import { ActivatedRoute } from '@angular/router'
import { LoginService } from './login.service';

Expand Down Expand Up @@ -31,15 +33,9 @@ intercept(
if(err instanceof HttpErrorResponse && err.status === 500) {
!this.ignoreHTTPErrors && this.dialog.open(ErrorComponent, {data: err.error});
}
if (err instanceof HttpErrorResponse && err.status === 401) {
if (err instanceof HttpErrorResponse) {
const url = req.url || '';
const isTargetEndpoint = (
url.includes('/SynBioHub/logout') ||
url.includes('/SynBioHub/listRegistryParts') ||
url.includes('/SynBioHub/listMyCollections')
);

if (isTargetEndpoint) {
const body = err.error;
const permissionMarker = 'org.synbiohub.frontend.PermissionException';
const isPermissionException = typeof body === 'string' && body.indexOf(permissionMarker) >= 0;
Expand All @@ -50,9 +46,21 @@ intercept(

const serverLabel = serverParam || 'the registry';
const message = `Disconnected from ${serverLabel}. Please sign in again.`;
!this.ignoreHTTPErrors && this.dialog.open(ErrorComponent, { data: message });
try {
this.dialog.openDialogs.forEach(d => {
try {
const ci = d.componentInstance;
if (ci instanceof CollectionCreationComponent) {
d.close();
}
} catch(e) {
}
});
} catch(e) {
}

!this.ignoreHTTPErrors && this.dialog.open(ErrorComponent, { data: message });
}
}
}
return throwError(err);
}));
Expand Down