]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+page-not-found/page-not-found.component.ts
Cleanup
[github/Chocobozzz/PeerTube.git] / client / src / app / +page-not-found / page-not-found.component.ts
CommitLineData
19b7ebfa
RK
1import { Component, OnInit } from '@angular/core'
2import { Title } from '@angular/platform-browser'
ab398a05 3import { Router } from '@angular/router'
19b7ebfa 4import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
a51bad1a 5
012580d9 6
a51bad1a
C
7@Component({
8 selector: 'my-page-not-found',
9 templateUrl: './page-not-found.component.html',
10 styleUrls: [ './page-not-found.component.scss' ]
11})
19b7ebfa
RK
12export class PageNotFoundComponent implements OnInit {
13 status = HttpStatusCode.NOT_FOUND_404
012580d9 14 type: 'video' | 'other' = 'other'
a51bad1a 15
19b7ebfa 16 public constructor (
ab398a05
RK
17 private titleService: Title,
18 private router: Router
19 ) {
20 const state = this.router.getCurrentNavigation()?.extras.state
21 this.type = state?.type || this.type
22 this.status = state?.obj.status || this.status
23 }
19b7ebfa
RK
24
25 ngOnInit () {
26 if (this.pathname.includes('teapot')) {
27 this.status = HttpStatusCode.I_AM_A_TEAPOT_418
28 this.titleService.setTitle($localize`I'm a teapot` + ' - PeerTube')
29 }
30 }
31
32 get pathname () {
33 return window.location.pathname
34 }
35
36 getMascotName () {
37 switch (this.status) {
38 case HttpStatusCode.I_AM_A_TEAPOT_418:
39 return 'happy'
ab398a05
RK
40 case HttpStatusCode.FORBIDDEN_403:
41 return 'arguing'
19b7ebfa
RK
42 case HttpStatusCode.NOT_FOUND_404:
43 default:
44 return 'defeated'
45 }
46 }
a51bad1a 47}