|
|
|
@ -4,7 +4,7 @@ import { connect, ConnectedProps } from 'react-redux'; |
|
|
|
|
|
|
|
|
|
import { applyFieldOverrides, DataFrame, SelectableValue, SplitOpen, TimeZone } from '@grafana/data'; |
|
|
|
|
import { getTemplateSrv, reportInteraction } from '@grafana/runtime'; |
|
|
|
|
import { Collapse, RadioButtonGroup, Table, AdHocFilterItem } from '@grafana/ui'; |
|
|
|
|
import { RadioButtonGroup, Table, AdHocFilterItem, PanelChrome } from '@grafana/ui'; |
|
|
|
|
import { config } from 'app/core/config'; |
|
|
|
|
import { PANEL_BORDER } from 'app/core/constants'; |
|
|
|
|
import { StoreState, TABLE_RESULTS_STYLE } from 'app/types'; |
|
|
|
@ -12,7 +12,6 @@ import { ExploreItemState, TABLE_RESULTS_STYLES, TableResultsStyle } from 'app/t |
|
|
|
|
|
|
|
|
|
import { MetaInfoText } from '../MetaInfoText'; |
|
|
|
|
import RawListContainer from '../PrometheusListView/RawListContainer'; |
|
|
|
|
import { selectIsWaitingForData } from '../state/query'; |
|
|
|
|
import { exploreDataLinkPostProcessorFactory } from '../utils/links'; |
|
|
|
|
|
|
|
|
|
interface RawPrometheusContainerProps { |
|
|
|
@ -32,11 +31,10 @@ interface PrometheusContainerState { |
|
|
|
|
function mapStateToProps(state: StoreState, { exploreId }: RawPrometheusContainerProps) { |
|
|
|
|
const explore = state.explore; |
|
|
|
|
const item: ExploreItemState = explore.panes[exploreId]!; |
|
|
|
|
const { tableResult, rawPrometheusResult, range } = item; |
|
|
|
|
const loadingInState = selectIsWaitingForData(exploreId)(state); |
|
|
|
|
const { tableResult, rawPrometheusResult, range, queryResponse } = item; |
|
|
|
|
const rawPrometheusFrame: DataFrame[] = rawPrometheusResult ? [rawPrometheusResult] : []; |
|
|
|
|
const result = (tableResult?.length ?? 0) > 0 && rawPrometheusResult ? tableResult : rawPrometheusFrame; |
|
|
|
|
const loading = result && result.length > 0 ? false : loadingInState; |
|
|
|
|
const loading = queryResponse.state; |
|
|
|
|
|
|
|
|
|
return { loading, tableResult: result, range }; |
|
|
|
|
} |
|
|
|
@ -86,7 +84,6 @@ export class RawPrometheusContainer extends PureComponent<Props, PrometheusConta |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className={spacing}> |
|
|
|
|
{this.state.resultsStyle === TABLE_RESULTS_STYLE.raw ? 'Raw' : 'Table'} |
|
|
|
|
<RadioButtonGroup |
|
|
|
|
onClick={() => { |
|
|
|
|
const props = { |
|
|
|
@ -133,13 +130,14 @@ export class RawPrometheusContainer extends PureComponent<Props, PrometheusConta |
|
|
|
|
(frame: DataFrame | undefined): frame is DataFrame => !!frame && frame.length !== 0 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const title = this.state.resultsStyle === TABLE_RESULTS_STYLE.raw ? 'Raw' : 'Table'; |
|
|
|
|
const label = this.state?.resultsStyle !== undefined ? this.renderLabel() : 'Table'; |
|
|
|
|
|
|
|
|
|
// Render table as default if resultsStyle is not set.
|
|
|
|
|
const renderTable = !this.state?.resultsStyle || this.state?.resultsStyle === TABLE_RESULTS_STYLE.table; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Collapse label={label} loading={loading} isOpen> |
|
|
|
|
<PanelChrome title={title} actions={label} loadingState={loading}> |
|
|
|
|
{frames?.length && ( |
|
|
|
|
<> |
|
|
|
|
{renderTable && ( |
|
|
|
@ -155,7 +153,7 @@ export class RawPrometheusContainer extends PureComponent<Props, PrometheusConta |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
{!frames?.length && <MetaInfoText metaItems={[{ value: '0 series returned' }]} />} |
|
|
|
|
</Collapse> |
|
|
|
|
</PanelChrome> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|