2020-02-05 13:54:37 -06:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
2020-06-23 07:10:17 -05:00
|
|
|
import { AuthService } from '@app/core'
|
|
|
|
import { ListOverflowItem } from '@app/shared/shared-main'
|
2020-02-05 13:54:37 -06:00
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2020-06-23 07:10:17 -05:00
|
|
|
import { UserRight } from '@shared/models'
|
2016-08-09 14:45:21 -05:00
|
|
|
|
|
|
|
@Component({
|
2019-04-02 10:39:21 -05:00
|
|
|
templateUrl: './admin.component.html'
|
2016-08-09 14:45:21 -05:00
|
|
|
})
|
2020-02-05 13:54:37 -06: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' })
|
2020-06-02 13:50:42 -05:00
|
|
|
if (this.hasVideoAbusesRight() || this.hasVideoBlocklistRight()) this.items.push({ label: this.i18n('Moderation'), routerLink: '/admin/moderation' })
|
2020-02-05 13:54:37 -06:00
|
|
|
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 03:41:49 -06: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)
|
|
|
|
}
|
|
|
|
|
2020-06-02 13:50:42 -05:00
|
|
|
hasVideoBlocklistRight () {
|
2020-06-09 09:07:10 -05:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
|
2017-12-08 03:41:49 -06:00
|
|
|
}
|
|
|
|
|
2019-04-11 03:56:29 -05:00
|
|
|
hasConfigRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
2017-12-08 03:41:49 -06:00
|
|
|
}
|
2018-01-17 03:32:03 -06:00
|
|
|
|
2019-07-10 11:30:27 -05:00
|
|
|
hasPluginsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:05:43 -05:00
|
|
|
hasLogsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:56:29 -05:00
|
|
|
hasJobsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
|
|
|
}
|
|
|
|
|
|
|
|
hasDebugRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
2018-01-17 03:32:03 -06:00
|
|
|
}
|
2016-08-09 14:45:21 -05:00
|
|
|
}
|