]>
Commit | Line | Data |
---|---|---|
19b7ebfa RK |
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' | |
a51bad1a C |
4 | |
5 | @Component({ | |
6 | selector: 'my-page-not-found', | |
7 | templateUrl: './page-not-found.component.html', | |
8 | styleUrls: [ './page-not-found.component.scss' ] | |
9 | }) | |
19b7ebfa RK |
10 | export class PageNotFoundComponent implements OnInit { |
11 | status = HttpStatusCode.NOT_FOUND_404 | |
a51bad1a | 12 | |
19b7ebfa RK |
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 | } | |
a51bad1a | 37 | } |