1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
3 import { ServerConfig } from '@shared/models'
4 import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
7 selector: 'my-my-account',
8 templateUrl: './my-account.component.html',
9 styleUrls: [ './my-account.component.scss' ]
11 export class MyAccountComponent implements OnInit {
12 menuEntries: TopMenuDropdownParam[] = []
15 private serverConfig: ServerConfig
18 private serverService: ServerService,
19 private authService: AuthService,
20 private screenService: ScreenService
23 get isBroadcastMessageDisplayed () {
24 return this.screenService.isBroadcastMessageDisplayed
28 this.serverConfig = this.serverService.getTmpConfig()
29 this.serverService.getConfig()
30 .subscribe(config => this.serverConfig = config)
32 this.user = this.authService.getUser()
34 this.authService.userInformationLoaded.subscribe(
35 () => this.buildMenu()
39 isVideoImportEnabled () {
40 const importConfig = this.serverConfig.import.videos
42 return importConfig.http.enabled || importConfig.torrent.enabled
45 private buildMenu () {
46 const libraryEntries: TopMenuDropdownParam = {
47 label: $localize`My library`,
50 label: $localize`My channels`,
51 routerLink: '/my-account/video-channels',
55 label: $localize`My videos`,
56 routerLink: '/my-account/videos',
58 isDisplayed: () => this.user.canSeeVideosLink
61 label: $localize`My playlists`,
62 routerLink: '/my-account/video-playlists',
66 label: $localize`My subscriptions`,
67 routerLink: '/my-account/subscriptions',
68 iconName: 'subscriptions'
71 label: $localize`My history`,
72 routerLink: '/my-account/history/videos',
78 if (this.isVideoImportEnabled()) {
79 libraryEntries.children.push({
81 routerLink: '/my-account/video-imports',
82 iconName: 'cloud-download',
83 isDisplayed: () => this.user.canSeeVideosLink
87 const miscEntries: TopMenuDropdownParam = {
88 label: $localize`Misc`,
91 label: $localize`Muted accounts`,
92 routerLink: '/my-account/blocklist/accounts',
96 label: $localize`Muted servers`,
97 routerLink: '/my-account/blocklist/servers',
98 iconName: 'peertube-x'
101 label: $localize`My abuse reports`,
102 routerLink: '/my-account/abuses',
106 label: $localize`Ownership changes`,
107 routerLink: '/my-account/ownership',
115 label: $localize`My settings`,
116 routerLink: '/my-account/settings'
119 label: $localize`My notifications`,
120 routerLink: '/my-account/notifications'