|
13 | 13 | const userEntitlements = data.userEntitlements || []; |
14 | 14 | const requiredRoles = data.requiredRoles || []; |
15 | 15 | const actionRoles = data.actionRoles || {}; |
| 16 | + const isCurrentConsumer = data.isCurrentConsumer || false; |
| 17 | + const rateLimitingInfo = data.rateLimitingInfo; |
16 | 18 |
|
17 | 19 | // Helper to check if user has a specific role |
18 | 20 | function hasRole(roleName: string): boolean { |
|
98 | 100 | </script> |
99 | 101 |
|
100 | 102 | <svelte:head> |
101 | | - <title>Edit Consumer - {consumer.app_name}</title> |
| 103 | + <title>{consumer.app_name} - Detail</title> |
102 | 104 | </svelte:head> |
103 | 105 |
|
104 | 106 | <PageRoleCheck {userEntitlements} {requiredRoles}> |
|
111 | 113 | </a> |
112 | 114 | </div> |
113 | 115 |
|
114 | | -<h1 class="text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2"> |
115 | | - Edit Consumer |
| 116 | +<h1 class="text-2xl font-bold text-gray-900 dark:text-gray-100 mb-4"> |
| 117 | + {consumer.app_name} - Detail |
116 | 118 | </h1> |
117 | 119 |
|
118 | | -<p class="mb-6 text-gray-600 dark:text-gray-400"> |
119 | | - Manage settings and scopes for <strong>{consumer.app_name}</strong> |
120 | | -</p> |
| 120 | +{#if isCurrentConsumer} |
| 121 | + <div class="mb-6 rounded-lg border border-blue-200 bg-blue-50 px-4 py-3 dark:border-blue-800 dark:bg-blue-900/20"> |
| 122 | + <div class="flex items-center gap-2"> |
| 123 | + <span class="text-blue-600 dark:text-blue-400">ℹ️</span> |
| 124 | + <span class="text-sm font-medium text-blue-800 dark:text-blue-200">This is the current consumer</span> |
| 125 | + <span class="text-xs text-blue-600 dark:text-blue-400">— the app you are using to access the API right now</span> |
| 126 | + </div> |
| 127 | + </div> |
| 128 | +{/if} |
121 | 129 |
|
122 | 130 | <!-- Error/Success Messages --> |
123 | 131 | {#if form?.error} |
|
168 | 176 | </div> |
169 | 177 | {/if} |
170 | 178 |
|
171 | | -<!-- Consumer Details Section --> |
| 179 | +<!-- Consumer / Client Section --> |
172 | 180 | <div class="mb-8 rounded-lg border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800"> |
173 | 181 | <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4"> |
174 | | - Consumer Details |
| 182 | + Consumer / Client |
175 | 183 | </h2> |
176 | 184 |
|
177 | 185 | <!-- Editable fields in 2-column grid --> |
178 | 186 | <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 mb-4 pb-4 border-b border-gray-100 dark:border-gray-700"> |
179 | | - <!-- App Name (Editable) --> |
| 187 | + <!-- Name (Editable) --> |
180 | 188 | <div> |
181 | 189 | <div class="flex items-center justify-between"> |
182 | | - <label class="block text-sm font-medium text-gray-500 dark:text-gray-400">App Name</label> |
| 190 | + <label class="block text-sm font-medium text-gray-500 dark:text-gray-400">Name</label> |
183 | 191 | {#if editingField !== "name"} |
184 | 192 | <button |
185 | 193 | type="button" |
|
481 | 489 | <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4"> |
482 | 490 | API Call Counters |
483 | 491 | </h2> |
484 | | - <p class="mb-4 text-sm text-gray-500 dark:text-gray-400"> |
485 | | - Current API usage for this consumer (from Redis). |
| 492 | + <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"> |
| 493 | + Current API usage for this consumer. |
486 | 494 | </p> |
| 495 | + {#if rateLimitingInfo} |
| 496 | + <p class="mb-4 text-[11px] text-gray-400 dark:text-gray-500"> |
| 497 | + Rate limiting: {rateLimitingInfo.enabled ? 'enabled' : 'disabled'} |
| 498 | + {#if rateLimitingInfo.enabled} |
| 499 | + • {rateLimitingInfo.is_active ? 'active' : 'inactive'} |
| 500 | + {#if rateLimitingInfo.technology} |
| 501 | + • backend: {rateLimitingInfo.technology} |
| 502 | + {/if} |
| 503 | + {#if rateLimitingInfo.service_available !== undefined} |
| 504 | + • service: {rateLimitingInfo.service_available ? 'available' : 'unavailable'} |
| 505 | + {/if} |
| 506 | + {/if} |
| 507 | + </p> |
| 508 | + {/if} |
487 | 509 | <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4"> |
488 | 510 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
489 | 511 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Second</div> |
490 | 512 | {#if consumer.call_counters?.per_second && typeof consumer.call_counters.per_second.calls_made === 'number'} |
491 | 513 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_second.calls_made}</div> |
492 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_second.reset_in_seconds}s</div> |
| 514 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_second.reset_in_seconds}s</div> |
| 515 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_second.status || ''}</div> |
493 | 516 | {:else} |
494 | 517 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
495 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 518 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
496 | 519 | {/if} |
497 | 520 | </div> |
498 | 521 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
499 | 522 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Minute</div> |
500 | 523 | {#if consumer.call_counters?.per_minute && typeof consumer.call_counters.per_minute.calls_made === 'number'} |
501 | 524 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_minute.calls_made}</div> |
502 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_minute.reset_in_seconds}s</div> |
| 525 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_minute.reset_in_seconds}s</div> |
| 526 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_minute.status || ''}</div> |
503 | 527 | {:else} |
504 | 528 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
505 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 529 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
506 | 530 | {/if} |
507 | 531 | </div> |
508 | 532 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
509 | 533 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Hour</div> |
510 | 534 | {#if consumer.call_counters?.per_hour && typeof consumer.call_counters.per_hour.calls_made === 'number'} |
511 | 535 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_hour.calls_made}</div> |
512 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_hour.reset_in_seconds}s</div> |
| 536 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_hour.reset_in_seconds}s</div> |
| 537 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_hour.status || ''}</div> |
513 | 538 | {:else} |
514 | 539 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
515 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 540 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
516 | 541 | {/if} |
517 | 542 | </div> |
518 | 543 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
519 | 544 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Day</div> |
520 | 545 | {#if consumer.call_counters?.per_day && typeof consumer.call_counters.per_day.calls_made === 'number'} |
521 | 546 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_day.calls_made}</div> |
522 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_day.reset_in_seconds}s</div> |
| 547 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_day.reset_in_seconds}s</div> |
| 548 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_day.status || ''}</div> |
523 | 549 | {:else} |
524 | 550 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
525 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 551 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
526 | 552 | {/if} |
527 | 553 | </div> |
528 | 554 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
529 | 555 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Week</div> |
530 | 556 | {#if consumer.call_counters?.per_week && typeof consumer.call_counters.per_week.calls_made === 'number'} |
531 | 557 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_week.calls_made}</div> |
532 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_week.reset_in_seconds}s</div> |
| 558 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_week.reset_in_seconds}s</div> |
| 559 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_week.status || ''}</div> |
533 | 560 | {:else} |
534 | 561 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
535 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 562 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
536 | 563 | {/if} |
537 | 564 | </div> |
538 | 565 | <div class="rounded-lg bg-gray-50 p-3 dark:bg-gray-900/50"> |
539 | 566 | <div class="text-xs font-medium text-gray-500 dark:text-gray-400">Per Month</div> |
540 | 567 | {#if consumer.call_counters?.per_month && typeof consumer.call_counters.per_month.calls_made === 'number'} |
541 | 568 | <div class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100">{consumer.call_counters.per_month.calls_made}</div> |
542 | | - <div class="text-xs text-gray-500 dark:text-gray-400">resets in {consumer.call_counters.per_month.reset_in_seconds}s</div> |
| 569 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">resets: {consumer.call_counters.per_month.reset_in_seconds}s</div> |
| 570 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">{consumer.call_counters.per_month.status || ''}</div> |
543 | 571 | {:else} |
544 | 572 | <div class="mt-1 text-lg font-semibold text-red-600 dark:text-red-400">Err</div> |
545 | | - <div class="text-xs text-gray-500 dark:text-gray-400">unavailable</div> |
| 573 | + <div class="text-[10px] text-gray-400 dark:text-gray-500">unavailable</div> |
546 | 574 | {/if} |
547 | 575 | </div> |
548 | 576 | </div> |
|
0 commit comments