From ab398a05e9ffaacb8fc713bb2ba9717ac463b34c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 24 Jan 2021 03:02:04 +0100 Subject: redirect to login on 401, display error variants in 404 component --- .../+page-not-found/page-not-found.component.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'client/src/app/+page-not-found/page-not-found.component.ts') diff --git a/client/src/app/+page-not-found/page-not-found.component.ts b/client/src/app/+page-not-found/page-not-found.component.ts index 81830d415..9302201ea 100644 --- a/client/src/app/+page-not-found/page-not-found.component.ts +++ b/client/src/app/+page-not-found/page-not-found.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core' import { Title } from '@angular/platform-browser' +import { Router } from '@angular/router' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' @Component({ @@ -9,10 +10,16 @@ import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' }) export class PageNotFoundComponent implements OnInit { status = HttpStatusCode.NOT_FOUND_404 + type: string public constructor ( - private titleService: Title - ) {} + private titleService: Title, + private router: Router + ) { + const state = this.router.getCurrentNavigation()?.extras.state + this.type = state?.type || this.type + this.status = state?.obj.status || this.status + } ngOnInit () { if (this.pathname.includes('teapot')) { @@ -25,10 +32,21 @@ export class PageNotFoundComponent implements OnInit { return window.location.pathname } + getRessourceName () { + switch (this.type) { + case 'video': + return $localize`video` + default: + return $localize`ressource` + } + } + getMascotName () { switch (this.status) { case HttpStatusCode.I_AM_A_TEAPOT_418: return 'happy' + case HttpStatusCode.FORBIDDEN_403: + return 'arguing' case HttpStatusCode.NOT_FOUND_404: default: return 'defeated' -- cgit v1.2.3