]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+admin/admin.component.ts
Put admin users in overview tab
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / admin.component.ts
... / ...
CommitLineData
1import { Component, OnInit } from '@angular/core'
2import { AuthService, ScreenService } from '@app/core'
3import { ListOverflowItem } from '@app/shared/shared-main'
4import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
5import { UserRight } from '@shared/models'
6
7@Component({
8 templateUrl: './admin.component.html',
9 styleUrls: [ './admin.component.scss' ]
10})
11export 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 (overviewItems.children.length !== 0) {
48 this.menuEntries.push(overviewItems)
49 }
50 }
51
52 private buildFederationItems () {
53 if (!this.hasServerFollowRight()) return
54
55 this.menuEntries.push({
56 label: $localize`Federation`,
57 children: [
58 {
59 label: $localize`Following`,
60 routerLink: '/admin/follows/following-list',
61 iconName: 'following'
62 },
63 {
64 label: $localize`Followers`,
65 routerLink: '/admin/follows/followers-list',
66 iconName: 'follower'
67 },
68 {
69 label: $localize`Video redundancies`,
70 routerLink: '/admin/follows/video-redundancies-list',
71 iconName: 'videos'
72 }
73 ]
74 })
75 }
76
77 private buildModerationItems () {
78 const moderationItems: TopMenuDropdownParam = {
79 label: $localize`Moderation`,
80 children: []
81 }
82
83 if (this.hasAbusesRight()) {
84 moderationItems.children.push({
85 label: $localize`Reports`,
86 routerLink: '/admin/moderation/abuses/list',
87 iconName: 'flag'
88 })
89 }
90
91 if (this.hasVideoBlocklistRight()) {
92 moderationItems.children.push({
93 label: $localize`Video blocks`,
94 routerLink: '/admin/moderation/video-blocks/list',
95 iconName: 'cross'
96 })
97 }
98
99 if (this.hasVideoCommentsRight()) {
100 moderationItems.children.push({
101 label: $localize`Video comments`,
102 routerLink: '/admin/moderation/video-comments/list',
103 iconName: 'message-circle'
104 })
105 }
106
107 if (this.hasAccountsBlocklistRight()) {
108 moderationItems.children.push({
109 label: $localize`Muted accounts`,
110 routerLink: '/admin/moderation/blocklist/accounts',
111 iconName: 'user-x'
112 })
113 }
114
115 if (this.hasServersBlocklistRight()) {
116 moderationItems.children.push({
117 label: $localize`Muted servers`,
118 routerLink: '/admin/moderation/blocklist/servers',
119 iconName: 'peertube-x'
120 })
121 }
122
123 if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
124 }
125
126 private buildConfigurationItems () {
127 if (this.hasConfigRight()) {
128 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
129 }
130 }
131
132 private buildPluginItems () {
133 if (this.hasPluginsRight()) {
134 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
135 }
136 }
137
138 private buildSystemItems () {
139 const systemItems: TopMenuDropdownParam = {
140 label: $localize`System`,
141 children: []
142 }
143
144 if (this.hasJobsRight()) {
145 systemItems.children.push({
146 label: $localize`Jobs`,
147 iconName: 'circle-tick',
148 routerLink: '/admin/system/jobs'
149 })
150 }
151
152 if (this.hasLogsRight()) {
153 systemItems.children.push({
154 label: $localize`Logs`,
155 iconName: 'playlists',
156 routerLink: '/admin/system/logs'
157 })
158 }
159
160 if (this.hasDebugRight()) {
161 systemItems.children.push({
162 label: $localize`Debug`,
163 iconName: 'cog',
164 routerLink: '/admin/system/debug'
165 })
166 }
167
168 if (systemItems.children.length !== 0) {
169 this.menuEntries.push(systemItems)
170 }
171 }
172
173 private hasUsersRight () {
174 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
175 }
176
177 private hasServerFollowRight () {
178 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
179 }
180
181 private hasAbusesRight () {
182 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
183 }
184
185 private hasVideoBlocklistRight () {
186 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
187 }
188
189 private hasAccountsBlocklistRight () {
190 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
191 }
192
193 private hasServersBlocklistRight () {
194 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
195 }
196
197 private hasConfigRight () {
198 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
199 }
200
201 private hasPluginsRight () {
202 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
203 }
204
205 private hasLogsRight () {
206 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
207 }
208
209 private hasJobsRight () {
210 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
211 }
212
213 private hasDebugRight () {
214 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
215 }
216
217 private hasVideoCommentsRight () {
218 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
219 }
220}