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