]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account.component.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
3 import { ServerConfig } from '@shared/models'
4 import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
5
6 @Component({
7 selector: 'my-my-account',
8 templateUrl: './my-account.component.html',
9 styleUrls: [ './my-account.component.scss' ]
10 })
11 export class MyAccountComponent implements OnInit {
12 menuEntries: TopMenuDropdownParam[] = []
13 user: AuthUser
14
15 private serverConfig: ServerConfig
16
17 constructor (
18 private serverService: ServerService,
19 private authService: AuthService,
20 private screenService: ScreenService
21 ) { }
22
23 get isBroadcastMessageDisplayed () {
24 return this.screenService.isBroadcastMessageDisplayed
25 }
26
27 ngOnInit (): void {
28 this.serverConfig = this.serverService.getTmpConfig()
29 this.serverService.getConfig()
30 .subscribe(config => this.serverConfig = config)
31
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 () {
46 const libraryEntries: TopMenuDropdownParam = {
47 label: $localize`My library`,
48 children: [
49 {
50 label: $localize`My channels`,
51 routerLink: '/my-account/video-channels',
52 iconName: 'channel'
53 },
54 {
55 label: $localize`My videos`,
56 routerLink: '/my-account/videos',
57 iconName: 'videos',
58 isDisplayed: () => this.user.canSeeVideosLink
59 },
60 {
61 label: $localize`My playlists`,
62 routerLink: '/my-account/video-playlists',
63 iconName: 'playlists'
64 },
65 {
66 label: $localize`My subscriptions`,
67 routerLink: '/my-account/subscriptions',
68 iconName: 'subscriptions'
69 },
70 {
71 label: $localize`My history`,
72 routerLink: '/my-account/history/videos',
73 iconName: 'history'
74 }
75 ]
76 }
77
78 if (this.isVideoImportEnabled()) {
79 libraryEntries.children.push({
80 label: 'My imports',
81 routerLink: '/my-account/video-imports',
82 iconName: 'cloud-download',
83 isDisplayed: () => this.user.canSeeVideosLink
84 })
85 }
86
87 const miscEntries: TopMenuDropdownParam = {
88 label: $localize`Misc`,
89 children: [
90 {
91 label: $localize`Muted accounts`,
92 routerLink: '/my-account/blocklist/accounts',
93 iconName: 'user-x'
94 },
95 {
96 label: $localize`Muted servers`,
97 routerLink: '/my-account/blocklist/servers',
98 iconName: 'peertube-x'
99 },
100 {
101 label: $localize`My abuse reports`,
102 routerLink: '/my-account/abuses',
103 iconName: 'flag'
104 },
105 {
106 label: $localize`Ownership changes`,
107 routerLink: '/my-account/ownership',
108 iconName: 'download'
109 }
110 ]
111 }
112
113 this.menuEntries = [
114 {
115 label: $localize`My settings`,
116 routerLink: '/my-account/settings'
117 },
118 {
119 label: $localize`My notifications`,
120 routerLink: '/my-account/notifications'
121 },
122 libraryEntries,
123 miscEntries
124 ]
125 }
126 }