PeerTube/client/src/app/+admin/admin.component.ts

155 lines
4.4 KiB
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core'
import { AuthService, ScreenService } from '@app/core'
2020-06-23 07:10:17 -05:00
import { ListOverflowItem } from '@app/shared/shared-main'
import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
import { UserRight } from '@shared/models'
2016-08-09 14:45:21 -05:00
@Component({
templateUrl: './admin.component.html',
styleUrls: [ './admin.component.scss' ]
2016-08-09 14:45:21 -05:00
})
export class AdminComponent implements OnInit {
items: ListOverflowItem[] = []
menuEntries: TopMenuDropdownParam[] = []
constructor (
private auth: AuthService,
private screen: ScreenService
) { }
get isBroadcastMessageDisplayed () {
return this.screen.isBroadcastMessageDisplayed
}
ngOnInit () {
2020-07-02 03:32:11 -05:00
const federationItems: TopMenuDropdownParam = {
label: $localize`Federation`,
children: [
{
label: $localize`Instances you follow`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/follows/following-list',
iconName: 'following'
},
{
label: $localize`Instances following you`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/follows/followers-list',
iconName: 'follower'
},
{
label: $localize`Video redundancies`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/follows/video-redundancies-list',
iconName: 'videos'
}
]
}
const moderationItems: TopMenuDropdownParam = {
label: $localize`Moderation`,
children: []
}
2020-07-02 03:32:11 -05:00
2020-07-07 07:34:16 -05:00
if (this.hasAbusesRight()) {
2020-07-02 03:32:11 -05:00
moderationItems.children.push({
label: $localize`Reports`,
routerLink: '/admin/moderation/abuses/list',
2020-07-02 03:32:11 -05:00
iconName: 'flag'
})
}
if (this.hasVideoBlocklistRight()) {
moderationItems.children.push({
label: $localize`Video blocks`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/moderation/video-blocks/list',
iconName: 'cross'
})
}
2020-11-13 09:38:23 -06:00
if (this.hasVideoCommentsRight()) {
moderationItems.children.push({
label: $localize`Video comments`,
routerLink: '/admin/moderation/video-comments/list',
iconName: 'message-circle'
})
}
2020-07-02 03:32:11 -05:00
if (this.hasAccountsBlocklistRight()) {
moderationItems.children.push({
label: $localize`Muted accounts`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/moderation/blocklist/accounts',
iconName: 'user-x'
2020-07-02 03:32:11 -05:00
})
}
if (this.hasServersBlocklistRight()) {
moderationItems.children.push({
label: $localize`Muted servers`,
2020-07-02 03:32:11 -05:00
routerLink: '/admin/moderation/blocklist/servers',
iconName: 'peertube-x'
2020-07-02 03:32:11 -05:00
})
}
if (this.hasUsersRight()) {
this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
}
if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
2020-07-07 07:34:16 -05:00
if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
if (this.hasConfigRight()) {
this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
}
if (this.hasPluginsRight()) {
this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
}
if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
this.menuEntries.push({ label: $localize`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)
}
2020-07-07 07:34:16 -05:00
hasAbusesRight () {
2020-07-01 09:05:30 -05:00
return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
2017-12-08 03:41:49 -06:00
}
hasVideoBlocklistRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
2017-12-08 03:41:49 -06:00
}
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)
2017-12-08 03:41:49 -06: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)
}
hasJobsRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
}
hasDebugRight () {
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
}
2020-11-13 09:38:23 -06:00
hasVideoCommentsRight () {
return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
}
2016-08-09 14:45:21 -05:00
}