1 import { Component, OnInit } from '@angular/core'
2 import { NavigationEnd, Router } from '@angular/router'
3 import { AuthService, ServerService } from '@app/core'
4 import { isInMobileView } from '@app/shared/misc/utils'
8 templateUrl: './app.component.html',
9 styleUrls: [ './app.component.scss' ]
11 export class AppComponent implements OnInit {
12 notificationOptions = {
18 showProgressBar: false,
20 preventDuplicates: false,
21 preventLastDuplicates: 'visible',
25 isMenuDisplayed = true
28 private router: Router,
29 private authService: AuthService,
30 private serverService: ServerService
33 get serverVersion () {
34 return this.serverService.getConfig().serverVersion
38 this.authService.loadClientCredentials()
40 if (this.authService.isLoggedIn()) {
41 // The service will automatically redirect to the login page if the token is not valid anymore
42 this.authService.refreshUserInformation()
45 // Load custom data from server
46 this.serverService.loadConfig()
47 this.serverService.loadVideoCategories()
48 this.serverService.loadVideoLanguages()
49 this.serverService.loadVideoLicences()
50 this.serverService.loadVideoPrivacies()
52 // Do not display menu on small screens
53 if (isInMobileView()) {
54 this.isMenuDisplayed = false
57 this.router.events.subscribe(
59 // User clicked on a link in the menu, change the page
60 if (e instanceof NavigationEnd && isInMobileView()) {
61 this.isMenuDisplayed = false
69 this.isMenuDisplayed = !this.isMenuDisplayed
72 getMainColClasses () {
73 // Take all width is the menu is not displayed
74 if (this.isMenuDisplayed === false) return [ 'expanded' ]