Skip to content

Commit

Permalink
[CP-3324] Byte calculation corrected: decimal to binary conversion im…
Browse files Browse the repository at this point in the history
…plemented
  • Loading branch information
dkarski committed Dec 11, 2024
1 parent 80a9646 commit 2915f5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions libs/generic-view/ui/src/lib/interactive/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const Tooltip: APIFC<undefined, TooltipConfig> & {
}

const updateTooltipPosition = () => {
const boundary = event.currentTarget.parentElement?.getBoundingClientRect();
const boundary = event.currentTarget.parentElement?.parentElement?.getBoundingClientRect();
const viewportWidth = boundary?.width || window.innerWidth
const viewportHeight = boundary?.height || window.innerHeight
const viewportTop = boundary?.top || 0
Expand All @@ -92,7 +92,6 @@ export const Tooltip: APIFC<undefined, TooltipConfig> & {
}

const updateTooltipPositionX = () => {

switch (placementVertical) {
case "top":
bottom - contentRect.height > 0 ? moveToTop() : moveToBottom()
Expand All @@ -104,7 +103,7 @@ export const Tooltip: APIFC<undefined, TooltipConfig> & {
break
}

const boundary = event.currentTarget.parentElement?.getBoundingClientRect();
const boundary = event.currentTarget.parentElement?.parentElement?.getBoundingClientRect();
const viewportWidth = boundary?.width || window.innerWidth
const viewportLeft = boundary?.left || 0
const cursorX = event.clientX + offset.x
Expand Down
4 changes: 2 additions & 2 deletions libs/generic-view/ui/src/lib/texts/format-bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export const formatBytes = (
return `0 ${units[minIndex]}`
}

let calculatedIndex = Math.floor(Math.log(bytes) / Math.log(1024))
let calculatedIndex = Math.floor(Math.log(bytes) / Math.log(1000))
calculatedIndex = Math.min(calculatedIndex, units.length - 1)

const index = Math.max(minIndex, calculatedIndex)

const adjustedBytes = bytes / Math.pow(1024, index)
const adjustedBytes = bytes / Math.pow(1000, index)

const roundedValue = parseFloat(adjustedBytes.toFixed(1))

Expand Down

0 comments on commit 2915f5b

Please sign in to comment.