]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.component.ts
Fix error display on signup page
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
CommitLineData
fd45e8f4 1import { Component, OnInit } from '@angular/core'
df98563e 2import { Router } from '@angular/router'
dc8bc31b 3
db7af09b 4import { AuthService, ServerService } from './core'
df98563e 5import { UserService } from './shared'
e2a2d6c8 6
dc8bc31b 7@Component({
3154f382
C
8 selector: 'my-app',
9 templateUrl: './app.component.html',
10 styleUrls: [ './app.component.scss' ]
dc8bc31b 11})
e2a2d6c8 12export class AppComponent implements OnInit {
7ddd02c9 13 notificationOptions = {
35bf0c83 14 timeOut: 5000,
7ddd02c9
C
15 lastOnBottom: true,
16 clickToClose: true,
17 maxLength: 0,
18 maxStack: 7,
19 showProgressBar: false,
20 pauseOnHover: false,
21 preventDuplicates: false,
22 preventLastDuplicates: 'visible',
23 rtl: false
df98563e 24 }
7ddd02c9 25
df98563e 26 isMenuDisplayed = true
67167390 27
df98563e 28 constructor (
3154f382 29 private router: Router,
e2a2d6c8 30 private authService: AuthService,
fd45e8f4 31 private serverService: ServerService
3154f382 32 ) {}
a99593ed 33
df98563e 34 ngOnInit () {
d592e0a9
C
35 this.authService.loadClientCredentials()
36
e2a2d6c8
C
37 if (this.authService.isLoggedIn()) {
38 // The service will automatically redirect to the login page if the token is not valid anymore
bcd9f81e 39 this.authService.refreshUserInformation()
e2a2d6c8 40 }
6e07c3de 41
db7af09b
C
42 // Load custom data from server
43 this.serverService.loadConfig()
44 this.serverService.loadVideoCategories()
45 this.serverService.loadVideoLanguages()
46 this.serverService.loadVideoLicences()
fd45e8f4 47 this.serverService.loadVideoPrivacies()
3eeeb87f
C
48
49 // Do not display menu on small screens
50 if (window.innerWidth < 600) {
df98563e 51 this.isMenuDisplayed = false
3eeeb87f 52 }
e2a2d6c8
C
53 }
54
df98563e
C
55 isInAdmin () {
56 return this.router.url.indexOf('/admin/') !== -1
dc8bc31b 57 }
67167390 58
df98563e 59 toggleMenu () {
a01f107b 60 window.scrollTo(0, 0)
df98563e 61 this.isMenuDisplayed = !this.isMenuDisplayed
67167390
C
62 }
63
df98563e 64 getMainColClasses () {
67167390
C
65 const colSizes = {
66 md: 10,
67 sm: 9,
68 xs: 9
df98563e 69 }
67167390
C
70
71 // Take all width is the menu is not displayed
72 if (this.isMenuDisplayed === false) {
df98563e 73 Object.keys(colSizes).forEach(col => colSizes[col] = 12)
67167390
C
74 }
75
a01f107b 76 const classes = []
df98563e 77 Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`))
67167390 78
df98563e 79 return classes
67167390 80 }
dc8bc31b 81}