diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/+admin/admin.component.ts | 97 | ||||
-rw-r--r-- | client/src/app/+admin/system/system.component.html | 10 | ||||
-rw-r--r-- | client/src/app/+admin/system/system.component.scss | 8 | ||||
-rw-r--r-- | client/src/app/+admin/system/system.component.ts | 18 |
4 files changed, 76 insertions, 57 deletions
diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 4b6fab6ed..15739f8d3 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts | |||
@@ -22,7 +22,24 @@ export class AdminComponent implements OnInit { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | ngOnInit () { | 24 | ngOnInit () { |
25 | const federationItems: TopMenuDropdownParam = { | 25 | this.buildOverviewItems() |
26 | this.buildFederationItems() | ||
27 | this.buildModerationItems() | ||
28 | this.buildConfigurationItems() | ||
29 | this.buildPluginItems() | ||
30 | this.buildSystemItems() | ||
31 | } | ||
32 | |||
33 | private buildOverviewItems () { | ||
34 | if (this.hasUsersRight()) { | ||
35 | this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' }) | ||
36 | } | ||
37 | } | ||
38 | |||
39 | private buildFederationItems () { | ||
40 | if (!this.hasServerFollowRight()) return | ||
41 | |||
42 | this.menuEntries.push({ | ||
26 | label: $localize`Federation`, | 43 | label: $localize`Federation`, |
27 | children: [ | 44 | children: [ |
28 | { | 45 | { |
@@ -41,8 +58,10 @@ export class AdminComponent implements OnInit { | |||
41 | iconName: 'videos' | 58 | iconName: 'videos' |
42 | } | 59 | } |
43 | ] | 60 | ] |
44 | } | 61 | }) |
62 | } | ||
45 | 63 | ||
64 | private buildModerationItems () { | ||
46 | const moderationItems: TopMenuDropdownParam = { | 65 | const moderationItems: TopMenuDropdownParam = { |
47 | label: $localize`Moderation`, | 66 | label: $localize`Moderation`, |
48 | children: [] | 67 | children: [] |
@@ -55,6 +74,7 @@ export class AdminComponent implements OnInit { | |||
55 | iconName: 'flag' | 74 | iconName: 'flag' |
56 | }) | 75 | }) |
57 | } | 76 | } |
77 | |||
58 | if (this.hasVideoBlocklistRight()) { | 78 | if (this.hasVideoBlocklistRight()) { |
59 | moderationItems.children.push({ | 79 | moderationItems.children.push({ |
60 | label: $localize`Video blocks`, | 80 | label: $localize`Video blocks`, |
@@ -62,6 +82,7 @@ export class AdminComponent implements OnInit { | |||
62 | iconName: 'cross' | 82 | iconName: 'cross' |
63 | }) | 83 | }) |
64 | } | 84 | } |
85 | |||
65 | if (this.hasVideoCommentsRight()) { | 86 | if (this.hasVideoCommentsRight()) { |
66 | moderationItems.children.push({ | 87 | moderationItems.children.push({ |
67 | label: $localize`Video comments`, | 88 | label: $localize`Video comments`, |
@@ -69,6 +90,7 @@ export class AdminComponent implements OnInit { | |||
69 | iconName: 'message-circle' | 90 | iconName: 'message-circle' |
70 | }) | 91 | }) |
71 | } | 92 | } |
93 | |||
72 | if (this.hasAccountsBlocklistRight()) { | 94 | if (this.hasAccountsBlocklistRight()) { |
73 | moderationItems.children.push({ | 95 | moderationItems.children.push({ |
74 | label: $localize`Muted accounts`, | 96 | label: $localize`Muted accounts`, |
@@ -76,6 +98,7 @@ export class AdminComponent implements OnInit { | |||
76 | iconName: 'user-x' | 98 | iconName: 'user-x' |
77 | }) | 99 | }) |
78 | } | 100 | } |
101 | |||
79 | if (this.hasServersBlocklistRight()) { | 102 | if (this.hasServersBlocklistRight()) { |
80 | moderationItems.children.push({ | 103 | moderationItems.children.push({ |
81 | label: $localize`Muted servers`, | 104 | label: $localize`Muted servers`, |
@@ -84,71 +107,101 @@ export class AdminComponent implements OnInit { | |||
84 | }) | 107 | }) |
85 | } | 108 | } |
86 | 109 | ||
87 | if (this.hasUsersRight()) { | 110 | if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems) |
88 | this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' }) | 111 | } |
89 | } | ||
90 | |||
91 | if (this.hasServerFollowRight()) this.menuEntries.push(federationItems) | ||
92 | if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems) | ||
93 | 112 | ||
113 | private buildConfigurationItems () { | ||
94 | if (this.hasConfigRight()) { | 114 | if (this.hasConfigRight()) { |
95 | this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' }) | 115 | this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' }) |
96 | } | 116 | } |
117 | } | ||
97 | 118 | ||
119 | private buildPluginItems () { | ||
98 | if (this.hasPluginsRight()) { | 120 | if (this.hasPluginsRight()) { |
99 | this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' }) | 121 | this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' }) |
100 | } | 122 | } |
123 | } | ||
124 | |||
125 | private buildSystemItems () { | ||
126 | const systemItems: TopMenuDropdownParam = { | ||
127 | label: $localize`System`, | ||
128 | children: [] | ||
129 | } | ||
130 | |||
131 | if (this.hasJobsRight()) { | ||
132 | systemItems.children.push({ | ||
133 | label: $localize`Jobs`, | ||
134 | iconName: 'circle-tick', | ||
135 | routerLink: '/admin/system/jobs' | ||
136 | }) | ||
137 | } | ||
138 | |||
139 | if (this.hasLogsRight()) { | ||
140 | systemItems.children.push({ | ||
141 | label: $localize`Logs`, | ||
142 | iconName: 'playlists', | ||
143 | routerLink: '/admin/system/logs' | ||
144 | }) | ||
145 | } | ||
146 | |||
147 | if (this.hasDebugRight()) { | ||
148 | systemItems.children.push({ | ||
149 | label: $localize`Debug`, | ||
150 | iconName: 'cog', | ||
151 | routerLink: '/admin/system/debug' | ||
152 | }) | ||
153 | } | ||
101 | 154 | ||
102 | if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) { | 155 | if (systemItems.children.length !== 0) { |
103 | this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' }) | 156 | this.menuEntries.push(systemItems) |
104 | } | 157 | } |
105 | } | 158 | } |
106 | 159 | ||
107 | hasUsersRight () { | 160 | private hasUsersRight () { |
108 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) | 161 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) |
109 | } | 162 | } |
110 | 163 | ||
111 | hasServerFollowRight () { | 164 | private hasServerFollowRight () { |
112 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) | 165 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) |
113 | } | 166 | } |
114 | 167 | ||
115 | hasAbusesRight () { | 168 | private hasAbusesRight () { |
116 | return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) | 169 | return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES) |
117 | } | 170 | } |
118 | 171 | ||
119 | hasVideoBlocklistRight () { | 172 | private hasVideoBlocklistRight () { |
120 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) | 173 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) |
121 | } | 174 | } |
122 | 175 | ||
123 | hasAccountsBlocklistRight () { | 176 | private hasAccountsBlocklistRight () { |
124 | return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) | 177 | return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST) |
125 | } | 178 | } |
126 | 179 | ||
127 | hasServersBlocklistRight () { | 180 | private hasServersBlocklistRight () { |
128 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) | 181 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST) |
129 | } | 182 | } |
130 | 183 | ||
131 | hasConfigRight () { | 184 | private hasConfigRight () { |
132 | return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) | 185 | return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION) |
133 | } | 186 | } |
134 | 187 | ||
135 | hasPluginsRight () { | 188 | private hasPluginsRight () { |
136 | return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) | 189 | return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS) |
137 | } | 190 | } |
138 | 191 | ||
139 | hasLogsRight () { | 192 | private hasLogsRight () { |
140 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) | 193 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) |
141 | } | 194 | } |
142 | 195 | ||
143 | hasJobsRight () { | 196 | private hasJobsRight () { |
144 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | 197 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) |
145 | } | 198 | } |
146 | 199 | ||
147 | hasDebugRight () { | 200 | private hasDebugRight () { |
148 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | 201 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) |
149 | } | 202 | } |
150 | 203 | ||
151 | hasVideoCommentsRight () { | 204 | private hasVideoCommentsRight () { |
152 | return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) | 205 | return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) |
153 | } | 206 | } |
154 | } | 207 | } |
diff --git a/client/src/app/+admin/system/system.component.html b/client/src/app/+admin/system/system.component.html index 5385887b7..0680b43f9 100644 --- a/client/src/app/+admin/system/system.component.html +++ b/client/src/app/+admin/system/system.component.html | |||
@@ -1,11 +1 @@ | |||
1 | <div class="admin-sub-header"> | ||
2 | <div class="admin-sub-nav"> | ||
3 | <a *ngIf="hasJobsRight()" i18n routerLink="jobs" routerLinkActive="active">Jobs</a> | ||
4 | |||
5 | <a *ngIf="hasLogsRight()" i18n routerLink="logs" routerLinkActive="active">Logs</a> | ||
6 | |||
7 | <a *ngIf="hasDebugRight()" i18n routerLink="debug" routerLinkActive="active">Debug</a> | ||
8 | </div> | ||
9 | </div> | ||
10 | |||
11 | <router-outlet></router-outlet> | <router-outlet></router-outlet> | |
diff --git a/client/src/app/+admin/system/system.component.scss b/client/src/app/+admin/system/system.component.scss deleted file mode 100644 index 18858ac1c..000000000 --- a/client/src/app/+admin/system/system.component.scss +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | @use '_variables' as *; | ||
2 | @use '_mixins' as *; | ||
3 | |||
4 | .form-sub-title { | ||
5 | @include margin-right(30px); | ||
6 | |||
7 | flex-grow: 0; | ||
8 | } | ||
diff --git a/client/src/app/+admin/system/system.component.ts b/client/src/app/+admin/system/system.component.ts index b544c2a97..b63160b86 100644 --- a/client/src/app/+admin/system/system.component.ts +++ b/client/src/app/+admin/system/system.component.ts | |||
@@ -1,24 +1,8 @@ | |||
1 | import { Component } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { UserRight } from '@shared/models' | ||
3 | import { AuthService } from '@app/core' | ||
4 | 2 | ||
5 | @Component({ | 3 | @Component({ |
6 | templateUrl: './system.component.html', | 4 | templateUrl: './system.component.html', |
7 | styleUrls: [ './system.component.scss' ] | 5 | styleUrls: [] |
8 | }) | 6 | }) |
9 | export class SystemComponent { | 7 | export class SystemComponent { |
10 | |||
11 | constructor (private auth: AuthService) {} | ||
12 | |||
13 | hasLogsRight () { | ||
14 | return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS) | ||
15 | } | ||
16 | |||
17 | hasJobsRight () { | ||
18 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | ||
19 | } | ||
20 | |||
21 | hasDebugRight () { | ||
22 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | ||
23 | } | ||
24 | } | 8 | } |