Skip to content

Commit 52c39a6

Browse files
authored
Add browser not supported page. Resolves #1140. (#1157)
1 parent 6a57084 commit 52c39a6

File tree

7 files changed

+209
-123
lines changed

7 files changed

+209
-123
lines changed

maintenance/explore/cell.png

287 KB
Loading

spa/src/app/app.routes.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* UCSC Genomics Institute - CGL
3-
* https://cgl.genomics.ucsc.edu/
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
44
*
5-
* Set of top-level routes used by Boardwalk.
5+
* Set of top-level routes used by HCA Data Portal.
66
*/
77

88
// Core dependencies
@@ -11,22 +11,29 @@ import { Route } from "@angular/router";
1111
// App components
1212
import { ErrorComponent } from "./system/error/error.component";
1313
import { NotFoundComponent } from "./system/not-found/not-found.component";
14+
import { BrowserCanActivateGuard } from "./shared/routing/browser.can-activate.guard";
1415

1516
export const AppRoutes: Route[] = [
1617
{
1718
path: "",
18-
redirectTo: "/projects",
19-
pathMatch: "full"
20-
}, {
21-
path: "error",
22-
component: ErrorComponent
23-
}, {
24-
path: "not-found",
25-
component: NotFoundComponent
26-
},
27-
{
28-
path: "**",
29-
redirectTo: "/projects",
30-
pathMatch: "full"
19+
canActivate: [BrowserCanActivateGuard],
20+
children: [
21+
{
22+
path: "",
23+
redirectTo: "/projects",
24+
pathMatch: "full"
25+
}, {
26+
path: "error",
27+
component: ErrorComponent
28+
}, {
29+
path: "not-found",
30+
component: NotFoundComponent
31+
},
32+
{
33+
path: "**",
34+
redirectTo: "/projects",
35+
pathMatch: "full"
36+
}
37+
]
3138
}
3239
];

spa/src/app/files/files.routes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,27 @@ import { ProjectSummaryStatsComponent } from "./project-summary-stats-component/
2424
import { ReleaseComponent } from "./releases/release.component";
2525
import { ReleaseFilesModalContainerComponent } from "./releases/release-files-modal-container/release-files-modal-container.component";
2626
import { ReleaseVisualizationsModalContainerComponent } from "./releases/visualizations-modal-container/release-visualizations-modal-container.component";
27+
import { BrowserCanActivateGuard } from "../shared/routing/browser.can-activate.guard";
2728

2829
export const routes: Route[] = [
2930
{
3031
path: "files",
32+
canActivate: [BrowserCanActivateGuard],
3133
component: FilesComponent
3234
},
3335
{
3436
path: "get-data",
37+
canActivate: [BrowserCanActivateGuard],
3538
component: HCAGetDataComponent
3639
},
3740
{
3841
path: "samples",
42+
canActivate: [BrowserCanActivateGuard],
3943
component: FilesComponent
4044
},
4145
{
4246
path: "projects",
47+
canActivate: [BrowserCanActivateGuard],
4348
children: [
4449
{
4550
path: "",
@@ -56,7 +61,7 @@ export const routes: Route[] = [
5661
},
5762
{
5863
path: "project-metadata",
59-
component: ProjectMetadataComponent
64+
component: ProjectMetadataComponent,
6065
},
6166
{
6267
path: "expression-matrices",
@@ -99,6 +104,7 @@ export const routes: Route[] = [
99104
},
100105
{
101106
path: "releases/2020-mar",
107+
canActivate: [BrowserCanActivateGuard],
102108
component: ReleaseComponent
103109
}
104110
];
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Determines if current browser is supported and if so, allows navigation to continue. If browser is not supported,
6+
* exits out of Angular and loads BNS page by updating the address bar.
7+
*/
8+
9+
// Core dependencies
10+
import { Injectable } from "@angular/core";
11+
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from "@angular/router";
12+
import { DeviceDetectorService } from "ngx-device-detector";
13+
14+
@Injectable()
15+
export class BrowserCanActivateGuard implements CanActivate {
16+
17+
/**
18+
* @param {DeviceDetectorService} deviceService
19+
*/
20+
constructor(private deviceService: DeviceDetectorService) {}
21+
22+
/**
23+
* Returns true if browser is supported and navigation can continue.
24+
*
25+
* @param {ActivatedRouteSnapshot} route
26+
* @param {RouterStateSnapshot} state
27+
* @returns {boolean}
28+
*/
29+
canActivate(route: ActivatedRouteSnapshot,
30+
state: RouterStateSnapshot): boolean {
31+
32+
return this.isBrowserSupported();
33+
}
34+
35+
/**
36+
* Returns true if browser is supported.
37+
*
38+
* @returns {boolean}
39+
*/
40+
private isBrowserSupported(): boolean {
41+
42+
// Display browser not supported for Internet Explorer.
43+
if ( this.deviceService.browser === "IE" ) {
44+
45+
window.location.href = "/static/browser-not-supported.html";
46+
return false;
47+
}
48+
49+
return true;
50+
}
51+
}

spa/src/app/shared/shared.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { FileDownloadComponent } from "./file-download/file-download.component";
3939
import { CopyToClipboardComponent } from "./copy-to-clipboard/copy-to-clipboard.component";
4040
import { NavComponent } from "./nav/nav.component";
4141
import { NoHitsComponent } from "./no-hits/no-hits.component";
42+
import { BrowserCanActivateGuard } from "./routing/browser.can-activate.guard";
4243

4344
@NgModule({
4445
imports: [
@@ -74,6 +75,7 @@ import { NoHitsComponent } from "./no-hits/no-hits.component";
7475
WarningTitleComponent
7576
],
7677
providers: [
78+
BrowserCanActivateGuard,
7779
GTMService,
7880
ResponsiveService
7981
],

spa/src/assets/images/cell/cell.png

1.34 MB
Loading

0 commit comments

Comments
 (0)