X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin.component.ts;h=9662522dc682db44d84a053622358976c5635edd;hb=d840487fed32b4604b02030c0d7464afa925904f;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..9662522dc 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -1,8 +1,62 @@ -import { Component } from '@angular/core'; +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' @Component({ - template: '' + templateUrl: './admin.component.html' }) +export class AdminComponent implements OnInit { + items: ListOverflowItem[] = [] -export class AdminComponent { + constructor ( + private auth: AuthService, + private i18n: I18n + ) {} + + 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.hasVideoBlacklistRight()) 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' }) + } + + 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_VIDEO_ABUSES) + } + + hasVideoBlacklistRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) + } + + 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) + } }