]>
Commit | Line | Data |
---|---|---|
df98563e C |
1 | import { Component, OnInit, ViewContainerRef } from '@angular/core' |
2 | import { Router } from '@angular/router' | |
dc8bc31b | 3 | |
db7af09b | 4 | import { AuthService, ServerService } from './core' |
df98563e | 5 | import { UserService } from './shared' |
e2a2d6c8 | 6 | |
dc8bc31b | 7 | @Component({ |
3154f382 C |
8 | selector: 'my-app', |
9 | templateUrl: './app.component.html', | |
10 | styleUrls: [ './app.component.scss' ] | |
dc8bc31b | 11 | }) |
e2a2d6c8 | 12 | export class AppComponent implements OnInit { |
7ddd02c9 | 13 | notificationOptions = { |
35bf0c83 | 14 | timeOut: 5000, |
7ddd02c9 C |
15 | lastOnBottom: true, |
16 | clickToClose: true, | |
17 | maxLength: 0, | |
18 | maxStack: 7, | |
19 | showProgressBar: false, | |
20 | pauseOnHover: false, | |
21 | preventDuplicates: false, | |
22 | preventLastDuplicates: 'visible', | |
23 | rtl: false | |
df98563e | 24 | } |
7ddd02c9 | 25 | |
df98563e | 26 | isMenuDisplayed = true |
67167390 | 27 | |
df98563e | 28 | constructor ( |
3154f382 | 29 | private router: Router, |
e2a2d6c8 | 30 | private authService: AuthService, |
db7af09b | 31 | private serverService: ServerService, |
a685e25c | 32 | private userService: UserService |
3154f382 | 33 | ) {} |
a99593ed | 34 | |
df98563e | 35 | ngOnInit () { |
d592e0a9 C |
36 | this.authService.loadClientCredentials() |
37 | ||
e2a2d6c8 C |
38 | if (this.authService.isLoggedIn()) { |
39 | // The service will automatically redirect to the login page if the token is not valid anymore | |
bcd9f81e | 40 | this.authService.refreshUserInformation() |
e2a2d6c8 | 41 | } |
6e07c3de | 42 | |
db7af09b C |
43 | // Load custom data from server |
44 | this.serverService.loadConfig() | |
45 | this.serverService.loadVideoCategories() | |
46 | this.serverService.loadVideoLanguages() | |
47 | this.serverService.loadVideoLicences() | |
3eeeb87f C |
48 | |
49 | // Do not display menu on small screens | |
50 | if (window.innerWidth < 600) { | |
df98563e | 51 | this.isMenuDisplayed = false |
3eeeb87f | 52 | } |
e2a2d6c8 C |
53 | } |
54 | ||
df98563e C |
55 | isInAdmin () { |
56 | return this.router.url.indexOf('/admin/') !== -1 | |
dc8bc31b | 57 | } |
67167390 | 58 | |
df98563e C |
59 | toggleMenu () { |
60 | this.isMenuDisplayed = !this.isMenuDisplayed | |
67167390 C |
61 | } |
62 | ||
df98563e | 63 | getMainColClasses () { |
67167390 C |
64 | const colSizes = { |
65 | md: 10, | |
66 | sm: 9, | |
67 | xs: 9 | |
df98563e | 68 | } |
67167390 C |
69 | |
70 | // Take all width is the menu is not displayed | |
71 | if (this.isMenuDisplayed === false) { | |
df98563e | 72 | Object.keys(colSizes).forEach(col => colSizes[col] = 12) |
67167390 C |
73 | } |
74 | ||
df98563e C |
75 | const classes = [ 'main-col' ] |
76 | Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`)) | |
67167390 | 77 | |
df98563e | 78 | return classes |
67167390 | 79 | } |
dc8bc31b | 80 | } |