mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
feat(detail): last active time info
This commit is contained in:
parent
f39f480028
commit
b80af34a45
@ -56,6 +56,7 @@ export default function ServerDetailOverview({
|
||||
load_15,
|
||||
net_out_transfer,
|
||||
net_in_transfer,
|
||||
last_active_time_string,
|
||||
} = formatNezhaInfo(nezhaWsData.now, server);
|
||||
|
||||
return (
|
||||
@ -88,7 +89,8 @@ export default function ServerDetailOverview({
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
{online && (
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@ -102,6 +104,7 @@ export default function ServerDetailOverview({
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
{version && (
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
@ -126,7 +129,10 @@ export default function ServerDetailOverview({
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
|
||||
|
||||
|
||||
{mem_total ? (<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@ -135,8 +141,11 @@ export default function ServerDetailOverview({
|
||||
<div className="text-xs">{formatBytes(mem_total)}</div>
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
</Card>) : null}
|
||||
|
||||
|
||||
|
||||
{disk_total ? (<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@ -145,7 +154,10 @@ export default function ServerDetailOverview({
|
||||
<div className="text-xs">{formatBytes(disk_total)}</div>
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Card>) : null}
|
||||
|
||||
|
||||
|
||||
{country_code && (
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
@ -211,14 +223,14 @@ export default function ServerDetailOverview({
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">{"Load"}</p>
|
||||
|
||||
<div className="text-xs">
|
||||
{load_1} / {load_5} / {load_15}
|
||||
</div>
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
{net_out_transfer ? (
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@ -232,7 +244,8 @@ export default function ServerDetailOverview({
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
): null}
|
||||
{net_in_transfer ? (<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@ -245,7 +258,7 @@ export default function ServerDetailOverview({
|
||||
)}
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Card>): null}
|
||||
</section>
|
||||
{server?.state.temperatures && server?.state.temperatures.length > 0 && (
|
||||
<section className="flex flex-wrap gap-2 mt-1">
|
||||
@ -266,6 +279,20 @@ export default function ServerDetailOverview({
|
||||
</Card>
|
||||
</section>
|
||||
)}
|
||||
<section className="flex flex-wrap gap-2 mt-1">
|
||||
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||
<CardContent className="px-1.5 py-1">
|
||||
<section className="flex flex-col items-start gap-0.5">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t("serverDetail.lastActive")}
|
||||
</p>
|
||||
<div className="text-xs">
|
||||
{last_active_time_string ? last_active_time_string : "N/A"}
|
||||
</div>
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -7,13 +7,16 @@ export function cn(...inputs: ClassValue[]) {
|
||||
}
|
||||
|
||||
export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
|
||||
const lastActiveTime = parseISOTimestamp(serverInfo.last_active);
|
||||
const lastActiveTime = serverInfo.last_active.startsWith("000") ? 0 : parseISOTimestamp(serverInfo.last_active);
|
||||
return {
|
||||
...serverInfo,
|
||||
cpu: serverInfo.state.cpu || 0,
|
||||
process: serverInfo.state.process_count || 0,
|
||||
up: serverInfo.state.net_out_speed / 1024 / 1024 || 0,
|
||||
down: serverInfo.state.net_in_speed / 1024 / 1024 || 0,
|
||||
last_active_time_string: lastActiveTime
|
||||
? new Date(lastActiveTime).toLocaleString()
|
||||
: "",
|
||||
online: now - lastActiveTime <= 30000,
|
||||
uptime: serverInfo.state.uptime || 0,
|
||||
version: serverInfo.host.version || null,
|
||||
|
@ -60,7 +60,8 @@
|
||||
"region": "Region",
|
||||
"system": "System",
|
||||
"upload": "Upload",
|
||||
"download": "Download"
|
||||
"download": "Download",
|
||||
"lastActive": "Last active time"
|
||||
},
|
||||
"serverDetailChart": {
|
||||
"process": "Process",
|
||||
|
@ -60,7 +60,8 @@
|
||||
"region": "区域",
|
||||
"system": "系统",
|
||||
"upload": "上传",
|
||||
"download": "下载"
|
||||
"download": "下载",
|
||||
"lastActive": "最后上报时间"
|
||||
},
|
||||
"serverDetailChart": {
|
||||
"process": "进程数",
|
||||
|
@ -60,7 +60,8 @@
|
||||
"region": "地區",
|
||||
"system": "系統",
|
||||
"upload": "上傳",
|
||||
"download": "下載"
|
||||
"download": "下載",
|
||||
"lastActive": "最後上報時間"
|
||||
},
|
||||
"serverDetailChart": {
|
||||
"process": "進程數",
|
||||
|
Loading…
x
Reference in New Issue
Block a user