Persis deduplication strategy in url

This commit is contained in:
Dominik Prokop
2019-02-07 17:46:33 +01:00
parent c71904e326
commit 229d646bfc
8 changed files with 121 additions and 35 deletions

View File

@@ -4,10 +4,10 @@ import { connect } from 'react-redux';
import { RawTimeRange, TimeRange } from '@grafana/ui';
import { ExploreId, ExploreItemState } from 'app/types/explore';
import { LogsModel } from 'app/core/logs_model';
import { LogsModel, LogsDedupStrategy } from 'app/core/logs_model';
import { StoreState } from 'app/types';
import { toggleLogs } from './state/actions';
import { toggleLogs, changeDedupStrategy } from './state/actions';
import Logs from './Logs';
import Panel from './Panel';
@@ -25,6 +25,8 @@ interface LogsContainerProps {
scanRange?: RawTimeRange;
showingLogs: boolean;
toggleLogs: typeof toggleLogs;
changeDedupStrategy: typeof changeDedupStrategy;
dedupStrategy: LogsDedupStrategy;
}
export class LogsContainer extends PureComponent<LogsContainerProps> {
@@ -32,6 +34,10 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
this.props.toggleLogs(this.props.exploreId);
};
handleDedupStrategyChange = (dedupStrategy: LogsDedupStrategy) => {
this.props.changeDedupStrategy(this.props.exploreId, dedupStrategy);
};
render() {
const {
exploreId,
@@ -45,12 +51,13 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
range,
showingLogs,
scanning,
scanRange,
scanRange
} = this.props;
return (
<Panel label="Logs" loading={loading} isOpen={showingLogs} onToggle={this.onClickLogsButton}>
<Logs
dedupStrategy={this.props.dedupStrategy || LogsDedupStrategy.none}
data={logsResult}
exploreId={exploreId}
key={logsResult && logsResult.id}
@@ -60,6 +67,7 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
onClickLabel={onClickLabel}
onStartScanning={onStartScanning}
onStopScanning={onStopScanning}
onDedupStrategyChange={this.handleDedupStrategyChange}
range={range}
scanning={scanning}
scanRange={scanRange}
@@ -69,11 +77,23 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
}
}
const selectItemUIState = (itemState: ExploreItemState) => {
const { showingGraph, showingLogs, showingTable, showingStartPage, dedupStrategy } = itemState;
return {
showingGraph,
showingLogs,
showingTable,
showingStartPage,
dedupStrategy,
};
};
function mapStateToProps(state: StoreState, { exploreId }) {
const explore = state.explore;
const item: ExploreItemState = explore[exploreId];
const { logsHighlighterExpressions, logsResult, queryTransactions, scanning, scanRange, showingLogs, range } = item;
const { logsHighlighterExpressions, logsResult, queryTransactions, scanning, scanRange, range } = item;
const loading = queryTransactions.some(qt => qt.resultType === 'Logs' && !qt.done);
const {showingLogs, dedupStrategy} = selectItemUIState(item);
// const dedup = item.dedup;
return {
loading,
logsHighlighterExpressions,
@@ -82,11 +102,13 @@ function mapStateToProps(state: StoreState, { exploreId }) {
scanRange,
showingLogs,
range,
dedupStrategy,
};
}
const mapDispatchToProps = {
toggleLogs,
changeDedupStrategy,
};
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(LogsContainer));