]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account.component.ts
factorize account/server blocklists for users and instance (#2875)
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
CommitLineData
ba430d75 1import { Component, OnInit } from '@angular/core'
5d08a6a7 2import { ServerService } from '@app/core'
4c8e4e04 3import { I18n } from '@ngx-translate/i18n-polyfill'
ddb83e49 4import { TopMenuDropdownParam } from '@app/shared/menu/top-menu-dropdown.component'
ba430d75 5import { ServerConfig } from '@shared/models'
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[] = []
d7639f66 14
ba430d75
C
15 private serverConfig: ServerConfig
16
5d08a6a7 17 constructor (
4c8e4e04 18 private serverService: ServerService,
4c8e4e04 19 private i18n: I18n
ba430d75
C
20 ) { }
21
22 ngOnInit (): void {
23 this.serverConfig = this.serverService.getTmpConfig()
24 this.serverService.getConfig()
25 .subscribe(config => this.serverConfig = config)
ddb83e49
C
26
27 const libraryEntries: TopMenuDropdownParam = {
28 label: this.i18n('My library'),
29 children: [
30 {
31 label: this.i18n('My channels'),
a55052c9
C
32 routerLink: '/my-account/video-channels',
33 iconName: 'folder'
ddb83e49
C
34 },
35 {
36 label: this.i18n('My videos'),
a55052c9
C
37 routerLink: '/my-account/videos',
38 iconName: 'videos'
ddb83e49 39 },
830b4faf
C
40 {
41 label: this.i18n('My playlists'),
a55052c9
C
42 routerLink: '/my-account/video-playlists',
43 iconName: 'playlists'
830b4faf 44 },
ddb83e49
C
45 {
46 label: this.i18n('My subscriptions'),
a55052c9
C
47 routerLink: '/my-account/subscriptions',
48 iconName: 'subscriptions'
80bfd33c
C
49 },
50 {
51 label: this.i18n('My history'),
a55052c9
C
52 routerLink: '/my-account/history/videos',
53 iconName: 'history'
ddb83e49
C
54 }
55 ]
56 }
5d08a6a7 57
ddb83e49
C
58 if (this.isVideoImportEnabled()) {
59 libraryEntries.children.push({
60 label: 'My imports',
a55052c9
C
61 routerLink: '/my-account/video-imports',
62 iconName: 'cloud-download'
ddb83e49
C
63 })
64 }
4c8e4e04 65
ddb83e49
C
66 const miscEntries: TopMenuDropdownParam = {
67 label: this.i18n('Misc'),
68 children: [
69 {
70 label: this.i18n('Muted accounts'),
a55052c9
C
71 routerLink: '/my-account/blocklist/accounts',
72 iconName: 'user'
ddb83e49
C
73 },
74 {
22839330 75 label: this.i18n('Muted servers'),
a55052c9
C
76 routerLink: '/my-account/blocklist/servers',
77 iconName: 'server'
ddb83e49
C
78 },
79 {
80 label: this.i18n('Ownership changes'),
a55052c9
C
81 routerLink: '/my-account/ownership',
82 iconName: 'im-with-her'
ddb83e49
C
83 }
84 ]
85 }
4c8e4e04 86
ddb83e49
C
87 this.menuEntries = [
88 {
89 label: this.i18n('My settings'),
90 routerLink: '/my-account/settings'
91 },
2f1548fd
C
92 {
93 label: this.i18n('My notifications'),
94 routerLink: '/my-account/notifications'
95 },
ddb83e49
C
96 libraryEntries,
97 miscEntries
98 ]
d7639f66
C
99 }
100
5d08a6a7 101 isVideoImportEnabled () {
ba430d75 102 const importConfig = this.serverConfig.import.videos
b0ee41df
C
103
104 return importConfig.http.enabled || importConfig.torrent.enabled
5d08a6a7 105 }
4c8e4e04 106
5d08a6a7 107}