my-library.component.ts 1.82 KB
Newer Older
1
2
import { Component, OnInit } from '@angular/core'
import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
Chocobozzz's avatar
Chocobozzz committed
3
import { HTMLServerConfig } from '@shared/models'
4
5
6
7
8
9
10
11
12
13
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

Chocobozzz's avatar
Chocobozzz committed
14
15

  private serverConfig: HTMLServerConfig
16
17
18
19
20
21
22
23
24
25
26
27

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

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

  ngOnInit (): void {
Chocobozzz's avatar
Chocobozzz committed
28
    this.serverConfig = this.serverService.getHTMLConfig()
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
75

    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'
      }
    ])
  }
}