import { Component, OnInit } from '@angular/core'
-import { UserRight } from '../../../../shared'
-import { AuthService } from '../core/auth/auth.service'
-import { ListOverflowItem } from '@app/shared/misc/list-overflow.component'
-import { I18n } from '@ngx-translate/i18n-polyfill'
+import { AuthService, ScreenService } from '@app/core'
+import { ListOverflowItem } from '@app/shared/shared-main'
+import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
+import { UserRight } from '@shared/models'
@Component({
- templateUrl: './admin.component.html'
+ templateUrl: './admin.component.html',
+ styleUrls: [ './admin.component.scss' ]
})
export class AdminComponent implements OnInit {
items: ListOverflowItem[] = []
+ menuEntries: TopMenuDropdownParam[] = []
constructor (
private auth: AuthService,
- private i18n: I18n
- ) {}
+ private screen: ScreenService
+ ) { }
+
+ get isBroadcastMessageDisplayed () {
+ return this.screen.isBroadcastMessageDisplayed
+ }
ngOnInit () {
- if (this.hasUsersRight()) this.items.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
- if (this.hasServerFollowRight()) this.items.push({ label: this.i18n('Follows & redundancies'), routerLink: '/admin/follows' })
- if (this.hasVideoAbusesRight() || this.hasVideoBlocklistRight()) this.items.push({ label: this.i18n('Moderation'), routerLink: '/admin/moderation' })
- if (this.hasConfigRight()) this.items.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
- if (this.hasPluginsRight()) this.items.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
- if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) this.items.push({ label: this.i18n('System'), routerLink: '/admin/system' })
+ const federationItems: TopMenuDropdownParam = {
+ label: $localize`Federation`,
+ children: [
+ {
+ label: $localize`Instances you follow`,
+ routerLink: '/admin/follows/following-list',
+ iconName: 'following'
+ },
+ {
+ label: $localize`Instances following you`,
+ routerLink: '/admin/follows/followers-list',
+ iconName: 'follower'
+ },
+ {
+ label: $localize`Video redundancies`,
+ routerLink: '/admin/follows/video-redundancies-list',
+ iconName: 'videos'
+ }
+ ]
+ }
+
+ const moderationItems: TopMenuDropdownParam = {
+ label: $localize`Moderation`,
+ children: []
+ }
+
+ if (this.hasAbusesRight()) {
+ moderationItems.children.push({
+ label: $localize`Reports`,
+ routerLink: '/admin/moderation/abuses/list',
+ iconName: 'flag'
+ })
+ }
+ if (this.hasVideoBlocklistRight()) {
+ moderationItems.children.push({
+ label: $localize`Video blocks`,
+ routerLink: '/admin/moderation/video-blocks/list',
+ iconName: 'cross'
+ })
+ }
+ if (this.hasAccountsBlocklistRight()) {
+ moderationItems.children.push({
+ label: $localize`Muted accounts`,
+ routerLink: '/admin/moderation/blocklist/accounts',
+ iconName: 'user-x'
+ })
+ }
+ if (this.hasServersBlocklistRight()) {
+ moderationItems.children.push({
+ label: $localize`Muted servers`,
+ routerLink: '/admin/moderation/blocklist/servers',
+ iconName: 'peertube-x'
+ })
+ }
+
+ if (this.hasUsersRight()) {
+ this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
+ }
+
+ if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
+ if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
+
+ if (this.hasConfigRight()) {
+ this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
+ }
+
+ if (this.hasPluginsRight()) {
+ this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
+ }
+
+ if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
+ this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' })
+ }
}
hasUsersRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
}
- hasVideoAbusesRight () {
- return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES)
+ hasAbusesRight () {
+ return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
}
hasVideoBlocklistRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
}
+ hasAccountsBlocklistRight () {
+ return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
+ }
+
+ hasServersBlocklistRight () {
+ return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
+ }
+
hasConfigRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
}