]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.component.ts
Move to HttpClient and PrimeNG data table
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
CommitLineData
df98563e
C
1import { Component, OnInit, ViewContainerRef } from '@angular/core'
2import { Router } from '@angular/router'
dc8bc31b 3
df98563e
C
4import { AuthService, ConfigService } from './core'
5import { VideoService } from './videos'
6import { 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 13export 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,
6e07c3de 34 private videoService: VideoService,
3154f382
C
35 viewContainerRef: ViewContainerRef
36 ) {}
a99593ed 37
df98563e 38 ngOnInit () {
d592e0a9
C
39 this.authService.loadClientCredentials()
40
e2a2d6c8
C
41 if (this.authService.isLoggedIn()) {
42 // The service will automatically redirect to the login page if the token is not valid anymore
df98563e 43 this.userService.checkTokenValidity()
e2a2d6c8 44 }
6e07c3de 45
df98563e
C
46 this.configService.loadConfig()
47 this.videoService.loadVideoCategories()
48 this.videoService.loadVideoLicences()
49 this.videoService.loadVideoLanguages()
3eeeb87f
C
50
51 // Do not display menu on small screens
52 if (window.innerWidth < 600) {
df98563e 53 this.isMenuDisplayed = false
3eeeb87f 54 }
e2a2d6c8
C
55 }
56
df98563e
C
57 isInAdmin () {
58 return this.router.url.indexOf('/admin/') !== -1
dc8bc31b 59 }
67167390 60
df98563e
C
61 toggleMenu () {
62 this.isMenuDisplayed = !this.isMenuDisplayed
67167390
C
63 }
64
df98563e 65 getMainColClasses () {
67167390
C
66 const colSizes = {
67 md: 10,
68 sm: 9,
69 xs: 9
df98563e 70 }
67167390
C
71
72 // Take all width is the menu is not displayed
73 if (this.isMenuDisplayed === false) {
df98563e 74 Object.keys(colSizes).forEach(col => colSizes[col] = 12)
67167390
C
75 }
76
df98563e
C
77 const classes = [ 'main-col' ]
78 Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`))
67167390 79
df98563e 80 return classes
67167390 81 }
dc8bc31b 82}