-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [M3-7758] - Linode Network Graph Tooltip - Incorrect Units #10197
Merged
bnussman-akamai
merged 2 commits into
linode:develop
from
bnussman-akamai:M3-7758-fix-linode-network-graphs-tooltip-unit
Feb 16, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Fixed | ||
--- | ||
|
||
Linode Network Graph Tooltip - Incorrect Units ([#10197](https://github.com/linode/manager/pull/10197)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { Stats } from '@linode/api-v4/lib/linodes'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import { Theme, styled, useTheme } from '@mui/material/styles'; | ||
import { map, pathOr } from 'ramda'; | ||
import * as React from 'react'; | ||
|
||
import { AreaChart } from 'src/components/AreaChart/AreaChart'; | ||
|
@@ -13,14 +12,10 @@ import { | |
formatBitsPerSecond, | ||
formatNetworkTooltip, | ||
generateNetworkUnits, | ||
NetworkUnit, | ||
} from 'src/features/Longview/shared/utilities'; | ||
import { useFlags } from 'src/hooks/useFlags'; | ||
import { | ||
Metrics, | ||
getMetrics, | ||
getTotalTraffic, | ||
} from 'src/utilities/statMetrics'; | ||
import { readableBytes } from 'src/utilities/unitConversions'; | ||
import { Metrics, getMetrics } from 'src/utilities/statMetrics'; | ||
|
||
import { StatsPanel } from './StatsPanel'; | ||
|
||
|
@@ -30,9 +25,6 @@ export interface TotalTrafficProps { | |
outTraffic: string; | ||
} | ||
|
||
const formatTotalTraffic = (value: number) => | ||
readableBytes(value, { base10: true }).formatted; | ||
|
||
export interface ChartProps { | ||
height: number; | ||
loading: boolean; | ||
|
@@ -64,7 +56,7 @@ interface NetworkStats { | |
const _getMetrics = (data: NetworkStats) => { | ||
return { | ||
privateIn: getMetrics(data.privateIn), | ||
privateOut: getMetrics(data.privateOut ?? []), | ||
privateOut: getMetrics(data.privateOut), | ||
publicIn: getMetrics(data.publicIn), | ||
publicOut: getMetrics(data.publicOut), | ||
}; | ||
|
@@ -77,42 +69,22 @@ export const NetworkGraphs = (props: Props) => { | |
const flags = useFlags(); | ||
|
||
const v4Data: NetworkStats = { | ||
privateIn: pathOr([], ['data', 'netv4', 'private_in'], stats), | ||
privateOut: pathOr([], ['data', 'netv4', 'private_out'], stats), | ||
publicIn: pathOr([], ['data', 'netv4', 'in'], stats), | ||
publicOut: pathOr([], ['data', 'netv4', 'out'], stats), | ||
privateIn: stats?.data.netv4.private_in ?? [], | ||
privateOut: stats?.data.netv4.private_out ?? [], | ||
publicIn: stats?.data.netv4.in ?? [], | ||
publicOut: stats?.data.netv4.out ?? [], | ||
}; | ||
|
||
const v6Data: NetworkStats = { | ||
privateIn: pathOr([], ['data', 'netv6', 'private_in'], stats), | ||
privateOut: pathOr([], ['data', 'netv6', 'private_out'], stats), | ||
publicIn: pathOr([], ['data', 'netv6', 'in'], stats), | ||
publicOut: pathOr([], ['data', 'netv6', 'out'], stats), | ||
privateIn: stats?.data.netv6.private_in ?? [], | ||
privateOut: stats?.data.netv6.private_out ?? [], | ||
publicIn: stats?.data.netv6.in ?? [], | ||
publicOut: stats?.data.netv6.out ?? [], | ||
}; | ||
|
||
const v4Metrics = _getMetrics(v4Data); | ||
const v6Metrics = _getMetrics(v6Data); | ||
|
||
const v4totalTraffic: TotalTrafficProps = map( | ||
formatTotalTraffic, | ||
getTotalTraffic( | ||
v4Metrics.publicIn.total, | ||
v4Metrics.publicOut.total, | ||
v4Data.publicIn.length, | ||
v6Metrics.publicIn.total, | ||
v6Metrics.publicOut.total | ||
) | ||
); | ||
|
||
const v6totalTraffic: TotalTrafficProps = map( | ||
formatTotalTraffic, | ||
getTotalTraffic( | ||
v6Metrics.publicIn.total, | ||
v6Metrics.publicOut.total, | ||
v6Metrics.publicIn.length | ||
) | ||
); | ||
|
||
// Convert to bytes, which is what generateNetworkUnits expects. | ||
const maxV4InBytes = | ||
Math.max( | ||
|
@@ -150,7 +122,6 @@ export const NetworkGraphs = (props: Props) => { | |
ariaLabel="IPv4 Network Traffic Graph" | ||
data={v4Data} | ||
metrics={v4Metrics} | ||
totalTraffic={v4totalTraffic} | ||
unit={v4Unit} | ||
{...commonGraphProps} | ||
/> | ||
|
@@ -166,7 +137,6 @@ export const NetworkGraphs = (props: Props) => { | |
ariaLabel="IPv6 Network Traffic Graph" | ||
data={v6Data} | ||
metrics={v6Metrics} | ||
totalTraffic={v6totalTraffic} | ||
unit={v6Unit} | ||
{...commonGraphProps} | ||
/> | ||
|
@@ -187,8 +157,7 @@ interface GraphProps { | |
rangeSelection: string; | ||
theme: Theme; | ||
timezone: string; | ||
totalTraffic: TotalTrafficProps; | ||
unit: string; | ||
unit: NetworkUnit; | ||
xAxisTickFormat: string; | ||
} | ||
|
||
|
@@ -210,7 +179,7 @@ const Graph = (props: GraphProps) => { | |
const format = formatBitsPerSecond; | ||
|
||
const convertNetworkData = (value: number) => { | ||
return convertNetworkToUnit(value, unit as any); | ||
return convertNetworkToUnit(value, unit); | ||
}; | ||
|
||
/** | ||
|
@@ -298,7 +267,7 @@ const Graph = (props: GraphProps) => { | |
height={420} | ||
showLegend | ||
timezone={timezone} | ||
unit={' Kb/s'} | ||
unit={` ${unit}/s`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the primary fix. We now pass the unit instead of using the hardcoded |
||
/> | ||
</Box> | ||
); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you β€οΈ