diff --git a/packages/grafnode-components/src/components/RequestTabPanel/index.js b/packages/grafnode-components/src/components/RequestTabPanel/index.js index 79cc6513d..4819f6f8a 100644 --- a/packages/grafnode-components/src/components/RequestTabPanel/index.js +++ b/packages/grafnode-components/src/components/RequestTabPanel/index.js @@ -86,11 +86,15 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re console.log(headers); if(data && !errors) { + // todo: alternate way to calculate length when content length is not present + const size = headers.map["content-length"]; + dispatch({ type: actions.RESPONSE_RECEIVED, response: { data: data, headers: Object.entries(headers.map), + size: size, status: status, duration: timeEnd - timeStart }, diff --git a/packages/grafnode-components/src/components/ResponsePane/ResponseSize/index.js b/packages/grafnode-components/src/components/ResponsePane/ResponseSize/index.js index 5e1b7e6b7..7f29e55fa 100644 --- a/packages/grafnode-components/src/components/ResponsePane/ResponseSize/index.js +++ b/packages/grafnode-components/src/components/ResponsePane/ResponseSize/index.js @@ -1,10 +1,20 @@ import React from 'react'; import StyledWrapper from './StyledWrapper'; -const ResponseSize = () => { +const ResponseSize = ({size}) => { + let sizeToDisplay = '' + + if(size > 1024 ) { // size is greater than 1kb + let kb = Math.floor(size / 1024); + let decimal = ((size % 1024) / 1024).toFixed(2) * 100; + sizeToDisplay = kb + '.' + decimal + 'KB'; + } else { + sizeToDisplay = size + 'B' + } + return ( - 8.31KB + {sizeToDisplay} ) }; diff --git a/packages/grafnode-components/src/components/ResponsePane/index.js b/packages/grafnode-components/src/components/ResponsePane/index.js index b74a6e698..a7dec1319 100644 --- a/packages/grafnode-components/src/components/ResponsePane/index.js +++ b/packages/grafnode-components/src/components/ResponsePane/index.js @@ -50,7 +50,7 @@ const ResponsePane = ({rightPaneWidth, response, isLoading}) => {
- +
) : null }