X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin.component.ts;h=15739f8d34dc59ec2d78a72aaf9fc790a7c6a64c;hb=dbb76162b9cf2d048505e4d6170b694388f68e75;hp=64a7400e7e954d5c8d3660a054b7c2c06cb132e7;hpb=b99290b1d5d736083513fb8f66e91f61bfe07e0b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 64a7400e7..15739f8d3 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -1,8 +1,207 @@ -import { Component } from '@angular/core'; +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({ - template: '' + templateUrl: './admin.component.html', + styleUrls: [ './admin.component.scss' ] }) +export class AdminComponent implements OnInit { + items: ListOverflowItem[] = [] + menuEntries: TopMenuDropdownParam[] = [] -export class AdminComponent { + constructor ( + private auth: AuthService, + private screen: ScreenService + ) { } + + get isBroadcastMessageDisplayed () { + return this.screen.isBroadcastMessageDisplayed + } + + ngOnInit () { + this.buildOverviewItems() + this.buildFederationItems() + this.buildModerationItems() + this.buildConfigurationItems() + this.buildPluginItems() + this.buildSystemItems() + } + + private buildOverviewItems () { + if (this.hasUsersRight()) { + this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' }) + } + } + + private buildFederationItems () { + if (!this.hasServerFollowRight()) return + + this.menuEntries.push({ + label: $localize`Federation`, + children: [ + { + label: $localize`Following`, + routerLink: '/admin/follows/following-list', + iconName: 'following' + }, + { + label: $localize`Followers`, + routerLink: '/admin/follows/followers-list', + iconName: 'follower' + }, + { + label: $localize`Video redundancies`, + routerLink: '/admin/follows/video-redundancies-list', + iconName: 'videos' + } + ] + }) + } + + private buildModerationItems () { + 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 (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems) + } + + private buildConfigurationItems () { + if (this.hasConfigRight()) { + this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' }) + } + } + + private buildPluginItems () { + if (this.hasPluginsRight()) { + this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' }) + } + } + + private buildSystemItems () { + const systemItems: TopMenuDropdownParam = { + label: $localize`System`, + children: [] + } + + if (this.hasJobsRight()) { + systemItems.children.push({ + label: $localize`Jobs`, + iconName: 'circle-tick', + routerLink: '/admin/system/jobs' + }) + } + + if (this.hasLogsRight()) { + systemItems.children.push({ + label: $localize`Logs`, + iconName: 'playlists', + routerLink: '/admin/system/logs' + }) + } + + if (this.hasDebugRight()) { + systemItems.children.push({ + label: $localize`Debug`, + iconName: 'cog', + routerLink: '/admin/system/debug' + }) + } + + if (systemItems.children.length !== 0) { + this.menuEntries.push(systemItems) + } + } + + private hasUsersRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) + } + + private hasServerFollowRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) + } + + private hasAbusesRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) + } + + private hasVideoBlocklistRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) + } + + private hasAccountsBlocklistRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) + } + + private hasServersBlocklistRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) + } + + private hasConfigRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) + } + + private hasPluginsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) + } + + private hasLogsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) + } + + private hasJobsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) + } + + private hasDebugRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) + } + + private hasVideoCommentsRight () { + return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) + } }