Skip to content

Commit

Permalink
fix: display error
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Dec 1, 2024
1 parent c879654 commit 6344064
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
20 changes: 14 additions & 6 deletions src/components/ServerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ export default function ServerCard({
}) {
const { t } = useTranslation();
const navigate = useNavigate();
const { name, country_code, online, cpu, up, down, mem, stg } =
formatNezhaInfo(now, serverInfo);
const {
name,
country_code,
online,
cpu,
up,
down,
mem,
stg,
net_in_transfer,
net_out_transfer,
} = formatNezhaInfo(now, serverInfo);

const showFlag = true;

Expand Down Expand Up @@ -108,15 +118,13 @@ export default function ServerCard({
variant="secondary"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] border-muted-50 shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.upload")}:
{formatBytes(serverInfo.state.net_out_transfer)}
{t("serverCard.upload")}:{formatBytes(net_out_transfer)}
</Badge>
<Badge
variant="outline"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.download")}:
{formatBytes(serverInfo.state.net_in_transfer)}
{t("serverCard.download")}:{formatBytes(net_in_transfer)}
</Badge>
</section>
</div>
Expand Down
32 changes: 21 additions & 11 deletions src/components/ServerCardInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ export default function ServerCardInline({
}) {
const { t } = useTranslation();
const navigate = useNavigate();
const { name, country_code, online, cpu, up, down, mem, stg } =
formatNezhaInfo(now, serverInfo);
const {
name,
country_code,
online,
cpu,
up,
down,
mem,
stg,
platform,
uptime,
net_in_transfer,
net_out_transfer,
} = formatNezhaInfo(now, serverInfo);

const showFlag = true;

Expand Down Expand Up @@ -65,22 +77,20 @@ export default function ServerCardInline({
className={"items-center flex flex-row gap-2 whitespace-nowrap"}
>
<div className="text-xs font-semibold">
{serverInfo.host.platform.includes("Windows") ? (
{platform.includes("Windows") ? (
<MageMicrosoftWindows className="size-[10px]" />
) : (
<p
className={`fl-${GetFontLogoClass(serverInfo.host.platform)}`}
/>
<p className={`fl-${GetFontLogoClass(platform)}`} />
)}
</div>
<div className={"flex w-14 flex-col"}>
<p className="text-xs text-muted-foreground">
{t("serverCard.system")}
</p>
<div className="flex items-center text-[10.5px] font-semibold">
{serverInfo.host.platform.includes("Windows")
{platform.includes("Windows")
? "Windows"
: GetOsName(serverInfo.host.platform)}
: GetOsName(platform)}
</div>
</div>
</div>
Expand All @@ -89,7 +99,7 @@ export default function ServerCardInline({
{t("serverCard.uptime")}
</p>
<div className="flex items-center text-xs font-semibold">
{(serverInfo.state.uptime / 86400).toFixed(0)} {"Days"}
{(uptime / 86400).toFixed(0)} {"Days"}
</div>
</div>
<div className={"flex w-14 flex-col"}>
Expand Down Expand Up @@ -142,15 +152,15 @@ export default function ServerCardInline({
{t("serverCard.totalUpload")}
</p>
<div className="flex items-center text-xs font-semibold">
{formatBytes(serverInfo.state.net_out_transfer)}
{formatBytes(net_out_transfer)}
</div>
</div>
<div className={"flex w-20 flex-col"}>
<p className="text-xs text-muted-foreground">
{t("serverCard.totalDownload")}
</p>
<div className="flex items-center text-xs font-semibold">
{formatBytes(serverInfo.state.net_in_transfer)}
{formatBytes(net_in_transfer)}
</div>
</div>
</section>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
disk: (serverInfo.state.disk_used / serverInfo.host.disk_total) * 100 || 0,
stg: (serverInfo.state.disk_used / serverInfo.host.disk_total) * 100 || 0,
country_code: serverInfo.country_code,
platform: serverInfo.host.platform || "",
net_out_transfer: serverInfo.state.net_out_transfer || 0,
net_in_transfer: serverInfo.state.net_in_transfer || 0,
};
}

Expand Down

0 comments on commit 6344064

Please sign in to comment.