1 import { Component, OnInit } from '@angular/core'
2 import { AuthService, ScreenService } from '@app/core'
3 import { ListOverflowItem } from '@app/shared/shared-main'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { UserRight } from '@shared/models'
6 import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component'
9 templateUrl: './admin.component.html',
10 styleUrls: [ './admin.component.scss' ]
12 export class AdminComponent implements OnInit {
13 items: ListOverflowItem[] = []
14 menuEntries: TopMenuDropdownParam[] = []
17 private auth: AuthService,
18 private screen: ScreenService,
22 get isBroadcastMessageDisplayed () {
23 return this.screen.isBroadcastMessageDisplayed
27 const federationItems: TopMenuDropdownParam = {
28 label: this.i18n('Federation'),
31 label: this.i18n('Instances you follow'),
32 routerLink: '/admin/follows/following-list',
36 label: this.i18n('Instances following you'),
37 routerLink: '/admin/follows/followers-list',
41 label: this.i18n('Video redundancies'),
42 routerLink: '/admin/follows/video-redundancies-list',
48 const moderationItems: TopMenuDropdownParam = {
49 label: this.i18n('Moderation'),
53 if (this.hasAbusesRight()) {
54 moderationItems.children.push({
55 label: this.i18n('Reports'),
56 routerLink: '/admin/moderation/abuses/list',
60 if (this.hasVideoBlocklistRight()) {
61 moderationItems.children.push({
62 label: this.i18n('Video blocks'),
63 routerLink: '/admin/moderation/video-blocks/list',
67 if (this.hasAccountsBlocklistRight()) {
68 moderationItems.children.push({
69 label: this.i18n('Muted accounts'),
70 routerLink: '/admin/moderation/blocklist/accounts',
74 if (this.hasServersBlocklistRight()) {
75 moderationItems.children.push({
76 label: this.i18n('Muted servers'),
77 routerLink: '/admin/moderation/blocklist/servers',
78 iconName: 'peertube-x'
82 if (this.hasUsersRight()) {
83 this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
86 if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
87 if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
89 if (this.hasConfigRight()) {
90 this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
93 if (this.hasPluginsRight()) {
94 this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
97 if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
98 this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' })
103 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
106 hasServerFollowRight () {
107 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
111 return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
114 hasVideoBlocklistRight () {
115 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
118 hasAccountsBlocklistRight () {
119 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
122 hasServersBlocklistRight () {
123 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
127 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
131 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
135 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
139 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
143 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)