feat: add value format for data metrics
This commit is contained in:
parent
a579b678cc
commit
f749f720db
@ -17,8 +17,13 @@ export const MonitorDataMetrics: React.FC<{
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
monitorId,
|
monitorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const provider = useMemo(
|
||||||
|
() => getMonitorProvider(monitorType),
|
||||||
|
[monitorType]
|
||||||
|
);
|
||||||
|
|
||||||
const providerOverview = useMemo(() => {
|
const providerOverview = useMemo(() => {
|
||||||
const provider = getMonitorProvider(monitorType);
|
|
||||||
if (!provider || !provider.overview) {
|
if (!provider || !provider.overview) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -30,7 +35,11 @@ export const MonitorDataMetrics: React.FC<{
|
|||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}, [monitorId, monitorType]);
|
}, [monitorId, provider]);
|
||||||
|
|
||||||
|
const formatterFn = provider?.valueFormatter
|
||||||
|
? provider?.valueFormatter
|
||||||
|
: (value: number) => `${value}ms`;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
@ -46,14 +55,14 @@ export const MonitorDataMetrics: React.FC<{
|
|||||||
<MonitorStatsBlock
|
<MonitorStatsBlock
|
||||||
title="Response"
|
title="Response"
|
||||||
desc="(Current)"
|
desc="(Current)"
|
||||||
text={`${currectResponse} ms`}
|
text={formatterFn(currectResponse)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MonitorStatsBlock
|
<MonitorStatsBlock
|
||||||
title="Avg. Response"
|
title="Avg. Response"
|
||||||
desc="(24 hour)"
|
desc="(24 hour)"
|
||||||
text={`${parseFloat(data.recent1DayAvg.toFixed(0))} ms`}
|
text={formatterFn(parseFloat(data.recent1DayAvg.toFixed(0)))}
|
||||||
/>
|
/>
|
||||||
<MonitorStatsBlock
|
<MonitorStatsBlock
|
||||||
title="Uptime"
|
title="Uptime"
|
||||||
|
Loading…
Reference in New Issue
Block a user