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