fix(SR/tab-stats): fix IOPS's and IOwait's values format (#2914)

This commit is contained in:
badrAZ 2018-05-02 14:17:13 +02:00 committed by Pierre Donias
parent 34f1ef1680
commit b9e574e32f

View File

@ -1,10 +1,22 @@
import ChartistGraph from 'react-chartist' import ChartistGraph from 'react-chartist'
import ChartistLegend from 'chartist-plugin-legend' import ChartistLegend from 'chartist-plugin-legend'
import ChartistTooltip from 'chartist-plugin-tooltip' import ChartistTooltip from 'chartist-plugin-tooltip'
import humanFormat from 'human-format'
import React from 'react' import React from 'react'
import { injectIntl } from 'react-intl' import { injectIntl } from 'react-intl'
import { messages } from 'intl' import { messages } from 'intl'
import { find, flatten, floor, get, map, max, size, sum, values } from 'lodash' import {
find,
flatten,
floor,
get,
map,
max,
round,
size,
sum,
values,
} from 'lodash'
import propTypes from '../prop-types-decorator' import propTypes from '../prop-types-decorator'
import { computeArraysSum } from '../xo-stats' import { computeArraysSum } from '../xo-stats'
@ -87,9 +99,9 @@ const makeLabelInterpolationFnc = (intl, nValues, endTimestamp, interval) => {
return (value, index) => return (value, index) =>
index % labelSpace === 0 index % labelSpace === 0
? intl.formatTime( ? intl.formatTime(
(endTimestamp - (nValues - index - 1) * interval) * 1000, (endTimestamp - (nValues - index - 1) * interval) * 1000,
format format
) )
: null : null
} }
@ -441,19 +453,19 @@ export const PoolPifLineChart = injectIntl(
const series = addSumSeries const series = addSumSeries
? map(ios, io => ({ ? map(ios, io => ({
name: `${intl.formatMessage(messages.poolAllHosts)} (${io})`, name: `${intl.formatMessage(messages.poolAllHosts)} (${io})`,
data: computeArraysSum( data: computeArraysSum(
map(data, ({ stats }) => computeArraysSum(stats.pifs[io])) map(data, ({ stats }) => computeArraysSum(stats.pifs[io]))
), ),
})) }))
: flatten( : flatten(
map(data, ({ stats, host }) => map(data, ({ stats, host }) =>
map(ios, io => ({ map(ios, io => ({
name: `${host} (${io})`, name: `${host} (${io})`,
data: computeArraysSum(stats.pifs[io]), data: computeArraysSum(stats.pifs[io]),
})) }))
)
) )
)
return ( return (
<ChartistGraph <ChartistGraph
@ -604,7 +616,11 @@ export const IopsLineChart = injectIntl(
nValues: length, nValues: length,
endTimestamp, endTimestamp,
interval, interval,
valueTransform: value => `${value.toPrecision(3)} /s`, valueTransform: value =>
humanFormat(value, {
decimals: 3,
unit: 'IOPS',
}),
}), }),
...options, ...options,
}} }}
@ -721,7 +737,7 @@ export const IowaitChart = injectIntl(
nValues: length, nValues: length,
endTimestamp, endTimestamp,
interval, interval,
valueTransform: value => `${value.toPrecision(2)}%`, valueTransform: value => `${round(value, 2)}%`,
}), }),
...options, ...options,
}} }}