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