diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index bf5f8044a37..3fd9df799af 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -9,13 +9,13 @@ import { PanelEditor } from './PanelEditor'; const TITLE_HEIGHT = 27; const PANEL_BORDER = 2; -export interface PanelChromeProps { +export interface Props { panel: PanelModel; dashboard: DashboardModel; component: any; } -export class PanelChrome extends React.Component { +export class PanelChrome extends React.Component { constructor(props) { super(props); diff --git a/public/app/features/panel/DataPanel.tsx b/public/app/features/panel/DataPanel.tsx index 5ea490e497d..a1669f6603d 100644 --- a/public/app/features/panel/DataPanel.tsx +++ b/public/app/features/panel/DataPanel.tsx @@ -1,23 +1,79 @@ import React, { Component, ComponentClass } from 'react'; import _ from 'lodash'; -export interface Props { +export interface OuterProps { type: string; - queries: Query[]; + queries: any[]; + isVisible: boolean; +} + +export interface AddedProps { + data: any[]; } interface State { isLoading: boolean; - timeSeries: TimeSeriesServerResponse[]; + data: any[]; } -export interface OriginalProps { - data: TimeSeriesServerResponse[]; - isLoading: boolean; -} +const DataPanel = (ComposedComponent: ComponentClass) => { + class Wrapper extends Component { + public static defaultProps = { + isVisible: true, + }; -const DataPanel = (ComposedComponent: ComponentClass) => { - class Wrapper extends Component {} + constructor(props: OuterProps) { + super(props); + + this.state = { + isLoading: false, + data: [], + }; + } + + public componentDidMount() { + this.issueQueries(); + } + + public issueQueries = () => { + const { queries, isVisible } = this.props; + + if (!isVisible) { + return; + } + + if (!queries.length) { + this.setState({ data: [{ message: 'no queries' }] }); + return; + } + + this.setState({ isLoading: true }); + }; + + public render() { + const { data, isLoading } = this.state; + + if (!data.length) { + return ( +
+

No Data

+
+ ); + } + + if (isLoading) { + return ( +
+

Loading

+
+ ); + } + + return ; + } + } return Wrapper; }; + +export default DataPanel;