]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/admin.component.ts
Migrate to $localize
[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 () {
57e56eb2 25 const federationItems: TopMenuDropdownParam = {
66357162 26 label: $localize`Federation`,
0a4cb95c
RK
27 children: [
28 {
66357162 29 label: $localize`Instances you follow`,
57e56eb2 30 routerLink: '/admin/follows/following-list',
ea7337cf 31 iconName: 'following'
0a4cb95c
RK
32 },
33 {
66357162 34 label: $localize`Instances following you`,
57e56eb2 35 routerLink: '/admin/follows/followers-list',
ea7337cf 36 iconName: 'follower'
0a4cb95c
RK
37 },
38 {
66357162 39 label: $localize`Video redundancies`,
57e56eb2 40 routerLink: '/admin/follows/video-redundancies-list',
0a4cb95c
RK
41 iconName: 'videos'
42 }
43 ]
44 }
45
46 const moderationItems: TopMenuDropdownParam = {
66357162 47 label: $localize`Moderation`,
0a4cb95c
RK
48 children: []
49 }
57e56eb2 50
4f32032f 51 if (this.hasAbusesRight()) {
57e56eb2 52 moderationItems.children.push({
66357162 53 label: $localize`Reports`,
8ca56654 54 routerLink: '/admin/moderation/abuses/list',
57e56eb2
C
55 iconName: 'flag'
56 })
57 }
58 if (this.hasVideoBlocklistRight()) {
59 moderationItems.children.push({
66357162 60 label: $localize`Video blocks`,
57e56eb2
C
61 routerLink: '/admin/moderation/video-blocks/list',
62 iconName: 'cross'
63 })
64 }
65 if (this.hasAccountsBlocklistRight()) {
66 moderationItems.children.push({
66357162 67 label: $localize`Muted accounts`,
57e56eb2 68 routerLink: '/admin/moderation/blocklist/accounts',
345b4a22 69 iconName: 'user-x'
57e56eb2
C
70 })
71 }
72 if (this.hasServersBlocklistRight()) {
73 moderationItems.children.push({
66357162 74 label: $localize`Muted servers`,
57e56eb2 75 routerLink: '/admin/moderation/blocklist/servers',
345b4a22 76 iconName: 'peertube-x'
57e56eb2
C
77 })
78 }
0a4cb95c 79
dfe3f7b7 80 if (this.hasUsersRight()) {
66357162 81 this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
dfe3f7b7
K
82 }
83
0a4cb95c 84 if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
4f32032f 85 if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
dfe3f7b7
K
86
87 if (this.hasConfigRight()) {
66357162 88 this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
dfe3f7b7
K
89 }
90
91 if (this.hasPluginsRight()) {
66357162 92 this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
dfe3f7b7
K
93 }
94
95 if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
66357162 96 this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' })
dfe3f7b7 97 }
24e7916c 98 }
04e0fc48
C
99
100 hasUsersRight () {
101 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
102 }
103
104 hasServerFollowRight () {
105 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
106 }
107
4f32032f 108 hasAbusesRight () {
d95d1559 109 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
04e0fc48
C
110 }
111
5baee5fc 112 hasVideoBlocklistRight () {
3487330d 113 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
04e0fc48
C
114 }
115
0a4cb95c
RK
116 hasAccountsBlocklistRight () {
117 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
118 }
119
120 hasServersBlocklistRight () {
121 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
122 }
123
5d79474c
C
124 hasConfigRight () {
125 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
04e0fc48 126 }
fd206f0b 127
d00dc28d
C
128 hasPluginsRight () {
129 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
130 }
131
2c22613c
C
132 hasLogsRight () {
133 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
134 }
135
5d79474c
C
136 hasJobsRight () {
137 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
138 }
139
140 hasDebugRight () {
141 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
fd206f0b 142 }
7da18e44 143}