]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account.component.ts
Fix regressions sub-menu titles on mobile-view
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
CommitLineData
ba430d75 1import { Component, OnInit } from '@angular/core'
dfe3f7b7 2import { AuthService, ServerService, AuthUser } from '@app/core'
4c8e4e04 3import { I18n } from '@ngx-translate/i18n-polyfill'
ba430d75 4import { ServerConfig } from '@shared/models'
0a4cb95c 5import { 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 12export 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 96 },
94148c90 97 {
41130b4c 98 label: this.i18n('My abuse reports'),
94148c90
C
99 routerLink: '/my-account/abuses',
100 iconName: 'flag'
101 },
ddb83e49
C
102 {
103 label: this.i18n('Ownership changes'),
a55052c9 104 routerLink: '/my-account/ownership',
345b4a22 105 iconName: 'download'
ddb83e49
C
106 }
107 ]
108 }
4c8e4e04 109
ddb83e49
C
110 this.menuEntries = [
111 {
112 label: this.i18n('My settings'),
113 routerLink: '/my-account/settings'
114 },
2f1548fd
C
115 {
116 label: this.i18n('My notifications'),
117 routerLink: '/my-account/notifications'
118 },
ddb83e49
C
119 libraryEntries,
120 miscEntries
121 ]
d7639f66 122 }
5d08a6a7 123}