diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-24 03:02:04 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-01-25 15:37:26 +0100 |
commit | ab398a05e9ffaacb8fc713bb2ba9717ac463b34c (patch) | |
tree | d73c6debfcc14c0dc05c681bb442e6f6fb6ce3a7 /client/src/app/+page-not-found/page-not-found.component.ts | |
parent | 6939cbac48e0a9823b34577836480ae3c28186be (diff) | |
download | PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.tar.gz PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.tar.zst PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.zip |
redirect to login on 401, display error variants in 404 component
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 | 22 |
1 files changed, 20 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 81830d415..9302201ea 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,5 +1,6 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { Title } from '@angular/platform-browser' | 2 | import { Title } from '@angular/platform-browser' |
3 | import { Router } from '@angular/router' | ||
3 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
4 | 5 | ||
5 | @Component({ | 6 | @Component({ |
@@ -9,10 +10,16 @@ import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | |||
9 | }) | 10 | }) |
10 | export class PageNotFoundComponent implements OnInit { | 11 | export class PageNotFoundComponent implements OnInit { |
11 | status = HttpStatusCode.NOT_FOUND_404 | 12 | status = HttpStatusCode.NOT_FOUND_404 |
13 | type: string | ||
12 | 14 | ||
13 | public constructor ( | 15 | public constructor ( |
14 | private titleService: Title | 16 | private titleService: Title, |
15 | ) {} | 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 | } | ||
16 | 23 | ||
17 | ngOnInit () { | 24 | ngOnInit () { |
18 | if (this.pathname.includes('teapot')) { | 25 | if (this.pathname.includes('teapot')) { |
@@ -25,10 +32,21 @@ export class PageNotFoundComponent implements OnInit { | |||
25 | return window.location.pathname | 32 | return window.location.pathname |
26 | } | 33 | } |
27 | 34 | ||
35 | getRessourceName () { | ||
36 | switch (this.type) { | ||
37 | case 'video': | ||
38 | return $localize`video` | ||
39 | default: | ||
40 | return $localize`ressource` | ||
41 | } | ||
42 | } | ||
43 | |||
28 | getMascotName () { | 44 | getMascotName () { |
29 | switch (this.status) { | 45 | switch (this.status) { |
30 | case HttpStatusCode.I_AM_A_TEAPOT_418: | 46 | case HttpStatusCode.I_AM_A_TEAPOT_418: |
31 | return 'happy' | 47 | return 'happy' |
48 | case HttpStatusCode.FORBIDDEN_403: | ||
49 | return 'arguing' | ||
32 | case HttpStatusCode.NOT_FOUND_404: | 50 | case HttpStatusCode.NOT_FOUND_404: |
33 | default: | 51 | default: |
34 | return 'defeated' | 52 | return 'defeated' |