mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Logs: Fix stats not being updated when log results change (#62317)
update stats in logdetails
This commit is contained in:
parent
d51e7ec7ef
commit
ae8c61c0b2
@ -1,4 +1,5 @@
|
|||||||
import { css, cx } from '@emotion/css';
|
import { css, cx } from '@emotion/css';
|
||||||
|
import { isEqual } from 'lodash';
|
||||||
import memoizeOne from 'memoize-one';
|
import memoizeOne from 'memoize-one';
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
@ -161,6 +162,12 @@ class UnThemedLogDetailsRow extends PureComponent<Props, State> {
|
|||||||
fieldStats: null,
|
fieldStats: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (this.state.showFieldsStats) {
|
||||||
|
this.updateStats();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showField = () => {
|
showField = () => {
|
||||||
const { onClickShowField: onClickShowDetectedField, parsedKey, row } = this.props;
|
const { onClickShowField: onClickShowDetectedField, parsedKey, row } = this.props;
|
||||||
if (onClickShowDetectedField) {
|
if (onClickShowDetectedField) {
|
||||||
@ -213,13 +220,20 @@ class UnThemedLogDetailsRow extends PureComponent<Props, State> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateStats = () => {
|
||||||
|
const { getStats } = this.props;
|
||||||
|
const fieldStats = getStats();
|
||||||
|
const fieldCount = fieldStats ? fieldStats.reduce((sum, stat) => sum + stat.count, 0) : 0;
|
||||||
|
if (!isEqual(this.state.fieldStats, fieldStats) || fieldCount !== this.state.fieldCount) {
|
||||||
|
this.setState({ fieldStats, fieldCount });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
showStats = () => {
|
showStats = () => {
|
||||||
const { getStats, isLabel, row, app } = this.props;
|
const { isLabel, row, app } = this.props;
|
||||||
const { showFieldsStats } = this.state;
|
const { showFieldsStats } = this.state;
|
||||||
if (!showFieldsStats) {
|
if (!showFieldsStats) {
|
||||||
const fieldStats = getStats();
|
this.updateStats();
|
||||||
const fieldCount = fieldStats ? fieldStats.reduce((sum, stat) => sum + stat.count, 0) : 0;
|
|
||||||
this.setState({ fieldStats, fieldCount });
|
|
||||||
}
|
}
|
||||||
this.toggleFieldsStats();
|
this.toggleFieldsStats();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user