]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/admin.component.ts
Update ffmpeg min version
[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'
24e7916c 4import { I18n } from '@ngx-translate/i18n-polyfill'
67ed6552 5import { UserRight } from '@shared/models'
0a4cb95c 6import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
7da18e44
C
7
8@Component({
0a4cb95c
RK
9 templateUrl: './admin.component.html',
10 styleUrls: [ './admin.component.scss' ]
7da18e44 11})
24e7916c
RK
12export class AdminComponent implements OnInit {
13 items: ListOverflowItem[] = []
0a4cb95c 14 menuEntries: TopMenuDropdownParam[] = []
24e7916c
RK
15
16 constructor (
17 private auth: AuthService,
7034b3c9 18 private screen: ScreenService,
24e7916c 19 private i18n: I18n
7034b3c9 20 ) { }
21
22 get isBroadcastMessageDisplayed () {
23 return this.screen.isBroadcastMessageDisplayed
24 }
24e7916c
RK
25
26 ngOnInit () {
57e56eb2
C
27 const federationItems: TopMenuDropdownParam = {
28 label: this.i18n('Federation'),
0a4cb95c
RK
29 children: [
30 {
31 label: this.i18n('Instances you follow'),
57e56eb2 32 routerLink: '/admin/follows/following-list',
ea7337cf 33 iconName: 'following'
0a4cb95c
RK
34 },
35 {
36 label: this.i18n('Instances following you'),
57e56eb2 37 routerLink: '/admin/follows/followers-list',
ea7337cf 38 iconName: 'follower'
0a4cb95c
RK
39 },
40 {
41 label: this.i18n('Video redundancies'),
57e56eb2 42 routerLink: '/admin/follows/video-redundancies-list',
0a4cb95c
RK
43 iconName: 'videos'
44 }
45 ]
46 }
47
48 const moderationItems: TopMenuDropdownParam = {
49 label: this.i18n('Moderation'),
50 children: []
51 }
57e56eb2 52
4f32032f 53 if (this.hasAbusesRight()) {
57e56eb2 54 moderationItems.children.push({
8ca56654
C
55 label: this.i18n('Reports'),
56 routerLink: '/admin/moderation/abuses/list',
57e56eb2
C
57 iconName: 'flag'
58 })
59 }
60 if (this.hasVideoBlocklistRight()) {
61 moderationItems.children.push({
62 label: this.i18n('Video blocks'),
63 routerLink: '/admin/moderation/video-blocks/list',
64 iconName: 'cross'
65 })
66 }
67 if (this.hasAccountsBlocklistRight()) {
68 moderationItems.children.push({
69 label: this.i18n('Muted accounts'),
70 routerLink: '/admin/moderation/blocklist/accounts',
345b4a22 71 iconName: 'user-x'
57e56eb2
C
72 })
73 }
74 if (this.hasServersBlocklistRight()) {
75 moderationItems.children.push({
76 label: this.i18n('Muted servers'),
77 routerLink: '/admin/moderation/blocklist/servers',
345b4a22 78 iconName: 'peertube-x'
57e56eb2
C
79 })
80 }
0a4cb95c 81
dfe3f7b7
K
82 if (this.hasUsersRight()) {
83 this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
84 }
85
0a4cb95c 86 if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
4f32032f 87 if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
dfe3f7b7
K
88
89 if (this.hasConfigRight()) {
90 this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
91 }
92
93 if (this.hasPluginsRight()) {
94 this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
95 }
96
97 if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
98 this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' })
99 }
24e7916c 100 }
04e0fc48
C
101
102 hasUsersRight () {
103 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
104 }
105
106 hasServerFollowRight () {
107 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
108 }
109
4f32032f 110 hasAbusesRight () {
d95d1559 111 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
04e0fc48
C
112 }
113
5baee5fc 114 hasVideoBlocklistRight () {
3487330d 115 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
04e0fc48
C
116 }
117
0a4cb95c
RK
118 hasAccountsBlocklistRight () {
119 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
120 }
121
122 hasServersBlocklistRight () {
123 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
124 }
125
5d79474c
C
126 hasConfigRight () {
127 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
04e0fc48 128 }
fd206f0b 129
d00dc28d
C
130 hasPluginsRight () {
131 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
132 }
133
2c22613c
C
134 hasLogsRight () {
135 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
136 }
137
5d79474c
C
138 hasJobsRight () {
139 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
140 }
141
142 hasDebugRight () {
143 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
fd206f0b 144 }
7da18e44 145}