From 19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 3 Dec 2020 13:13:46 +0100 Subject: refactor 404 page --- .../+page-not-found/page-not-found.component.ts | 31 ++++++++++++++++++++-- 1 file changed, 29 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 c91bb8649..81830d415 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,10 +1,37 @@ -import { Component } from '@angular/core' +import { Component, OnInit } from '@angular/core' +import { Title } from '@angular/platform-browser' +import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' @Component({ selector: 'my-page-not-found', templateUrl: './page-not-found.component.html', styleUrls: [ './page-not-found.component.scss' ] }) -export class PageNotFoundComponent { +export class PageNotFoundComponent implements OnInit { + status = HttpStatusCode.NOT_FOUND_404 + public constructor ( + private titleService: Title + ) {} + + ngOnInit () { + if (this.pathname.includes('teapot')) { + this.status = HttpStatusCode.I_AM_A_TEAPOT_418 + this.titleService.setTitle($localize`I'm a teapot` + ' - PeerTube') + } + } + + get pathname () { + return window.location.pathname + } + + getMascotName () { + switch (this.status) { + case HttpStatusCode.I_AM_A_TEAPOT_418: + return 'happy' + case HttpStatusCode.NOT_FOUND_404: + default: + return 'defeated' + } + } } -- cgit v1.2.3