2020-02-05 20:54:37 +01:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
2017-12-08 10:41:49 +01:00
|
|
|
import { UserRight } from '../../../../shared'
|
|
|
|
import { AuthService } from '../core/auth/auth.service'
|
2020-02-05 20:54:37 +01:00
|
|
|
import { ListOverflowItem } from '@app/shared/misc/list-overflow.component'
|
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2016-08-09 21:45:21 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-04-02 17:39:21 +02:00
|
|
|
templateUrl: './admin.component.html'
|
2016-08-09 21:45:21 +02:00
|
|
|
})
|
2020-02-05 20:54:37 +01:00
|
|
|
export class AdminComponent implements OnInit {
|
|
|
|
items: ListOverflowItem[] = []
|
|
|
|
|
|
|
|
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' })
|
|
|
|
}
|
2017-12-08 10:41:49 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-04-11 10:56:29 +02:00
|
|
|
hasConfigRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
2017-12-08 10:41:49 +01:00
|
|
|
}
|
2018-01-17 10:32:03 +01:00
|
|
|
|
2019-07-10 18:30:27 +02:00
|
|
|
hasPluginsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 10:05:43 +02:00
|
|
|
hasLogsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 10:56:29 +02:00
|
|
|
hasJobsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
|
|
|
}
|
|
|
|
|
|
|
|
hasDebugRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
2018-01-17 10:32:03 +01:00
|
|
|
}
|
2016-08-09 21:45:21 +02:00
|
|
|
}
|