Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 39fd21f

Browse files
committed
Cache Config fields
1 parent 2790f06 commit 39fd21f

1 file changed

Lines changed: 232 additions & 95 deletions

File tree

‎src/routes/(protected)/system/cache/+page.svelte‎

Lines changed: 232 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
let lastUpdated = $state<string>("");
2424
let copiedNamespaceId = $state<string | null>(null);
2525
let invalidatingNamespaceId = $state<string | null>(null);
26+
let copiedCacheConfig = $state(false);
2627
2728
async function fetchCacheConfig() {
2829
try {
@@ -157,6 +158,35 @@ TTL Info: ${namespace.ttl_info || "TTL info NOT FOUND"}`;
157158
}
158159
}
159160
161+
async function copyCacheConfig() {
162+
try {
163+
const info = `Cache Configuration
164+
Instance ID: ${cacheConfig.instance_id || "N/A"}
165+
Environment: ${cacheConfig.environment || "N/A"}
166+
Global Prefix: ${cacheConfig.global_prefix || "N/A"}
167+
168+
Redis Status:
169+
Available: ${cacheConfig.redis_status?.available ? "Yes" : "No"}
170+
URL: ${cacheConfig.redis_status?.url || "N/A"}
171+
Port: ${cacheConfig.redis_status?.port ?? "N/A"}
172+
Use SSL: ${cacheConfig.redis_status?.use_ssl !== undefined ? (cacheConfig.redis_status.use_ssl ? "Yes" : "No") : "N/A"}
173+
174+
In-Memory Status:
175+
Available: ${cacheConfig.in_memory_status?.available ? "Yes" : "No"}
176+
Current Size: ${cacheConfig.in_memory_status?.current_size ?? "N/A"}`;
177+
178+
await navigator.clipboard.writeText(info);
179+
copiedCacheConfig = true;
180+
181+
// Reset after 2 seconds
182+
setTimeout(() => {
183+
copiedCacheConfig = false;
184+
}, 2000);
185+
} catch (err) {
186+
console.error("Failed to copy cache config:", err);
187+
}
188+
}
189+
160190
// Compute storage location statistics
161191
let storageStats = $derived.by(() => {
162192
if (!cacheInfo?.namespaces) return null;
@@ -215,9 +245,58 @@ TTL Info: ${namespace.ttl_info || "TTL info NOT FOUND"}`;
215245

216246
<!-- Cache Configuration Section -->
217247
<div class="mb-8">
218-
<h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-gray-100">
219-
Cache Configuration
220-
</h2>
248+
<div class="mb-4 flex items-center justify-between">
249+
<h2 class="text-xl font-semibold text-gray-900 dark:text-gray-100">
250+
Cache Configuration
251+
</h2>
252+
<button
253+
onclick={copyCacheConfig}
254+
class="rounded-lg p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200"
255+
title="Copy cache configuration"
256+
aria-label="Copy cache configuration"
257+
>
258+
{#if copiedCacheConfig}
259+
<svg
260+
class="h-5 w-5 text-green-600 dark:text-green-400"
261+
fill="none"
262+
stroke="currentColor"
263+
viewBox="0 0 24 24"
264+
>
265+
<polyline
266+
stroke-linecap="round"
267+
stroke-linejoin="round"
268+
stroke-width="2"
269+
points="20 6 9 17 4 12"
270+
/>
271+
</svg>
272+
{:else}
273+
<svg
274+
class="h-5 w-5"
275+
fill="none"
276+
stroke="currentColor"
277+
viewBox="0 0 24 24"
278+
>
279+
<rect
280+
x="9"
281+
y="9"
282+
width="13"
283+
height="13"
284+
rx="2"
285+
ry="2"
286+
stroke-linecap="round"
287+
stroke-linejoin="round"
288+
stroke-width="2"
289+
/>
290+
<path
291+
d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
292+
stroke-linecap="round"
293+
stroke-linejoin="round"
294+
stroke-width="2"
295+
/>
296+
</svg>
297+
{/if}
298+
</button>
299+
</div>
221300
{#if errorConfig}
222301
<div
223302
class="rounded-lg border border-red-200 bg-red-50 p-4 text-red-800 dark:border-red-800 dark:bg-red-900/20 dark:text-red-200"
@@ -240,96 +319,154 @@ TTL Info: ${namespace.ttl_info || "TTL info NOT FOUND"}`;
240319
<div
241320
class="rounded-lg border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800"
242321
>
243-
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
244-
<div>
245-
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
246-
Enabled
247-
</div>
248-
<div
249-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
250-
>
251-
{cacheConfig.enabled ? "Yes" : "No"}
252-
</div>
253-
</div>
322+
<div class="space-y-6">
323+
<!-- Instance Information -->
254324
<div>
255-
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
256-
Provider
257-
</div>
258-
<div
259-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
325+
<h3
326+
class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300"
260327
>
261-
{cacheConfig.provider || "N/A"}
262-
</div>
263-
</div>
264-
<div>
265-
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
266-
Instance ID
267-
</div>
268-
<div
269-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
270-
>
271-
{cacheConfig.instance_id || "N/A"}
272-
</div>
273-
</div>
274-
<div>
275-
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
276-
Environment
277-
</div>
278-
<div
279-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
280-
>
281-
{cacheConfig.environment || "N/A"}
282-
</div>
283-
</div>
284-
<div>
285-
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
286-
Global Prefix
287-
</div>
288-
<div
289-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
290-
>
291-
{cacheConfig.global_prefix || "N/A"}
292-
</div>
293-
</div>
294-
{#if cacheConfig.url}
295-
<div>
296-
<div
297-
class="text-sm font-medium text-gray-600 dark:text-gray-400"
298-
>
299-
Redis URL
328+
Instance Information
329+
</h3>
330+
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
331+
<div>
332+
<div
333+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
334+
>
335+
Instance ID
336+
</div>
337+
<div
338+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
339+
>
340+
{cacheConfig.instance_id || "N/A"}
341+
</div>
300342
</div>
301-
<div
302-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
303-
>
304-
{cacheConfig.url}
343+
<div>
344+
<div
345+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
346+
>
347+
Environment
348+
</div>
349+
<div
350+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
351+
>
352+
{cacheConfig.environment || "N/A"}
353+
</div>
354+
</div>
355+
<div>
356+
<div
357+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
358+
>
359+
Global Prefix
360+
</div>
361+
<div
362+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
363+
>
364+
{cacheConfig.global_prefix || "N/A"}
365+
</div>
305366
</div>
306367
</div>
307-
{/if}
308-
{#if cacheConfig.port}
368+
</div>
369+
370+
<!-- Redis Status -->
371+
{#if cacheConfig.redis_status}
309372
<div>
310-
<div
311-
class="text-sm font-medium text-gray-600 dark:text-gray-400"
373+
<h3
374+
class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300"
312375
>
313-
Port
314-
</div>
376+
Redis Status
377+
</h3>
315378
<div
316-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
379+
class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4"
317380
>
318-
{cacheConfig.port}
381+
<div>
382+
<div
383+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
384+
>
385+
Available
386+
</div>
387+
<div
388+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
389+
>
390+
{cacheConfig.redis_status.available ? "Yes" : "No"}
391+
</div>
392+
</div>
393+
<div>
394+
<div
395+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
396+
>
397+
URL
398+
</div>
399+
<div
400+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
401+
>
402+
{cacheConfig.redis_status.url || "N/A"}
403+
</div>
404+
</div>
405+
<div>
406+
<div
407+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
408+
>
409+
Port
410+
</div>
411+
<div
412+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
413+
>
414+
{cacheConfig.redis_status.port ?? "N/A"}
415+
</div>
416+
</div>
417+
<div>
418+
<div
419+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
420+
>
421+
Use SSL
422+
</div>
423+
<div
424+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
425+
>
426+
{cacheConfig.redis_status.use_ssl !== undefined
427+
? cacheConfig.redis_status.use_ssl
428+
? "Yes"
429+
: "No"
430+
: "N/A"}
431+
</div>
432+
</div>
319433
</div>
320434
</div>
321435
{/if}
322-
{#if cacheConfig.use_ssl !== undefined}
436+
437+
<!-- In-Memory Status -->
438+
{#if cacheConfig.in_memory_status}
323439
<div>
324-
<div
325-
class="text-sm font-medium text-gray-600 dark:text-gray-400"
440+
<h3
441+
class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300"
326442
>
327-
Use SSL
328-
</div>
329-
<div
330-
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
331-
>
332-
{cacheConfig.use_ssl ? "Yes" : "No"}
443+
In-Memory Status
444+
</h3>
445+
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
446+
<div>
447+
<div
448+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
449+
>
450+
Available
451+
</div>
452+
<div
453+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
454+
>
455+
{cacheConfig.in_memory_status.available ? "Yes" : "No"}
456+
</div>
457+
</div>
458+
<div>
459+
<div
460+
class="text-sm font-medium text-gray-600 dark:text-gray-400"
461+
>
462+
Current Size
463+
</div>
464+
<div
465+
class="mt-1 text-lg font-semibold text-gray-900 dark:text-gray-100"
466+
>
467+
{cacheConfig.in_memory_status.current_size ?? "N/A"}
468+
</div>
469+
</div>
333470
</div>
334471
</div>
335472
{/if}
@@ -445,38 +582,38 @@ TTL Info: ${namespace.ttl_info || "TTL info NOT FOUND"}`;
445582
<div class="mt-2 space-y-1 text-sm">
446583
{#if storageStats.redis > 0}
447584
<div class="flex items-center justify-between">
448-
<span class="text-gray-700 dark:text-gray-300">Redis:</span>
449-
<span
450-
class="font-semibold text-purple-600 dark:text-purple-400"
451-
>{storageStats.redis}</span
585+
<span class="text-gray-700 dark:text-gray-300"
586+
>{storageStats.redis} Namespace{storageStats.redis !== 1
587+
? "s"
588+
: ""} in Redis</span
452589
>
453590
</div>
454591
{/if}
455592
{#if storageStats.memory > 0}
456593
<div class="flex items-center justify-between">
457-
<span class="text-gray-700 dark:text-gray-300">Memory:</span
458-
>
459-
<span class="font-semibold text-blue-600 dark:text-blue-400"
460-
>{storageStats.memory}</span
594+
<span class="text-gray-700 dark:text-gray-300"
595+
>{storageStats.memory} Namespace{storageStats.memory !== 1
596+
? "s"
597+
: ""} in Memory</span
461598
>
462599
</div>
463600
{/if}
464601
{#if storageStats.both > 0}
465602
<div class="flex items-center justify-between">
466-
<span class="text-gray-700 dark:text-gray-300">Both:</span>
467-
<span
468-
class="font-semibold text-green-600 dark:text-green-400"
469-
>{storageStats.both}</span
603+
<span class="text-gray-700 dark:text-gray-300"
604+
>{storageStats.both} Namespace{storageStats.both !== 1
605+
? "s"
606+
: ""} in Both</span
470607
>
471608
</div>
472609
{/if}
473610
{#if storageStats.unknown > 0}
474611
<div class="flex items-center justify-between">
475612
<span class="text-gray-700 dark:text-gray-300"
476-
>Unknown:</span
477-
>
478-
<span class="font-semibold text-gray-600 dark:text-gray-400"
479-
>{storageStats.unknown}</span
613+
>{storageStats.unknown} Namespace{storageStats.unknown !==
614+
1
615+
? "s"
616+
: ""} with Unknown Location</span
480617
>
481618
</div>
482619
{/if}

0 commit comments

Comments
 (0)