diff --git a/ui/src/shared/components/AutoRefresh.tsx b/ui/src/shared/components/AutoRefresh.tsx index 32c09ccb5f..cfbb2f5a53 100644 --- a/ui/src/shared/components/AutoRefresh.tsx +++ b/ui/src/shared/components/AutoRefresh.tsx @@ -4,7 +4,6 @@ import _ from 'lodash' import {fetchTimeSeries} from 'src/shared/apis/query' import {DEFAULT_TIME_SERIES} from 'src/shared/constants/series' import {TimeSeriesServerResponse, TimeSeriesResponse} from 'src/types/series' -import {timeSeriesToTableGraph} from 'src/utils/timeSeriesTransformers' interface Axes { bounds: { @@ -131,8 +130,7 @@ const AutoRefresh = ( }) if (grabDataForDownload) { - const {data} = timeSeriesToTableGraph(newSeries) - grabDataForDownload(data) + grabDataForDownload(newSeries) } } catch (err) { console.error(err) diff --git a/ui/src/shared/components/Layout.js b/ui/src/shared/components/Layout.js index aa441602b2..213468c1c9 100644 --- a/ui/src/shared/components/Layout.js +++ b/ui/src/shared/components/Layout.js @@ -23,11 +23,11 @@ const getSource = (cell, source, sources, defaultSource) => { @ErrorHandling class LayoutState extends Component { state = { - celldata: [[]], + cellData: [], } - grabDataForDownload = celldata => { - this.setState({celldata}) + grabDataForDownload = cellData => { + this.setState({cellData}) } render() { @@ -59,7 +59,7 @@ const Layout = ( source, sources, onZoom, - celldata, + cellData, templates, timeRange, isEditable, @@ -79,7 +79,7 @@ const Layout = ( ) => ( ) -const {array, arrayOf, bool, func, number, shape, string} = PropTypes +const {arrayOf, bool, func, number, shape, string} = PropTypes Layout.contextTypes = { source: shape(), @@ -200,7 +200,7 @@ LayoutState.propTypes = {...propTypes} Layout.propTypes = { ...propTypes, grabDataForDownload: func, - celldata: arrayOf(array), + cellData: arrayOf(shape({})), } export default LayoutState diff --git a/ui/src/shared/components/LayoutCell.js b/ui/src/shared/components/LayoutCell.js index f1658e8ac7..9b758a8884 100644 --- a/ui/src/shared/components/LayoutCell.js +++ b/ui/src/shared/components/LayoutCell.js @@ -11,6 +11,7 @@ import {notifyCSVDownloadFailed} from 'src/shared/copy/notifications' import download from 'src/external/download.js' import {ErrorHandling} from 'src/shared/decorators/errors' import {dataToCSV} from 'src/shared/parsing/dataToCSV' +import {timeSeriesToTableGraph} from 'src/utils/timeSeriesTransformers' @ErrorHandling class LayoutCell extends Component { @@ -24,9 +25,11 @@ class LayoutCell extends Component { handleCSVDownload = cell => () => { const joinedName = cell.name.split(' ').join('_') - const {celldata} = this.props + const {cellData} = this.props + const {data} = timeSeriesToTableGraph(cellData) + try { - download(dataToCSV(celldata), `${joinedName}.csv`, 'text/plain') + download(dataToCSV(data), `${joinedName}.csv`, 'text/plain') } catch (error) { notify(notifyCSVDownloadFailed()) console.error(error) @@ -34,7 +37,7 @@ class LayoutCell extends Component { } render() { - const {cell, children, isEditable, celldata, onCloneCell} = this.props + const {cell, children, isEditable, cellData, onCloneCell} = this.props const queries = _.get(cell, ['queries'], []) @@ -49,7 +52,7 @@ class LayoutCell extends Component {