|
13 | 13 |
|
14 | 14 | let { data }: { data: PageData } = $props(); |
15 | 15 |
|
| 16 | + // Read level from query param: system, bank, or both (default) |
| 17 | + let level = $derived<"system" | "bank" | "both">( |
| 18 | + (() => { |
| 19 | + const param = $page.url.searchParams.get("level"); |
| 20 | + if (param === "system" || param === "bank") return param; |
| 21 | + return "both"; |
| 22 | + })() |
| 23 | + ); |
| 24 | +
|
| 25 | + let showSystem = $derived(level === "system" || level === "both"); |
| 26 | + let showBank = $derived(level === "bank" || level === "both"); |
| 27 | +
|
16 | 28 | let userEntitlements = $derived(data.userEntitlements || []); |
17 | 29 |
|
18 | 30 | let hasSystemReadRole = $derived( |
|
83 | 95 | return entity.schema || null; |
84 | 96 | } |
85 | 97 |
|
86 | | - // Combine system and bank entities with a level marker |
| 98 | + // Combine system and bank entities with a level marker, filtered by query param |
87 | 99 | const allEntities = $derived([ |
88 | | - ...(data.entities || []).map((e: any) => ({ ...e, _level: "System" })), |
89 | | - ...bankEntities.map((e: any) => ({ ...e, _level: "Bank" })), |
| 100 | + ...(showSystem ? (data.entities || []).map((e: any) => ({ ...e, _level: "System" })) : []), |
| 101 | + ...(showBank ? bankEntities.map((e: any) => ({ ...e, _level: "Bank" })) : []), |
90 | 102 | ]); |
91 | 103 |
|
92 | 104 | const filteredEntities = $derived( |
|
195 | 207 | </script> |
196 | 208 |
|
197 | 209 | <svelte:head> |
198 | | - <title>System Dynamic Entities - API Manager</title> |
| 210 | + <title>{level === "system" ? "System" : level === "bank" ? "Bank" : ""} Dynamic Entities - API Manager</title> |
199 | 211 | </svelte:head> |
200 | 212 |
|
201 | 213 | <div class="container mx-auto px-4 py-8"> |
202 | 214 | <!-- Header --> |
203 | 215 | <div class="mb-6 flex items-center justify-between"> |
204 | 216 | <div> |
205 | 217 | <h1 class="text-3xl font-bold text-gray-900 dark:text-gray-100"> |
206 | | - Dynamic Entities |
| 218 | + {level === "system" ? "System" : level === "bank" ? "Bank" : ""} Dynamic Entities |
207 | 219 | </h1> |
208 | 220 | <p class="mt-1 text-gray-600 dark:text-gray-400"> |
209 | | - System-wide and bank-level dynamic data entities |
| 221 | + {#if level === "system"} |
| 222 | + System-wide dynamic data entities |
| 223 | + {:else if level === "bank"} |
| 224 | + Bank-level dynamic data entities{#if currentBank.bank} for {currentBank.bank.full_name || currentBank.bankId}{/if} |
| 225 | + {:else} |
| 226 | + System-wide and bank-level dynamic data entities |
| 227 | + {/if} |
210 | 228 | </p> |
211 | 229 | </div> |
212 | 230 | <a |
|
232 | 250 |
|
233 | 251 | <!-- Stats --> |
234 | 252 | <div class="mb-6 flex items-center gap-4"> |
235 | | - <div |
236 | | - class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800" |
237 | | - > |
238 | | - <div class="text-sm text-gray-600 dark:text-gray-400">System</div> |
239 | | - <div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100"> |
240 | | - {data.entities?.length || 0} |
241 | | - </div> |
242 | | - </div> |
243 | | - <div |
244 | | - class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800" |
245 | | - > |
246 | | - <div class="text-sm text-gray-600 dark:text-gray-400"> |
247 | | - Bank {#if currentBank.bank}({currentBank.bank.full_name || currentBank.bank.short_name || currentBank.bankId}){/if} |
| 253 | + {#if showSystem} |
| 254 | + <div |
| 255 | + class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800" |
| 256 | + > |
| 257 | + <div class="text-sm text-gray-600 dark:text-gray-400">System</div> |
| 258 | + <div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100"> |
| 259 | + {data.entities?.length || 0} |
| 260 | + </div> |
248 | 261 | </div> |
249 | | - <div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100"> |
250 | | - {#if bankEntitiesLoading} |
251 | | - <span class="text-sm text-gray-400">...</span> |
252 | | - {:else if currentBank.bankId} |
253 | | - {bankEntities.length} |
254 | | - {:else} |
255 | | - <span class="text-sm text-gray-400">-</span> |
256 | | - {/if} |
| 262 | + {/if} |
| 263 | + {#if showBank} |
| 264 | + <div |
| 265 | + class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800" |
| 266 | + > |
| 267 | + <div class="text-sm text-gray-600 dark:text-gray-400"> |
| 268 | + Bank {#if currentBank.bank}({currentBank.bank.full_name || currentBank.bank.short_name || currentBank.bankId}){/if} |
| 269 | + </div> |
| 270 | + <div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100"> |
| 271 | + {#if bankEntitiesLoading} |
| 272 | + <span class="text-sm text-gray-400">...</span> |
| 273 | + {:else if currentBank.bankId} |
| 274 | + {bankEntities.length} |
| 275 | + {:else} |
| 276 | + <span class="text-sm text-gray-400">-</span> |
| 277 | + {/if} |
| 278 | + </div> |
257 | 279 | </div> |
258 | | - </div> |
| 280 | + {/if} |
259 | 281 | <div class="flex gap-2"> |
260 | 282 | <a |
261 | 283 | href={apiExplorerDynamicEntityUrl} |
|
377 | 399 | </div> |
378 | 400 | {/if} |
379 | 401 |
|
380 | | - {#if bankEntitiesError} |
| 402 | + {#if showBank && bankEntitiesError} |
381 | 403 | <div |
382 | 404 | class="mb-6 rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20" |
383 | 405 | > |
|
388 | 410 | {/if} |
389 | 411 |
|
390 | 412 | <!-- Role Checks --> |
391 | | - {#if !hasSystemReadRole} |
| 413 | + {#if showSystem && !hasSystemReadRole} |
392 | 414 | <MissingRoleAlert |
393 | 415 | roles={["CanGetSystemLevelDynamicEntities"]} |
394 | 416 | message="You need this role to list system-level dynamic entities" |
395 | 417 | /> |
396 | 418 | {/if} |
397 | | - {#if currentBank.bankId && !hasBankReadRole} |
| 419 | + {#if showBank && currentBank.bankId && !hasBankReadRole} |
398 | 420 | <MissingRoleAlert |
399 | 421 | roles={["CanGetBankLevelDynamicEntities"]} |
400 | 422 | bankId={currentBank.bankId} |
|
484 | 506 | <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700"> |
485 | 507 | <thead class="bg-gray-50 dark:bg-gray-900"> |
486 | 508 | <tr> |
487 | | - <th |
488 | | - class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400" |
489 | | - > |
490 | | - Level |
491 | | - </th> |
| 509 | + {#if level === "both"} |
| 510 | + <th |
| 511 | + class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400" |
| 512 | + > |
| 513 | + Level |
| 514 | + </th> |
| 515 | + {/if} |
492 | 516 | <th |
493 | 517 | class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400" |
494 | 518 | > |
|
527 | 551 | {#each filteredEntities as entity} |
528 | 552 | {@const schema = getSchema(entity)} |
529 | 553 | <tr class="hover:bg-gray-50 dark:hover:bg-gray-700/50"> |
530 | | - <td class="whitespace-nowrap px-3 py-3 text-sm"> |
531 | | - {#if entity._level === "System"} |
532 | | - <span class="inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-xs font-medium text-purple-800 dark:bg-purple-900/30 dark:text-purple-300">System</span> |
533 | | - {:else} |
534 | | - <span class="inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-800 dark:bg-blue-900/30 dark:text-blue-300">Bank</span> |
535 | | - {/if} |
536 | | - </td> |
| 554 | + {#if level === "both"} |
| 555 | + <td class="whitespace-nowrap px-3 py-3 text-sm"> |
| 556 | + {#if entity._level === "System"} |
| 557 | + <span class="inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-xs font-medium text-purple-800 dark:bg-purple-900/30 dark:text-purple-300">System</span> |
| 558 | + {:else} |
| 559 | + <span class="inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-800 dark:bg-blue-900/30 dark:text-blue-300">Bank</span> |
| 560 | + {/if} |
| 561 | + </td> |
| 562 | + {/if} |
537 | 563 | <td class="whitespace-nowrap px-3 py-3 text-sm font-medium"> |
538 | 564 | <a |
539 | 565 | href="/dynamic-entities/system/{entity.dynamic_entity_id}" |
|
0 commit comments