]>
Commit | Line | Data |
---|---|---|
df98563e C |
1 | import { Component, OnInit, ViewContainerRef } from '@angular/core' |
2 | import { Router } from '@angular/router' | |
dc8bc31b | 3 | |
df98563e | 4 | import { AuthService, ConfigService } 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 C |
13 | notificationOptions = { |
14 | timeOut: 3000, | |
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, |
92fb909c | 31 | private configService: ConfigService, |
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 | |
df98563e | 40 | this.userService.checkTokenValidity() |
e2a2d6c8 | 41 | } |
6e07c3de | 42 | |
df98563e | 43 | this.configService.loadConfig() |
3eeeb87f C |
44 | |
45 | // Do not display menu on small screens | |
46 | if (window.innerWidth < 600) { | |
df98563e | 47 | this.isMenuDisplayed = false |
3eeeb87f | 48 | } |
e2a2d6c8 C |
49 | } |
50 | ||
df98563e C |
51 | isInAdmin () { |
52 | return this.router.url.indexOf('/admin/') !== -1 | |
dc8bc31b | 53 | } |
67167390 | 54 | |
df98563e C |
55 | toggleMenu () { |
56 | this.isMenuDisplayed = !this.isMenuDisplayed | |
67167390 C |
57 | } |
58 | ||
df98563e | 59 | getMainColClasses () { |
67167390 C |
60 | const colSizes = { |
61 | md: 10, | |
62 | sm: 9, | |
63 | xs: 9 | |
df98563e | 64 | } |
67167390 C |
65 | |
66 | // Take all width is the menu is not displayed | |
67 | if (this.isMenuDisplayed === false) { | |
df98563e | 68 | Object.keys(colSizes).forEach(col => colSizes[col] = 12) |
67167390 C |
69 | } |
70 | ||
df98563e C |
71 | const classes = [ 'main-col' ] |
72 | Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`)) | |
67167390 | 73 | |
df98563e | 74 | return classes |
67167390 | 75 | } |
dc8bc31b | 76 | } |