From 7161f4dc0cbc660798655a63a39325b15f9e9c2b Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 21 Feb 2017 12:34:01 -0600 Subject: [PATCH] WIP make resizing work --- ui/src/shared/components/LayoutRenderer.js | 88 ++++++++++++++-------- ui/src/shared/components/LineGraph.js | 31 ++++---- 2 files changed, 74 insertions(+), 45 deletions(-) diff --git a/ui/src/shared/components/LayoutRenderer.js b/ui/src/shared/components/LayoutRenderer.js index 92cdd8e5e6..5b49a71427 100644 --- a/ui/src/shared/components/LayoutRenderer.js +++ b/ui/src/shared/components/LayoutRenderer.js @@ -9,39 +9,48 @@ import _ from 'lodash'; const RefreshingLineGraph = AutoRefresh(LineGraph); const RefreshingSingleStat = AutoRefresh(SingleStat); +const { + children, + arrayOf, + node, + number, + shape, + string, +} = PropTypes; + export const LayoutRenderer = React.createClass({ propTypes: { - timeRange: PropTypes.shape({ - defaultGroupBy: PropTypes.string.isRequired, - queryValue: PropTypes.string.isRequired, + timeRange: shape({ + defaultGroupBy: string.isRequired, + queryValue: string.isRequired, }).isRequired, - cells: PropTypes.arrayOf( - PropTypes.shape({ - queries: PropTypes.arrayOf( - PropTypes.shape({ - label: PropTypes.string, - range: PropTypes.shape({ - upper: PropTypes.number, - lower: PropTypes.number, + cells: arrayOf( + shape({ + queries: arrayOf( + shape({ + label: string, + range: shape({ + upper: number, + lower: number, }), - rp: PropTypes.string, - text: PropTypes.string.isRequired, - database: PropTypes.string.isRequired, - groupbys: PropTypes.arrayOf(PropTypes.string), - wheres: PropTypes.arrayOf(PropTypes.string), + rp: string, + text: string.isRequired, + database: string.isRequired, + groupbys: arrayOf(string), + wheres: arrayOf(string), }).isRequired ).isRequired, - x: PropTypes.number.isRequired, - y: PropTypes.number.isRequired, - w: PropTypes.number.isRequired, - h: PropTypes.number.isRequired, - i: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, + x: number.isRequired, + y: number.isRequired, + w: number.isRequired, + h: number.isRequired, + i: string.isRequired, + name: string.isRequired, }).isRequired ), - autoRefreshMs: PropTypes.number.isRequired, - host: PropTypes.string, - source: PropTypes.string, + autoRefreshMs: number.isRequired, + host: string, + source: string, }, getInitialState() { @@ -105,12 +114,9 @@ export const LayoutRenderer = React.createClass({ } return ( -
-

{cell.name}

-
- -
-
+ + + ); }); }, @@ -141,4 +147,24 @@ export const LayoutRenderer = React.createClass({ }, }); +const Wrapper = React.createClass({ + propTypes: { + children: node.isRequired, + }, + render() { + const that = this; + const newChildren = React.Children.map(this.props.children, (child) => { + return React.cloneElement(child, { + height: that.props.style.height, + }) + }) + + return ( +
+ {newChildren} +
+ ); + } +}); + export default LayoutRenderer; diff --git a/ui/src/shared/components/LineGraph.js b/ui/src/shared/components/LineGraph.js index ea36c088d5..cfd38b73f7 100644 --- a/ui/src/shared/components/LineGraph.js +++ b/ui/src/shared/components/LineGraph.js @@ -25,6 +25,7 @@ export default React.createClass({ y: arrayOf(number), y2: arrayOf(number), }), + height: string, title: string, isFetchingInitially: bool, isRefreshing: bool, @@ -100,20 +101,22 @@ export default React.createClass({ } return ( -
- {isRefreshing ? this.renderSpinner() : null} - - {showSingleStat ?
{roundedValue}
: null} +
+
+ {isRefreshing ? this.renderSpinner() : null} + + {showSingleStat ?
{roundedValue}
: null} +
); },