diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-03 13:13:46 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-03 14:55:47 +0100 |
commit | 19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6 (patch) | |
tree | ab602e242c52e0936eb8f958acfc343bd14f540e /client/src/app/+page-not-found/page-not-found.component.ts | |
parent | 5bfc33b6f1caa50c607bd7334b4a72003c2bd1a6 (diff) | |
download | PeerTube-19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6.tar.gz PeerTube-19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6.tar.zst PeerTube-19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6.zip |
refactor 404 page
Diffstat (limited to 'client/src/app/+page-not-found/page-not-found.component.ts')
-rw-r--r-- | client/src/app/+page-not-found/page-not-found.component.ts | 31 |
1 files changed, 29 insertions, 2 deletions
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 @@ | |||
1 | import { Component } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { Title } from '@angular/platform-browser' | ||
3 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
2 | 4 | ||
3 | @Component({ | 5 | @Component({ |
4 | selector: 'my-page-not-found', | 6 | selector: 'my-page-not-found', |
5 | templateUrl: './page-not-found.component.html', | 7 | templateUrl: './page-not-found.component.html', |
6 | styleUrls: [ './page-not-found.component.scss' ] | 8 | styleUrls: [ './page-not-found.component.scss' ] |
7 | }) | 9 | }) |
8 | export class PageNotFoundComponent { | 10 | export class PageNotFoundComponent implements OnInit { |
11 | status = HttpStatusCode.NOT_FOUND_404 | ||
9 | 12 | ||
13 | public constructor ( | ||
14 | private titleService: Title | ||
15 | ) {} | ||
16 | |||
17 | ngOnInit () { | ||
18 | if (this.pathname.includes('teapot')) { | ||
19 | this.status = HttpStatusCode.I_AM_A_TEAPOT_418 | ||
20 | this.titleService.setTitle($localize`I'm a teapot` + ' - PeerTube') | ||
21 | } | ||
22 | } | ||
23 | |||
24 | get pathname () { | ||
25 | return window.location.pathname | ||
26 | } | ||
27 | |||
28 | getMascotName () { | ||
29 | switch (this.status) { | ||
30 | case HttpStatusCode.I_AM_A_TEAPOT_418: | ||
31 | return 'happy' | ||
32 | case HttpStatusCode.NOT_FOUND_404: | ||
33 | default: | ||
34 | return 'defeated' | ||
35 | } | ||
36 | } | ||
10 | } | 37 | } |