feat: add manual refresh button to dashboard header
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import useSWR, { useSWRConfig } from 'swr';
|
||||
import NodeList from './NodeList';
|
||||
import VMList from './VMList';
|
||||
import LXCList from './LXCList';
|
||||
@@ -94,6 +94,15 @@ export default function Dashboard() {
|
||||
window.open(vm.consoleUrl, '_blank');
|
||||
};
|
||||
|
||||
const { mutate } = useSWRConfig();
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setIsRefreshing(true);
|
||||
await mutate(['/api/nodes', '/api/vms', '/api/lxc', '/api/status']);
|
||||
setIsRefreshing(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen p-4 sm:p-6 lg:p-8">
|
||||
{/* Header */}
|
||||
@@ -105,6 +114,13 @@ export default function Dashboard() {
|
||||
{new Date().toLocaleTimeString()}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleRefresh}
|
||||
disabled={isRefreshing}
|
||||
className="self-start rounded-md border border-border-card bg-bg-card px-3 py-1.5 text-sm font-medium text-text-secondary hover:border-accent hover:text-accent disabled:opacity-50"
|
||||
>
|
||||
{isRefreshing ? 'Refreshing…' : '↻ Refresh'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Summary Cards */}
|
||||
|
||||
Reference in New Issue
Block a user