]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+page-not-found/page-not-found.component.ts
Add account setup message to welcome alert after signup
[github/Chocobozzz/PeerTube.git] / client / src / app / +page-not-found / page-not-found.component.ts
index c91bb8649bf19185f0a665afb4ef679dcb900f63..10645a634597a0269b358cac42f73d477cf98b43 100644 (file)
@@ -1,10 +1,46 @@
-import { Component } from '@angular/core'
+import { Component, OnInit } from '@angular/core'
+import { Title } from '@angular/platform-browser'
+import { Router } from '@angular/router'
+import { HttpStatusCode } from '@shared/models'
 
 @Component({
   selector: 'my-page-not-found',
   templateUrl: './page-not-found.component.html',
   styleUrls: [ './page-not-found.component.scss' ]
 })
-export class PageNotFoundComponent {
+export class PageNotFoundComponent implements OnInit {
+  status = HttpStatusCode.NOT_FOUND_404
+  type: 'video' | 'other' = 'other'
 
+  public constructor (
+    private titleService: Title,
+    private router: Router
+  ) {
+    const state = this.router.getCurrentNavigation()?.extras.state
+    this.type = state?.type || this.type
+    this.status = state?.obj.status || this.status
+  }
+
+  ngOnInit () {
+    if (this.pathname.includes('teapot')) {
+      this.status = HttpStatusCode.I_AM_A_TEAPOT_418
+      this.titleService.setTitle($localize`I'm a teapot` + ' - PeerTube')
+    }
+  }
+
+  get pathname () {
+    return window.location.pathname
+  }
+
+  getMascotName () {
+    switch (this.status) {
+      case HttpStatusCode.I_AM_A_TEAPOT_418:
+        return 'happy'
+      case HttpStatusCode.FORBIDDEN_403:
+        return 'arguing'
+      case HttpStatusCode.NOT_FOUND_404:
+      default:
+        return 'defeated'
+    }
+  }
 }