diff options
Diffstat (limited to 'client/src/app/+my-account')
-rw-r--r-- | client/src/app/+my-account/my-account.component.ts | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts index 07cab37fc..5b2238f5a 100644 --- a/client/src/app/+my-account/my-account.component.ts +++ b/client/src/app/+my-account/my-account.component.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { ServerService } from '@app/core' | 2 | import { AuthService, ServerService, AuthUser } from '@app/core' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | 3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
4 | import { ServerConfig } from '@shared/models' | 4 | import { ServerConfig } from '@shared/models' |
5 | import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component' | 5 | import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component' |
@@ -11,11 +11,13 @@ import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdo | |||
11 | }) | 11 | }) |
12 | export class MyAccountComponent implements OnInit { | 12 | export class MyAccountComponent implements OnInit { |
13 | menuEntries: TopMenuDropdownParam[] = [] | 13 | menuEntries: TopMenuDropdownParam[] = [] |
14 | user: AuthUser | ||
14 | 15 | ||
15 | private serverConfig: ServerConfig | 16 | private serverConfig: ServerConfig |
16 | 17 | ||
17 | constructor ( | 18 | constructor ( |
18 | private serverService: ServerService, | 19 | private serverService: ServerService, |
20 | private authService: AuthService, | ||
19 | private i18n: I18n | 21 | private i18n: I18n |
20 | ) { } | 22 | ) { } |
21 | 23 | ||
@@ -24,6 +26,20 @@ export class MyAccountComponent implements OnInit { | |||
24 | this.serverService.getConfig() | 26 | this.serverService.getConfig() |
25 | .subscribe(config => this.serverConfig = config) | 27 | .subscribe(config => this.serverConfig = config) |
26 | 28 | ||
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 () { | ||
27 | const libraryEntries: TopMenuDropdownParam = { | 43 | const libraryEntries: TopMenuDropdownParam = { |
28 | label: this.i18n('My library'), | 44 | label: this.i18n('My library'), |
29 | children: [ | 45 | children: [ |
@@ -35,7 +51,8 @@ export class MyAccountComponent implements OnInit { | |||
35 | { | 51 | { |
36 | label: this.i18n('My videos'), | 52 | label: this.i18n('My videos'), |
37 | routerLink: '/my-account/videos', | 53 | routerLink: '/my-account/videos', |
38 | iconName: 'videos' | 54 | iconName: 'videos', |
55 | isDisplayed: () => this.user.canSeeVideosLink | ||
39 | }, | 56 | }, |
40 | { | 57 | { |
41 | label: this.i18n('My playlists'), | 58 | label: this.i18n('My playlists'), |
@@ -45,7 +62,7 @@ export class MyAccountComponent implements OnInit { | |||
45 | { | 62 | { |
46 | label: this.i18n('My subscriptions'), | 63 | label: this.i18n('My subscriptions'), |
47 | routerLink: '/my-account/subscriptions', | 64 | routerLink: '/my-account/subscriptions', |
48 | iconName: 'subscriptions' | 65 | iconName: 'inbox-full' |
49 | }, | 66 | }, |
50 | { | 67 | { |
51 | label: this.i18n('My history'), | 68 | label: this.i18n('My history'), |
@@ -59,7 +76,8 @@ export class MyAccountComponent implements OnInit { | |||
59 | libraryEntries.children.push({ | 76 | libraryEntries.children.push({ |
60 | label: 'My imports', | 77 | label: 'My imports', |
61 | routerLink: '/my-account/video-imports', | 78 | routerLink: '/my-account/video-imports', |
62 | iconName: 'cloud-download' | 79 | iconName: 'cloud-download', |
80 | isDisplayed: () => this.user.canSeeVideosLink | ||
63 | }) | 81 | }) |
64 | } | 82 | } |
65 | 83 | ||
@@ -97,11 +115,4 @@ export class MyAccountComponent implements OnInit { | |||
97 | miscEntries | 115 | miscEntries |
98 | ] | 116 | ] |
99 | } | 117 | } |
100 | |||
101 | isVideoImportEnabled () { | ||
102 | const importConfig = this.serverConfig.import.videos | ||
103 | |||
104 | return importConfig.http.enabled || importConfig.torrent.enabled | ||
105 | } | ||
106 | |||
107 | } | 118 | } |