Skip to content

Commit 7ffef91

Browse files
authored
feat: add boot time display in ServerDetailOverview and localization … (#35)
* feat: add boot time display in ServerDetailOverview and localization support * chore: auto-fix linting and formatting issues
1 parent 1a38ce8 commit 7ffef91

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

src/components/ServerDetailOverview.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
7474
net_out_transfer,
7575
net_in_transfer,
7676
last_active_time_string,
77+
boot_time_string,
7778
} = formatNezhaInfo(nezhaWsData.now, server)
7879

7980
const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
@@ -285,6 +286,14 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
285286
</section>
286287

287288
<section className="flex flex-wrap gap-2 mt-1">
289+
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
290+
<CardContent className="px-1.5 py-1">
291+
<section className="flex flex-col items-start gap-0.5">
292+
<p className="text-xs text-muted-foreground">{t("serverDetail.bootTime")}</p>
293+
<div className="text-xs">{boot_time_string ? boot_time_string : "N/A"}</div>
294+
</section>
295+
</CardContent>
296+
</Card>
288297
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
289298
<CardContent className="px-1.5 py-1">
290299
<section className="flex flex-col items-start gap-0.5">

src/lib/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
3535
swap_total: serverInfo.host.swap_total || 0,
3636
disk_total: serverInfo.host.disk_total || 0,
3737
boot_time: serverInfo.host.boot_time || 0,
38+
boot_time_string: serverInfo.host.boot_time ? dayjs(serverInfo.host.boot_time * 1000).format("YYYY-MM-DD HH:mm:ss") : "",
3839
platform_version: serverInfo.host.platform_version || "",
3940
cpu_info: serverInfo.host.cpu || [],
4041
gpu_info: serverInfo.host.gpu || [],

src/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"upload": "Upload",
6868
"download": "Download",
6969
"lastActive": "Last active time",
70-
"temperature": "Temperature"
70+
"temperature": "Temperature",
71+
"bootTime": "Boot time"
7172
},
7273
"serverDetailChart": {
7374
"process": "Process",

src/locales/zh-CN/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"upload": "上传",
6868
"download": "下载",
6969
"lastActive": "最后上报时间",
70-
"temperature": "温度"
70+
"temperature": "温度",
71+
"bootTime": "启动时间"
7172
},
7273
"serverDetailChart": {
7374
"process": "进程数",

src/locales/zh-TW/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"upload": "上傳",
6868
"download": "下載",
6969
"lastActive": "最後上報時間",
70-
"temperature": "溫度"
70+
"temperature": "溫度",
71+
"bootTime": "啟動時間"
7172
},
7273
"serverDetailChart": {
7374
"process": "進程數",

0 commit comments

Comments
 (0)