2020-02-05 19:54:37 +00:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
2020-08-10 21:28:31 +00:00
|
|
|
import { AuthService, ScreenService } from '@app/core'
|
2020-06-23 12:10:17 +00:00
|
|
|
import { ListOverflowItem } from '@app/shared/shared-main'
|
2020-07-02 07:00:17 +00:00
|
|
|
import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
|
2020-08-12 08:40:04 +00:00
|
|
|
import { UserRight } from '@shared/models'
|
2016-08-09 19:45:21 +00:00
|
|
|
|
|
|
|
@Component({
|
2020-07-02 07:00:17 +00:00
|
|
|
templateUrl: './admin.component.html',
|
|
|
|
styleUrls: [ './admin.component.scss' ]
|
2016-08-09 19:45:21 +00:00
|
|
|
})
|
2020-02-05 19:54:37 +00:00
|
|
|
export class AdminComponent implements OnInit {
|
|
|
|
items: ListOverflowItem[] = []
|
2020-07-02 07:00:17 +00:00
|
|
|
menuEntries: TopMenuDropdownParam[] = []
|
2020-02-05 19:54:37 +00:00
|
|
|
|
|
|
|
constructor (
|
|
|
|
private auth: AuthService,
|
2020-08-12 08:40:04 +00:00
|
|
|
private screen: ScreenService
|
2020-08-10 21:28:31 +00:00
|
|
|
) { }
|
|
|
|
|
|
|
|
get isBroadcastMessageDisplayed () {
|
|
|
|
return this.screen.isBroadcastMessageDisplayed
|
|
|
|
}
|
2020-02-05 19:54:37 +00:00
|
|
|
|
|
|
|
ngOnInit () {
|
2021-10-20 08:27:51 +00:00
|
|
|
this.buildOverviewItems()
|
|
|
|
this.buildFederationItems()
|
|
|
|
this.buildModerationItems()
|
|
|
|
this.buildConfigurationItems()
|
|
|
|
this.buildPluginItems()
|
|
|
|
this.buildSystemItems()
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildOverviewItems () {
|
2021-10-27 07:36:37 +00:00
|
|
|
const overviewItems: TopMenuDropdownParam = {
|
|
|
|
label: $localize`Overview`,
|
|
|
|
children: []
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
if (this.hasUsersRight()) {
|
2021-10-27 07:36:37 +00:00
|
|
|
overviewItems.children.push({
|
|
|
|
label: $localize`Users`,
|
|
|
|
routerLink: '/admin/users',
|
|
|
|
iconName: 'user'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-10-27 09:42:05 +00:00
|
|
|
if (this.hasVideosRight()) {
|
|
|
|
overviewItems.children.push({
|
|
|
|
label: $localize`Videos`,
|
|
|
|
routerLink: '/admin/videos',
|
|
|
|
iconName: 'videos'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-02-28 15:27:25 +00:00
|
|
|
if (this.hasVideoCommentsRight()) {
|
|
|
|
overviewItems.children.push({
|
|
|
|
label: $localize`Comments`,
|
|
|
|
routerLink: '/admin/comments',
|
|
|
|
iconName: 'message-circle'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-10-27 07:36:37 +00:00
|
|
|
if (overviewItems.children.length !== 0) {
|
|
|
|
this.menuEntries.push(overviewItems)
|
2021-10-20 08:27:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildFederationItems () {
|
|
|
|
if (!this.hasServerFollowRight()) return
|
|
|
|
|
|
|
|
this.menuEntries.push({
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Federation`,
|
2020-07-02 07:00:17 +00:00
|
|
|
children: [
|
|
|
|
{
|
2021-07-20 12:15:15 +00:00
|
|
|
label: $localize`Following`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/follows/following-list',
|
2020-07-03 08:28:19 +00:00
|
|
|
iconName: 'following'
|
2020-07-02 07:00:17 +00:00
|
|
|
},
|
|
|
|
{
|
2021-07-20 12:15:15 +00:00
|
|
|
label: $localize`Followers`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/follows/followers-list',
|
2020-07-03 08:28:19 +00:00
|
|
|
iconName: 'follower'
|
2020-07-02 07:00:17 +00:00
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Video redundancies`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/follows/video-redundancies-list',
|
2020-07-02 07:00:17 +00:00
|
|
|
iconName: 'videos'
|
|
|
|
}
|
|
|
|
]
|
2021-10-20 08:27:51 +00:00
|
|
|
})
|
|
|
|
}
|
2020-07-02 07:00:17 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private buildModerationItems () {
|
2020-07-02 07:00:17 +00:00
|
|
|
const moderationItems: TopMenuDropdownParam = {
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Moderation`,
|
2020-07-02 07:00:17 +00:00
|
|
|
children: []
|
|
|
|
}
|
2020-07-02 08:32:11 +00:00
|
|
|
|
2020-07-07 12:34:16 +00:00
|
|
|
if (this.hasAbusesRight()) {
|
2020-07-02 08:32:11 +00:00
|
|
|
moderationItems.children.push({
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Reports`,
|
2020-07-09 09:58:46 +00:00
|
|
|
routerLink: '/admin/moderation/abuses/list',
|
2020-07-02 08:32:11 +00:00
|
|
|
iconName: 'flag'
|
|
|
|
})
|
|
|
|
}
|
2021-10-20 08:27:51 +00:00
|
|
|
|
2020-07-02 08:32:11 +00:00
|
|
|
if (this.hasVideoBlocklistRight()) {
|
|
|
|
moderationItems.children.push({
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Video blocks`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/moderation/video-blocks/list',
|
|
|
|
iconName: 'cross'
|
|
|
|
})
|
|
|
|
}
|
2021-10-20 08:27:51 +00:00
|
|
|
|
2020-07-02 08:32:11 +00:00
|
|
|
if (this.hasAccountsBlocklistRight()) {
|
|
|
|
moderationItems.children.push({
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Muted accounts`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/moderation/blocklist/accounts',
|
2020-07-23 12:42:06 +00:00
|
|
|
iconName: 'user-x'
|
2020-07-02 08:32:11 +00:00
|
|
|
})
|
|
|
|
}
|
2021-10-20 08:27:51 +00:00
|
|
|
|
2020-07-02 08:32:11 +00:00
|
|
|
if (this.hasServersBlocklistRight()) {
|
|
|
|
moderationItems.children.push({
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Muted servers`,
|
2020-07-02 08:32:11 +00:00
|
|
|
routerLink: '/admin/moderation/blocklist/servers',
|
2020-07-23 12:42:06 +00:00
|
|
|
iconName: 'peertube-x'
|
2020-07-02 08:32:11 +00:00
|
|
|
})
|
|
|
|
}
|
2020-07-02 07:00:17 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
|
|
|
|
}
|
2020-07-28 13:18:38 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private buildConfigurationItems () {
|
2020-07-28 13:18:38 +00:00
|
|
|
if (this.hasConfigRight()) {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
|
2020-07-28 13:18:38 +00:00
|
|
|
}
|
2021-10-20 08:27:51 +00:00
|
|
|
}
|
2020-07-28 13:18:38 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private buildPluginItems () {
|
2020-07-28 13:18:38 +00:00
|
|
|
if (this.hasPluginsRight()) {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
|
2020-07-28 13:18:38 +00:00
|
|
|
}
|
2021-10-20 08:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private buildSystemItems () {
|
|
|
|
const systemItems: TopMenuDropdownParam = {
|
|
|
|
label: $localize`System`,
|
|
|
|
children: []
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hasJobsRight()) {
|
|
|
|
systemItems.children.push({
|
|
|
|
label: $localize`Jobs`,
|
|
|
|
iconName: 'circle-tick',
|
|
|
|
routerLink: '/admin/system/jobs'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hasLogsRight()) {
|
|
|
|
systemItems.children.push({
|
|
|
|
label: $localize`Logs`,
|
|
|
|
iconName: 'playlists',
|
|
|
|
routerLink: '/admin/system/logs'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hasDebugRight()) {
|
|
|
|
systemItems.children.push({
|
|
|
|
label: $localize`Debug`,
|
|
|
|
iconName: 'cog',
|
|
|
|
routerLink: '/admin/system/debug'
|
|
|
|
})
|
|
|
|
}
|
2020-07-28 13:18:38 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
if (systemItems.children.length !== 0) {
|
|
|
|
this.menuEntries.push(systemItems)
|
2020-07-28 13:18:38 +00:00
|
|
|
}
|
2020-02-05 19:54:37 +00:00
|
|
|
}
|
2017-12-08 09:41:49 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasUsersRight () {
|
2017-12-08 09:41:49 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasServerFollowRight () {
|
2017-12-08 09:41:49 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasAbusesRight () {
|
2020-07-01 14:05:30 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
|
2017-12-08 09:41:49 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasVideoBlocklistRight () {
|
2020-06-09 14:07:10 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
|
2017-12-08 09:41:49 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasAccountsBlocklistRight () {
|
2020-07-02 07:00:17 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasServersBlocklistRight () {
|
2020-07-02 07:00:17 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasConfigRight () {
|
2019-04-11 08:56:29 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
2017-12-08 09:41:49 +00:00
|
|
|
}
|
2018-01-17 09:32:03 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasPluginsRight () {
|
2019-07-10 16:30:27 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasLogsRight () {
|
2019-04-11 08:05:43 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasJobsRight () {
|
2019-04-11 08:56:29 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasDebugRight () {
|
2019-04-11 08:56:29 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
2018-01-17 09:32:03 +00:00
|
|
|
}
|
2020-11-13 15:38:23 +00:00
|
|
|
|
2021-10-20 08:27:51 +00:00
|
|
|
private hasVideoCommentsRight () {
|
2020-11-13 15:38:23 +00:00
|
|
|
return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
|
|
|
|
}
|
2021-10-27 09:42:05 +00:00
|
|
|
|
|
|
|
private hasVideosRight () {
|
|
|
|
return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS)
|
|
|
|
}
|
2016-08-09 19:45:21 +00:00
|
|
|
}
|