]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-library/my-library.component.ts
Make /a and /c default URLs for accounts and channels
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / my-library.component.ts
CommitLineData
17119e4a
C
1import { Component, OnInit } from '@angular/core'
2import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
3import { ServerConfig } from '@shared/models'
4import { 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})
10export class MyLibraryComponent implements OnInit {
11 menuEntries: TopMenuDropdownParam[] = []
12 user: AuthUser
13
14 private serverConfig: ServerConfig
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.getTmpConfig()
28 this.serverService.getConfig()
29 .subscribe(config => this.serverConfig = config)
30
31 this.user = this.authService.getUser()
32
33 this.authService.userInformationLoaded.subscribe(
34 () => this.buildMenu()
35 )
36 }
37
38 isVideoImportEnabled () {
39 const importConfig = this.serverConfig.import.videos
40
41 return importConfig.http.enabled || importConfig.torrent.enabled
42 }
43
44 private buildMenu () {
45 this.menuEntries = [
46 {
47 label: $localize`Channels`,
48 routerLink: '/my-library/video-channels'
49 }
50 ]
51
52 if (this.user.canSeeVideosLink) {
53 this.menuEntries.push({
54 label: $localize`Videos`,
55 routerLink: '/my-library/videos'
56 })
57 }
58
59 this.menuEntries = this.menuEntries.concat([
60 {
61 label: $localize`Playlists`,
62 routerLink: '/my-library/video-playlists'
63 },
64
65 {
66 label: $localize`Subscriptions`,
67 routerLink: '/my-library/subscriptions'
68 },
69
70 {
71 label: $localize`History`,
72 routerLink: '/my-library/history/videos'
73 }
74 ])
75 }
76}