]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/admin.component.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / admin.component.ts
CommitLineData
24e7916c 1import { Component, OnInit } from '@angular/core'
118626c8 2import { AuthService, ScreenService, ServerService } from '@app/core'
67ed6552 3import { ListOverflowItem } from '@app/shared/shared-main'
0a4cb95c 4import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
66357162 5import { UserRight } from '@shared/models'
7da18e44
C
6
7@Component({
0a4cb95c
RK
8 templateUrl: './admin.component.html',
9 styleUrls: [ './admin.component.scss' ]
7da18e44 10})
24e7916c
RK
11export class AdminComponent implements OnInit {
12 items: ListOverflowItem[] = []
0a4cb95c 13 menuEntries: TopMenuDropdownParam[] = []
24e7916c
RK
14
15 constructor (
16 private auth: AuthService,
118626c8
C
17 private screen: ScreenService,
18 private server: ServerService
7034b3c9 19 ) { }
20
21 get isBroadcastMessageDisplayed () {
22 return this.screen.isBroadcastMessageDisplayed
23 }
24e7916c
RK
24
25 ngOnInit () {
118626c8
C
26 this.server.configReloaded.subscribe(() => this.buildMenu())
27
28 this.buildMenu()
29 }
30
31 private buildMenu () {
32 this.menuEntries = []
33
dbb76162
C
34 this.buildOverviewItems()
35 this.buildFederationItems()
36 this.buildModerationItems()
37 this.buildConfigurationItems()
38 this.buildPluginItems()
39 this.buildSystemItems()
40 }
41
42 private buildOverviewItems () {
00004f7f
C
43 const overviewItems: TopMenuDropdownParam = {
44 label: $localize`Overview`,
45 children: []
46 }
47
dbb76162 48 if (this.hasUsersRight()) {
00004f7f
C
49 overviewItems.children.push({
50 label: $localize`Users`,
51 routerLink: '/admin/users',
52 iconName: 'user'
53 })
54 }
55
33f6dce1
C
56 if (this.hasVideosRight()) {
57 overviewItems.children.push({
58 label: $localize`Videos`,
59 routerLink: '/admin/videos',
60 iconName: 'videos'
61 })
62 }
63
5a51ecc2
C
64 if (this.hasVideoCommentsRight()) {
65 overviewItems.children.push({
66 label: $localize`Comments`,
67 routerLink: '/admin/comments',
68 iconName: 'message-circle'
69 })
70 }
71
00004f7f
C
72 if (overviewItems.children.length !== 0) {
73 this.menuEntries.push(overviewItems)
dbb76162
C
74 }
75 }
76
77 private buildFederationItems () {
78 if (!this.hasServerFollowRight()) return
79
80 this.menuEntries.push({
66357162 81 label: $localize`Federation`,
0a4cb95c
RK
82 children: [
83 {
4d029ef8 84 label: $localize`Following`,
57e56eb2 85 routerLink: '/admin/follows/following-list',
ea7337cf 86 iconName: 'following'
0a4cb95c
RK
87 },
88 {
4d029ef8 89 label: $localize`Followers`,
57e56eb2 90 routerLink: '/admin/follows/followers-list',
ea7337cf 91 iconName: 'follower'
0a4cb95c
RK
92 },
93 {
66357162 94 label: $localize`Video redundancies`,
57e56eb2 95 routerLink: '/admin/follows/video-redundancies-list',
0a4cb95c
RK
96 iconName: 'videos'
97 }
98 ]
dbb76162
C
99 })
100 }
0a4cb95c 101
dbb76162 102 private buildModerationItems () {
0a4cb95c 103 const moderationItems: TopMenuDropdownParam = {
66357162 104 label: $localize`Moderation`,
0a4cb95c
RK
105 children: []
106 }
57e56eb2 107
9589907c
C
108 if (this.hasRegistrationsRight()) {
109 moderationItems.children.push({
110 label: $localize`Registrations`,
111 routerLink: '/admin/moderation/registrations/list',
112 iconName: 'user'
113 })
114 }
115
4f32032f 116 if (this.hasAbusesRight()) {
57e56eb2 117 moderationItems.children.push({
66357162 118 label: $localize`Reports`,
8ca56654 119 routerLink: '/admin/moderation/abuses/list',
57e56eb2
C
120 iconName: 'flag'
121 })
122 }
dbb76162 123
57e56eb2
C
124 if (this.hasVideoBlocklistRight()) {
125 moderationItems.children.push({
66357162 126 label: $localize`Video blocks`,
57e56eb2
C
127 routerLink: '/admin/moderation/video-blocks/list',
128 iconName: 'cross'
129 })
130 }
dbb76162 131
57e56eb2
C
132 if (this.hasAccountsBlocklistRight()) {
133 moderationItems.children.push({
66357162 134 label: $localize`Muted accounts`,
57e56eb2 135 routerLink: '/admin/moderation/blocklist/accounts',
345b4a22 136 iconName: 'user-x'
57e56eb2
C
137 })
138 }
dbb76162 139
57e56eb2
C
140 if (this.hasServersBlocklistRight()) {
141 moderationItems.children.push({
66357162 142 label: $localize`Muted servers`,
57e56eb2 143 routerLink: '/admin/moderation/blocklist/servers',
345b4a22 144 iconName: 'peertube-x'
57e56eb2
C
145 })
146 }
0a4cb95c 147
dbb76162
C
148 if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
149 }
dfe3f7b7 150
dbb76162 151 private buildConfigurationItems () {
dfe3f7b7 152 if (this.hasConfigRight()) {
66357162 153 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
dfe3f7b7 154 }
dbb76162 155 }
dfe3f7b7 156
dbb76162 157 private buildPluginItems () {
dfe3f7b7 158 if (this.hasPluginsRight()) {
66357162 159 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
dfe3f7b7 160 }
dbb76162
C
161 }
162
163 private buildSystemItems () {
164 const systemItems: TopMenuDropdownParam = {
165 label: $localize`System`,
166 children: []
167 }
168
118626c8
C
169 if (this.isRemoteRunnersEnabled() && this.hasRunnersRight()) {
170 systemItems.children.push({
171 label: $localize`Remote runners`,
172 iconName: 'codesandbox',
173 routerLink: '/admin/system/runners/runners-list'
174 })
175
176 systemItems.children.push({
177 label: $localize`Runner jobs`,
178 iconName: 'globe',
179 routerLink: '/admin/system/runners/jobs-list'
180 })
181 }
182
dbb76162
C
183 if (this.hasJobsRight()) {
184 systemItems.children.push({
118626c8 185 label: $localize`Local jobs`,
dbb76162
C
186 iconName: 'circle-tick',
187 routerLink: '/admin/system/jobs'
188 })
189 }
190
191 if (this.hasLogsRight()) {
192 systemItems.children.push({
193 label: $localize`Logs`,
194 iconName: 'playlists',
195 routerLink: '/admin/system/logs'
196 })
197 }
198
199 if (this.hasDebugRight()) {
200 systemItems.children.push({
201 label: $localize`Debug`,
202 iconName: 'cog',
203 routerLink: '/admin/system/debug'
204 })
205 }
dfe3f7b7 206
dbb76162
C
207 if (systemItems.children.length !== 0) {
208 this.menuEntries.push(systemItems)
dfe3f7b7 209 }
24e7916c 210 }
04e0fc48 211
dbb76162 212 private hasUsersRight () {
04e0fc48
C
213 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
214 }
215
dbb76162 216 private hasServerFollowRight () {
04e0fc48
C
217 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
218 }
219
dbb76162 220 private hasAbusesRight () {
d95d1559 221 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
04e0fc48
C
222 }
223
dbb76162 224 private hasVideoBlocklistRight () {
3487330d 225 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
04e0fc48
C
226 }
227
dbb76162 228 private hasAccountsBlocklistRight () {
0a4cb95c
RK
229 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
230 }
231
dbb76162 232 private hasServersBlocklistRight () {
0a4cb95c
RK
233 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
234 }
235
dbb76162 236 private hasConfigRight () {
5d79474c 237 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
04e0fc48 238 }
fd206f0b 239
dbb76162 240 private hasPluginsRight () {
d00dc28d
C
241 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
242 }
243
dbb76162 244 private hasLogsRight () {
2c22613c
C
245 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
246 }
247
dbb76162 248 private hasJobsRight () {
5d79474c
C
249 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
250 }
251
118626c8
C
252 private hasRunnersRight () {
253 return this.auth.getUser().hasRight(UserRight.MANAGE_RUNNERS)
254 }
255
dbb76162 256 private hasDebugRight () {
5d79474c 257 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
fd206f0b 258 }
0f8d00e3 259
dbb76162 260 private hasVideoCommentsRight () {
0f8d00e3
C
261 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
262 }
33f6dce1
C
263
264 private hasVideosRight () {
265 return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS)
266 }
9589907c
C
267
268 private hasRegistrationsRight () {
269 return this.auth.getUser().hasRight(UserRight.MANAGE_REGISTRATIONS)
270 }
118626c8
C
271
272 private isRemoteRunnersEnabled () {
273 const config = this.server.getHTMLConfig()
274
5e47f6ab
C
275 return config.transcoding.remoteRunners.enabled ||
276 config.live.transcoding.remoteRunners.enabled ||
277 config.videoStudio.remoteRunners.enabled
118626c8 278 }
7da18e44 279}