]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.component.ts
Hide description previews on mobile view
[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'
6693df9d 4import { isInMobileView } from '@app/shared/misc/utils'
e2a2d6c8 5
dc8bc31b 6@Component({
3154f382
C
7 selector: 'my-app',
8 templateUrl: './app.component.html',
9 styleUrls: [ './app.component.scss' ]
dc8bc31b 10})
e2a2d6c8 11export class AppComponent implements OnInit {
7ddd02c9 12 notificationOptions = {
35bf0c83 13 timeOut: 5000,
7ddd02c9
C
14 lastOnBottom: true,
15 clickToClose: true,
16 maxLength: 0,
17 maxStack: 7,
18 showProgressBar: false,
19 pauseOnHover: false,
20 preventDuplicates: false,
21 preventLastDuplicates: 'visible',
22 rtl: false
df98563e 23 }
7ddd02c9 24
df98563e 25 isMenuDisplayed = true
67167390 26
df98563e 27 constructor (
3154f382 28 private router: Router,
e2a2d6c8 29 private authService: AuthService,
fd45e8f4 30 private serverService: ServerService
3154f382 31 ) {}
a99593ed 32
915c5bbe
C
33 get serverVersion () {
34 return this.serverService.getConfig().serverVersion
35 }
36
df98563e 37 ngOnInit () {
d592e0a9
C
38 this.authService.loadClientCredentials()
39
e2a2d6c8
C
40 if (this.authService.isLoggedIn()) {
41 // The service will automatically redirect to the login page if the token is not valid anymore
bcd9f81e 42 this.authService.refreshUserInformation()
e2a2d6c8 43 }
6e07c3de 44
db7af09b
C
45 // Load custom data from server
46 this.serverService.loadConfig()
47 this.serverService.loadVideoCategories()
48 this.serverService.loadVideoLanguages()
49 this.serverService.loadVideoLicences()
fd45e8f4 50 this.serverService.loadVideoPrivacies()
3eeeb87f
C
51
52 // Do not display menu on small screens
6693df9d 53 if (isInMobileView()) {
df98563e 54 this.isMenuDisplayed = false
3eeeb87f 55 }
c8cf5952
C
56
57 this.router.events.subscribe(
58 e => {
59 // User clicked on a link in the menu, change the page
6693df9d 60 if (e instanceof NavigationEnd && isInMobileView()) {
c8cf5952
C
61 this.isMenuDisplayed = false
62 }
63 }
64 )
e2a2d6c8
C
65 }
66
df98563e 67 toggleMenu () {
a01f107b 68 window.scrollTo(0, 0)
df98563e 69 this.isMenuDisplayed = !this.isMenuDisplayed
67167390
C
70 }
71
df98563e 72 getMainColClasses () {
67167390 73 // Take all width is the menu is not displayed
b33f657c 74 if (this.isMenuDisplayed === false) return [ 'expanded' ]
67167390 75
b33f657c 76 return []
67167390 77 }
dc8bc31b 78}