X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin.component.ts;h=1e137e63ed78701904bdbe8d168b5fdb7699247f;hb=57f6896f67cfc570cf3605dd94b0778101b2d9b9;hp=93ec216bfd7efd12fcef1e36dc949e317d340a6f;hpb=df98563e2104b82b119c00a3cd83cd0dc1242d25;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 93ec216bf..1e137e63e 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -1,8 +1,128 @@ -import { Component } from '@angular/core' +import { Component, OnInit } from '@angular/core' +import { AuthService } 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' @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 i18n: I18n + ) {} + + ngOnInit () { + const federationItems: TopMenuDropdownParam = { + label: this.i18n('Federation'), + children: [ + { + label: this.i18n('Instances you follow'), + routerLink: '/admin/follows/following-list', + iconName: 'following' + }, + { + label: this.i18n('Instances following you'), + routerLink: '/admin/follows/followers-list', + iconName: 'follower' + }, + { + label: this.i18n('Video redundancies'), + routerLink: '/admin/follows/video-redundancies-list', + iconName: 'videos' + } + ] + } + + const moderationItems: TopMenuDropdownParam = { + label: this.i18n('Moderation'), + children: [] + } + + if (this.hasVideoAbusesRight()) { + moderationItems.children.push({ + label: this.i18n('Video reports'), + routerLink: '/admin/moderation/video-abuses/list', + iconName: 'flag' + }) + } + if (this.hasVideoBlocklistRight()) { + moderationItems.children.push({ + label: this.i18n('Video blocks'), + routerLink: '/admin/moderation/video-blocks/list', + iconName: 'cross' + }) + } + if (this.hasAccountsBlocklistRight()) { + moderationItems.children.push({ + label: this.i18n('Muted accounts'), + routerLink: '/admin/moderation/blocklist/accounts', + iconName: 'user' + }) + } + if (this.hasServersBlocklistRight()) { + moderationItems.children.push({ + label: this.i18n('Muted servers'), + routerLink: '/admin/moderation/blocklist/servers', + iconName: 'server' + }) + } + + if (this.hasUsersRight()) this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' }) + if (this.hasServerFollowRight()) this.menuEntries.push(federationItems) + if (this.hasVideoAbusesRight() || 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' }) + } + + hasUsersRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) + } + + hasServerFollowRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) + } + + hasVideoAbusesRight () { + 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) + } + + 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) + } }