2024-04-04 08:17:59 +02:00
|
|
|
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'
|
2024-04-04 08:17:59 +02:00
|
|
|
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',
|
2018-09-05 14:42:59 +02:00
|
|
|
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 {
|
2018-12-05 14:21:10 +01:00
|
|
|
menuEntries: TopMenuDropdownParam[] = []
|
2020-07-28 15:18:38 +02:00
|
|
|
user: AuthUser
|
2018-09-05 17:18:13 +02:00
|
|
|
|
2024-04-04 08:17:59 +02:00
|
|
|
constructor (
|
|
|
|
private pluginService: PluginService,
|
|
|
|
private screenService: ScreenService
|
|
|
|
) { }
|
2019-12-18 15:31:54 +01:00
|
|
|
|
2020-08-10 23:28:31 +02:00
|
|
|
get isBroadcastMessageDisplayed () {
|
|
|
|
return this.screenService.isBroadcastMessageDisplayed
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:31:54 +01:00
|
|
|
ngOnInit (): void {
|
2024-04-04 08:17:59 +02:00
|
|
|
this.pluginService.ensurePluginsAreLoaded('my-account')
|
|
|
|
.then(() => this.buildMenu())
|
2020-07-28 15:18:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private buildMenu () {
|
2024-04-04 08:17:59 +02:00
|
|
|
const clientRoutes = this.pluginService.getAllRegisteredClientRoutesForParent('/my-account') || {}
|
|
|
|
|
2020-11-12 15:28:54 +01:00
|
|
|
const moderationEntries: TopMenuDropdownParam = {
|
|
|
|
label: $localize`Moderation`,
|
2018-12-05 14:21:10 +01:00
|
|
|
children: [
|
|
|
|
{
|
2020-08-12 10:40:04 +02:00
|
|
|
label: $localize`Muted accounts`,
|
2019-03-20 13:53:51 +01:00
|
|
|
routerLink: '/my-account/blocklist/accounts',
|
2020-07-23 14:42:06 +02:00
|
|
|
iconName: 'user-x'
|
2018-12-05 14:21:10 +01:00
|
|
|
},
|
|
|
|
{
|
2020-08-12 10:40:04 +02:00
|
|
|
label: $localize`Muted servers`,
|
2019-03-20 13:53:51 +01:00
|
|
|
routerLink: '/my-account/blocklist/servers',
|
2020-07-23 14:42:06 +02:00
|
|
|
iconName: 'peertube-x'
|
2018-12-05 14:21:10 +01:00
|
|
|
},
|
2020-07-27 11:40:30 +02:00
|
|
|
{
|
2020-11-12 15:28:54 +01:00
|
|
|
label: $localize`Abuse reports`,
|
2020-07-27 11:40:30 +02:00
|
|
|
routerLink: '/my-account/abuses',
|
|
|
|
iconName: 'flag'
|
2018-12-05 14:21:10 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2018-09-05 14:42:59 +02:00
|
|
|
|
2018-12-05 14:21:10 +01:00
|
|
|
this.menuEntries = [
|
|
|
|
{
|
2020-11-12 15:28:54 +01:00
|
|
|
label: $localize`Settings`,
|
2018-12-05 14:21:10 +01:00
|
|
|
routerLink: '/my-account/settings'
|
|
|
|
},
|
2020-11-12 15:28:54 +01:00
|
|
|
|
2019-01-08 11:26:41 +01:00
|
|
|
{
|
2020-11-12 15:28:54 +01:00
|
|
|
label: $localize`Notifications`,
|
2019-01-08 11:26:41 +01:00
|
|
|
routerLink: '/my-account/notifications'
|
|
|
|
},
|
2020-11-12 15:28:54 +01:00
|
|
|
|
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'
|
|
|
|
},
|
|
|
|
|
2024-04-04 08:17:59 +02:00
|
|
|
moderationEntries,
|
|
|
|
|
|
|
|
...Object.values(clientRoutes)
|
|
|
|
.map(clientRoute => ({
|
|
|
|
label: clientRoute.menuItem?.label,
|
|
|
|
routerLink: '/my-account/p/' + clientRoute.route
|
|
|
|
}))
|
2018-12-05 14:21:10 +01:00
|
|
|
]
|
2018-09-05 17:18:13 +02:00
|
|
|
}
|
2018-08-03 11:10:31 +02:00
|
|
|
}
|