X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin.component.ts;h=dd92ed2caffaed20564d9d331ab116e800ac3d21;hb=8cbc40b2fe9d36ef0505b9441276ca561342e9e9;hp=1a4dd67862d96460b57f1b24db192f9420171bfe;hpb=fd206f0b2d7e5c8e00e2817266d90ec54f79e1da;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 1a4dd6786..dd92ed2ca 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -1,13 +1,108 @@ -import { Component } from '@angular/core' -import { UserRight } from '../../../../shared' -import { AuthService } from '../core/auth/auth.service' +import { Component, OnInit } from '@angular/core' +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', styleUrls: [ './admin.component.scss' ] }) -export class AdminComponent { - constructor (private auth: AuthService) {} +export class AdminComponent implements OnInit { + items: ListOverflowItem[] = [] + menuEntries: TopMenuDropdownParam[] = [] + + constructor ( + private auth: AuthService, + private screen: ScreenService + ) { } + + get isBroadcastMessageDisplayed () { + return this.screen.isBroadcastMessageDisplayed + } + + ngOnInit () { + 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.hasVideoCommentsRight()) { + moderationItems.children.push({ + label: $localize`Video comments`, + routerLink: '/admin/moderation/video-comments/list', + iconName: 'message-circle' + }) + } + 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_USERS) @@ -17,19 +112,43 @@ export class AdminComponent { 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) } - hasVideoBlacklistRight () { + hasVideoBlocklistRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) } - hasJobsRight () { - return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) + 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) } + + hasPluginsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) + } + + hasLogsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) + } + + hasJobsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) + } + + hasDebugRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) + } + + hasVideoCommentsRight () { + return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) + } }