]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/admin.component.ts
Add videos list admin component
[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 (overviewItems.children.length !== 0) {
56 this.menuEntries.push(overviewItems)
57 }
58 }
59
60 private buildFederationItems () {
61 if (!this.hasServerFollowRight()) return
62
63 this.menuEntries.push({
64 label: $localize`Federation`,
65 children: [
66 {
67 label: $localize`Following`,
68 routerLink: '/admin/follows/following-list',
69 iconName: 'following'
70 },
71 {
72 label: $localize`Followers`,
73 routerLink: '/admin/follows/followers-list',
74 iconName: 'follower'
75 },
76 {
77 label: $localize`Video redundancies`,
78 routerLink: '/admin/follows/video-redundancies-list',
79 iconName: 'videos'
80 }
81 ]
82 })
83 }
84
85 private buildModerationItems () {
86 const moderationItems: TopMenuDropdownParam = {
87 label: $localize`Moderation`,
88 children: []
89 }
90
91 if (this.hasAbusesRight()) {
92 moderationItems.children.push({
93 label: $localize`Reports`,
94 routerLink: '/admin/moderation/abuses/list',
95 iconName: 'flag'
96 })
97 }
98
99 if (this.hasVideoBlocklistRight()) {
100 moderationItems.children.push({
101 label: $localize`Video blocks`,
102 routerLink: '/admin/moderation/video-blocks/list',
103 iconName: 'cross'
104 })
105 }
106
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 }
114
115 if (this.hasAccountsBlocklistRight()) {
116 moderationItems.children.push({
117 label: $localize`Muted accounts`,
118 routerLink: '/admin/moderation/blocklist/accounts',
119 iconName: 'user-x'
120 })
121 }
122
123 if (this.hasServersBlocklistRight()) {
124 moderationItems.children.push({
125 label: $localize`Muted servers`,
126 routerLink: '/admin/moderation/blocklist/servers',
127 iconName: 'peertube-x'
128 })
129 }
130
131 if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
132 }
133
134 private buildConfigurationItems () {
135 if (this.hasConfigRight()) {
136 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
137 }
138 }
139
140 private buildPluginItems () {
141 if (this.hasPluginsRight()) {
142 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
143 }
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 }
175
176 if (systemItems.children.length !== 0) {
177 this.menuEntries.push(systemItems)
178 }
179 }
180
181 private hasUsersRight () {
182 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
183 }
184
185 private hasServerFollowRight () {
186 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
187 }
188
189 private hasAbusesRight () {
190 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
191 }
192
193 private hasVideoBlocklistRight () {
194 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
195 }
196
197 private hasAccountsBlocklistRight () {
198 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
199 }
200
201 private hasServersBlocklistRight () {
202 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
203 }
204
205 private hasConfigRight () {
206 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
207 }
208
209 private hasPluginsRight () {
210 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
211 }
212
213 private hasLogsRight () {
214 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
215 }
216
217 private hasJobsRight () {
218 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
219 }
220
221 private hasDebugRight () {
222 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
223 }
224
225 private hasVideoCommentsRight () {
226 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
227 }
228
229 private hasVideosRight () {
230 return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS)
231 }
232 }