aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-library/my-library.component.ts
blob: 16a7f63e330597cc0e3586603f502d8f178879c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Component, OnInit } from '@angular/core'
import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
import { HTMLServerConfig } from '@shared/models'
import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'

@Component({
  templateUrl: './my-library.component.html',
  styleUrls: [ './my-library.component.scss' ]
})
export class MyLibraryComponent implements OnInit {
  menuEntries: TopMenuDropdownParam[] = []
  user: AuthUser

  private serverConfig: HTMLServerConfig

  constructor (
    private serverService: ServerService,
    private authService: AuthService,
    private screenService: ScreenService
  ) { }

  get isBroadcastMessageDisplayed () {
    return this.screenService.isBroadcastMessageDisplayed
  }

  ngOnInit (): void {
    this.serverConfig = this.serverService.getHTMLConfig()

    this.user = this.authService.getUser()

    this.authService.userInformationLoaded.subscribe(
      () => this.buildMenu()
    )
  }

  isVideoImportEnabled () {
    const importConfig = this.serverConfig.import.videos

    return importConfig.http.enabled || importConfig.torrent.enabled
  }

  private buildMenu () {
    this.menuEntries = [
      {
        label: $localize`Channels`,
        routerLink: '/my-library/video-channels'
      }
    ]

    if (this.user.canSeeVideosLink) {
      this.menuEntries.push({
        label: $localize`Videos`,
        routerLink: '/my-library/videos'
      })
    }

    this.menuEntries = this.menuEntries.concat([
      {
        label: $localize`Playlists`,
        routerLink: '/my-library/video-playlists'
      },

      {
        label: $localize`Subscriptions`,
        routerLink: '/my-library/subscriptions'
      },

      {
        label: $localize`History`,
        routerLink: '/my-library/history/videos'
      }
    ])
  }
}