]>
Commit | Line | Data |
---|---|---|
24e7916c | 1 | import { Component, OnInit } from '@angular/core' |
7034b3c9 | 2 | import { AuthService, ScreenService } from '@app/core' |
67ed6552 | 3 | import { ListOverflowItem } from '@app/shared/shared-main' |
0a4cb95c | 4 | import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component' |
66357162 | 5 | import { UserRight } from '@shared/models' |
7da18e44 C |
6 | |
7 | @Component({ | |
0a4cb95c RK |
8 | templateUrl: './admin.component.html', |
9 | styleUrls: [ './admin.component.scss' ] | |
7da18e44 | 10 | }) |
24e7916c RK |
11 | export class AdminComponent implements OnInit { |
12 | items: ListOverflowItem[] = [] | |
0a4cb95c | 13 | menuEntries: TopMenuDropdownParam[] = [] |
24e7916c RK |
14 | |
15 | constructor ( | |
16 | private auth: AuthService, | |
66357162 | 17 | private screen: ScreenService |
7034b3c9 | 18 | ) { } |
19 | ||
20 | get isBroadcastMessageDisplayed () { | |
21 | return this.screen.isBroadcastMessageDisplayed | |
22 | } | |
24e7916c RK |
23 | |
24 | ngOnInit () { | |
57e56eb2 | 25 | const federationItems: TopMenuDropdownParam = { |
66357162 | 26 | label: $localize`Federation`, |
0a4cb95c RK |
27 | children: [ |
28 | { | |
66357162 | 29 | label: $localize`Instances you follow`, |
57e56eb2 | 30 | routerLink: '/admin/follows/following-list', |
ea7337cf | 31 | iconName: 'following' |
0a4cb95c RK |
32 | }, |
33 | { | |
66357162 | 34 | label: $localize`Instances following you`, |
57e56eb2 | 35 | routerLink: '/admin/follows/followers-list', |
ea7337cf | 36 | iconName: 'follower' |
0a4cb95c RK |
37 | }, |
38 | { | |
66357162 | 39 | label: $localize`Video redundancies`, |
57e56eb2 | 40 | routerLink: '/admin/follows/video-redundancies-list', |
0a4cb95c RK |
41 | iconName: 'videos' |
42 | } | |
43 | ] | |
44 | } | |
45 | ||
46 | const moderationItems: TopMenuDropdownParam = { | |
66357162 | 47 | label: $localize`Moderation`, |
0a4cb95c RK |
48 | children: [] |
49 | } | |
57e56eb2 | 50 | |
4f32032f | 51 | if (this.hasAbusesRight()) { |
57e56eb2 | 52 | moderationItems.children.push({ |
66357162 | 53 | label: $localize`Reports`, |
8ca56654 | 54 | routerLink: '/admin/moderation/abuses/list', |
57e56eb2 C |
55 | iconName: 'flag' |
56 | }) | |
57 | } | |
58 | if (this.hasVideoBlocklistRight()) { | |
59 | moderationItems.children.push({ | |
66357162 | 60 | label: $localize`Video blocks`, |
57e56eb2 C |
61 | routerLink: '/admin/moderation/video-blocks/list', |
62 | iconName: 'cross' | |
63 | }) | |
64 | } | |
0f8d00e3 C |
65 | if (this.hasVideoCommentsRight()) { |
66 | moderationItems.children.push({ | |
67 | label: $localize`Video comments`, | |
68 | routerLink: '/admin/moderation/video-comments/list', | |
69 | iconName: 'message-circle' | |
70 | }) | |
71 | } | |
57e56eb2 C |
72 | if (this.hasAccountsBlocklistRight()) { |
73 | moderationItems.children.push({ | |
66357162 | 74 | label: $localize`Muted accounts`, |
57e56eb2 | 75 | routerLink: '/admin/moderation/blocklist/accounts', |
345b4a22 | 76 | iconName: 'user-x' |
57e56eb2 C |
77 | }) |
78 | } | |
79 | if (this.hasServersBlocklistRight()) { | |
80 | moderationItems.children.push({ | |
66357162 | 81 | label: $localize`Muted servers`, |
57e56eb2 | 82 | routerLink: '/admin/moderation/blocklist/servers', |
345b4a22 | 83 | iconName: 'peertube-x' |
57e56eb2 C |
84 | }) |
85 | } | |
0a4cb95c | 86 | |
dfe3f7b7 | 87 | if (this.hasUsersRight()) { |
66357162 | 88 | this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' }) |
dfe3f7b7 K |
89 | } |
90 | ||
0a4cb95c | 91 | if (this.hasServerFollowRight()) this.menuEntries.push(federationItems) |
4f32032f | 92 | if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems) |
dfe3f7b7 K |
93 | |
94 | if (this.hasConfigRight()) { | |
66357162 | 95 | this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' }) |
dfe3f7b7 K |
96 | } |
97 | ||
98 | if (this.hasPluginsRight()) { | |
66357162 | 99 | this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' }) |
dfe3f7b7 K |
100 | } |
101 | ||
102 | if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) { | |
66357162 | 103 | this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' }) |
dfe3f7b7 | 104 | } |
24e7916c | 105 | } |
04e0fc48 C |
106 | |
107 | hasUsersRight () { | |
108 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) | |
109 | } | |
110 | ||
111 | hasServerFollowRight () { | |
112 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) | |
113 | } | |
114 | ||
4f32032f | 115 | hasAbusesRight () { |
d95d1559 | 116 | return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) |
04e0fc48 C |
117 | } |
118 | ||
5baee5fc | 119 | hasVideoBlocklistRight () { |
3487330d | 120 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) |
04e0fc48 C |
121 | } |
122 | ||
0a4cb95c RK |
123 | hasAccountsBlocklistRight () { |
124 | return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) | |
125 | } | |
126 | ||
127 | hasServersBlocklistRight () { | |
128 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) | |
129 | } | |
130 | ||
5d79474c C |
131 | hasConfigRight () { |
132 | return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) | |
04e0fc48 | 133 | } |
fd206f0b | 134 | |
d00dc28d C |
135 | hasPluginsRight () { |
136 | return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) | |
137 | } | |
138 | ||
2c22613c C |
139 | hasLogsRight () { |
140 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) | |
141 | } | |
142 | ||
5d79474c C |
143 | hasJobsRight () { |
144 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | |
145 | } | |
146 | ||
147 | hasDebugRight () { | |
148 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | |
fd206f0b | 149 | } |
0f8d00e3 C |
150 | |
151 | hasVideoCommentsRight () { | |
152 | return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) | |
153 | } | |
7da18e44 | 154 | } |