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'
8 selector: 'my-my-account',
9 templateUrl: './my-account.component.html',
10 styleUrls: [ './my-account.component.scss' ]
12 export class MyAccountComponent implements OnInit {
13 menuEntries: TopMenuDropdownParam[] = []
16 private serverConfig: ServerConfig
19 private serverService: ServerService,
20 private authService: AuthService,
25 this.serverConfig = this.serverService.getTmpConfig()
26 this.serverService.getConfig()
27 .subscribe(config => this.serverConfig = config)
29 this.user = this.authService.getUser()
31 this.authService.userInformationLoaded.subscribe(
32 () => this.buildMenu()
36 isVideoImportEnabled () {
37 const importConfig = this.serverConfig.import.videos
39 return importConfig.http.enabled || importConfig.torrent.enabled
42 private buildMenu () {
43 const libraryEntries: TopMenuDropdownParam = {
44 label: this.i18n('My library'),
47 label: this.i18n('My channels'),
48 routerLink: '/my-account/video-channels',
52 label: this.i18n('My videos'),
53 routerLink: '/my-account/videos',
55 isDisplayed: () => this.user.canSeeVideosLink
58 label: this.i18n('My playlists'),
59 routerLink: '/my-account/video-playlists',
63 label: this.i18n('My subscriptions'),
64 routerLink: '/my-account/subscriptions',
65 iconName: 'inbox-full'
68 label: this.i18n('My history'),
69 routerLink: '/my-account/history/videos',
75 if (this.isVideoImportEnabled()) {
76 libraryEntries.children.push({
78 routerLink: '/my-account/video-imports',
79 iconName: 'cloud-download',
80 isDisplayed: () => this.user.canSeeVideosLink
84 const miscEntries: TopMenuDropdownParam = {
85 label: this.i18n('Misc'),
88 label: this.i18n('Muted accounts'),
89 routerLink: '/my-account/blocklist/accounts',
93 label: this.i18n('Muted servers'),
94 routerLink: '/my-account/blocklist/servers',
95 iconName: 'peertube-x'
98 label: this.i18n('My abuses'),
99 routerLink: '/my-account/abuses',
103 label: this.i18n('Ownership changes'),
104 routerLink: '/my-account/ownership',
112 label: this.i18n('My settings'),
113 routerLink: '/my-account/settings'
116 label: this.i18n('My notifications'),
117 routerLink: '/my-account/notifications'