diff --git a/ui/src/app/app-routing.module.ts b/ui/src/app/app-routing.module.ts index 07f851645..c4fb2f2a4 100644 --- a/ui/src/app/app-routing.module.ts +++ b/ui/src/app/app-routing.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core' import { RouterModule, Routes } from '@angular/router' import { navbarRoute } from './layout/navbar/navbar.route' +import { errorRoutes } from './error/error.route' const routes: Routes = [ { @@ -14,7 +15,7 @@ const routes: Routes = [ ] @NgModule({ - imports: [RouterModule.forRoot([...routes, navbarRoute])], + imports: [RouterModule.forRoot([...routes, ...errorRoutes, navbarRoute])], exports: [RouterModule], }) export class AppRoutingModule {} diff --git a/ui/src/app/error/error-alert.component.ts b/ui/src/app/error/error-alert.component.ts index 426e9053a..c0ac12e53 100644 --- a/ui/src/app/error/error-alert.component.ts +++ b/ui/src/app/error/error-alert.component.ts @@ -18,7 +18,6 @@ export class ErrorAlertComponent implements OnInit { ngOnInit(): void { this.sub = this.errorService.on().subscribe((err: AppError) => { - const alerts = [...this.alerts] const alert: ErrorAlert = { type: 'danger', msg: err.message, diff --git a/ui/src/app/error/error.component.html b/ui/src/app/error/error.component.html index 27d6bed7a..8cfd83ef3 100644 --- a/ui/src/app/error/error.component.html +++ b/ui/src/app/error/error.component.html @@ -1 +1,17 @@ -

error works!

+
+
+
+

Your request cannot be processed

+ +
+
{{ errorMessage }}
+
+
+ You are not authorized to access this page. +
+
+ The page does not exist. +
+
+
+
diff --git a/ui/src/app/error/error.component.spec.ts b/ui/src/app/error/error.component.spec.ts index bfc85b143..7df37e3cb 100644 --- a/ui/src/app/error/error.component.spec.ts +++ b/ui/src/app/error/error.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ErrorComponent } from './error.component'; +import { AppModule } from '../app.module'; describe('ErrorComponent', () => { let component: ErrorComponent; @@ -8,6 +9,7 @@ describe('ErrorComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ + imports: [AppModule], declarations: [ErrorComponent] }); fixture = TestBed.createComponent(ErrorComponent); diff --git a/ui/src/app/error/error.component.ts b/ui/src/app/error/error.component.ts index 4c81fe943..2d9f6cd8d 100644 --- a/ui/src/app/error/error.component.ts +++ b/ui/src/app/error/error.component.ts @@ -1,9 +1,29 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { AccountService } from '../account'; @Component({ selector: 'app-error', templateUrl: './error.component.html' }) -export class ErrorComponent { +export class ErrorComponent implements OnInit { + errorMessage: string | undefined; + error403: boolean | undefined; + error404: boolean | undefined; + constructor(private route: ActivatedRoute, private accountService: AccountService) {} + + ngOnInit() { + this.route.data.subscribe(routeData => { + if (routeData['error403']) { + this.error403 = routeData['error403']; + } + if (routeData['error404']) { + this.error404 = routeData['error404']; + } + if (routeData['errorMessage']) { + this.errorMessage = routeData['errorMessage']; + } + }); + } } diff --git a/ui/src/app/error/error.route.ts b/ui/src/app/error/error.route.ts new file mode 100644 index 000000000..15fe90591 --- /dev/null +++ b/ui/src/app/error/error.route.ts @@ -0,0 +1,36 @@ +import { Routes } from '@angular/router'; + +import { ErrorComponent } from './error.component'; + +export const errorRoutes: Routes = [ + { + path: 'error', + component: ErrorComponent, + data: { + authorities: [], + pageTitle: 'error.title.string' + } + }, + { + path: 'accessdenied', + component: ErrorComponent, + data: { + authorities: [], + pageTitle: 'error.title.string', + error403: true + } + }, + { + path: '404', + component: ErrorComponent, + data: { + authorities: [], + pageTitle: 'error.title.string', + error404: true + } + }, + { + path: '**', + redirectTo: '/404' + } +];