mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 22:48:46 +00:00
mini-non-chart charts
This commit is contained in:
parent
c2058f353d
commit
17b0f635d8
12 changed files with 437 additions and 245 deletions
|
@ -15,12 +15,13 @@ const pointsLimit = 15;
|
|||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
const [, interfaceName] = widget.metric.split(':');
|
||||
const { chart, metric } = widget;
|
||||
const [, interfaceName] = metric.split(':');
|
||||
|
||||
const [dataPoints, setDataPoints] = useState(new Array(pointsLimit).fill({ value: 0 }, 0, pointsLimit));
|
||||
|
||||
const { data, error } = useWidgetAPI(widget, 'network', {
|
||||
refreshInterval: 1000,
|
||||
refreshInterval: chart ? 1000 : 5000,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -54,18 +55,20 @@ export default function Component({ service }) {
|
|||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<ChartDual
|
||||
dataPoints={dataPoints}
|
||||
label={[t("docker.tx"), t("docker.rx")]}
|
||||
formatter={(value) => t("common.byterate", {
|
||||
value,
|
||||
maximumFractionDigits: 0,
|
||||
})}
|
||||
/>
|
||||
<Container chart={chart}>
|
||||
{ chart && (
|
||||
<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 && chart && (
|
||||
<div className="text-xs opacity-50">
|
||||
{interfaceData.interface_name}
|
||||
</div>
|
||||
|
@ -79,6 +82,16 @@ export default function Component({ service }) {
|
|||
</div>
|
||||
</Block>
|
||||
|
||||
{ !chart && (
|
||||
<Block position="top-3 right-3">
|
||||
{interfaceData && interfaceData.interface_name && (
|
||||
<div className="text-xs opacity-50">
|
||||
{interfaceData.interface_name}
|
||||
</div>
|
||||
)}
|
||||
</Block>
|
||||
)}
|
||||
|
||||
<Block position="bottom-3 right-3">
|
||||
<div className="text-xs opacity-75">
|
||||
{t("common.bitrate", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue