From eb9295702ceed3cb7b31dfb558a3893b63169b13 Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 18 Sep 2017 14:40:13 -0700 Subject: [PATCH] WIP show query errors on cells --- ui/src/dashboards/actions/index.js | 15 ++++++++ ui/src/dashboards/components/Dashboard.js | 9 +++-- ui/src/dashboards/containers/DashboardPage.js | 15 ++++++-- ui/src/dashboards/reducers/ui.js | 35 +++++++++++++++++++ ui/src/shared/components/LayoutRenderer.js | 3 ++ 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index 24eca86edd..c5940bcaf9 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -158,6 +158,21 @@ export const editTemplateVariableValues = ( }, }) +export const editDashboardQueryStatus = ( + dashboardID, + cellID, + queryID, + status +) => ({ + type: 'EDIT_DASHBOARD_QUERY_STATUS', + payload: { + dashboardID, + cellID, + queryID, + status, + }, +}) + // Async Action Creators export const getDashboardsAsync = () => async dispatch => { diff --git a/ui/src/dashboards/components/Dashboard.js b/ui/src/dashboards/components/Dashboard.js index ddbe4436b3..b42b16bcd7 100644 --- a/ui/src/dashboards/components/Dashboard.js +++ b/ui/src/dashboards/components/Dashboard.js @@ -17,14 +17,15 @@ const Dashboard = ({ onUpdateCell, onDeleteCell, synchronizer, + editQueryStatus, + onSelectTemplate, onPositionChange, + onCancelEditCell, inPresentationMode, onOpenTemplateManager, + showTemplateControlBar, templatesIncludingDashTime, onSummonOverlayTechnologies, - onSelectTemplate, - showTemplateControlBar, - onCancelEditCell, }) => { const cells = dashboard.cells.map(cell => { const dashboardCell = {...cell} @@ -73,6 +74,7 @@ const Dashboard = ({ onSummonOverlayTechnologies={onSummonOverlayTechnologies} synchronizer={synchronizer} onZoom={onZoom} + editQueryStatus={editQueryStatus} /> :

This Dashboard has no Cells

@@ -116,6 +118,7 @@ Dashboard.propTypes = { onRenameCell: func, onUpdateCell: func, onDeleteCell: func, + editQueryStatus: func, onSummonOverlayTechnologies: func, synchronizer: func, source: shape({ diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.js index ff54a75223..8e0a1026bb 100644 --- a/ui/src/dashboards/containers/DashboardPage.js +++ b/ui/src/dashboards/containers/DashboardPage.js @@ -198,6 +198,16 @@ class DashboardPage extends Component { this.setState({zoomedTimeRange: {zoomedLower, zoomedUpper}}) } + handleEditDashboardQueryStatus = cellID => (queryID, status) => { + const {params: dashboardID, dashboardActions} = this.props + dashboardActions.editDashboardQueryStatus( + dashboardID, + cellID, + queryID, + status + ) + } + getActiveDashboard() { const {params: {dashboardID}, dashboards} = this.props return dashboards.find(d => d.id === +dashboardID) @@ -215,7 +225,7 @@ class DashboardPage extends Component { dashboards, autoRefresh, cellQueryStatus, - dashboardActions, + dashboardActions: {editCellQueryStatus}, inPresentationMode, handleChooseAutoRefresh, handleClickPresentationButton, @@ -304,7 +314,7 @@ class DashboardPage extends Component { onSave={this.handleSaveEditedCell} onCancel={this.handleDismissOverlay} templates={templatesIncludingDashTime} - editQueryStatus={dashboardActions.editCellQueryStatus} + editQueryStatus={editCellQueryStatus} /> : null} {isEditMode @@ -349,6 +359,7 @@ class DashboardPage extends Component { onZoom={this.handleZoomedTimeRange} onAddCell={this.handleAddCell} synchronizer={this.synchronizer} + editQueryStatus={this.handleEditDashboardQueryStatus} inPresentationMode={inPresentationMode} onEditCell={this.handleEditDashboardCell} onPositionChange={this.handleUpdatePosition} diff --git a/ui/src/dashboards/reducers/ui.js b/ui/src/dashboards/reducers/ui.js index 3b3c7f39dd..4cef6b5413 100644 --- a/ui/src/dashboards/reducers/ui.js +++ b/ui/src/dashboards/reducers/ui.js @@ -24,6 +24,12 @@ export default function ui(state = initialState, action) { dashboards, } + const dashboards = state.dashboards.map( + d => { + dashboards: + } + ) + return {...state, ...newState} } @@ -303,6 +309,35 @@ export default function ui(state = initialState, action) { return {...state, dashboards} } + + case 'EDIT_DASHBOARD_QUERY_STATUS': { + const {dashboardID, cellID, queryID, status} = action.payload + + const dashboards = state.dashboards.map( + dashboard => + dashboard.id === dashboardID + ? { + ...dashboard, + cells: dashboard.cells.map( + cell => + cell.i === cellID + ? { + ...cell, + queries: cell.queries.map(q => { + q.id === queryID + ? { + ...q, + status, + } + : q + }), + } + : cell + ), + } + : dashboard + ) + } } return state diff --git a/ui/src/shared/components/LayoutRenderer.js b/ui/src/shared/components/LayoutRenderer.js index 91a84ffbcc..79f1b2651b 100644 --- a/ui/src/shared/components/LayoutRenderer.js +++ b/ui/src/shared/components/LayoutRenderer.js @@ -149,6 +149,7 @@ class LayoutRenderer extends Component { synchronizer, isEditable, onZoom, + editQueryStatus, } = this.props return cells.map(cell => { @@ -178,6 +179,7 @@ class LayoutRenderer extends Component { cellHeight={h} axes={axes} onZoom={onZoom} + editQueryStatus={editQueryStatus(cell.i)} />}
@@ -300,6 +302,7 @@ LayoutRenderer.propTypes = { onRenameCell: func, onUpdateCell: func, onDeleteCell: func, + editQueryStatus: func, onSummonOverlayTechnologies: func, synchronizer: func, isStatusPage: bool,