1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, ScreenService, 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,
21 private screenService: ScreenService,
25 get isBroadcastMessageDisplayed () {
26 return this.screenService.isBroadcastMessageDisplayed
30 this.serverConfig = this.serverService.getTmpConfig()
31 this.serverService.getConfig()
32 .subscribe(config => this.serverConfig = config)
34 this.user = this.authService.getUser()
36 this.authService.userInformationLoaded.subscribe(
37 () => this.buildMenu()
41 isVideoImportEnabled () {
42 const importConfig = this.serverConfig.import.videos
44 return importConfig.http.enabled || importConfig.torrent.enabled
47 private buildMenu () {
48 const libraryEntries: TopMenuDropdownParam = {
49 label: this.i18n('My library'),
52 label: this.i18n('My channels'),
53 routerLink: '/my-account/video-channels',
57 label: this.i18n('My videos'),
58 routerLink: '/my-account/videos',
60 isDisplayed: () => this.user.canSeeVideosLink
63 label: this.i18n('My playlists'),
64 routerLink: '/my-account/video-playlists',
68 label: this.i18n('My subscriptions'),
69 routerLink: '/my-account/subscriptions',
70 iconName: 'subscriptions'
73 label: this.i18n('My history'),
74 routerLink: '/my-account/history/videos',
80 if (this.isVideoImportEnabled()) {
81 libraryEntries.children.push({
83 routerLink: '/my-account/video-imports',
84 iconName: 'cloud-download',
85 isDisplayed: () => this.user.canSeeVideosLink
89 const miscEntries: TopMenuDropdownParam = {
90 label: this.i18n('Misc'),
93 label: this.i18n('Muted accounts'),
94 routerLink: '/my-account/blocklist/accounts',
98 label: this.i18n('Muted servers'),
99 routerLink: '/my-account/blocklist/servers',
100 iconName: 'peertube-x'
103 label: this.i18n('My abuse reports'),
104 routerLink: '/my-account/abuses',
108 label: this.i18n('Ownership changes'),
109 routerLink: '/my-account/ownership',
117 label: this.i18n('My settings'),
118 routerLink: '/my-account/settings'
121 label: this.i18n('My notifications'),
122 routerLink: '/my-account/notifications'