Skip to content

Commit

Permalink
fix: Update resource acquisition notation elements. (#2945)
Browse files Browse the repository at this point in the history
resolves #2946

**Changes:**
- Improved decimal precision in percentage displays by adding `.toFixed(1)` to ensure consistent one decimal place
- Increased network traffic (TX/RX) decimal precision from 1 to 2 places for more accurate readings

**Impact:**
These changes provide more precise numerical representations in the Agent Detail Modal, particularly for percentage values and network traffic measurements, leading to better monitoring accuracy.

**How to test:**
1. Visit Resources page.
2. Click the info icon of any agent.

**Checklist:**
- [x] Mention to the original issue
- [ ] Documentation
- [x] Minium required manager version: 24.09
- [x] Specific setting for review
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
  • Loading branch information
agatha197 committed Dec 18, 2024
1 parent 3afb0d3 commit 23bc698
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions react/src/components/AgentDetailModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { convertBinarySizeUnit, convertDecimalSizeUnit } from '../helper';
import {
convertBinarySizeUnit,
convertDecimalSizeUnit,
toFixedFloorWithoutTrailingZeros,
} from '../helper';
import { useResourceSlotsDetails } from '../hooks/backendai';
import BAIModal, { BAIModalProps } from './BAIModal';
import BAIProgressWithLabel from './BAIProgressWithLabel';
Expand Down Expand Up @@ -78,7 +82,9 @@ const AgentDetailModal: React.FC<AgentDetailModalProps> = ({
</Typography.Text>
<BAIProgressWithLabel
percent={value?.pct}
valueLabel={value?.pct + '%'}
valueLabel={
toFixedFloorWithoutTrailingZeros(value?.pct, 1) + '%'
}
/>
</Flex>
))}
Expand Down Expand Up @@ -124,7 +130,7 @@ const AgentDetailModal: React.FC<AgentDetailModalProps> = ({
convertDecimalSizeUnit(
parsedLiveStat?.node?.net_tx?.current,
'm',
1,
2,
)?.numberUnit
}
B
Expand All @@ -137,7 +143,7 @@ const AgentDetailModal: React.FC<AgentDetailModalProps> = ({
convertDecimalSizeUnit(
parsedLiveStat?.node?.net_rx?.current,
'm',
1,
2,
)?.numberUnit
}
B
Expand Down Expand Up @@ -177,7 +183,12 @@ const AgentDetailModal: React.FC<AgentDetailModalProps> = ({
</Typography.Text>
<BAIProgressWithLabel
percent={_.toFinite((value?.[1] as LiveStat)?.pct)}
valueLabel={(value?.[1] as LiveStat)?.pct + '%'}
valueLabel={
toFixedFloorWithoutTrailingZeros(
(value?.[1] as LiveStat)?.pct,
1,
) + '%'
}
/>
</Flex>
),
Expand Down Expand Up @@ -211,7 +222,12 @@ const AgentDetailModal: React.FC<AgentDetailModalProps> = ({
</Typography.Text>
<BAIProgressWithLabel
percent={_.toFinite((value?.[1] as LiveStat)?.pct)}
valueLabel={(value?.[1] as LiveStat)?.pct + '%'}
valueLabel={
toFixedFloorWithoutTrailingZeros(
(value?.[1] as LiveStat)?.pct,
1,
) + '%'
}
/>
</Flex>
),
Expand Down

0 comments on commit 23bc698

Please sign in to comment.