]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.component.ts
Mobile version: menu full width and autoclosed
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
CommitLineData
fd45e8f4 1import { Component, OnInit } from '@angular/core'
c8cf5952 2import { NavigationEnd, Router } from '@angular/router'
4cb6d457 3import { AuthService, ServerService } from '@app/core'
e2a2d6c8 4
dc8bc31b 5@Component({
3154f382
C
6 selector: 'my-app',
7 templateUrl: './app.component.html',
8 styleUrls: [ './app.component.scss' ]
dc8bc31b 9})
e2a2d6c8 10export class AppComponent implements OnInit {
7ddd02c9 11 notificationOptions = {
35bf0c83 12 timeOut: 5000,
7ddd02c9
C
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
df98563e 22 }
7ddd02c9 23
df98563e 24 isMenuDisplayed = true
67167390 25
df98563e 26 constructor (
3154f382 27 private router: Router,
e2a2d6c8 28 private authService: AuthService,
fd45e8f4 29 private serverService: ServerService
3154f382 30 ) {}
a99593ed 31
df98563e 32 ngOnInit () {
d592e0a9
C
33 this.authService.loadClientCredentials()
34
e2a2d6c8
C
35 if (this.authService.isLoggedIn()) {
36 // The service will automatically redirect to the login page if the token is not valid anymore
bcd9f81e 37 this.authService.refreshUserInformation()
e2a2d6c8 38 }
6e07c3de 39
db7af09b
C
40 // Load custom data from server
41 this.serverService.loadConfig()
42 this.serverService.loadVideoCategories()
43 this.serverService.loadVideoLanguages()
44 this.serverService.loadVideoLicences()
fd45e8f4 45 this.serverService.loadVideoPrivacies()
3eeeb87f
C
46
47 // Do not display menu on small screens
48 if (window.innerWidth < 600) {
df98563e 49 this.isMenuDisplayed = false
3eeeb87f 50 }
c8cf5952
C
51
52 this.router.events.subscribe(
53 e => {
54 // User clicked on a link in the menu, change the page
55 if (e instanceof NavigationEnd && window.innerWidth < 600) {
56 this.isMenuDisplayed = false
57 }
58 }
59 )
e2a2d6c8
C
60 }
61
df98563e 62 toggleMenu () {
a01f107b 63 window.scrollTo(0, 0)
df98563e 64 this.isMenuDisplayed = !this.isMenuDisplayed
67167390
C
65 }
66
df98563e 67 getMainColClasses () {
67167390 68 // Take all width is the menu is not displayed
b33f657c 69 if (this.isMenuDisplayed === false) return [ 'expanded' ]
67167390 70
b33f657c 71 return []
67167390 72 }
dc8bc31b 73}