Skip to content

Commit e3606ef

Browse files
author
Néstor Diaz
authored
Add not found page (#444)
1 parent 2ec6d8a commit e3606ef

8 files changed

Lines changed: 81 additions & 39 deletions

File tree

src/app/app-routing.module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import { PasswordResetReqComponent } from './auth/password-reset/password-reset-
77
import { PasswordResetComponent } from './auth/password-reset/password-reset.component';
88
import { SignInComponent } from './auth/signin/signin.component';
99
import { SignUpComponent } from './auth/signup/signup.component';
10+
import { NotFoundComponent } from './pages/not-found/not-found.component';
1011

1112
const appRoutes: Routes = [
12-
{ path: '', redirectTo: 'submissions', pathMatch: 'full' },
13-
{ path: '', loadChildren: () => import('./pages/pages.module').then((m) => m.PagesModule) },
1413
{ path: 'signin', component: SignInComponent },
1514
{ path: 'signup', component: SignUpComponent },
1615
{ path: 'activate/:key', component: ActivateComponent },
1716
{ path: 'password_reset_request', component: PasswordResetReqComponent },
1817
{ path: 'password_reset/:key', component: PasswordResetComponent },
19-
{ path: 'resend_activation_link', component: ActivationLinkReqComponent }
18+
{ path: 'resend_activation_link', component: ActivationLinkReqComponent },
19+
{ path: '', component: SignInComponent },
20+
{ path: '**', component: NotFoundComponent }
2021
];
2122

2223
@NgModule({

src/app/auth-guard.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class AuthGuard implements CanActivate {
99
// tslint:disable-next-line: variable-name
1010
canActivate(_route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
1111
if (this.userSession.isAnonymous()) {
12-
this.router.navigate(['/signin', { next: state.url }]);
12+
this.router.navigate(['/signin'], { queryParams: { next: state.url } });
1313
return false;
1414
} else {
1515
return true;

src/app/auth/signin/signin.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ export class SignInComponent implements OnInit {
2424

2525
ngOnInit(): void {
2626
if (!this.userSession.isAnonymous()) {
27-
this.router.navigate(['']);
27+
this.router.navigate(['submissions']);
2828
}
2929
}
3030

3131
onSubmit(form: NgForm): void {
3232
this.resetGlobalError();
33-
const next = this.route.snapshot.paramMap.get('next') || '/submissions';
33+
const next = this.route.snapshot.queryParamMap.get('next') || '/submissions';
3434

3535
if (form.valid) {
3636
this.isLoading = true;
3737
this.authService.login(this.model).subscribe(
3838
(user: UserInfo) => {
3939
this.userSession.create(user);
40-
this.router.navigate([next]);
40+
this.router.navigateByUrl(next);
4141
},
4242
(error: ServerError) => {
4343
this.isLoading = false;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="container text-center mt-5">
2+
<div class="row">
3+
<div class="col-md-12">
4+
<div class="error-template">
5+
<h1>Oops!</h1>
6+
<h5 class="mb-3">The requested page was not found</h5>
7+
<div class="d-flex justify-content-center">
8+
<a routerLink="/" class="btn btn-primary mr-2">
9+
<i class="fas fa-home"></i>
10+
Home
11+
</a>
12+
<button class="btn btn-light" (click)="sendEmail()"
13+
role="button">
14+
<i class="far fa-envelope"></i>
15+
Contact BioStudies
16+
</button>
17+
</div>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'st-not-found',
5+
templateUrl: './not-found.component.html'
6+
})
7+
export class NotFoundComponent {
8+
sendEmail(): void {
9+
window.location.href = 'mailto:biostudies@ebi.ac.uk?Subject=BioStudies Submission Tool Page not found';
10+
}
11+
}

src/app/pages/pages-routing.module.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,45 @@ import { AuthGuard } from 'app/auth-guard.service';
66
import { DirectSubmitComponent } from './submission/submission-direct/direct-submit.component';
77
import { SubmissionEditComponent } from './submission/submission-edit/submission-edit.component';
88
import { SubmListComponent } from './submission/submission-list/subm-list.component';
9+
import { PagesComponent } from './pages.component';
910

1011
const pagesRoutes: Routes = [
1112
{ path: 'help', component: HelpComponent },
1213
{ path: 'files', component: FileListComponent, canActivate: [AuthGuard] },
1314
{
1415
path: 'submissions',
15-
component: SubmListComponent,
16+
component: PagesComponent,
1617
data: { isSent: true, reuse: true },
17-
canActivate: [AuthGuard]
18-
},
19-
{
20-
path: 'submissions/draft',
21-
component: SubmListComponent,
22-
data: { isSent: false, reuse: true },
23-
canActivate: [AuthGuard]
24-
},
25-
{
26-
path: 'submissions/direct_upload',
27-
component: DirectSubmitComponent,
28-
canActivate: [AuthGuard]
29-
},
30-
{
31-
path: 'submissions/edit/:accno',
32-
component: SubmissionEditComponent,
33-
canActivate: [AuthGuard],
34-
runGuardsAndResolvers: 'always'
35-
},
36-
{
37-
path: 'submissions/new/:accno',
38-
component: SubmissionEditComponent,
39-
data: { isNew: true },
40-
canActivate: [AuthGuard]
41-
},
42-
{
43-
path: 'submissions/:accno',
44-
component: SubmissionEditComponent,
45-
data: { readonly: true },
4618
canActivate: [AuthGuard],
47-
runGuardsAndResolvers: 'always'
19+
children: [
20+
{
21+
path: 'draft',
22+
component: SubmListComponent,
23+
data: { isSent: false, reuse: true }
24+
},
25+
{ path: 'direct_upload', component: DirectSubmitComponent },
26+
{
27+
path: 'edit/:accno',
28+
component: SubmissionEditComponent,
29+
runGuardsAndResolvers: 'always'
30+
},
31+
{
32+
path: 'new/:accno',
33+
component: SubmissionEditComponent,
34+
data: { isNew: true }
35+
},
36+
{
37+
path: ':accno',
38+
component: SubmissionEditComponent,
39+
data: { readonly: true },
40+
runGuardsAndResolvers: 'always'
41+
},
42+
{
43+
path: '',
44+
component: SubmListComponent,
45+
data: { isSent: true, reuse: true }
46+
}
47+
]
4848
}
4949
];
5050

src/app/pages/pages.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'st-page',
5+
template: '<router-outlet></router-outlet>'
6+
})
7+
export class PagesComponent {}

src/app/pages/pages.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { SharedModule } from 'app/shared/shared.module';
3+
import { PagesComponent } from './pages.component';
4+
import { NotFoundComponent } from './not-found/not-found.component';
35
import { HelpComponent } from './help/help.component';
46
import { PagesRoutingModule } from './pages-routing.module';
57
import { SubmissionDirectModule } from './submission/submission-direct/submission-direct.module';
@@ -16,6 +18,6 @@ import { FileModule } from './file/file.module';
1618
SubmissionEditModule,
1719
SubmissionListModule
1820
],
19-
declarations: [HelpComponent]
21+
declarations: [PagesComponent, HelpComponent, NotFoundComponent]
2022
})
2123
export class PagesModule {}

0 commit comments

Comments
 (0)