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';
|
'use client';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR, { useSWRConfig } from 'swr';
|
||||||
import NodeList from './NodeList';
|
import NodeList from './NodeList';
|
||||||
import VMList from './VMList';
|
import VMList from './VMList';
|
||||||
import LXCList from './LXCList';
|
import LXCList from './LXCList';
|
||||||
@@ -94,6 +94,15 @@ export default function Dashboard() {
|
|||||||
window.open(vm.consoleUrl, '_blank');
|
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 (
|
return (
|
||||||
<div className="min-h-screen p-4 sm:p-6 lg:p-8">
|
<div className="min-h-screen p-4 sm:p-6 lg:p-8">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -105,6 +114,13 @@ export default function Dashboard() {
|
|||||||
{new Date().toLocaleTimeString()}
|
{new Date().toLocaleTimeString()}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Summary Cards */}
|
{/* Summary Cards */}
|
||||||
|
|||||||
Reference in New Issue
Block a user