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