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