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