Skip to content

Commit

Permalink
feat: separate upload and download traffic display
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Oct 19, 2024
1 parent 5f1d849 commit 4040c6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
13 changes: 9 additions & 4 deletions app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function ServerOverviewClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher);
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
return (
<section className="grid grid-cols-2 gap-4 md:grid-cols-4">
<section className="grid grid-cols-2 gap-4 lg:grid-cols-4">
<Card>
<CardContent className="px-6 py-3">
<section className="flex flex-col gap-1">
Expand Down Expand Up @@ -94,9 +94,14 @@ export default function ServerOverviewClient() {
{t("p_3463-3530_Totalbandwidth")}
</p>
{data ? (
<p className="text-lg font-semibold">
{formatBytes(data?.total_bandwidth)}
</p>
<section className="flex pt-[4px] items-center gap-2">
<p className="text-[14px] font-semibold">
{formatBytes(data?.total_out_bandwidth)}
</p>
<p className="text-[14px] font-semibold">
{formatBytes(data?.total_in_bandwidth)}
</p>
</section>
) : (
<div className="flex h-7 items-center">
<Loader visible={true} />
Expand Down
3 changes: 2 additions & 1 deletion app/[locale]/types/nezha-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export type ServerApi = {
live_servers: number;
offline_servers: number;
total_bandwidth: number;
total_out_bandwidth: number;
total_in_bandwidth: number;
result: NezhaAPISafe[];
};

Expand Down
6 changes: 4 additions & 2 deletions lib/serverFetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export async function GetNezhaData() {
const data: ServerApi = {
live_servers: 0,
offline_servers: 0,
total_bandwidth: 0,
total_out_bandwidth: 0,
total_in_bandwidth: 0,
result: [],
};

Expand All @@ -61,7 +62,8 @@ export async function GetNezhaData() {
data.live_servers += 1;
element.online_status = true;
}
data.total_bandwidth += element.status.NetOutTransfer;
data.total_out_bandwidth += element.status.NetOutTransfer;
data.total_in_bandwidth += element.status.NetInTransfer;

delete element.ipv4;
delete element.ipv6;
Expand Down

0 comments on commit 4040c6d

Please sign in to comment.