#71 added a generic error view

This commit is contained in:
Fabio Formosa
2022-11-05 20:28:56 +01:00
parent 3242457cce
commit 83401a2ecb
8 changed files with 65 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import {NotFoundComponent} from './views/not-found';
import {ForbiddenComponent} from './views/forbidden';
import {ManagerComponent} from './views/manager';
import {GenericErrorComponent} from './views/error/genericError.component';
export const routes: Routes = [
{
@@ -33,6 +34,10 @@ export const routes: Routes = [
path: '403',
component: ForbiddenComponent
},
{
path: 'error',
component: GenericErrorComponent
},
{
path: '**',
redirectTo: '/404'

View File

@@ -59,9 +59,9 @@ import {
} from './services';
import { ForbiddenComponent } from './views/forbidden/forbidden.component';
import { APP_BASE_HREF } from '@angular/common';
import { environment } from '../environments/environment';
import {SimpleTriggerConfigComponent} from './components/simple-trigger-config';
import JobService from './services/job.service';
import {GenericErrorComponent} from './views/error/genericError.component';
export function initUserFactory(userService: UserService) {
return () => userService.fetchLoggedUser();
@@ -116,6 +116,7 @@ export function jwtOptionsFactory(apiService: ApiService) {
LogsPanelComponent,
ProgressPanelComponent,
ForbiddenComponent,
GenericErrorComponent,
TriggerListComponent
],
imports: [

View File

@@ -35,13 +35,15 @@ export class UserService {
this.currentUser = user;
this.router.initialNavigation();
}, err => {
console.log(`error retrieving current user due to ` + err);
console.log(`error retrieving current user due to ` + JSON.stringify(err));
const httpErrorResponse = err as HttpErrorResponse;
if (httpErrorResponse.status === 404) {
this.isAnAnonymousUser = true;
this.router.initialNavigation();
return;
}
// TODO generic error!
if (httpErrorResponse.status < 200 || httpErrorResponse.status > 399)
this.router.navigateByUrl('/error');
});
}

View File

@@ -0,0 +1,13 @@
<div fxLayout="column" fxLayoutAlign="center" style="text-align: center">
<div>
<div>
<p style="font-size: 4em; margin-bottom: 0">Unexpected Error</p>
<p>Please try again later!</p>
</div>
</div>
<div>
<p>
<img src="assets/image/error.svg" alt="generic error"/>
</p>
</div>
</div>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {GenericErrorComponent} from './genericError.component';
describe('GenericComponent', () => {
let component: GenericErrorComponent;
let fixture: ComponentFixture<GenericErrorComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GenericErrorComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(GenericErrorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'qrzmng-generic-error',
templateUrl: './genericError.component.html',
styleUrls: ['./genericError.component.css']
})
export class GenericErrorComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.7 KiB