|
@@ -2,9 +2,13 @@ import dynamic from "next/dynamic";
|
|
import { useState, useEffect } from "react";
|
|
import { useState, useEffect } from "react";
|
|
import { useTranslation } from "next-i18next";
|
|
import { useTranslation } from "next-i18next";
|
|
|
|
|
|
|
|
+import Error from "../components/error";
|
|
|
|
+import Container from "../components/container";
|
|
|
|
+import Block from "../components/block";
|
|
|
|
+
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
|
|
-const ChartDual = dynamic(() => import("./chart_dual"), { ssr: false });
|
|
|
|
|
|
+const ChartDual = dynamic(() => import("../components/chart_dual"), { ssr: false });
|
|
|
|
|
|
const pointsLimit = 15;
|
|
const pointsLimit = 15;
|
|
|
|
|
|
@@ -36,61 +40,53 @@ export default function Component({ service }) {
|
|
}, [data, interfaceName]);
|
|
}, [data, interfaceName]);
|
|
|
|
|
|
if (error) {
|
|
if (error) {
|
|
- return <div>
|
|
|
|
- <div className="h-[68px] overflow-clip">
|
|
|
|
- <div className="absolute bottom-2 left-2 z-20 text-red-400 text-xs opacity-80">
|
|
|
|
- {t("widget.api_error")}
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </div>;
|
|
|
|
|
|
+ return <Container><Error error={error} /></Container>;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!data) {
|
|
if (!data) {
|
|
- return <div>
|
|
|
|
- <div className="h-[68px] overflow-clip">
|
|
|
|
- <div className="absolute bottom-2 left-2 z-20 text-xs opacity-80">
|
|
|
|
- -
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </div>;
|
|
|
|
|
|
+ return <Container><Block position={{bottom: 2, left: 2}}>-</Block></Container>;
|
|
}
|
|
}
|
|
|
|
+
|
|
const interfaceData = data.find((item) => item[item.key] === interfaceName);
|
|
const interfaceData = data.find((item) => item[item.key] === interfaceName);
|
|
|
|
|
|
if (!interfaceData) {
|
|
if (!interfaceData) {
|
|
- return <div>
|
|
|
|
- <div className="h-[68px] overflow-clip" />
|
|
|
|
- </div>;
|
|
|
|
|
|
+ return <Container><Block position={{bottom: 2, left: 2}}>-</Block></Container>;
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
- <>
|
|
|
|
- <div className="absolute -top-1 -left-1 h-[120px] w-[calc(100%+0.5em)] z-0">
|
|
|
|
- <ChartDual
|
|
|
|
- dataPoints={dataPoints}
|
|
|
|
- label={[t("docker.tx"), t("docker.rx")]}
|
|
|
|
- formatter={(value) => t("common.byterate", {
|
|
|
|
- value,
|
|
|
|
- maximumFractionDigits: 0,
|
|
|
|
- })}
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
- <div className="absolute bottom-3 left-3 z-10 text-xs opacity-80 pointer-events-none">
|
|
|
|
|
|
+ <Container>
|
|
|
|
+ <ChartDual
|
|
|
|
+ dataPoints={dataPoints}
|
|
|
|
+ label={[t("docker.tx"), t("docker.rx")]}
|
|
|
|
+ formatter={(value) => t("common.byterate", {
|
|
|
|
+ value,
|
|
|
|
+ maximumFractionDigits: 0,
|
|
|
|
+ })}
|
|
|
|
+ />
|
|
|
|
+
|
|
|
|
+ <Block position={{bottom: 3, left: 3}}>
|
|
{interfaceData && interfaceData.interface_name && (
|
|
{interfaceData && interfaceData.interface_name && (
|
|
- <div className="text-xs opacity-80">
|
|
|
|
|
|
+ <div className="text-xs opacity-50">
|
|
{interfaceData.interface_name}
|
|
{interfaceData.interface_name}
|
|
</div>
|
|
</div>
|
|
)}
|
|
)}
|
|
- {t("common.bitrate", {
|
|
|
|
- value: interfaceData.tx,
|
|
|
|
- maximumFractionDigits: 0,
|
|
|
|
- })} {t("docker.tx")}
|
|
|
|
- </div>
|
|
|
|
- <div className="absolute bottom-3 right-3 z-10 text-xs opacity-80 pointer-events-none">
|
|
|
|
- {t("common.bitrate", {
|
|
|
|
- value: interfaceData.rx,
|
|
|
|
- maximumFractionDigits: 0,
|
|
|
|
- })} {t("docker.rx")}
|
|
|
|
- </div>
|
|
|
|
- <div className="h-[68px] overflow-clip" />
|
|
|
|
- </>
|
|
|
|
|
|
+
|
|
|
|
+ <div className="text-xs opacity-75">
|
|
|
|
+ {t("common.bitrate", {
|
|
|
|
+ value: interfaceData.tx,
|
|
|
|
+ maximumFractionDigits: 0,
|
|
|
|
+ })} {t("docker.tx")}
|
|
|
|
+ </div>
|
|
|
|
+ </Block>
|
|
|
|
+
|
|
|
|
+ <Block position={{bottom: 3, right: 3}}>
|
|
|
|
+ <div className="text-xs opacity-75">
|
|
|
|
+ {t("common.bitrate", {
|
|
|
|
+ value: interfaceData.rx,
|
|
|
|
+ maximumFractionDigits: 0,
|
|
|
|
+ })} {t("docker.rx")}
|
|
|
|
+ </div>
|
|
|
|
+ </Block>
|
|
|
|
+ </Container>
|
|
);
|
|
);
|
|
}
|
|
}
|