From 5bc23e36b8af6708d396bba2996fec38c5fea54a Mon Sep 17 00:00:00 2001 From: 0fatal <72899968+0fatal@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:03:03 +0800 Subject: [PATCH] fix(web): fix monitor yaxis overflow (#1928) * fix(web): fix monitor yaxis overflow --- .../SysSetting/AppMonitor/AreaCard/index.tsx | 21 +++++++++++++++-- .../SysSetting/AppMonitor/PieCard/index.tsx | 4 +++- .../setting/SysSetting/AppMonitor/index.tsx | 6 +++++ .../DatabaseMonitor/AreaCard/index.tsx | 23 +++++++++++++++---- .../DatabaseMonitor/PieCard/index.tsx | 2 +- .../SysSetting/DatabaseMonitor/index.tsx | 21 ++++++++++++----- 6 files changed, 63 insertions(+), 14 deletions(-) diff --git a/web/src/pages/app/setting/SysSetting/AppMonitor/AreaCard/index.tsx b/web/src/pages/app/setting/SysSetting/AppMonitor/AreaCard/index.tsx index 82f89c57cd..337da88e44 100644 --- a/web/src/pages/app/setting/SysSetting/AppMonitor/AreaCard/index.tsx +++ b/web/src/pages/app/setting/SysSetting/AppMonitor/AreaCard/index.tsx @@ -92,6 +92,8 @@ export default function AreaCard(props: { maxValue: number; unit: string; className?: string; + longestTick: string; + onLongestTickChange: (val: string) => void; }) { const { data, @@ -104,6 +106,8 @@ export default function AreaCard(props: { maxValue, unit, className, + longestTick, + onLongestTickChange, } = props; const [chartData, setChartData] = useState([]); useEffect(() => { @@ -147,6 +151,14 @@ export default function AreaCard(props: { ); }, [data, dataNumber, title]); + const tickFormatter = (val: string) => { + const formattedTick = val.toString(); + if (longestTick.length < formattedTick.length) { + onLongestTickChange(formattedTick); + } + return val; + }; + return (
@@ -178,7 +190,7 @@ export default function AreaCard(props: { )}
- + - +

{entry.value}

-

{formatSize(pieData[index]?.value * 1024 * 1024)}

+

+ {formatSize(pieData[index]?.value * 1024 * 1024)} +

))} diff --git a/web/src/pages/app/setting/SysSetting/AppMonitor/index.tsx b/web/src/pages/app/setting/SysSetting/AppMonitor/index.tsx index a897ce36ec..ae4d735f5d 100644 --- a/web/src/pages/app/setting/SysSetting/AppMonitor/index.tsx +++ b/web/src/pages/app/setting/SysSetting/AppMonitor/index.tsx @@ -46,6 +46,8 @@ export default function AppMonitor() { return cpuData.length > memoryData.length ? [t("All"), ...cpuData] : [t("All"), ...memoryData]; }, [monitorData, t]); + const [longestTick, setLongestTick] = useState(""); + return (
{isLoading ? ( @@ -66,6 +68,8 @@ export default function AppMonitor() { unit="Core" maxValue={limitCPU / 1000} className="h-1/2 p-4" + longestTick={longestTick} + onLongestTickChange={(val) => setLongestTick(val)} /> setLongestTick(val)} />
void; }) { const { data, @@ -124,7 +125,8 @@ export default function AreaCard(props: { unit, className, syncId, - tableMarginLeft, + longestTick, + onLongestTickChange, } = props; const [chartData, setChartData] = useState([]); useEffect(() => { @@ -173,6 +175,14 @@ export default function AreaCard(props: { } }, [data, podName, title]); + const tickFormatter = (val: string) => { + const formattedTick = val.toString(); + if (longestTick.length < formattedTick.length) { + onLongestTickChange(formattedTick); + } + return val; + }; + return (
@@ -205,7 +215,7 @@ export default function AreaCard(props: { @@ -219,7 +229,12 @@ export default function AreaCard(props: { domain={[Date.now() - 60 * 60 * 1000, Date.now()]} stroke="#C0C2D2" /> - + {maxValue !== 0 && (

{entry.value}

-

{(pieData[index]?.value).toFixed(3)} MB

+

{(pieData[index]?.value).toFixed(3)} MB

))} diff --git a/web/src/pages/app/setting/SysSetting/DatabaseMonitor/index.tsx b/web/src/pages/app/setting/SysSetting/DatabaseMonitor/index.tsx index 39a785d215..d6be22e590 100644 --- a/web/src/pages/app/setting/SysSetting/DatabaseMonitor/index.tsx +++ b/web/src/pages/app/setting/SysSetting/DatabaseMonitor/index.tsx @@ -76,6 +76,9 @@ export default function DatabaseMonitor() { return [t("All"), ...uniquePods]; }, [cpuData, memoryData, t]); + const [longestTick, setLongestTick] = useState(""); + const [longestTick1, setLongestTick1] = useState(""); + return ( @@ -107,7 +110,8 @@ export default function DatabaseMonitor() { maxValue={limitCPU / 1000} className="h-1/3 p-4" syncId="tab1" - tableMarginLeft={-28} + longestTick={longestTick} + onLongestTickChange={(val) => setLongestTick(val)} /> setLongestTick(val)} /> setLongestTick(val)} />
@@ -194,7 +200,8 @@ export default function DatabaseMonitor() { maxValue={0} className="h-1/3 p-4" syncId="" - tableMarginLeft={-25} + longestTick={longestTick1} + onLongestTickChange={(val) => setLongestTick1(val)} /> setLongestTick1(val)} /> setLongestTick1(val)} />
) : (