Skip to content

Commit

Permalink
Implement results from no timestamp in Explorer (opensearch-project#1554
Browse files Browse the repository at this point in the history
) (opensearch-project#1582)

* history location state retrieval



* small changes to see results from no timestamp



* remove time field if there is no default timestamp



* explorer events ui update



* changes to disable timepicker



* modify timepicker logic to disappear instead of disable



* allow for visualizations without timestamps



* allow for saved queries to load with no timestamp



* fix linting complaints



* change naming convention



* add new no timestamp jest test



* stop app analytics from crashing



---------


(cherry picked from commit 73899a2)

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent cb78382 commit d14447e
Show file tree
Hide file tree
Showing 11 changed files with 813 additions and 81 deletions.
17 changes: 17 additions & 0 deletions public/components/common/query_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,23 @@ export const composeFinalQuery = (
});
};

export const composeFinalQueryWithoutTimestamp = (
curQuery: string,
appBaseQuery: string,
selectedPatternField?: string,
patternRegex?: string,
filteredPattern?: string
) => {
let fullQuery = curQuery.includes(appBaseQuery) ? curQuery : buildQuery(appBaseQuery, curQuery);
if (isEmpty(fullQuery)) return '';

// if a pattern is selected as filter, build it into finalQuery
if (selectedPatternField && filteredPattern)
fullQuery = buildPatternsQuery(fullQuery, selectedPatternField, patternRegex, filteredPattern);

return fullQuery;
};

export const removeBacktick = (stringContainsBacktick: string) => {
if (!stringContainsBacktick) return '';
return stringContainsBacktick.replace(/`/g, '');
Expand Down
37 changes: 25 additions & 12 deletions public/components/common/search/date_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { EuiSuperDatePicker, EuiToolTip } from '@elastic/eui';
import React from 'react';
import { i18n } from '@osd/i18n';
import { uiSettingsService } from '../../../../common/utils';
import { coreRefs } from '../../../framework/core_refs';
import { IDatePickerProps } from './search';
Expand All @@ -23,28 +24,40 @@ export function DatePicker(props: IDatePickerProps) {
} = props;

const handleTimeChange = (e: any) => handleTimePickerChange([e.start, e.end]);
const allowTimeChanging = !coreRefs.queryAssistEnabled || isAppAnalytics;

let finalizedStartTime;
let finalizedEndTime;
let setDisabled;
let toolTipMessage;

if (coreRefs.queryAssistEnabled && !isAppAnalytics) {
// is query assistant inside log explorer
finalizedStartTime = QUERY_ASSIST_START_TIME;
finalizedEndTime = QUERY_ASSIST_END_TIME;
setDisabled = true;
toolTipMessage = i18n.translate('discover.queryAssistant.timePickerDisabledMessage', {
defaultMessage: 'Date range has been disabled to accomodate timerange of all datasets',
});
} else {
finalizedStartTime = startTime;
finalizedEndTime = endTime;
setDisabled = false;
toolTipMessage = false;
}

return (
<>
<EuiToolTip
position="bottom"
content={
allowTimeChanging
? false
: 'Date range has been disabled to accomodate timerange of all datasets'
}
>
<EuiToolTip position="bottom" content={toolTipMessage}>
<EuiSuperDatePicker
data-test-subj="pplSearchDatePicker"
start={allowTimeChanging ? startTime : QUERY_ASSIST_START_TIME}
end={allowTimeChanging ? endTime : QUERY_ASSIST_END_TIME}
start={finalizedStartTime}
end={finalizedEndTime}
dateFormat={uiSettingsService.get('dateFormat')}
onTimeChange={handleTimeChange}
onRefresh={handleTimeRangePickerRefresh}
className="osdQueryBar__datePicker"
showUpdateButton={false}
isDisabled={!allowTimeChanging}
isDisabled={setDisabled}
/>
</EuiToolTip>
</>
Expand Down
59 changes: 31 additions & 28 deletions public/components/common/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
resetSummary,
selectQueryAssistantSummarization,
} from '../../event_analytics/redux/slices/query_assistant_summarization_slice';
import { reset } from '../../event_analytics/redux/slices/query_result_slice';
import { reset, selectQueryResult } from '../../event_analytics/redux/slices/query_result_slice';
import {
changeData,
changeQuery,
Expand Down Expand Up @@ -123,6 +123,7 @@ export const Search = (props: any) => {
} = props;

const queryRedux = useSelector(selectQueries)[tabId];
const queryResults = useSelector(selectQueryResult)[tabId];
const queryAssistantSummarization = useSelector(selectQueryAssistantSummarization)[tabId];
const dispatch = useDispatch();
const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX);
Expand Down Expand Up @@ -409,33 +410,35 @@ export const Search = (props: any) => {
</EuiFlexItem>
)}
<EuiFlexItem grow={false} />
<EuiFlexItem className="euiFlexItem--flexGrowZero event-date-picker" grow={false}>
{!isLiveTailOn && (
<DatePicker
startTime={startTime}
endTime={endTime}
setStartTime={setStartTime}
setEndTime={setEndTime}
setIsOutputStale={setIsOutputStale}
liveStreamChecked={props.liveStreamChecked}
onLiveStreamChange={props.onLiveStreamChange}
handleTimePickerChange={(tRange: string[]) => {
// modifies run button to look like the update button, if there is a time change, disables timepicker setting update if timepicker is disabled
setNeedsUpdate(
!showQueryArea && // keeps statement false if using query assistant ui, timepicker shouldn't change run button
!(tRange[0] === startTime && tRange[1] === endTime) // checks to see if the time given is different from prev
);
// keeps the time range change local, to be used when update pressed
setStartTime(tRange[0]);
setEndTime(tRange[1]);
}}
handleTimeRangePickerRefresh={() => {
onQuerySearch(queryLang);
}}
isAppAnalytics={isAppAnalytics}
/>
)}
</EuiFlexItem>
{!(queryRedux.selectedTimestamp === '' && queryResults?.datarows) && ( // index with no timestamp, dont show timepicker
<EuiFlexItem className="euiFlexItem--flexGrowZero event-date-picker" grow={false}>
{!isLiveTailOn && (
<DatePicker
startTime={startTime}
endTime={endTime}
setStartTime={setStartTime}
setEndTime={setEndTime}
setIsOutputStale={setIsOutputStale}
liveStreamChecked={props.liveStreamChecked}
onLiveStreamChange={props.onLiveStreamChange}
handleTimePickerChange={(tRange: string[]) => {
// modifies run button to look like the update button, if there is a time change, disables timepicker setting update if timepicker is disabled
setNeedsUpdate(
!showQueryArea && // keeps statement false if using query assistant ui, timepicker shouldn't change run button
!(tRange[0] === startTime && tRange[1] === endTime) // checks to see if the time given is different from prev
);
// keeps the time range change local, to be used when update pressed
setStartTime(tRange[0]);
setEndTime(tRange[1]);
}}
handleTimeRangePickerRefresh={() => {
onQuerySearch(queryLang);
}}
isAppAnalytics={isAppAnalytics}
/>
)}
</EuiFlexItem>
)}
{!showQueryArea && (
<EuiFlexItem grow={false}>
<EuiToolTip position="bottom" content={needsUpdate ? 'Click to apply' : false}>
Expand Down
Loading

0 comments on commit d14447e

Please sign in to comment.