Skip to content

Commit 3eca559

Browse files
restored dashboard
1 parent f795cd4 commit 3eca559

4 files changed

Lines changed: 61 additions & 12 deletions

File tree

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

3-
import { ExternalLink } from 'lucide-react'
4-
import { InstanceTerminalWorkspace } from '@/components/instances/instance-terminal-workspace'
3+
import { ExternalLink, LoaderCircle } from 'lucide-react'
4+
import { useState } from 'react'
55
import { buttonVariants } from '@/components/ui/button'
66
import type { Instance } from '@/types/instance'
77

@@ -13,21 +13,52 @@ export function InstanceDashboard({ instance }: { instance: Instance }) {
1313
: baseUrl
1414
: null
1515

16-
return (
17-
<section className="flex flex-col gap-4">
18-
<InstanceTerminalWorkspace instance={instance} />
16+
const [loaded, setLoaded] = useState(false)
17+
18+
if (!dashboardUrl) {
19+
return (
20+
<div className="flex min-h-[28rem] items-center justify-center rounded-xl border bg-card p-8 text-center">
21+
<div className="max-w-sm space-y-3">
22+
<h2 className="text-base font-semibold">Dashboard not available</h2>
23+
<p className="text-sm text-muted-foreground">
24+
This instance doesn&apos;t have a reachable dashboard URL yet. Wait for provisioning to complete, then refresh.
25+
</p>
26+
</div>
27+
</div>
28+
)
29+
}
1930

20-
{dashboardUrl && (
31+
return (
32+
<div className="flex flex-col gap-3">
33+
<div className="flex items-center justify-end">
2134
<a
2235
href={dashboardUrl}
2336
target="_blank"
2437
rel="noopener noreferrer"
25-
className={buttonVariants({ variant: 'outline', size: 'sm', className: 'w-fit' })}
38+
className={buttonVariants({ variant: 'outline', size: 'sm' })}
2639
>
2740
<ExternalLink className="h-4 w-4" />
28-
Open Control UI
41+
Open in new tab
2942
</a>
30-
)}
31-
</section>
43+
</div>
44+
45+
<div className="relative overflow-hidden rounded-xl border bg-card">
46+
{!loaded && (
47+
<div className="absolute inset-0 z-10 flex items-center justify-center bg-card">
48+
<div className="flex items-center gap-2 text-sm text-muted-foreground">
49+
<LoaderCircle className="h-4 w-4 animate-spin" />
50+
Loading dashboard...
51+
</div>
52+
</div>
53+
)}
54+
<iframe
55+
src={dashboardUrl}
56+
className="h-[calc(100dvh-14rem)] w-full bg-background"
57+
title="OpenClaw Dashboard"
58+
allow="clipboard-read; clipboard-write"
59+
onLoad={() => setLoaded(true)}
60+
/>
61+
</div>
62+
</div>
3263
)
3364
}

src/components/instances/instance-tabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cn } from '@/lib/utils'
66

77
const tabs = [
88
{ label: 'Overview', href: '' },
9+
{ label: 'Dashboard', href: '/dashboard' },
910
{ label: 'Terminal', href: '/terminal' },
1011
{ label: 'Settings', href: '/settings' },
1112
{ label: 'Usage', href: '/usage' },

src/lib/control-plane.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,22 @@ export async function provisionInstance(
5353
},
5454
})
5555

56-
await supabaseAdmin
56+
const { error: updateError } = await supabaseAdmin
5757
.from('instances')
5858
.update({
5959
hetzner_server_id: server.id,
6060
hetzner_server_type: plan.hetzner_type,
6161
ip_address: server.public_net.ipv4.ip,
6262
gateway_token: gatewayToken,
6363
dashboard_url: dashboardUrl,
64-
config_version: 2,
6564
})
6665
.eq('id', instance.id)
6766

67+
if (updateError) {
68+
console.error('Failed to update instance after server creation:', updateError)
69+
throw new Error(`Instance DB update failed: ${updateError.message}`)
70+
}
71+
6872
if (isDnsConfigured()) {
6973
try {
7074
const dns = await createDnsRecord(instance.slug, server.public_net.ipv4.ip)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Add config_version column that was in Drizzle schema but missing from DB
2+
ALTER TABLE public.instances
3+
ADD COLUMN IF NOT EXISTS config_version INTEGER NOT NULL DEFAULT 1;
4+
5+
-- Expand instance_events CHECK to include event types used at runtime
6+
ALTER TABLE public.instance_events DROP CONSTRAINT IF EXISTS instance_events_event_type_check;
7+
ALTER TABLE public.instance_events
8+
ADD CONSTRAINT instance_events_event_type_check CHECK (event_type IN (
9+
'created', 'provisioning', 'provisioned', 'started', 'stopped',
10+
'restarted', 'error', 'deleting', 'deleted', 'config_updated',
11+
'plan_changed', 'subscription_created', 'server_created', 'dns_created',
12+
'payment_completed'
13+
));

0 commit comments

Comments
 (0)