]>
Commit | Line | Data |
---|---|---|
fd45e8f4 | 1 | import { Component, OnInit } from '@angular/core' |
c8cf5952 | 2 | import { NavigationEnd, Router } from '@angular/router' |
4cb6d457 | 3 | import { 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 | 10 | export 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 | |
915c5bbe C |
32 | get serverVersion () { |
33 | return this.serverService.getConfig().serverVersion | |
34 | } | |
35 | ||
df98563e | 36 | ngOnInit () { |
d592e0a9 C |
37 | this.authService.loadClientCredentials() |
38 | ||
e2a2d6c8 C |
39 | if (this.authService.isLoggedIn()) { |
40 | // The service will automatically redirect to the login page if the token is not valid anymore | |
bcd9f81e | 41 | this.authService.refreshUserInformation() |
e2a2d6c8 | 42 | } |
6e07c3de | 43 | |
db7af09b C |
44 | // Load custom data from server |
45 | this.serverService.loadConfig() | |
46 | this.serverService.loadVideoCategories() | |
47 | this.serverService.loadVideoLanguages() | |
48 | this.serverService.loadVideoLicences() | |
fd45e8f4 | 49 | this.serverService.loadVideoPrivacies() |
3eeeb87f C |
50 | |
51 | // Do not display menu on small screens | |
52 | if (window.innerWidth < 600) { | |
df98563e | 53 | this.isMenuDisplayed = false |
3eeeb87f | 54 | } |
c8cf5952 C |
55 | |
56 | this.router.events.subscribe( | |
57 | e => { | |
58 | // User clicked on a link in the menu, change the page | |
59 | if (e instanceof NavigationEnd && window.innerWidth < 600) { | |
60 | this.isMenuDisplayed = false | |
61 | } | |
62 | } | |
63 | ) | |
e2a2d6c8 C |
64 | } |
65 | ||
df98563e | 66 | toggleMenu () { |
a01f107b | 67 | window.scrollTo(0, 0) |
df98563e | 68 | this.isMenuDisplayed = !this.isMenuDisplayed |
67167390 C |
69 | } |
70 | ||
df98563e | 71 | getMainColClasses () { |
67167390 | 72 | // Take all width is the menu is not displayed |
b33f657c | 73 | if (this.isMenuDisplayed === false) return [ 'expanded' ] |
67167390 | 74 | |
b33f657c | 75 | return [] |
67167390 | 76 | } |
dc8bc31b | 77 | } |