Skip to content

Commit

Permalink
[Bug]: Date Histogram 2 way sync issue fix (opensearch-project#1033)
Browse files Browse the repository at this point in the history
* Date-histogram 2 way sync issue fixed

Signed-off-by: Dipra Aich <dipra_aich@persistent.com>

* Test run snapshot update changes

Signed-off-by: Dipra Aich <dipra_aich@persistent.com>

Signed-off-by: Dipra Aich <dipra_aich@persistent.com>
Signed-off-by: Koustubh Karmalkar <koustubh_karmalkar@persistent.com>
  • Loading branch information
DipraAich authored and Koustubh5585 committed Sep 27, 2022
1 parent ea13692 commit 3683da3
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export const Explorer = ({
const [browserTabFocus, setBrowserTabFocus] = useState(true);
const [liveTimestamp, setLiveTimestamp] = useState(DATE_PICKER_FORMAT);
const [triggerAvailability, setTriggerAvailability] = useState(false);
const [isValidDataConfigOptionSelected, setIsValidDataConfigOptionSelected] = useState<Boolean>(false);
const [isValidDataConfigOptionSelected, setIsValidDataConfigOptionSelected] = useState<Boolean>(
false
);

const queryRef = useRef();
const appBasedRef = useRef('');
Expand Down Expand Up @@ -491,7 +493,6 @@ export const Explorer = ({
handleQuerySearch(availability);
};


/**
* Toggle fields between selected and unselected sets
* @param field field to be toggled
Expand Down Expand Up @@ -630,7 +631,7 @@ export const Explorer = ({
0
)}
showResetButton={false}
onResetQuery={() => {}}
onResetQuery={() => { }}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -671,7 +672,7 @@ export const Explorer = ({
<HitsCounter
hits={totalHits}
showResetButton={false}
onResetQuery={() => {}}
onResetQuery={() => { }}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>since {liveTimestamp}</EuiFlexItem>
Expand Down Expand Up @@ -746,7 +747,7 @@ export const Explorer = ({
};

const changeIsValidConfigOptionState = (isValidConfig: Boolean) =>
setIsValidDataConfigOptionSelected(isValidConfig);
setIsValidDataConfigOptionSelected(isValidConfig);

const getExplorerVis = () => {
return (
Expand Down Expand Up @@ -825,14 +826,12 @@ export const Explorer = ({

const handleQuerySearch = useCallback(
async (availability?: boolean) => {

// clear previous selected timestamp when index pattern changes
if (
!isEmpty(tempQuery) &&
!isEmpty(query[RAW_QUERY]) &&
isIndexPatternChanged(tempQuery, query[RAW_QUERY])
) {

await updateCurrentTimeStamp('');
}
if (availability !== true) {
Expand All @@ -843,12 +842,31 @@ export const Explorer = ({
if (selectedContentTabId === TAB_CHART_ID) {
// parse stats section on every search
const qm = new QueryManager();
const statsTokens =
qm
.queryParser()
.parse(tempQuery)
.getStats();

const statsTokens = qm.queryParser().parse(tempQuery).getStats();
const timeUnitValue = TIME_INTERVAL_OPTIONS.find(
(time_unit) => time_unit.value === statsTokens.groupby?.span.span_expression.time_unit
)?.text;
const span =
statsTokens.groupby?.span !== null
? {
time_field: [
{
name: statsTokens.groupby?.span.span_expression.field,
type: 'timestamp',
label: statsTokens.groupby?.span.span_expression.field,
},
],
unit: [
{
text: timeUnitValue,
value: statsTokens.groupby?.span.span_expression.time_unit,
label: timeUnitValue,
},
],
interval: statsTokens.groupby?.span.span_expression.literal_value,
}
: undefined;

await dispatch(
changeVizConfig({
tabId,
Expand All @@ -864,6 +882,7 @@ export const Explorer = ({
label: agg.name ?? '',
name: agg.name ?? '',
})),
span,
},
},
})
Expand Down Expand Up @@ -1190,7 +1209,7 @@ export const Explorer = ({
explorerFields,
explorerData,
http,
query
query,
}}
>
<div className="dscAppContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,139 +384,82 @@ exports[`Gauge component Renders gauge component 1`] = `
}
}
>
<Plt
config={Object {}}
data={
Array [
Object {
"domain": Object {
"column": 0,
"row": 0,
},
"gauge": Object {},
"mode": "gauge+number+delta",
"title": Object {
"align": "center",
"font": Object {
"size": 14,
},
"text": "error, count()",
},
"type": "indicator",
"value": 154,
},
]
}
layout={
Object {
"colorway": Array [
"#8C55A3",
],
"grid": Object {
"columns": 1,
"pattern": "independent",
"rows": 1,
},
"height": 220,
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
},
"showlegend": true,
"title": "",
}
}
<EmptyPlaceholder
icon="visGauge"
>
<PlotlyComponent
config={
Object {
"displayModeBar": false,
}
}
data={
Array [
Object {
"domain": Object {
"column": 0,
"row": 0,
},
"gauge": Object {},
"mode": "gauge+number+delta",
"title": Object {
"align": "center",
"font": Object {
"size": 14,
},
"text": "error, count()",
},
"type": "indicator",
"value": 154,
},
]
}
debug={false}
divId="explorerPlotComponent"
layout={
Object {
"autosize": true,
"barmode": "stack",
"colorway": Array [
"#8C55A3",
],
"grid": Object {
"columns": 1,
"pattern": "independent",
"rows": 1,
},
"height": 220,
"hovermode": "closest",
"legend": Object {
"orientation": "h",
"traceorder": "normal",
},
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
},
"showlegend": true,
"title": "",
"xaxis": Object {
"automargin": true,
"rangemode": "normal",
"showgrid": true,
"zeroline": false,
},
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"zeroline": false,
},
}
}
style={
Object {
"height": "100%",
"width": "100%",
}
}
useResizeHandler={true}
<EuiText
className="lnsChart__empty"
color="subdued"
data-test-subj="vizWorkspace__noData"
size="xs"
textAlign="center"
>
<div
id="explorerPlotComponent"
style={
Object {
"height": "100%",
"width": "100%",
}
}
/>
</PlotlyComponent>
</Plt>
className="euiText euiText--extraSmall lnsChart__empty"
data-test-subj="vizWorkspace__noData"
>
<EuiTextAlign
textAlign="center"
>
<div
className="euiTextAlign euiTextAlign--center"
>
<EuiTextColor
color="subdued"
component="div"
>
<div
className="euiTextColor euiTextColor--subdued"
>
<EuiIcon
color="subdued"
size="xxl"
type="visGauge"
>
<EuiIconEmpty
aria-hidden={true}
className="euiIcon euiIcon--xxLarge euiIcon--subdued euiIcon-isLoading"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
className="euiIcon euiIcon--xxLarge euiIcon--subdued euiIcon-isLoading"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<EuiSpacer
size="l"
>
<div
className="euiSpacer euiSpacer--l"
/>
</EuiSpacer>
<p>
<FormattedMessage
defaultMessage="No results found"
id="visualization_noData"
values={Object {}}
>
<span>
No results found
</span>
</FormattedMessage>
</p>
</div>
</EuiTextColor>
</div>
</EuiTextAlign>
</div>
</EuiText>
</EmptyPlaceholder>
</Gauge>
`;
Loading

0 comments on commit 3683da3

Please sign in to comment.