]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-library/my-library.component.ts
Merge branch 'feature/video-filters' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / my-library.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
3 import { HTMLServerConfig } from '@shared/models'
4 import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
5
6 @Component({
7 templateUrl: './my-library.component.html',
8 styleUrls: [ './my-library.component.scss' ]
9 })
10 export class MyLibraryComponent implements OnInit {
11 menuEntries: TopMenuDropdownParam[] = []
12 user: AuthUser
13
14 private serverConfig: HTMLServerConfig
15
16 constructor (
17 private serverService: ServerService,
18 private authService: AuthService,
19 private screenService: ScreenService
20 ) { }
21
22 get isBroadcastMessageDisplayed () {
23 return this.screenService.isBroadcastMessageDisplayed
24 }
25
26 ngOnInit (): void {
27 this.serverConfig = this.serverService.getHTMLConfig()
28
29 this.user = this.authService.getUser()
30
31 this.authService.userInformationLoaded.subscribe(
32 () => this.buildMenu()
33 )
34 }
35
36 isVideoImportEnabled () {
37 const importConfig = this.serverConfig.import.videos
38
39 return importConfig.http.enabled || importConfig.torrent.enabled
40 }
41
42 private buildMenu () {
43 this.menuEntries = [
44 {
45 label: $localize`Channels`,
46 routerLink: '/my-library/video-channels'
47 }
48 ]
49
50 if (this.user.canSeeVideosLink) {
51 this.menuEntries.push({
52 label: $localize`Videos`,
53 routerLink: '/my-library/videos'
54 })
55 }
56
57 this.menuEntries = this.menuEntries.concat([
58 {
59 label: $localize`Playlists`,
60 routerLink: '/my-library/video-playlists'
61 },
62
63 {
64 label: $localize`Subscriptions`,
65 routerLink: '/my-library/subscriptions'
66 },
67
68 {
69 label: $localize`History`,
70 routerLink: '/my-library/history/videos'
71 }
72 ])
73 }
74 }