]>
Commit | Line | Data |
---|---|---|
e2a2d6c8 | 1 | import { Component, OnInit, ViewContainerRef } from '@angular/core'; |
ab32b0fc | 2 | import { Router } from '@angular/router'; |
dc8bc31b | 3 | |
92fb909c | 4 | import { AuthService, ConfigService } from './core'; |
6e07c3de | 5 | import { VideoService } from './videos'; |
e2a2d6c8 C |
6 | import { UserService } from './shared'; |
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 | |
25 | }; | |
26 | ||
67167390 C |
27 | isMenuDisplayed = true; |
28 | ||
3154f382 C |
29 | constructor( |
30 | private router: Router, | |
e2a2d6c8 | 31 | private authService: AuthService, |
92fb909c | 32 | private configService: ConfigService, |
e2a2d6c8 | 33 | private userService: UserService, |
6e07c3de | 34 | private videoService: VideoService, |
3154f382 C |
35 | viewContainerRef: ViewContainerRef |
36 | ) {} | |
a99593ed | 37 | |
e2a2d6c8 C |
38 | ngOnInit() { |
39 | if (this.authService.isLoggedIn()) { | |
40 | // The service will automatically redirect to the login page if the token is not valid anymore | |
41 | this.userService.checkTokenValidity(); | |
42 | } | |
6e07c3de | 43 | |
92fb909c | 44 | this.configService.loadConfig(); |
6e07c3de | 45 | this.videoService.loadVideoCategories(); |
d07137b9 | 46 | this.videoService.loadVideoLicences(); |
db216afd | 47 | this.videoService.loadVideoLanguages(); |
3eeeb87f C |
48 | |
49 | // Do not display menu on small screens | |
50 | if (window.innerWidth < 600) { | |
51 | this.isMenuDisplayed = false; | |
52 | } | |
e2a2d6c8 C |
53 | } |
54 | ||
beacf699 C |
55 | isInAdmin() { |
56 | return this.router.url.indexOf('/admin/') !== -1; | |
dc8bc31b | 57 | } |
67167390 C |
58 | |
59 | toggleMenu() { | |
60 | this.isMenuDisplayed = !this.isMenuDisplayed; | |
61 | } | |
62 | ||
63 | getMainColClasses() { | |
64 | const colSizes = { | |
65 | md: 10, | |
66 | sm: 9, | |
67 | xs: 9 | |
165c8d25 | 68 | }; |
67167390 C |
69 | |
70 | // Take all width is the menu is not displayed | |
71 | if (this.isMenuDisplayed === false) { | |
72 | Object.keys(colSizes).forEach(col => colSizes[col] = 12); | |
73 | } | |
74 | ||
165c8d25 | 75 | const classes = [ 'main-col' ]; |
67167390 C |
76 | Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`)); |
77 | ||
78 | return classes; | |
79 | } | |
dc8bc31b | 80 | } |