]>
Commit | Line | Data |
---|---|---|
ba430d75 | 1 | import { Component, OnInit } from '@angular/core' |
dfe3f7b7 | 2 | import { AuthService, 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, |
4c8e4e04 | 21 | private i18n: I18n |
ba430d75 C |
22 | ) { } |
23 | ||
24 | ngOnInit (): void { | |
25 | this.serverConfig = this.serverService.getTmpConfig() | |
26 | this.serverService.getConfig() | |
27 | .subscribe(config => this.serverConfig = config) | |
ddb83e49 | 28 | |
dfe3f7b7 K |
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 () { | |
ddb83e49 C |
43 | const libraryEntries: TopMenuDropdownParam = { |
44 | label: this.i18n('My library'), | |
45 | children: [ | |
46 | { | |
47 | label: this.i18n('My channels'), | |
a55052c9 | 48 | routerLink: '/my-account/video-channels', |
c41c0e28 | 49 | iconName: 'channel' |
ddb83e49 C |
50 | }, |
51 | { | |
52 | label: this.i18n('My videos'), | |
a55052c9 | 53 | routerLink: '/my-account/videos', |
dfe3f7b7 K |
54 | iconName: 'videos', |
55 | isDisplayed: () => this.user.canSeeVideosLink | |
ddb83e49 | 56 | }, |
830b4faf C |
57 | { |
58 | label: this.i18n('My playlists'), | |
a55052c9 C |
59 | routerLink: '/my-account/video-playlists', |
60 | iconName: 'playlists' | |
830b4faf | 61 | }, |
ddb83e49 C |
62 | { |
63 | label: this.i18n('My subscriptions'), | |
a55052c9 | 64 | routerLink: '/my-account/subscriptions', |
dfe3f7b7 | 65 | iconName: 'inbox-full' |
80bfd33c C |
66 | }, |
67 | { | |
68 | label: this.i18n('My history'), | |
a55052c9 C |
69 | routerLink: '/my-account/history/videos', |
70 | iconName: 'history' | |
ddb83e49 C |
71 | } |
72 | ] | |
73 | } | |
5d08a6a7 | 74 | |
ddb83e49 C |
75 | if (this.isVideoImportEnabled()) { |
76 | libraryEntries.children.push({ | |
77 | label: 'My imports', | |
a55052c9 | 78 | routerLink: '/my-account/video-imports', |
dfe3f7b7 K |
79 | iconName: 'cloud-download', |
80 | isDisplayed: () => this.user.canSeeVideosLink | |
ddb83e49 C |
81 | }) |
82 | } | |
4c8e4e04 | 83 | |
ddb83e49 C |
84 | const miscEntries: TopMenuDropdownParam = { |
85 | label: this.i18n('Misc'), | |
86 | children: [ | |
87 | { | |
88 | label: this.i18n('Muted accounts'), | |
a55052c9 | 89 | routerLink: '/my-account/blocklist/accounts', |
345b4a22 | 90 | iconName: 'user-x' |
ddb83e49 C |
91 | }, |
92 | { | |
22839330 | 93 | label: this.i18n('Muted servers'), |
a55052c9 | 94 | routerLink: '/my-account/blocklist/servers', |
345b4a22 | 95 | iconName: 'peertube-x' |
ddb83e49 C |
96 | }, |
97 | { | |
98 | label: this.i18n('Ownership changes'), | |
a55052c9 | 99 | routerLink: '/my-account/ownership', |
345b4a22 | 100 | iconName: 'download' |
ddb83e49 C |
101 | } |
102 | ] | |
103 | } | |
4c8e4e04 | 104 | |
ddb83e49 C |
105 | this.menuEntries = [ |
106 | { | |
107 | label: this.i18n('My settings'), | |
108 | routerLink: '/my-account/settings' | |
109 | }, | |
2f1548fd C |
110 | { |
111 | label: this.i18n('My notifications'), | |
112 | routerLink: '/my-account/notifications' | |
113 | }, | |
ddb83e49 C |
114 | libraryEntries, |
115 | miscEntries | |
116 | ] | |
d7639f66 | 117 | } |
5d08a6a7 | 118 | } |