feat(console): redesign Hub Console UI for desktop
- Stat cards grid (Device ID, Gateway, State, Agents) with copy buttons - Connection state badge with colored dot indicator - Inline gateway URL form with accent Connect button - Agent table with hover-reveal copy and delete actions - Toast notification on clipboard copy - Centered container layout (960px max) - Consistent dark theme matching Multica Client branding Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9ba793fee
commit
f3ec056b90
1 changed files with 429 additions and 42 deletions
|
|
@ -6,74 +6,461 @@
|
|||
<title>Hub Console</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace; background: #0a0a0a; color: #e0e0e0; padding: 2rem; }
|
||||
h1 { font-size: 1.4rem; margin-bottom: 1.5rem; color: #fff; }
|
||||
h2 { font-size: 1rem; margin-bottom: 0.8rem; color: #999; text-transform: uppercase; letter-spacing: 0.05em; }
|
||||
.card { background: #161616; border: 1px solid #2a2a2a; border-radius: 8px; padding: 1.2rem; margin-bottom: 1.2rem; }
|
||||
.hub-info span { display: inline-block; margin-right: 2rem; color: #888; }
|
||||
.hub-info span b { color: #e0e0e0; }
|
||||
.agent-list { list-style: none; }
|
||||
.agent-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid #222; font-family: monospace; font-size: 0.85rem; }
|
||||
.agent-list li:last-child { border-bottom: none; }
|
||||
.gateway-form { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.8rem; }
|
||||
.gateway-form input { background: #0a0a0a; color: #e0e0e0; border: 1px solid #444; border-radius: 4px; padding: 0.4rem 0.6rem; font-size: 0.85rem; font-family: monospace; flex: 1; }
|
||||
.gateway-form input:focus { outline: none; border-color: #666; }
|
||||
button { background: #2a2a2a; color: #e0e0e0; border: 1px solid #444; border-radius: 4px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.8rem; }
|
||||
button:hover { background: #3a3a3a; }
|
||||
.btn-create { background: #1a3a1a; border-color: #2a5a2a; }
|
||||
.btn-create:hover { background: #2a4a2a; }
|
||||
.btn-delete { background: #3a1a1a; border-color: #5a2a2a; }
|
||||
.btn-delete:hover { background: #4a2a2a; }
|
||||
.empty { color: #555; font-style: italic; font-size: 0.85rem; }
|
||||
|
||||
:root {
|
||||
--bg: #0f172a;
|
||||
--surface: #1e293b;
|
||||
--surface-2: #334155;
|
||||
--border: rgba(148,163,184,0.1);
|
||||
--text: #f1f5f9;
|
||||
--text-dim: #94a3b8;
|
||||
--text-muted: #64748b;
|
||||
--accent: #6366f1;
|
||||
--accent-light: #818cf8;
|
||||
--green: #34d399;
|
||||
--yellow: #fbbf24;
|
||||
--red: #f87171;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Segoe UI", Roboto, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ── Header ── */
|
||||
.header {
|
||||
background: var(--surface);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0 32px;
|
||||
height: 56px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.header-logo {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.header-subtitle {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted);
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
/* ── Container ── */
|
||||
.container {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
padding: 28px 32px;
|
||||
}
|
||||
|
||||
/* ── Stat cards ── */
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 14px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.stat-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 16px 18px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 0.88rem;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-family: "SF Mono", "Fira Code", monospace;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.stat-value .copy-btn {
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
.stat-card:hover .copy-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* ── State badge ── */
|
||||
.state-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.state-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-muted);
|
||||
}
|
||||
.state-dot.registered {
|
||||
background: var(--green);
|
||||
box-shadow: 0 0 8px rgba(52,211,153,0.5);
|
||||
}
|
||||
.state-dot.connected {
|
||||
background: var(--yellow);
|
||||
}
|
||||
.state-dot.disconnected {
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
/* ── Gateway form ── */
|
||||
.gateway-section {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.gateway-section label {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.gateway-section input {
|
||||
flex: 1;
|
||||
background: var(--bg);
|
||||
border: 1px solid rgba(148,163,184,0.12);
|
||||
border-radius: 8px;
|
||||
padding: 9px 12px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
font-family: "SF Mono", "Fira Code", monospace;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.gateway-section input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
|
||||
}
|
||||
|
||||
/* ── Buttons ── */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
padding: 8px 16px;
|
||||
transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.btn:active { transform: scale(0.97); }
|
||||
.btn-accent {
|
||||
background: linear-gradient(135deg, #6366f1, #8b5cf6);
|
||||
color: white;
|
||||
box-shadow: 0 2px 8px rgba(99,102,241,0.25);
|
||||
}
|
||||
.btn-accent:hover {
|
||||
box-shadow: 0 4px 12px rgba(99,102,241,0.35);
|
||||
}
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-dim);
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.btn-ghost:hover {
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
}
|
||||
.btn-danger-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.btn-danger-ghost:hover {
|
||||
background: rgba(248,113,113,0.1);
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
/* ── Copy button ── */
|
||||
.copy-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.copy-btn:hover {
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
}
|
||||
.copy-btn.copied {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
/* ── Agents section ── */
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.agent-table {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.agent-table-head {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 0.68rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.agent-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
padding: 12px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
transition: background 0.1s;
|
||||
}
|
||||
.agent-row:last-child { border-bottom: none; }
|
||||
.agent-row:hover { background: rgba(148,163,184,0.04); }
|
||||
.agent-id {
|
||||
font-family: "SF Mono", "Fira Code", monospace;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-dim);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.agent-id .copy-btn { opacity: 0; transition: opacity 0.15s; }
|
||||
.agent-row:hover .copy-btn { opacity: 1; }
|
||||
.agent-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.agent-actions .btn-danger-ghost { opacity: 0; transition: opacity 0.15s; }
|
||||
.agent-row:hover .btn-danger-ghost { opacity: 1; }
|
||||
|
||||
.empty-state {
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
/* ── Toast ── */
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateY(80px);
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.3);
|
||||
opacity: 0;
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
pointer-events: none;
|
||||
z-index: 100;
|
||||
}
|
||||
.toast.show {
|
||||
transform: translateX(-50%) translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hub Console</h1>
|
||||
|
||||
<div class="card">
|
||||
<h2>Hub Status</h2>
|
||||
<div class="hub-info" id="hub-info">Loading...</div>
|
||||
<div class="gateway-form">
|
||||
<input type="text" id="gateway-url" placeholder="Gateway URL">
|
||||
<button class="btn-create" onclick="updateGateway()">Connect</button>
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<h1>Hub Console</h1>
|
||||
<span class="header-subtitle">Multica</span>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<!-- Stats -->
|
||||
<div class="stats" id="stats">
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Device ID</div>
|
||||
<div class="stat-value" id="stat-device">—</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Gateway</div>
|
||||
<div class="stat-value" id="stat-gateway">—</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">State</div>
|
||||
<div class="stat-value" id="stat-state">—</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Agents</div>
|
||||
<div class="stat-value" id="stat-agents">—</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Gateway URL -->
|
||||
<div class="gateway-section">
|
||||
<label>Gateway URL</label>
|
||||
<input type="text" id="gateway-url" placeholder="https://gateway.example.com">
|
||||
<button class="btn btn-accent" onclick="updateGateway()">Connect</button>
|
||||
</div>
|
||||
|
||||
<!-- Agents -->
|
||||
<div class="section-header">
|
||||
<span class="section-title">Agents</span>
|
||||
<button class="btn btn-accent" onclick="createAgent()">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
||||
Create Agent
|
||||
</button>
|
||||
</div>
|
||||
<div class="agent-table" id="agent-table">
|
||||
<div class="agent-table-head">
|
||||
<span>Agent ID</span>
|
||||
<span>Actions</span>
|
||||
</div>
|
||||
<div id="agent-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>Agents</h2>
|
||||
<div style="margin-bottom: 0.8rem;">
|
||||
<button class="btn-create" onclick="createAgent()">+ Create Agent</button>
|
||||
</div>
|
||||
<ul class="agent-list" id="agent-list"></ul>
|
||||
</div>
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script>
|
||||
const API = '/api';
|
||||
|
||||
function copyIcon() {
|
||||
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>';
|
||||
}
|
||||
|
||||
function checkIcon() {
|
||||
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>';
|
||||
}
|
||||
|
||||
function trashIcon() {
|
||||
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>';
|
||||
}
|
||||
|
||||
function showToast(msg) {
|
||||
const el = document.getElementById('toast');
|
||||
el.textContent = msg;
|
||||
el.classList.add('show');
|
||||
setTimeout(() => el.classList.remove('show'), 2000);
|
||||
}
|
||||
|
||||
function copyText(text, btnEl) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
btnEl.innerHTML = checkIcon();
|
||||
btnEl.classList.add('copied');
|
||||
showToast('Copied to clipboard');
|
||||
setTimeout(() => {
|
||||
btnEl.innerHTML = copyIcon();
|
||||
btnEl.classList.remove('copied');
|
||||
}, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
function truncateId(id) {
|
||||
if (!id || id.length <= 12) return id || '—';
|
||||
return id.slice(0, 8) + '...' + id.slice(-4);
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
const [hubRes, agentsRes] = await Promise.all([
|
||||
fetch(`${API}/hub`).then(r => r.json()),
|
||||
fetch(`${API}/agents`).then(r => r.json()),
|
||||
]);
|
||||
|
||||
const stateColor = hubRes.connectionState === 'registered' ? '#4a4' : hubRes.connectionState === 'connected' ? '#aa4' : '#a44';
|
||||
document.getElementById('hub-info').innerHTML =
|
||||
`<span>Device: <b>${hubRes.deviceId}</b></span>` +
|
||||
`<span>Gateway: <b>${hubRes.url}</b></span>` +
|
||||
`<span>State: <b style="color:${stateColor}">${hubRes.connectionState}</b></span>` +
|
||||
`<span>Agents: <b>${hubRes.agentCount}</b></span>`;
|
||||
// Stats
|
||||
const deviceId = hubRes.deviceId || '—';
|
||||
document.getElementById('stat-device').innerHTML =
|
||||
`<span title="${deviceId}">${truncateId(deviceId)}</span>` +
|
||||
(deviceId !== '—' ? `<button class="copy-btn" onclick="copyText('${deviceId}', this)">${copyIcon()}</button>` : '');
|
||||
|
||||
document.getElementById('stat-gateway').innerHTML =
|
||||
`<span title="${hubRes.url || ''}" style="overflow:hidden;text-overflow:ellipsis">${hubRes.url || '—'}</span>`;
|
||||
|
||||
const state = hubRes.connectionState || 'disconnected';
|
||||
const stateLabel = state.charAt(0).toUpperCase() + state.slice(1);
|
||||
document.getElementById('stat-state').innerHTML =
|
||||
`<span class="state-badge"><span class="state-dot ${state}"></span>${stateLabel}</span>`;
|
||||
|
||||
document.getElementById('stat-agents').textContent = hubRes.agentCount ?? 0;
|
||||
|
||||
// Gateway input
|
||||
const input = document.getElementById('gateway-url');
|
||||
if (!input.dataset.edited) {
|
||||
input.value = hubRes.url;
|
||||
input.value = hubRes.url || '';
|
||||
}
|
||||
|
||||
// Agent list
|
||||
const list = document.getElementById('agent-list');
|
||||
if (agentsRes.length === 0) {
|
||||
list.innerHTML = '<li class="empty">No agents</li>';
|
||||
list.innerHTML = '<div class="empty-state">No agents yet. Create one to get started.</div>';
|
||||
} else {
|
||||
list.innerHTML = agentsRes.map(a =>
|
||||
`<li><span>${a.id}</span><button class="btn-delete" onclick="deleteAgent('${a.id}')">Delete</button></li>`
|
||||
`<div class="agent-row">` +
|
||||
`<div class="agent-id">` +
|
||||
`<span title="${a.id}">${a.id}</span>` +
|
||||
`<button class="copy-btn" onclick="copyText('${a.id}', this)">${copyIcon()}</button>` +
|
||||
`</div>` +
|
||||
`<div class="agent-actions">` +
|
||||
`<button class="btn-danger-ghost btn" onclick="deleteAgent('${a.id}')" title="Delete">${trashIcon()}</button>` +
|
||||
`</div>` +
|
||||
`</div>`
|
||||
).join('');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue