소스 검색

Explore: show message if queries did not return data

- every result viewer displays a message that it received an empty data
  set
David Kaltschmidt 7 년 전
부모
커밋
f1c1633d15

+ 10 - 9
public/app/containers/Explore/Explore.tsx

@@ -440,12 +440,12 @@ export class Explore extends React.Component<any, IExploreState> {
               </a>
             </div>
           ) : (
-            <div className="navbar-buttons explore-first-button">
-              <button className="btn navbar-button" onClick={this.handleClickCloseSplit}>
-                Close Split
+              <div className="navbar-buttons explore-first-button">
+                <button className="btn navbar-button" onClick={this.handleClickCloseSplit}>
+                  Close Split
               </button>
-            </div>
-          )}
+              </div>
+            )}
           {!datasourceMissing ? (
             <div className="navbar-buttons">
               <Select
@@ -513,21 +513,22 @@ export class Explore extends React.Component<any, IExploreState> {
               onExecuteQuery={this.handleSubmit}
               onRemoveQueryRow={this.handleRemoveQueryRow}
             />
-            {queryError ? <div className="text-warning m-a-2">{queryError}</div> : null}
+            {queryError && !loading ? <div className="text-warning m-a-2">{queryError}</div> : null}
             <main className="m-t-2">
               {supportsGraph && showingGraph ? (
                 <Graph
                   data={graphResult}
+                  height={graphHeight}
+                  loading={loading}
                   id={`explore-graph-${position}`}
                   options={requestOptions}
-                  height={graphHeight}
                   split={split}
                 />
               ) : null}
               {supportsTable && showingTable ? (
-                <Table data={tableResult} onClickCell={this.onClickTableCell} className="m-t-3" />
+                <Table className="m-t-3" data={tableResult} loading={loading} onClickCell={this.onClickTableCell} />
               ) : null}
-              {supportsLogs && showingLogs ? <Logs data={logsResult} /> : null}
+              {supportsLogs && showingLogs ? <Logs data={logsResult} loading={loading} /> : null}
             </main>
           </div>
         ) : null}

+ 8 - 1
public/app/containers/Explore/Graph.tsx

@@ -123,7 +123,14 @@ class Graph extends Component<any, any> {
   }
 
   render() {
-    const { data, height } = this.props;
+    const { data, height, loading } = this.props;
+    if (!loading && data && data.length === 0) {
+      return (
+        <div className="panel-container">
+          <div className="muted m-a-1">The queries returned no time series to graph.</div>
+        </div>
+      );
+    }
     return (
       <div className="panel-container">
         <div id={this.props.id} className="explore-graph" style={{ height }} />

+ 1 - 0
public/app/containers/Explore/Logs.tsx

@@ -5,6 +5,7 @@ import { LogsModel, LogRow } from 'app/core/logs_model';
 interface LogsProps {
   className?: string;
   data: LogsModel;
+  loading: boolean;
 }
 
 const EXAMPLE_QUERY = '{job="default/prometheus"}';

+ 19 - 2
public/app/containers/Explore/Table.tsx

@@ -6,6 +6,7 @@ const EMPTY_TABLE = new TableModel();
 interface TableProps {
   className?: string;
   data: TableModel;
+  loading: boolean;
   onClickCell?: (columnKey: string, rowValue: string) => void;
 }
 
@@ -38,8 +39,24 @@ function Cell(props: SFCCellProps) {
 
 export default class Table extends PureComponent<TableProps, {}> {
   render() {
-    const { className = '', data, onClickCell } = this.props;
-    const tableModel = data || EMPTY_TABLE;
+    const { className = '', data, loading, onClickCell } = this.props;
+    let tableModel = data || EMPTY_TABLE;
+    if (!loading && data && data.rows.length === 0) {
+      return (
+        <table className={`${className} filter-table`}>
+          <thead>
+            <tr>
+              <th>Table</th>
+            </tr>
+          </thead>
+          <tbody>
+            <tr>
+              <td className="muted">The queries returned no data for a table.</td>
+            </tr>
+          </tbody>
+        </table>
+      );
+    }
     return (
       <table className={`${className} filter-table`}>
         <thead>