1 import { Component, OnInit } from '@angular/core'
2 import { AuthService } 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,
22 const federationItems: TopMenuDropdownParam = {
23 label: this.i18n('Federation'),
26 label: this.i18n('Instances you follow'),
27 routerLink: '/admin/follows/following-list',
31 label: this.i18n('Instances following you'),
32 routerLink: '/admin/follows/followers-list',
36 label: this.i18n('Video redundancies'),
37 routerLink: '/admin/follows/video-redundancies-list',
43 const moderationItems: TopMenuDropdownParam = {
44 label: this.i18n('Moderation'),
48 if (this.hasVideoAbusesRight()) {
49 moderationItems.children.push({
50 label: this.i18n('Video reports'),
51 routerLink: '/admin/moderation/video-abuses/list',
55 if (this.hasVideoBlocklistRight()) {
56 moderationItems.children.push({
57 label: this.i18n('Video blocks'),
58 routerLink: '/admin/moderation/video-blocks/list',
62 if (this.hasAccountsBlocklistRight()) {
63 moderationItems.children.push({
64 label: this.i18n('Muted accounts'),
65 routerLink: '/admin/moderation/blocklist/accounts',
69 if (this.hasServersBlocklistRight()) {
70 moderationItems.children.push({
71 label: this.i18n('Muted servers'),
72 routerLink: '/admin/moderation/blocklist/servers',
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' })
86 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
89 hasServerFollowRight () {
90 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
93 hasVideoAbusesRight () {
94 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES)
97 hasVideoBlocklistRight () {
98 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
101 hasAccountsBlocklistRight () {
102 return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
105 hasServersBlocklistRight () {
106 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
110 return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
114 return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
118 return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
122 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
126 return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)