2020-01-24 14:44:18 -08:00
|
|
|
import React, { FC } from 'react';
|
2019-11-26 11:48:53 -08:00
|
|
|
import { Alert } from 'reactstrap';
|
|
|
|
import Graph from './Graph';
|
2020-01-14 10:34:48 -08:00
|
|
|
import { QueryParams } from '../../types/types';
|
|
|
|
import { isPresent } from '../../utils';
|
2019-11-26 11:48:53 -08:00
|
|
|
|
2020-01-24 14:44:18 -08:00
|
|
|
interface GraphTabContentProps {
|
2019-11-26 11:48:53 -08:00
|
|
|
data: any;
|
|
|
|
stacked: boolean;
|
2020-01-24 14:44:18 -08:00
|
|
|
useLocalTime: boolean;
|
2019-11-26 11:48:53 -08:00
|
|
|
lastQueryParams: QueryParams | null;
|
2020-01-24 14:44:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const GraphTabContent: FC<GraphTabContentProps> = ({ data, stacked, useLocalTime, lastQueryParams }) => {
|
2019-11-26 11:48:53 -08:00
|
|
|
if (!isPresent(data)) {
|
|
|
|
return <Alert color="light">No data queried yet</Alert>;
|
|
|
|
}
|
|
|
|
if (data.result.length === 0) {
|
|
|
|
return <Alert color="secondary">Empty query result</Alert>;
|
|
|
|
}
|
|
|
|
if (data.resultType !== 'matrix') {
|
|
|
|
return (
|
|
|
|
<Alert color="danger">Query result is of wrong type '{data.resultType}', should be 'matrix' (range vector).</Alert>
|
|
|
|
);
|
|
|
|
}
|
2020-01-24 14:44:18 -08:00
|
|
|
return <Graph data={data} stacked={stacked} useLocalTime={useLocalTime} queryParams={lastQueryParams} />;
|
2019-11-26 11:48:53 -08:00
|
|
|
};
|