]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/admin.component.ts
Fix broadcast message inconsistency with preview
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / admin.component.ts
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'
6
7 @Component({
8 templateUrl: './admin.component.html',
9 styleUrls: [ './admin.component.scss' ]
10 })
11 export class AdminComponent implements OnInit {
12 items: ListOverflowItem[] = []
13 menuEntries: TopMenuDropdownParam[] = []
14
15 constructor (
16 private auth: AuthService,
17 private screen: ScreenService
18 ) { }
19
20 get isBroadcastMessageDisplayed () {
21 return this.screen.isBroadcastMessageDisplayed
22 }
23
24 ngOnInit () {
25 this.buildOverviewItems()
26 this.buildFederationItems()
27 this.buildModerationItems()
28 this.buildConfigurationItems()
29 this.buildPluginItems()
30 this.buildSystemItems()
31 }
32
33 private buildOverviewItems () {
34 const overviewItems: TopMenuDropdownParam = {
35 label: $localize`Overview`,
36 children: []
37 }
38
39 if (this.hasUsersRight()) {
40 overviewItems.children.push({
41 label: $localize`Users`,
42 routerLink: '/admin/users',
43 iconName: 'user'
44 })
45 }
46
47 if (this.hasVideosRight()) {
48 overviewItems.children.push({
49 label: $localize`Videos`,
50 routerLink: '/admin/videos',
51 iconName: 'videos'
52 })
53 }
54
55 if (this.hasVideoCommentsRight()) {
56 overviewItems.children.push({
57 label: $localize`Comments`,
58 routerLink: '/admin/comments',
59 iconName: 'message-circle'
60 })
61 }
62
63 if (overviewItems.children.length !== 0) {
64 this.menuEntries.push(overviewItems)
65 }
66 }
67
68 private buildFederationItems () {
69 if (!this.hasServerFollowRight()) return
70
71 this.menuEntries.push({
72 label: $localize`Federation`,
73 children: [
74 {
75 label: $localize`Following`,
76 routerLink: '/admin/follows/following-list',
77 iconName: 'following'
78 },
79 {
80 label: $localize`Followers`,
81 routerLink: '/admin/follows/followers-list',
82 iconName: 'follower'
83 },
84 {
85 label: $localize`Video redundancies`,
86 routerLink: '/admin/follows/video-redundancies-list',
87 iconName: 'videos'
88 }
89 ]
90 })
91 }
92
93 private buildModerationItems () {
94 const moderationItems: TopMenuDropdownParam = {
95 label: $localize`Moderation`,
96 children: []
97 }
98
99 if (this.hasRegistrationsRight()) {
100 moderationItems.children.push({
101 label: $localize`Registrations`,
102 routerLink: '/admin/moderation/registrations/list',
103 iconName: 'user'
104 })
105 }
106
107 if (this.hasAbusesRight()) {
108 moderationItems.children.push({
109 label: $localize`Reports`,
110 routerLink: '/admin/moderation/abuses/list',
111 iconName: 'flag'
112 })
113 }
114
115 if (this.hasVideoBlocklistRight()) {
116 moderationItems.children.push({
117 label: $localize`Video blocks`,
118 routerLink: '/admin/moderation/video-blocks/list',
119 iconName: 'cross'
120 })
121 }
122
123 if (this.hasAccountsBlocklistRight()) {
124 moderationItems.children.push({
125 label: $localize`Muted accounts`,
126 routerLink: '/admin/moderation/blocklist/accounts',
127 iconName: 'user-x'
128 })
129 }
130
131 if (this.hasServersBlocklistRight()) {
132 moderationItems.children.push({
133 label: $localize`Muted servers`,
134 routerLink: '/admin/moderation/blocklist/servers',
135 iconName: 'peertube-x'
136 })
137 }
138
139 if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
140 }
141
142 private buildConfigurationItems () {
143 if (this.hasConfigRight()) {
144 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
145 }
146 }
147
148 private buildPluginItems () {
149 if (this.hasPluginsRight()) {
150 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
151 }
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 }
183
184 if (systemItems.children.length !== 0) {
185 this.menuEntries.push(systemItems)
186 }
187 }
188
189 private hasUsersRight () {
190 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
191 }
192
193 private hasServerFollowRight () {
194 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
195 }
196
197 private hasAbusesRight () {
198 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
199 }
200
201 private hasVideoBlocklistRight () {
202 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
203 }
204
205 private hasAccountsBlocklistRight () {
206 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
207 }
208
209 private hasServersBlocklistRight () {
210 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
211 }
212
213 private hasConfigRight () {
214 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
215 }
216
217 private hasPluginsRight () {
218 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
219 }
220
221 private hasLogsRight () {
222 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
223 }
224
225 private hasJobsRight () {
226 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
227 }
228
229 private hasDebugRight () {
230 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
231 }
232
233 private hasVideoCommentsRight () {
234 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
235 }
236
237 private hasVideosRight () {
238 return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS)
239 }
240
241 private hasRegistrationsRight () {
242 return this.auth.getUser().hasRight(UserRight.MANAGE_REGISTRATIONS)
243 }
244 }