diff --git a/src/js/components/Search.jsx b/src/js/components/Search.jsx index d83e7b0..1516472 100644 --- a/src/js/components/Search.jsx +++ b/src/js/components/Search.jsx @@ -13,10 +13,11 @@ import { filtersToArray, getDefaultFilters, getNameByID, + renderError, validateFilters } from '../modules/utilities' import {fetchSearchResults, resetSearchResults} from '../modules/search-results' -import {grey300, white} from 'material-ui/styles/colors' +import {grey300, red500, white} from 'material-ui/styles/colors' import {header, headerAppName, main, verticalTop} from '../styles/common' import React, {Component, PropTypes} from 'react' @@ -173,11 +174,35 @@ class Search extends Component { ) } + + if (searchResults.error) { + const {message} = searchResults.error + const spanStyle = {...style.span, color: red500} + let text = {} + + try { + text = JSON.parse(message) + } catch (err) { + text.label = message + text.data = {} + } + + return ( + renderError(text, style.wrapper, spanStyle) + ) + } const {data = []} = searchResults if (data.length === 0) { - return
+ const message = { + label: 'No data', + data: {} + } + + return ( + renderError(message, style.wrapper, style.span) + ) } const visualization = { diff --git a/src/js/components/visualization/Visualization.jsx b/src/js/components/visualization/Visualization.jsx index e28fc5e..29b9b42 100644 --- a/src/js/components/visualization/Visualization.jsx +++ b/src/js/components/visualization/Visualization.jsx @@ -8,8 +8,8 @@ import {MapComponent} from './MapComponent' import {SummaryComponent} from './SummaryComponent' import {TableComponent} from './TableComponent' import VisualizationToolbar from './VisualizationToolbar' -import {excludeEmptyFilters, filtersToArray, generateMenuItems} from '../../modules/utilities' -import {grey300, white} from 'material-ui/styles/colors' +import {excludeEmptyFilters, filtersToArray, generateMenuItems, renderError} from '../../modules/utilities' +import {grey300, red500, white} from 'material-ui/styles/colors' import React, {Component, PropTypes} from 'react' const components = {ChartComponent, MapComponent, SummaryComponent, TableComponent} @@ -21,6 +21,16 @@ const style = { flexDirection: 'column', height: '100%', overflow: 'hidden' + }, + flex: { + flex: 1, + position: 'relative' + }, + span: { + left: '50%', + position: 'absolute', + top: '50%', + transform: 'translate(-50%, -50%)' } } const getTypeGroup = (type) => { @@ -93,6 +103,23 @@ class Visualization extends Component { typeGroup } } + + renderError (message) { + const {visualization} = this.props + const {name} = visualization + const spanStyle = {...style.span, color: red500} + const error = renderError(message, style.flex, spanStyle) + + return ( ++ + {key}: + {data[key].toString()} + +
+ ) + }) + } + +