]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account.component.ts
Add alert and hide upload view when no upload is possible (#2966)
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, ServerService, AuthUser } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { ServerConfig } from '@shared/models'
5 import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
6
7 @Component({
8 selector: 'my-my-account',
9 templateUrl: './my-account.component.html',
10 styleUrls: [ './my-account.component.scss' ]
11 })
12 export class MyAccountComponent implements OnInit {
13 menuEntries: TopMenuDropdownParam[] = []
14 user: AuthUser
15
16 private serverConfig: ServerConfig
17
18 constructor (
19 private serverService: ServerService,
20 private authService: AuthService,
21 private i18n: I18n
22 ) { }
23
24 ngOnInit (): void {
25 this.serverConfig = this.serverService.getTmpConfig()
26 this.serverService.getConfig()
27 .subscribe(config => this.serverConfig = config)
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 () {
43 const libraryEntries: TopMenuDropdownParam = {
44 label: this.i18n('My library'),
45 children: [
46 {
47 label: this.i18n('My channels'),
48 routerLink: '/my-account/video-channels',
49 iconName: 'channel'
50 },
51 {
52 label: this.i18n('My videos'),
53 routerLink: '/my-account/videos',
54 iconName: 'videos',
55 isDisplayed: () => this.user.canSeeVideosLink
56 },
57 {
58 label: this.i18n('My playlists'),
59 routerLink: '/my-account/video-playlists',
60 iconName: 'playlists'
61 },
62 {
63 label: this.i18n('My subscriptions'),
64 routerLink: '/my-account/subscriptions',
65 iconName: 'inbox-full'
66 },
67 {
68 label: this.i18n('My history'),
69 routerLink: '/my-account/history/videos',
70 iconName: 'history'
71 }
72 ]
73 }
74
75 if (this.isVideoImportEnabled()) {
76 libraryEntries.children.push({
77 label: 'My imports',
78 routerLink: '/my-account/video-imports',
79 iconName: 'cloud-download',
80 isDisplayed: () => this.user.canSeeVideosLink
81 })
82 }
83
84 const miscEntries: TopMenuDropdownParam = {
85 label: this.i18n('Misc'),
86 children: [
87 {
88 label: this.i18n('Muted accounts'),
89 routerLink: '/my-account/blocklist/accounts',
90 iconName: 'user-x'
91 },
92 {
93 label: this.i18n('Muted servers'),
94 routerLink: '/my-account/blocklist/servers',
95 iconName: 'peertube-x'
96 },
97 {
98 label: this.i18n('Ownership changes'),
99 routerLink: '/my-account/ownership',
100 iconName: 'download'
101 }
102 ]
103 }
104
105 this.menuEntries = [
106 {
107 label: this.i18n('My settings'),
108 routerLink: '/my-account/settings'
109 },
110 {
111 label: this.i18n('My notifications'),
112 routerLink: '/my-account/notifications'
113 },
114 libraryEntries,
115 miscEntries
116 ]
117 }
118 }