1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, ScreenService } from '@app/core'
3 import { ListOverflowItem } from '@app/shared/shared-main'
4 import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
5 import { UserRight } from '@shared/models'
8 templateUrl: './admin.component.html',
9 styleUrls: [ './admin.component.scss' ]
11 export class AdminComponent implements OnInit {
12 items: ListOverflowItem[] = []
13 menuEntries: TopMenuDropdownParam[] = []
16 private auth: AuthService,
17 private screen: ScreenService
20 get isBroadcastMessageDisplayed () {
21 return this.screen.isBroadcastMessageDisplayed
25 const federationItems: TopMenuDropdownParam = {
26 label: $localize`Federation`,
29 label: $localize`Instances you follow`,
30 routerLink: '/admin/follows/following-list',
34 label: $localize`Instances following you`,
35 routerLink: '/admin/follows/followers-list',
39 label: $localize`Video redundancies`,
40 routerLink: '/admin/follows/video-redundancies-list',
46 const moderationItems: TopMenuDropdownParam = {
47 label: $localize`Moderation`,
51 if (this.hasAbusesRight()) {
52 moderationItems.children.push({
53 label: $localize`Reports`,
54 routerLink: '/admin/moderation/abuses/list',
58 if (this.hasVideoBlocklistRight()) {
59 moderationItems.children.push({
60 label: $localize`Video blocks`,
61 routerLink: '/admin/moderation/video-blocks/list',
65 if (this.hasVideoCommentsRight()) {
66 moderationItems.children.push({
67 label: $localize`Video comments`,
68 routerLink: '/admin/moderation/video-comments/list',
69 iconName: 'message-circle'
72 if (this.hasAccountsBlocklistRight()) {
73 moderationItems.children.push({
74 label: $localize`Muted accounts`,
75 routerLink: '/admin/moderation/blocklist/accounts',
79 if (this.hasServersBlocklistRight()) {
80 moderationItems.children.push({
81 label: $localize`Muted servers`,
82 routerLink: '/admin/moderation/blocklist/servers',
83 iconName: 'peertube-x'
87 if (this.hasUsersRight()) {
88 this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
91 if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
92 if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
94 if (this.hasConfigRight()) {
95 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
98 if (this.hasPluginsRight()) {
99 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
102 if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
103 this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' })
108 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
111 hasServerFollowRight () {
112 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
116 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
119 hasVideoBlocklistRight () {
120 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
123 hasAccountsBlocklistRight () {
124 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
127 hasServersBlocklistRight () {
128 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
132 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
136 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
140 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
144 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
148 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
151 hasVideoCommentsRight () {
152 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)