Fix Table view in DE graph
parent
780c6812ab
commit
2c36a53d31
|
@ -2,7 +2,14 @@ import React, {PropTypes} from 'react';
|
||||||
import Table from './Table';
|
import Table from './Table';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const {bool, string, shape, arrayOf, func} = PropTypes;
|
const {
|
||||||
|
arrayOf,
|
||||||
|
bool,
|
||||||
|
func,
|
||||||
|
number,
|
||||||
|
shape,
|
||||||
|
string,
|
||||||
|
} = PropTypes;
|
||||||
|
|
||||||
const MultiTable = React.createClass({
|
const MultiTable = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -10,6 +17,7 @@ const MultiTable = React.createClass({
|
||||||
host: arrayOf(string.isRequired).isRequired,
|
host: arrayOf(string.isRequired).isRequired,
|
||||||
text: string.isRequired,
|
text: string.isRequired,
|
||||||
})),
|
})),
|
||||||
|
height: number,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
|
@ -40,13 +48,14 @@ const MultiTable = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTable() {
|
renderTable() {
|
||||||
|
const {height} = this.props;
|
||||||
const query = this.getActiveQuery();
|
const query = this.getActiveQuery();
|
||||||
const noQuery = !query || !query.text;
|
const noQuery = !query || !query.text;
|
||||||
if (noQuery) {
|
if (noQuery) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Table key={query.text} query={query} />;
|
return <Table key={query.text} query={query} height={height} />;
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTabs() {
|
renderTabs() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ const ChronoTable = React.createClass({
|
||||||
text: string.isRequired,
|
text: string.isRequired,
|
||||||
}),
|
}),
|
||||||
containerWidth: number.isRequired,
|
containerWidth: number.isRequired,
|
||||||
|
height: number,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
|
@ -45,6 +46,12 @@ const ChronoTable = React.createClass({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDefaultProps() {
|
||||||
|
return {
|
||||||
|
height: 600,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
fetchCellData(query) {
|
fetchCellData(query) {
|
||||||
this.setState({isLoading: true});
|
this.setState({isLoading: true});
|
||||||
// second param is db, we want to leave this blank
|
// second param is db, we want to leave this blank
|
||||||
|
@ -81,30 +88,33 @@ const ChronoTable = React.createClass({
|
||||||
|
|
||||||
// Table data as a list of array.
|
// Table data as a list of array.
|
||||||
render() {
|
render() {
|
||||||
const {containerWidth} = this.props;
|
const {containerWidth, height} = this.props;
|
||||||
const {cellData, columnWidths, isLoading} = this.state;
|
const {cellData, columnWidths, isLoading} = this.state;
|
||||||
const {columns, values} = cellData;
|
const {columns, values} = cellData;
|
||||||
|
|
||||||
const ownerHeight = 300;
|
// adjust height to proper value by subtracting the heights of the UI around it
|
||||||
|
// tab height, graph-container vertical padding, graph-heading height, multitable-header height
|
||||||
|
const stylePixelOffset = 136;
|
||||||
|
|
||||||
const rowHeight = 34;
|
const rowHeight = 34;
|
||||||
const height = 300;
|
|
||||||
const width = 200;
|
const width = 200;
|
||||||
const headerHeight = 40;
|
const headerHeight = 30;
|
||||||
const minWidth = 70;
|
const minWidth = 70;
|
||||||
|
const styleAdjustedHeight = height - stylePixelOffset;
|
||||||
|
|
||||||
if (!isLoading && !values.length) {
|
if (!isLoading && !values.length) {
|
||||||
return <div>Your query returned no data</div>;
|
return <div className="generic-empty-state">Your query returned no data</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
onColumnResizeEndCallback={this.handleColumnResize}
|
onColumnResizeEndCallback={this.handleColumnResize}
|
||||||
isColumnResizing={false}
|
isColumnResizing={false}
|
||||||
ownerHeight={ownerHeight}
|
|
||||||
rowHeight={rowHeight}
|
rowHeight={rowHeight}
|
||||||
rowsCount={values.length}
|
rowsCount={values.length}
|
||||||
width={containerWidth}
|
width={containerWidth}
|
||||||
height={height}
|
ownerHeight={styleAdjustedHeight}
|
||||||
|
height={styleAdjustedHeight}
|
||||||
headerHeight={headerHeight}>
|
headerHeight={headerHeight}>
|
||||||
{columns.map((columnName, colIndex) => {
|
{columns.map((columnName, colIndex) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -23,6 +23,7 @@ const Visualization = React.createClass({
|
||||||
name: string,
|
name: string,
|
||||||
activeQueryIndex: number,
|
activeQueryIndex: number,
|
||||||
height: string,
|
height: string,
|
||||||
|
heightPixels: number,
|
||||||
},
|
},
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
|
@ -44,7 +45,7 @@ const Visualization = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {queryConfigs, timeRange, activeQueryIndex, height} = this.props;
|
const {queryConfigs, timeRange, activeQueryIndex, height, heightPixels} = this.props;
|
||||||
const {source} = this.context;
|
const {source} = this.context;
|
||||||
const proxyLink = source.links.proxy;
|
const proxyLink = source.links.proxy;
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ const Visualization = React.createClass({
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="graph-container">
|
<div className={classNames("", {"graph-container": isGraphInView, "table-container": !isGraphInView})}>
|
||||||
{isGraphInView ? (
|
{isGraphInView ? (
|
||||||
<RefreshingLineGraph
|
<RefreshingLineGraph
|
||||||
queries={queries}
|
queries={queries}
|
||||||
|
@ -80,7 +81,7 @@ const Visualization = React.createClass({
|
||||||
activeQueryIndex={activeQueryIndex}
|
activeQueryIndex={activeQueryIndex}
|
||||||
isInDataExplorer={isInDataExplorer}
|
isInDataExplorer={isInDataExplorer}
|
||||||
/>
|
/>
|
||||||
) : <MultiTable queries={queries} />}
|
) : <MultiTable queries={queries} height={heightPixels} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,16 +48,19 @@ const ResizeContainer = React.createClass({
|
||||||
// Don't trigger a resize if the new sizes are too small
|
// Don't trigger a resize if the new sizes are too small
|
||||||
const minTopPanelHeight = 300;
|
const minTopPanelHeight = 300;
|
||||||
const minBottomPanelHeight = 250;
|
const minBottomPanelHeight = 250;
|
||||||
if (((newTopPanelPercent / turnToPercent) * appHeight) < minTopPanelHeight || ((newBottomPanelPercent / turnToPercent) * appHeight) < minBottomPanelHeight) {
|
const topHeightPixels = ((newTopPanelPercent / turnToPercent) * appHeight);
|
||||||
|
const bottomHeightPixels = ((newBottomPanelPercent / turnToPercent) * appHeight);
|
||||||
|
|
||||||
|
if (topHeightPixels < minTopPanelHeight || bottomHeightPixels < minBottomPanelHeight) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({topHeight: `${(newTopPanelPercent)}%`, bottomHeight: `${(newBottomPanelPercent)}%`});
|
this.setState({topHeight: `${(newTopPanelPercent)}%`, bottomHeight: `${(newBottomPanelPercent)}%`, topHeightPixels});
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {topHeight, bottomHeight, isDragging} = this.state;
|
const {topHeight, bottomHeight, isDragging, topHeightPixels} = this.state;
|
||||||
const top = React.cloneElement(this.props.children[0], {height: topHeight});
|
const top = React.cloneElement(this.props.children[0], {height: topHeight, heightPixels: topHeightPixels});
|
||||||
const bottom = React.cloneElement(this.props.children[1], {height: bottomHeight, top: topHeight});
|
const bottom = React.cloneElement(this.props.children[1], {height: bottomHeight, top: topHeight});
|
||||||
const handle = <ResizeHandle isDragging={isDragging} onHandleStartDrag={this.handleStartDrag} top={topHeight} />;
|
const handle = <ResizeHandle isDragging={isDragging} onHandleStartDrag={this.handleStartDrag} top={topHeight} />;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,41 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.table-container {
|
||||||
|
background-color: $graph-bg-color;
|
||||||
|
border-radius: 0 0 $graph-radius $graph-radius;
|
||||||
|
padding: 8px 16px;
|
||||||
|
position: relative;
|
||||||
|
top: $de-vertical-margin;
|
||||||
|
height: calc(100% - #{$de-graph-heading-height} - #{($de-vertical-margin * 2)});
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
position: absolute;
|
||||||
|
width: calc(100% - #{($de-vertical-margin * 2)});
|
||||||
|
height: calc(100% - #{$de-vertical-margin});
|
||||||
|
top: ($de-vertical-margin/2);
|
||||||
|
left: $de-vertical-margin;;
|
||||||
|
}
|
||||||
|
& > div .multi-table__tabs {
|
||||||
|
position: absolute;
|
||||||
|
height: 30px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
& > div > div:last-child {
|
||||||
|
position: absolute;
|
||||||
|
top: 30px;
|
||||||
|
height: calc(100% - 30px) !important;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.fixedDataTableLayout_main {
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
.generic-empty-state {
|
||||||
|
background-color: $g6-smoke;
|
||||||
|
padding: 50px 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
.graph-container {
|
.graph-container {
|
||||||
background-color: $graph-bg-color;
|
background-color: $graph-bg-color;
|
||||||
border-radius: 0 0 $graph-radius $graph-radius;
|
border-radius: 0 0 $graph-radius $graph-radius;
|
||||||
|
|
Loading…
Reference in New Issue