PeerTube/client/src/app/+my-account/my-account.component.ts

87 lines
2.3 KiB
TypeScript
Raw Normal View History

import { NgClass } from '@angular/common'
2019-12-18 15:31:54 +01:00
import { Component, OnInit } from '@angular/core'
2024-03-04 10:01:52 +01:00
import { RouterOutlet } from '@angular/router'
import { AuthUser, PluginService, ScreenService } from '@app/core'
import { TopMenuDropdownComponent, TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
2018-04-23 16:16:05 +02:00
@Component({
2018-04-24 15:10:54 +02:00
selector: 'my-my-account',
templateUrl: './my-account.component.html',
2024-03-04 10:01:52 +01:00
styleUrls: [ './my-account.component.scss' ],
standalone: true,
imports: [ TopMenuDropdownComponent, NgClass, RouterOutlet ]
2018-04-23 16:16:05 +02:00
})
2019-12-18 15:31:54 +01:00
export class MyAccountComponent implements OnInit {
menuEntries: TopMenuDropdownParam[] = []
user: AuthUser
2018-09-05 17:18:13 +02:00
constructor (
private pluginService: PluginService,
private screenService: ScreenService
) { }
2019-12-18 15:31:54 +01:00
get isBroadcastMessageDisplayed () {
return this.screenService.isBroadcastMessageDisplayed
}
2019-12-18 15:31:54 +01:00
ngOnInit (): void {
this.pluginService.ensurePluginsAreLoaded('my-account')
.then(() => this.buildMenu())
}
private buildMenu () {
const clientRoutes = this.pluginService.getAllRegisteredClientRoutesForParent('/my-account') || {}
const moderationEntries: TopMenuDropdownParam = {
label: $localize`Moderation`,
children: [
{
label: $localize`Muted accounts`,
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/blocklist/accounts',
iconName: 'user-x'
},
{
label: $localize`Muted servers`,
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/blocklist/servers',
iconName: 'peertube-x'
},
{
label: $localize`Abuse reports`,
routerLink: '/my-account/abuses',
iconName: 'flag'
}
]
}
this.menuEntries = [
{
label: $localize`Settings`,
routerLink: '/my-account/settings'
},
2019-01-08 11:26:41 +01:00
{
label: $localize`Notifications`,
2019-01-08 11:26:41 +01:00
routerLink: '/my-account/notifications'
},
2024-02-12 10:50:29 +01:00
{
label: $localize`Import/Export`,
routerLink: '/my-account/import-export'
},
2020-11-09 16:25:27 +01:00
{
label: $localize`Applications`,
routerLink: '/my-account/applications'
},
moderationEntries,
...Object.values(clientRoutes)
.map(clientRoute => ({
label: clientRoute.menuItem?.label,
routerLink: '/my-account/p/' + clientRoute.route
}))
]
2018-09-05 17:18:13 +02:00
}
2018-08-03 11:10:31 +02:00
}