X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin.component.ts;h=630bfe25392a10f6ff2b0f30415bf669c670171c;hb=464e4ed92c119c8f5d8ae561ad1d27a90d2581a0;hp=4345d1945e6567aa6462ee39f2fb5a0399d9258d;hpb=8ca56654a176ee8f350d31282c6cac4a59f58499;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 4345d1945..630bfe253 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -1,9 +1,8 @@ import { Component, OnInit } from '@angular/core' -import { AuthService } from '@app/core' +import { AuthService, ScreenService } from '@app/core' import { ListOverflowItem } from '@app/shared/shared-main' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { UserRight } from '@shared/models' import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component' +import { UserRight } from '@shared/models' @Component({ templateUrl: './admin.component.html', @@ -15,114 +14,231 @@ export class AdminComponent implements OnInit { constructor ( private auth: AuthService, - private i18n: I18n - ) {} + private screen: ScreenService + ) { } + + get isBroadcastMessageDisplayed () { + return this.screen.isBroadcastMessageDisplayed + } ngOnInit () { - const federationItems: TopMenuDropdownParam = { - label: this.i18n('Federation'), + this.buildOverviewItems() + this.buildFederationItems() + this.buildModerationItems() + this.buildConfigurationItems() + this.buildPluginItems() + this.buildSystemItems() + } + + private buildOverviewItems () { + const overviewItems: TopMenuDropdownParam = { + label: $localize`Overview`, + children: [] + } + + if (this.hasUsersRight()) { + overviewItems.children.push({ + label: $localize`Users`, + routerLink: '/admin/users', + iconName: 'user' + }) + } + + if (this.hasVideosRight()) { + overviewItems.children.push({ + label: $localize`Videos`, + routerLink: '/admin/videos', + iconName: 'videos' + }) + } + + if (this.hasVideoCommentsRight()) { + overviewItems.children.push({ + label: $localize`Comments`, + routerLink: '/admin/comments', + iconName: 'message-circle' + }) + } + + if (overviewItems.children.length !== 0) { + this.menuEntries.push(overviewItems) + } + } + + private buildFederationItems () { + if (!this.hasServerFollowRight()) return + + this.menuEntries.push({ + label: $localize`Federation`, children: [ { - label: this.i18n('Instances you follow'), + label: $localize`Following`, routerLink: '/admin/follows/following-list', iconName: 'following' }, { - label: this.i18n('Instances following you'), + label: $localize`Followers`, routerLink: '/admin/follows/followers-list', iconName: 'follower' }, { - label: this.i18n('Video redundancies'), + label: $localize`Video redundancies`, routerLink: '/admin/follows/video-redundancies-list', iconName: 'videos' } ] - } + }) + } + private buildModerationItems () { const moderationItems: TopMenuDropdownParam = { - label: this.i18n('Moderation'), + label: $localize`Moderation`, children: [] } + if (this.hasRegistrationsRight()) { + moderationItems.children.push({ + label: $localize`Registrations`, + routerLink: '/admin/moderation/registrations/list', + iconName: 'user' + }) + } + if (this.hasAbusesRight()) { moderationItems.children.push({ - label: this.i18n('Reports'), + label: $localize`Reports`, routerLink: '/admin/moderation/abuses/list', iconName: 'flag' }) } + if (this.hasVideoBlocklistRight()) { moderationItems.children.push({ - label: this.i18n('Video blocks'), + label: $localize`Video blocks`, routerLink: '/admin/moderation/video-blocks/list', iconName: 'cross' }) } + if (this.hasAccountsBlocklistRight()) { moderationItems.children.push({ - label: this.i18n('Muted accounts'), + label: $localize`Muted accounts`, routerLink: '/admin/moderation/blocklist/accounts', - iconName: 'user' + iconName: 'user-x' }) } + if (this.hasServersBlocklistRight()) { moderationItems.children.push({ - label: this.i18n('Muted servers'), + label: $localize`Muted servers`, routerLink: '/admin/moderation/blocklist/servers', - iconName: 'server' + 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 (this.hasUsersRight()) this.menuEntries.push({ label: this.i18n('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: this.i18n('Configuration'), routerLink: '/admin/config' }) - if (this.hasPluginsRight()) this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' }) - if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' }) + if (systemItems.children.length !== 0) { + this.menuEntries.push(systemItems) + } } - hasUsersRight () { + private hasUsersRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) } - hasServerFollowRight () { + private hasServerFollowRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) } - hasAbusesRight () { + private hasAbusesRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) } - hasVideoBlocklistRight () { + private hasVideoBlocklistRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) } - hasAccountsBlocklistRight () { + private hasAccountsBlocklistRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) } - hasServersBlocklistRight () { + private hasServersBlocklistRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) } - hasConfigRight () { + private hasConfigRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) } - hasPluginsRight () { + private hasPluginsRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) } - hasLogsRight () { + private hasLogsRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) } - hasJobsRight () { + private hasJobsRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) } - hasDebugRight () { + private hasDebugRight () { return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) } + + private hasVideoCommentsRight () { + return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) + } + + private hasVideosRight () { + return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS) + } + + private hasRegistrationsRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_REGISTRATIONS) + } }