-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getDefaultServer static method to AppCconfig and updated the ap…
…plication to use it. This includes introducing a new route guard on search routes that contain a gene but no server. For now, the method returns the first server in the list of servers in the config file.
- Loading branch information
1 parent
26f037d
commit c93449a
Showing
6 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Angular | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; | ||
// store | ||
import { Store } from "@ngrx/store"; | ||
import * as routerActions from "../store/actions/router.actions"; | ||
import * as fromRoot from "../store/reducers"; | ||
// app | ||
import { AppConfig } from "../app.config"; | ||
|
||
@Injectable() | ||
export class DefaultSearchGuard implements CanActivate { | ||
|
||
constructor(private router: Router, private store: Store<fromRoot.State>) { } | ||
|
||
// this guard is only triggered when no server is provided, which Search needs, | ||
// so instead of activating it always redirects to the default server | ||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { | ||
const url = "/search" + | ||
"/" + AppConfig.getDefaultServer().id + | ||
"/" + route.params.gene; | ||
this.store.dispatch(new routerActions.Go({path: [url, {routeParam: 1}]})); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { DefaultSearchGuard } from "./default-search.guard"; | ||
import { MultiGuard } from "./multi.guard"; | ||
import { SearchGuard } from "./search.guard"; | ||
|
||
export const guards: any[] = [ | ||
DefaultSearchGuard, | ||
MultiGuard, | ||
SearchGuard, | ||
]; | ||
|
||
export * from "./default-search.guard"; | ||
export * from "./multi.guard"; | ||
export * from "./search.guard"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters