]>
Commit | Line | Data |
---|---|---|
24e7916c | 1 | import { Component, OnInit } from '@angular/core' |
67ed6552 C |
2 | import { AuthService } from '@app/core' |
3 | import { ListOverflowItem } from '@app/shared/shared-main' | |
24e7916c | 4 | import { I18n } from '@ngx-translate/i18n-polyfill' |
67ed6552 | 5 | import { UserRight } from '@shared/models' |
0a4cb95c | 6 | import { 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 |
12 | export 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', |
ea7337cf | 28 | iconName: 'following' |
0a4cb95c RK |
29 | }, |
30 | { | |
31 | label: this.i18n('Instances following you'), | |
57e56eb2 | 32 | routerLink: '/admin/follows/followers-list', |
ea7337cf | 33 | iconName: 'follower' |
0a4cb95c RK |
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 | 47 | |
4f32032f | 48 | if (this.hasAbusesRight()) { |
57e56eb2 | 49 | moderationItems.children.push({ |
8ca56654 C |
50 | label: this.i18n('Reports'), |
51 | routerLink: '/admin/moderation/abuses/list', | |
57e56eb2 C |
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', | |
345b4a22 | 66 | iconName: 'user-x' |
57e56eb2 C |
67 | }) |
68 | } | |
69 | if (this.hasServersBlocklistRight()) { | |
70 | moderationItems.children.push({ | |
71 | label: this.i18n('Muted servers'), | |
72 | routerLink: '/admin/moderation/blocklist/servers', | |
345b4a22 | 73 | iconName: 'peertube-x' |
57e56eb2 C |
74 | }) |
75 | } | |
0a4cb95c | 76 | |
dfe3f7b7 K |
77 | if (this.hasUsersRight()) { |
78 | this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' }) | |
79 | } | |
80 | ||
0a4cb95c | 81 | if (this.hasServerFollowRight()) this.menuEntries.push(federationItems) |
4f32032f | 82 | if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems) |
dfe3f7b7 K |
83 | |
84 | if (this.hasConfigRight()) { | |
85 | this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' }) | |
86 | } | |
87 | ||
88 | if (this.hasPluginsRight()) { | |
89 | this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' }) | |
90 | } | |
91 | ||
92 | if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) { | |
93 | this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' }) | |
94 | } | |
24e7916c | 95 | } |
04e0fc48 C |
96 | |
97 | hasUsersRight () { | |
98 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) | |
99 | } | |
100 | ||
101 | hasServerFollowRight () { | |
102 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) | |
103 | } | |
104 | ||
4f32032f | 105 | hasAbusesRight () { |
d95d1559 | 106 | return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) |
04e0fc48 C |
107 | } |
108 | ||
5baee5fc | 109 | hasVideoBlocklistRight () { |
3487330d | 110 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) |
04e0fc48 C |
111 | } |
112 | ||
0a4cb95c RK |
113 | hasAccountsBlocklistRight () { |
114 | return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) | |
115 | } | |
116 | ||
117 | hasServersBlocklistRight () { | |
118 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) | |
119 | } | |
120 | ||
5d79474c C |
121 | hasConfigRight () { |
122 | return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) | |
04e0fc48 | 123 | } |
fd206f0b | 124 | |
d00dc28d C |
125 | hasPluginsRight () { |
126 | return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) | |
127 | } | |
128 | ||
2c22613c C |
129 | hasLogsRight () { |
130 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) | |
131 | } | |
132 | ||
5d79474c C |
133 | hasJobsRight () { |
134 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | |
135 | } | |
136 | ||
137 | hasDebugRight () { | |
138 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | |
fd206f0b | 139 | } |
7da18e44 | 140 | } |