]>
Commit | Line | Data |
---|---|---|
24e7916c | 1 | import { Component, OnInit } from '@angular/core' |
04e0fc48 C |
2 | import { UserRight } from '../../../../shared' |
3 | import { AuthService } from '../core/auth/auth.service' | |
24e7916c RK |
4 | import { ListOverflowItem } from '@app/shared/misc/list-overflow.component' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
7da18e44 C |
6 | |
7 | @Component({ | |
f421fa06 | 8 | templateUrl: './admin.component.html' |
7da18e44 | 9 | }) |
24e7916c RK |
10 | export class AdminComponent implements OnInit { |
11 | items: ListOverflowItem[] = [] | |
12 | ||
13 | constructor ( | |
14 | private auth: AuthService, | |
15 | private i18n: I18n | |
16 | ) {} | |
17 | ||
18 | ngOnInit () { | |
19 | if (this.hasUsersRight()) this.items.push({ label: this.i18n('Users'), routerLink: '/admin/users' }) | |
20 | if (this.hasServerFollowRight()) this.items.push({ label: this.i18n('Follows & redundancies'), routerLink: '/admin/follows' }) | |
5baee5fc | 21 | if (this.hasVideoAbusesRight() || this.hasVideoBlocklistRight()) this.items.push({ label: this.i18n('Moderation'), routerLink: '/admin/moderation' }) |
24e7916c RK |
22 | if (this.hasConfigRight()) this.items.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' }) |
23 | if (this.hasPluginsRight()) this.items.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' }) | |
24 | if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) this.items.push({ label: this.i18n('System'), routerLink: '/admin/system' }) | |
25 | } | |
04e0fc48 C |
26 | |
27 | hasUsersRight () { | |
28 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) | |
29 | } | |
30 | ||
31 | hasServerFollowRight () { | |
32 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) | |
33 | } | |
34 | ||
35 | hasVideoAbusesRight () { | |
36 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES) | |
37 | } | |
38 | ||
5baee5fc | 39 | hasVideoBlocklistRight () { |
3487330d | 40 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) |
04e0fc48 C |
41 | } |
42 | ||
5d79474c C |
43 | hasConfigRight () { |
44 | return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) | |
04e0fc48 | 45 | } |
fd206f0b | 46 | |
d00dc28d C |
47 | hasPluginsRight () { |
48 | return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) | |
49 | } | |
50 | ||
2c22613c C |
51 | hasLogsRight () { |
52 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) | |
53 | } | |
54 | ||
5d79474c C |
55 | hasJobsRight () { |
56 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | |
57 | } | |
58 | ||
59 | hasDebugRight () { | |
60 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | |
fd206f0b | 61 | } |
7da18e44 | 62 | } |