diff options
Diffstat (limited to 'client/src/app/+my-account/my-account.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account.component.ts | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts index d728caf07..d9381ebfa 100644 --- a/client/src/app/+my-account/my-account.component.ts +++ b/client/src/app/+my-account/my-account.component.ts | |||
@@ -1,38 +1,72 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { ServerService } from '@app/core' | 2 | import { ServerService } from '@app/core' |
3 | import { NavigationStart, Router } from '@angular/router' | ||
4 | import { filter } from 'rxjs/operators' | ||
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | 3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
6 | import { Subscription } from 'rxjs' | 4 | import { TopMenuDropdownParam } from '@app/shared/menu/top-menu-dropdown.component' |
7 | 5 | ||
8 | @Component({ | 6 | @Component({ |
9 | selector: 'my-my-account', | 7 | selector: 'my-my-account', |
10 | templateUrl: './my-account.component.html', | 8 | templateUrl: './my-account.component.html', |
11 | styleUrls: [ './my-account.component.scss' ] | 9 | styleUrls: [ './my-account.component.scss' ] |
12 | }) | 10 | }) |
13 | export class MyAccountComponent implements OnInit, OnDestroy { | 11 | export class MyAccountComponent { |
14 | 12 | menuEntries: TopMenuDropdownParam[] = [] | |
15 | libraryLabel = '' | ||
16 | miscLabel = '' | ||
17 | |||
18 | private routeSub: Subscription | ||
19 | 13 | ||
20 | constructor ( | 14 | constructor ( |
21 | private serverService: ServerService, | 15 | private serverService: ServerService, |
22 | private router: Router, | ||
23 | private i18n: I18n | 16 | private i18n: I18n |
24 | ) {} | 17 | ) { |
18 | |||
19 | const libraryEntries: TopMenuDropdownParam = { | ||
20 | label: this.i18n('My library'), | ||
21 | children: [ | ||
22 | { | ||
23 | label: this.i18n('My channels'), | ||
24 | routerLink: '/my-account/videos' | ||
25 | }, | ||
26 | { | ||
27 | label: this.i18n('My videos'), | ||
28 | routerLink: '/my-account/videos' | ||
29 | }, | ||
30 | { | ||
31 | label: this.i18n('My subscriptions'), | ||
32 | routerLink: '/my-account/subscriptions' | ||
33 | } | ||
34 | ] | ||
35 | } | ||
25 | 36 | ||
26 | ngOnInit () { | 37 | if (this.isVideoImportEnabled()) { |
27 | this.updateLabels(this.router.url) | 38 | libraryEntries.children.push({ |
39 | label: 'My imports', | ||
40 | routerLink: '/my-account/video-imports' | ||
41 | }) | ||
42 | } | ||
28 | 43 | ||
29 | this.routeSub = this.router.events | 44 | const miscEntries: TopMenuDropdownParam = { |
30 | .pipe(filter(event => event instanceof NavigationStart)) | 45 | label: this.i18n('Misc'), |
31 | .subscribe((event: NavigationStart) => this.updateLabels(event.url)) | 46 | children: [ |
32 | } | 47 | { |
48 | label: this.i18n('Muted accounts'), | ||
49 | routerLink: '/my-account/blocklist/accounts' | ||
50 | }, | ||
51 | { | ||
52 | label: this.i18n('Muted instances'), | ||
53 | routerLink: '/my-account/blocklist/servers' | ||
54 | }, | ||
55 | { | ||
56 | label: this.i18n('Ownership changes'), | ||
57 | routerLink: '/my-account/ownership' | ||
58 | } | ||
59 | ] | ||
60 | } | ||
33 | 61 | ||
34 | ngOnDestroy () { | 62 | this.menuEntries = [ |
35 | if (this.routeSub) this.routeSub.unsubscribe() | 63 | { |
64 | label: this.i18n('My settings'), | ||
65 | routerLink: '/my-account/settings' | ||
66 | }, | ||
67 | libraryEntries, | ||
68 | miscEntries | ||
69 | ] | ||
36 | } | 70 | } |
37 | 71 | ||
38 | isVideoImportEnabled () { | 72 | isVideoImportEnabled () { |
@@ -41,27 +75,4 @@ export class MyAccountComponent implements OnInit, OnDestroy { | |||
41 | return importConfig.http.enabled || importConfig.torrent.enabled | 75 | return importConfig.http.enabled || importConfig.torrent.enabled |
42 | } | 76 | } |
43 | 77 | ||
44 | private updateLabels (url: string) { | ||
45 | const [ path ] = url.split('?') | ||
46 | |||
47 | if (path.startsWith('/my-account/video-channels')) { | ||
48 | this.libraryLabel = this.i18n('Channels') | ||
49 | } else if (path.startsWith('/my-account/videos')) { | ||
50 | this.libraryLabel = this.i18n('Videos') | ||
51 | } else if (path.startsWith('/my-account/subscriptions')) { | ||
52 | this.libraryLabel = this.i18n('Subscriptions') | ||
53 | } else if (path.startsWith('/my-account/video-imports')) { | ||
54 | this.libraryLabel = this.i18n('Video imports') | ||
55 | } else { | ||
56 | this.libraryLabel = '' | ||
57 | } | ||
58 | |||
59 | if (path.startsWith('/my-account/blocklist/accounts')) { | ||
60 | this.miscLabel = this.i18n('Muted accounts') | ||
61 | } else if (path.startsWith('/my-account/blocklist/servers')) { | ||
62 | this.miscLabel = this.i18n('Muted instances') | ||
63 | } else { | ||
64 | this.miscLabel = '' | ||
65 | } | ||
66 | } | ||
67 | } | 78 | } |