]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
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
47 if (overviewItems.children.length !== 0) {
48 this.menuEntries.push(overviewItems)
dbb76162
C
49 }
50 }
51
52 private buildFederationItems () {
53 if (!this.hasServerFollowRight()) return
54
55 this.menuEntries.push({
66357162 56 label: $localize`Federation`,
0a4cb95c
RK
57 children: [
58 {
4d029ef8 59 label: $localize`Following`,
57e56eb2 60 routerLink: '/admin/follows/following-list',
ea7337cf 61 iconName: 'following'
0a4cb95c
RK
62 },
63 {
4d029ef8 64 label: $localize`Followers`,
57e56eb2 65 routerLink: '/admin/follows/followers-list',
ea7337cf 66 iconName: 'follower'
0a4cb95c
RK
67 },
68 {
66357162 69 label: $localize`Video redundancies`,
57e56eb2 70 routerLink: '/admin/follows/video-redundancies-list',
0a4cb95c
RK
71 iconName: 'videos'
72 }
73 ]
dbb76162
C
74 })
75 }
0a4cb95c 76
dbb76162 77 private buildModerationItems () {
0a4cb95c 78 const moderationItems: TopMenuDropdownParam = {
66357162 79 label: $localize`Moderation`,
0a4cb95c
RK
80 children: []
81 }
57e56eb2 82
4f32032f 83 if (this.hasAbusesRight()) {
57e56eb2 84 moderationItems.children.push({
66357162 85 label: $localize`Reports`,
8ca56654 86 routerLink: '/admin/moderation/abuses/list',
57e56eb2
C
87 iconName: 'flag'
88 })
89 }
dbb76162 90
57e56eb2
C
91 if (this.hasVideoBlocklistRight()) {
92 moderationItems.children.push({
66357162 93 label: $localize`Video blocks`,
57e56eb2
C
94 routerLink: '/admin/moderation/video-blocks/list',
95 iconName: 'cross'
96 })
97 }
dbb76162 98
0f8d00e3
C
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 }
dbb76162 106
57e56eb2
C
107 if (this.hasAccountsBlocklistRight()) {
108 moderationItems.children.push({
66357162 109 label: $localize`Muted accounts`,
57e56eb2 110 routerLink: '/admin/moderation/blocklist/accounts',
345b4a22 111 iconName: 'user-x'
57e56eb2
C
112 })
113 }
dbb76162 114
57e56eb2
C
115 if (this.hasServersBlocklistRight()) {
116 moderationItems.children.push({
66357162 117 label: $localize`Muted servers`,
57e56eb2 118 routerLink: '/admin/moderation/blocklist/servers',
345b4a22 119 iconName: 'peertube-x'
57e56eb2
C
120 })
121 }
0a4cb95c 122
dbb76162
C
123 if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
124 }
dfe3f7b7 125
dbb76162 126 private buildConfigurationItems () {
dfe3f7b7 127 if (this.hasConfigRight()) {
66357162 128 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
dfe3f7b7 129 }
dbb76162 130 }
dfe3f7b7 131
dbb76162 132 private buildPluginItems () {
dfe3f7b7 133 if (this.hasPluginsRight()) {
66357162 134 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
dfe3f7b7 135 }
dbb76162
C
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 }
dfe3f7b7 167
dbb76162
C
168 if (systemItems.children.length !== 0) {
169 this.menuEntries.push(systemItems)
dfe3f7b7 170 }
24e7916c 171 }
04e0fc48 172
dbb76162 173 private hasUsersRight () {
04e0fc48
C
174 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
175 }
176
dbb76162 177 private hasServerFollowRight () {
04e0fc48
C
178 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
179 }
180
dbb76162 181 private hasAbusesRight () {
d95d1559 182 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
04e0fc48
C
183 }
184
dbb76162 185 private hasVideoBlocklistRight () {
3487330d 186 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
04e0fc48
C
187 }
188
dbb76162 189 private hasAccountsBlocklistRight () {
0a4cb95c
RK
190 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
191 }
192
dbb76162 193 private hasServersBlocklistRight () {
0a4cb95c
RK
194 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
195 }
196
dbb76162 197 private hasConfigRight () {
5d79474c 198 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
04e0fc48 199 }
fd206f0b 200
dbb76162 201 private hasPluginsRight () {
d00dc28d
C
202 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
203 }
204
dbb76162 205 private hasLogsRight () {
2c22613c
C
206 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
207 }
208
dbb76162 209 private hasJobsRight () {
5d79474c
C
210 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
211 }
212
dbb76162 213 private hasDebugRight () {
5d79474c 214 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
fd206f0b 215 }
0f8d00e3 216
dbb76162 217 private hasVideoCommentsRight () {
0f8d00e3
C
218 return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
219 }
7da18e44 220}