Files
webup-cloud/frontend/src/views/Nodes.vue
T
WebUp Cloud db82325ed7
Verify control plane / verify (push) Canceled after 0s
Initial import of WebUp Cloud
2026-11-07 13:31:14 +08:00

191 lines
5.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { api } from "../api";
const local = ref<any>(null),
nodes = ref<any[]>([]),
error = ref(""),
busy = ref(false),
details = ref("");
const workers = ref<any>({ workers: [], execution: null, queuedTasks: 0 });
const gb = (n: number) =>
n === undefined ? "—" : (n / 1024 ** 3).toFixed(2) + " GB";
async function load() {
try {
[local.value, nodes.value, workers.value] = await Promise.all([
api("/admin/nodes/control-plane"),
api("/admin/nodes"),
api("/admin/workers"),
]);
} catch (e) {
error.value = (e as Error).message;
}
}
async function refresh() {
busy.value = true;
error.value = "";
try {
nodes.value = (
await api("/admin/nodes/refresh", {
method: "POST",
signal: AbortSignal.timeout(125000),
})
).items;
} catch (e) {
error.value = (e as Error).message;
} finally {
busy.value = false;
}
}
onMounted(load);
</script>
<template>
<div class="page-heading">
<div>
<span class="eyebrow">INFRASTRUCTURE</span>
<h1>服务器与节点</h1>
<p>控制面真实主机信息与运行集群节点分别显示。</p>
</div>
<button class="primary" :disabled="busy" @click="refresh">
同步集群节点
</button>
</div>
<div v-if="error" class="alert error">{{ error }}</div>
<section
v-if="workers.execution"
class="panel form-panel"
style="margin-bottom: 24px"
>
<h3>AI 执行服务 · {{ workers.execution.ready ? "已就绪" : "未就绪" }}</h3>
<p style="margin-top: 12px">{{ workers.execution.reason }}</p>
<p class="muted">
当前排队 {{ workers.queuedTasks }} 项 · 就绪实例
{{ workers.execution.readyWorkers }} 个
</p>
<div
v-if="!workers.workers.length"
class="alert info"
style="margin-top: 14px"
>
尚未收到执行实例心跳。请在测试集群部署隔离网关,再启用独立 AI
Worker;前端和 API 服务正常运行并不代表执行服务已启动。
</div>
<div v-else class="table-scroll">
<table>
<thead>
<tr>
<th>实例</th>
<th>状态</th>
<th>本实例容量 / 执行中</th>
<th>健康检查</th>
<th>最后心跳</th>
</tr>
</thead>
<tbody>
<tr v-for="w in workers.workers" :key="w.instance_id">
<td>
<code>{{ w.instance_id.slice(0, 8) }}</code>
</td>
<td>
{{
w.status === "STOPPED"
? "已停止"
: !w.fresh
? "心跳超时"
: w.status === "READY"
? "已就绪"
: "环境异常"
}}
</td>
<td>{{ w.capacity }} / {{ w.active_tasks }}</td>
<td>{{ w.detail }}</td>
<td>{{ new Date(w.updated_at).toLocaleString() }}</td>
</tr>
</tbody>
</table>
</div>
</section>
<section v-if="local" class="stats">
<div class="stat-card">
<div>控制面 CPU</div>
<strong>{{ local.processors }} 核</strong
><small
>负载
{{
local.cpuLoad === null
? "未采集"
: (local.cpuLoad * 100).toFixed(1) + "%"
}}</small
>
</div>
<div class="stat-card">
<div>物理内存</div>
<strong class="text-stat">{{ gb(local.physicalMemoryTotal) }}</strong
><small>可用 {{ gb(local.physicalMemoryFree) }}</small>
</div>
<div class="stat-card">
<div>磁盘</div>
<strong class="text-stat">{{ gb(local.diskTotal) }}</strong
><small>可用 {{ gb(local.diskUsable) }}</small>
</div>
<div class="stat-card">
<div>JVM 堆内存</div>
<strong class="text-stat">{{ gb(local.heapUsed) }}</strong
><small>上限 {{ gb(local.heapMax) }}</small>
</div>
</section>
<section v-if="local" class="panel form-panel">
<h3>控制面运行环境</h3>
<p class="muted" style="margin-top: 14px">
{{ local.os }} · {{ local.architecture }} · Java {{ local.javaVersion }} ·
运行 {{ Math.floor(local.uptimeMillis / 60000) }} 分钟
</p>
<button class="text-link" style="margin-top: 12px" @click="load">
刷新本机信息 →
</button>
</section>
<section class="panel table-panel" style="margin-top: 24px">
<div class="panel-heading"><h3>运行集群节点</h3></div>
<div class="table-scroll">
<table>
<thead>
<tr>
<th>节点</th>
<th>状态</th>
<th>CPU / 内存</th>
<th>内网地址</th>
<th>最近采集</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="n in nodes" :key="n.name">
<td>{{ n.name }}</td>
<td>{{ n.status }}</td>
<td>{{ n.cpu_capacity }} / {{ n.memory_capacity }}</td>
<td>{{ n.internal_ip }}</td>
<td>{{ new Date(n.last_seen).toLocaleString() }}</td>
<td>
<button
class="link"
@click="
details = JSON.stringify(JSON.parse(n.node_info), null, 2)
"
>
详细信息
</button>
</td>
</tr>
<tr v-if="!nodes.length">
<td class="empty" colspan="6">
尚未同步运行节点。未配置网关时不展示模拟节点。
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section v-if="details" class="panel event-log">
<pre style="white-space: pre-wrap">{{ details }}</pre>
</section>
</template>