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