]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account.component.ts
Fix tokens loading
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
CommitLineData
ba430d75 1import { Component, OnInit } from '@angular/core'
66357162 2import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
ba430d75 3import { ServerConfig } from '@shared/models'
0a4cb95c 4import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
4bb6886d
C
5
6@Component({
0626e7af 7 selector: 'my-my-account',
4c8e4e04
C
8 templateUrl: './my-account.component.html',
9 styleUrls: [ './my-account.component.scss' ]
4bb6886d 10})
ba430d75 11export class MyAccountComponent implements OnInit {
ddb83e49 12 menuEntries: TopMenuDropdownParam[] = []
dfe3f7b7 13 user: AuthUser
d7639f66 14
ba430d75
C
15 private serverConfig: ServerConfig
16
5d08a6a7 17 constructor (
4c8e4e04 18 private serverService: ServerService,
dfe3f7b7 19 private authService: AuthService,
66357162
C
20 private screenService: ScreenService
21 ) { }
ba430d75 22
7034b3c9 23 get isBroadcastMessageDisplayed () {
24 return this.screenService.isBroadcastMessageDisplayed
25 }
26
ba430d75
C
27 ngOnInit (): void {
28 this.serverConfig = this.serverService.getTmpConfig()
29 this.serverService.getConfig()
30 .subscribe(config => this.serverConfig = config)
ddb83e49 31
dfe3f7b7
K
32 this.user = this.authService.getUser()
33
34 this.authService.userInformationLoaded.subscribe(
35 () => this.buildMenu()
36 )
37 }
38
39 isVideoImportEnabled () {
40 const importConfig = this.serverConfig.import.videos
41
42 return importConfig.http.enabled || importConfig.torrent.enabled
43 }
44
45 private buildMenu () {
ddb83e49 46 const libraryEntries: TopMenuDropdownParam = {
66357162 47 label: $localize`My library`,
ddb83e49
C
48 children: [
49 {
66357162 50 label: $localize`My channels`,
a55052c9 51 routerLink: '/my-account/video-channels',
c41c0e28 52 iconName: 'channel'
ddb83e49
C
53 },
54 {
66357162 55 label: $localize`My videos`,
a55052c9 56 routerLink: '/my-account/videos',
dfe3f7b7
K
57 iconName: 'videos',
58 isDisplayed: () => this.user.canSeeVideosLink
ddb83e49 59 },
830b4faf 60 {
66357162 61 label: $localize`My playlists`,
a55052c9
C
62 routerLink: '/my-account/video-playlists',
63 iconName: 'playlists'
830b4faf 64 },
ddb83e49 65 {
66357162 66 label: $localize`My subscriptions`,
a55052c9 67 routerLink: '/my-account/subscriptions',
8bed6181 68 iconName: 'subscriptions'
80bfd33c
C
69 },
70 {
66357162 71 label: $localize`My history`,
a55052c9
C
72 routerLink: '/my-account/history/videos',
73 iconName: 'history'
ddb83e49
C
74 }
75 ]
76 }
5d08a6a7 77
ddb83e49
C
78 if (this.isVideoImportEnabled()) {
79 libraryEntries.children.push({
80 label: 'My imports',
a55052c9 81 routerLink: '/my-account/video-imports',
dfe3f7b7
K
82 iconName: 'cloud-download',
83 isDisplayed: () => this.user.canSeeVideosLink
ddb83e49
C
84 })
85 }
4c8e4e04 86
ddb83e49 87 const miscEntries: TopMenuDropdownParam = {
66357162 88 label: $localize`Misc`,
ddb83e49
C
89 children: [
90 {
66357162 91 label: $localize`Muted accounts`,
a55052c9 92 routerLink: '/my-account/blocklist/accounts',
345b4a22 93 iconName: 'user-x'
ddb83e49
C
94 },
95 {
66357162 96 label: $localize`Muted servers`,
a55052c9 97 routerLink: '/my-account/blocklist/servers',
345b4a22 98 iconName: 'peertube-x'
ddb83e49 99 },
94148c90 100 {
66357162 101 label: $localize`My abuse reports`,
94148c90
C
102 routerLink: '/my-account/abuses',
103 iconName: 'flag'
104 },
ddb83e49 105 {
66357162 106 label: $localize`Ownership changes`,
a55052c9 107 routerLink: '/my-account/ownership',
345b4a22 108 iconName: 'download'
ddb83e49
C
109 }
110 ]
111 }
4c8e4e04 112
ddb83e49
C
113 this.menuEntries = [
114 {
66357162 115 label: $localize`My settings`,
ddb83e49
C
116 routerLink: '/my-account/settings'
117 },
2f1548fd 118 {
66357162 119 label: $localize`My notifications`,
2f1548fd
C
120 routerLink: '/my-account/notifications'
121 },
ddb83e49
C
122 libraryEntries,
123 miscEntries
124 ]
d7639f66 125 }
5d08a6a7 126}