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