]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/admin.component.ts
add blocked filter in users list to filter banned users
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / admin.component.ts
CommitLineData
24e7916c 1import { Component, OnInit } from '@angular/core'
67ed6552
C
2import { AuthService } from '@app/core'
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,
18 private i18n: I18n
19 ) {}
20
21 ngOnInit () {
57e56eb2
C
22 const federationItems: TopMenuDropdownParam = {
23 label: this.i18n('Federation'),
0a4cb95c
RK
24 children: [
25 {
26 label: this.i18n('Instances you follow'),
57e56eb2 27 routerLink: '/admin/follows/following-list',
0a4cb95c
RK
28 iconName: 'sign-out'
29 },
30 {
31 label: this.i18n('Instances following you'),
57e56eb2 32 routerLink: '/admin/follows/followers-list',
0a4cb95c
RK
33 iconName: 'sign-in'
34 },
35 {
36 label: this.i18n('Video redundancies'),
57e56eb2 37 routerLink: '/admin/follows/video-redundancies-list',
0a4cb95c
RK
38 iconName: 'videos'
39 }
40 ]
41 }
42
43 const moderationItems: TopMenuDropdownParam = {
44 label: this.i18n('Moderation'),
45 children: []
46 }
57e56eb2
C
47
48 if (this.hasVideoAbusesRight()) {
49 moderationItems.children.push({
50 label: this.i18n('Video reports'),
51 routerLink: '/admin/moderation/video-abuses/list',
52 iconName: 'flag'
53 })
54 }
55 if (this.hasVideoBlocklistRight()) {
56 moderationItems.children.push({
57 label: this.i18n('Video blocks'),
58 routerLink: '/admin/moderation/video-blocks/list',
59 iconName: 'cross'
60 })
61 }
62 if (this.hasAccountsBlocklistRight()) {
63 moderationItems.children.push({
64 label: this.i18n('Muted accounts'),
65 routerLink: '/admin/moderation/blocklist/accounts',
66 iconName: 'user'
67 })
68 }
69 if (this.hasServersBlocklistRight()) {
70 moderationItems.children.push({
71 label: this.i18n('Muted servers'),
72 routerLink: '/admin/moderation/blocklist/servers',
73 iconName: 'server'
74 })
75 }
0a4cb95c
RK
76
77 if (this.hasUsersRight()) this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
78 if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
79 if (this.hasVideoAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
80 if (this.hasConfigRight()) this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
81 if (this.hasPluginsRight()) this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
82 if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' })
24e7916c 83 }
04e0fc48
C
84
85 hasUsersRight () {
86 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
87 }
88
89 hasServerFollowRight () {
90 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
91 }
92
93 hasVideoAbusesRight () {
94 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES)
95 }
96
5baee5fc 97 hasVideoBlocklistRight () {
3487330d 98 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
04e0fc48
C
99 }
100
0a4cb95c
RK
101 hasAccountsBlocklistRight () {
102 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
103 }
104
105 hasServersBlocklistRight () {
106 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
107 }
108
5d79474c
C
109 hasConfigRight () {
110 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
04e0fc48 111 }
fd206f0b 112
d00dc28d
C
113 hasPluginsRight () {
114 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
115 }
116
2c22613c
C
117 hasLogsRight () {
118 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
119 }
120
5d79474c
C
121 hasJobsRight () {
122 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
123 }
124
125 hasDebugRight () {
126 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
fd206f0b 127 }
7da18e44 128}