fix: allow node cabinet fallback when dashboard unavailable
This commit is contained in:
@@ -27,17 +27,20 @@ export default function NodeCabinetPage() {
|
|||||||
const nodeId = params.nodeId as string;
|
const nodeId = params.nodeId as string;
|
||||||
const nodeLabel = getNodeLabel(nodeId);
|
const nodeLabel = getNodeLabel(nodeId);
|
||||||
|
|
||||||
|
const dashboardEnabled = nodeId === 'node-1-hetzner-gex44';
|
||||||
|
|
||||||
// Basic node profile from node_cache
|
// Basic node profile from node_cache
|
||||||
const { node: nodeProfile, isLoading: profileLoading, error: profileError } = useNodeProfile(nodeId);
|
const { node: nodeProfile, isLoading: profileLoading, error: profileError } = useNodeProfile(nodeId);
|
||||||
|
|
||||||
// Full dashboard (if available - currently only for NODE1)
|
// Full dashboard (if available - currently only for NODE1)
|
||||||
const { dashboard, isLoading: dashboardLoading, error: dashboardError, refresh, lastUpdated } = useNodeDashboard({
|
const { dashboard, isLoading: dashboardLoading, error: dashboardError, refresh, lastUpdated } = useNodeDashboard({
|
||||||
refreshInterval: 30000,
|
refreshInterval: 30000,
|
||||||
enabled: nodeId === 'node-1-hetzner-gex44' // Only enable for NODE1
|
enabled: dashboardEnabled
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = profileLoading || dashboardLoading;
|
const isLoading = profileLoading || (dashboardEnabled && dashboardLoading);
|
||||||
const error = profileError || (dashboardError && nodeId === 'node-1-hetzner-gex44');
|
const shouldShowError = (!!profileError && !nodeProfile) || (!nodeProfile && !dashboard);
|
||||||
|
|
||||||
const isProduction = nodeProfile?.environment === 'production';
|
const isProduction = nodeProfile?.environment === 'production';
|
||||||
|
|
||||||
if (isLoading && !nodeProfile && !dashboard) {
|
if (isLoading && !nodeProfile && !dashboard) {
|
||||||
@@ -55,13 +58,13 @@ export default function NodeCabinetPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error || (!nodeProfile && !dashboard)) {
|
if (shouldShowError) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gradient-to-br from-slate-900 via-purple-900/20 to-slate-900 p-6">
|
<div className="min-h-screen bg-gradient-to-br from-slate-900 via-purple-900/20 to-slate-900 p-6">
|
||||||
<div className="max-w-7xl mx-auto">
|
<div className="max-w-7xl mx-auto">
|
||||||
<div className="bg-red-500/10 border border-red-500/20 rounded-2xl p-6 text-center">
|
<div className="bg-red-500/10 border border-red-500/20 rounded-2xl p-6 text-center">
|
||||||
<p className="text-red-400 text-lg mb-2">Failed to load node</p>
|
<p className="text-red-400 text-lg mb-2">Failed to load node</p>
|
||||||
<p className="text-white/50 mb-4">{(error as Error)?.message || 'Node not found'}</p>
|
<p className="text-white/50 mb-4">{profileError?.message || 'Node not found'}</p>
|
||||||
<Link
|
<Link
|
||||||
href="/nodes"
|
href="/nodes"
|
||||||
className="px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-lg transition-colors inline-block"
|
className="px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-lg transition-colors inline-block"
|
||||||
@@ -109,6 +112,12 @@ export default function NodeCabinetPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{dashboardError && (
|
||||||
|
<div className="mb-6 bg-amber-500/10 border border-amber-500/20 text-amber-200 rounded-xl px-4 py-3 text-sm">
|
||||||
|
Детальний моніторинг тимчасово недоступний. Показано останній кешований профіль ноди.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Main Grid */}
|
{/* Main Grid */}
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||||
<div className="lg:col-span-2 space-y-6">
|
<div className="lg:col-span-2 space-y-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user