]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnInit } from '@angular/core' | |
2 | import { NavigationEnd, Router } from '@angular/router' | |
3 | import { AuthService, ServerService } from '@app/core' | |
4 | ||
5 | @Component({ | |
6 | selector: 'my-app', | |
7 | templateUrl: './app.component.html', | |
8 | styleUrls: [ './app.component.scss' ] | |
9 | }) | |
10 | export class AppComponent implements OnInit { | |
11 | notificationOptions = { | |
12 | timeOut: 5000, | |
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 | |
22 | } | |
23 | ||
24 | isMenuDisplayed = true | |
25 | ||
26 | constructor ( | |
27 | private router: Router, | |
28 | private authService: AuthService, | |
29 | private serverService: ServerService | |
30 | ) {} | |
31 | ||
32 | get serverVersion () { | |
33 | return this.serverService.getConfig().serverVersion | |
34 | } | |
35 | ||
36 | ngOnInit () { | |
37 | this.authService.loadClientCredentials() | |
38 | ||
39 | if (this.authService.isLoggedIn()) { | |
40 | // The service will automatically redirect to the login page if the token is not valid anymore | |
41 | this.authService.refreshUserInformation() | |
42 | } | |
43 | ||
44 | // Load custom data from server | |
45 | this.serverService.loadConfig() | |
46 | this.serverService.loadVideoCategories() | |
47 | this.serverService.loadVideoLanguages() | |
48 | this.serverService.loadVideoLicences() | |
49 | this.serverService.loadVideoPrivacies() | |
50 | ||
51 | // Do not display menu on small screens | |
52 | if (window.innerWidth < 600) { | |
53 | this.isMenuDisplayed = false | |
54 | } | |
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 | ) | |
64 | } | |
65 | ||
66 | toggleMenu () { | |
67 | window.scrollTo(0, 0) | |
68 | this.isMenuDisplayed = !this.isMenuDisplayed | |
69 | } | |
70 | ||
71 | getMainColClasses () { | |
72 | // Take all width is the menu is not displayed | |
73 | if (this.isMenuDisplayed === false) return [ 'expanded' ] | |
74 | ||
75 | return [] | |
76 | } | |
77 | } |