]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app.component.ts
Begin video watch design
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { Router } from '@angular/router'
3 import { AuthService, ServerService } from './core'
4
5 @Component({
6 selector: 'my-app',
7 templateUrl: './app.component.html',
8 styleUrls: [ './app.component.scss' ]
9 })
10 export class AppComponent implements OnInit {
11 notificationOptions = {
12 timeOut: 5000,
13 lastOnBottom: true,
14 clickToClose: true,
15 maxLength: 0,
16 maxStack: 7,
17 showProgressBar: false,
18 pauseOnHover: false,
19 preventDuplicates: false,
20 preventLastDuplicates: 'visible',
21 rtl: false
22 }
23
24 isMenuDisplayed = true
25
26 constructor (
27 private router: Router,
28 private authService: AuthService,
29 private serverService: ServerService
30 ) {}
31
32 ngOnInit () {
33 this.authService.loadClientCredentials()
34
35 if (this.authService.isLoggedIn()) {
36 // The service will automatically redirect to the login page if the token is not valid anymore
37 this.authService.refreshUserInformation()
38 }
39
40 // Load custom data from server
41 this.serverService.loadConfig()
42 this.serverService.loadVideoCategories()
43 this.serverService.loadVideoLanguages()
44 this.serverService.loadVideoLicences()
45 this.serverService.loadVideoPrivacies()
46
47 // Do not display menu on small screens
48 if (window.innerWidth < 600) {
49 this.isMenuDisplayed = false
50 }
51 }
52
53 isInAdmin () {
54 return this.router.url.indexOf('/admin/') !== -1
55 }
56
57 toggleMenu () {
58 window.scrollTo(0, 0)
59 this.isMenuDisplayed = !this.isMenuDisplayed
60 }
61
62 getMainColClasses () {
63 // Take all width is the menu is not displayed
64 if (this.isMenuDisplayed === false) return [ 'expanded' ]
65
66 return []
67 }
68 }