2020-02-05 14:54:37 -05:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
2020-06-23 08:10:17 -04:00
|
|
|
import { AuthService } from '@app/core'
|
|
|
|
import { ListOverflowItem } from '@app/shared/shared-main'
|
2020-02-05 14:54:37 -05:00
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2020-06-23 08:10:17 -04:00
|
|
|
import { UserRight } from '@shared/models'
|
2020-07-02 03:00:17 -04:00
|
|
|
import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
|
2016-08-09 15:45:21 -04:00
|
|
|
|
|
|
|
@Component({
|
2020-07-02 03:00:17 -04:00
|
|
|
templateUrl: './admin.component.html',
|
|
|
|
styleUrls: [ './admin.component.scss' ]
|
2016-08-09 15:45:21 -04:00
|
|
|
})
|
2020-02-05 14:54:37 -05:00
|
|
|
export class AdminComponent implements OnInit {
|
|
|
|
items: ListOverflowItem[] = []
|
2020-07-02 03:00:17 -04:00
|
|
|
menuEntries: TopMenuDropdownParam[] = []
|
2020-02-05 14:54:37 -05:00
|
|
|
|
|
|
|
constructor (
|
|
|
|
private auth: AuthService,
|
|
|
|
private i18n: I18n
|
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit () {
|
2020-07-02 04:32:11 -04:00
|
|
|
const federationItems: TopMenuDropdownParam = {
|
|
|
|
label: this.i18n('Federation'),
|
2020-07-02 03:00:17 -04:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: this.i18n('Instances you follow'),
|
2020-07-02 04:32:11 -04:00
|
|
|
routerLink: '/admin/follows/following-list',
|
2020-07-02 03:00:17 -04:00
|
|
|
iconName: 'sign-out'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.i18n('Instances following you'),
|
2020-07-02 04:32:11 -04:00
|
|
|
routerLink: '/admin/follows/followers-list',
|
2020-07-02 03:00:17 -04:00
|
|
|
iconName: 'sign-in'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.i18n('Video redundancies'),
|
2020-07-02 04:32:11 -04:00
|
|
|
routerLink: '/admin/follows/video-redundancies-list',
|
2020-07-02 03:00:17 -04:00
|
|
|
iconName: 'videos'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
const moderationItems: TopMenuDropdownParam = {
|
|
|
|
label: this.i18n('Moderation'),
|
|
|
|
children: []
|
|
|
|
}
|
2020-07-02 04:32:11 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
})
|
|
|
|
}
|
2020-07-02 03:00:17 -04:00
|
|
|
|
|
|
|
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' })
|
2020-02-05 14:54:37 -05:00
|
|
|
}
|
2017-12-08 04:41:49 -05: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 14:50:42 -04:00
|
|
|
hasVideoBlocklistRight () {
|
2020-06-09 10:07:10 -04:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
|
2017-12-08 04:41:49 -05:00
|
|
|
}
|
|
|
|
|
2020-07-02 03:00:17 -04:00
|
|
|
hasAccountsBlocklistRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
|
|
|
|
}
|
|
|
|
|
|
|
|
hasServersBlocklistRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
|
|
|
|
}
|
|
|
|
|
2019-04-11 04:56:29 -04:00
|
|
|
hasConfigRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
2017-12-08 04:41:49 -05:00
|
|
|
}
|
2018-01-17 04:32:03 -05:00
|
|
|
|
2019-07-10 12:30:27 -04:00
|
|
|
hasPluginsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 04:05:43 -04:00
|
|
|
hasLogsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
|
|
|
}
|
|
|
|
|
2019-04-11 04:56:29 -04:00
|
|
|
hasJobsRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
|
|
|
}
|
|
|
|
|
|
|
|
hasDebugRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
2018-01-17 04:32:03 -05:00
|
|
|
}
|
2016-08-09 15:45:21 -04:00
|
|
|
}
|