Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explorer's timeheader & color change #959

Merged
merged 26 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
141e9a8
horizontal to vertical hits/timechart
paulstn Aug 15, 2023
1486cca
Added timespan to the header
paulstn Aug 15, 2023
1c9eece
Correct formatting of timespan header
paulstn Aug 15, 2023
5fe2524
small todo reminder
paulstn Aug 15, 2023
55a9c3b
Fixing type issues and undefined behavior
paulstn Aug 18, 2023
aab5046
Color and y-axis name change
paulstn Aug 22, 2023
655cdc6
fix timechart header to be up to date
paulstn Aug 23, 2023
d3755a8
added all snapshots
paulstn Aug 25, 2023
227eefa
added upstream snapshots
paulstn Aug 25, 2023
700d764
added one missing snapshot
paulstn Aug 25, 2023
12b4fef
snapshot
paulstn Aug 28, 2023
9d2dd25
jest test change upload
paulstn Aug 28, 2023
19391eb
constant datetimes to timeheader added
paulstn Aug 28, 2023
6aa863b
Updated OSD to get new snapshots
paulstn Aug 28, 2023
1b1a74b
remove redundant field, update constants, move daterange up
paulstn Aug 28, 2023
1244818
snapshot
paulstn Aug 28, 2023
db240fb
remove unneeded brackets
paulstn Aug 29, 2023
da63e09
change back color
paulstn Aug 29, 2023
1d23803
code clarity change
paulstn Aug 29, 2023
f8b3188
updated snapshots
paulstn Aug 29, 2023
00eafa3
change back some code
paulstn Aug 30, 2023
c3c790f
modify line to use lodash array sum
paulstn Sep 1, 2023
ae81d0d
Merge branch 'main' of https://github.com/opensearch-project/dashboar…
paulstn Sep 1, 2023
92fa380
Merge branch 'main' of https://github.com/opensearch-project/dashboar…
paulstn Sep 5, 2023
a91c993
Merge branch 'main' of https://github.com/opensearch-project/dashboar…
paulstn Sep 7, 2023
f1e5bfe
Merge branch 'explorer-header-color' of https://github.com/paulstn/da…
paulstn Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const DEFAULT_COLUMNS = ['', 'Time', '_source'];
export const OTEL_TRACE_ID = 'traceId';
export const JAEGER_TRACE_ID = 'traceID';
export const DATE_PICKER_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const DATE_DISPLAY_FORMAT = 'MMM D, YYYY @ HH:mm:ss.SSS';
paulstn marked this conversation as resolved.
Show resolved Hide resolved
export const DEFAULT_DATETIME_STRING = 'now';
export const TIME_INTERVAL_OPTIONS = [
{
text: 'Minute',
Expand Down
56 changes: 23 additions & 33 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import React, {
useState,
} from 'react';
import { batch, useDispatch, useSelector } from 'react-redux';
import _ from 'lodash';
import { LogExplorerRouterContext } from '..';
import {
CREATE_TAB_PARAM,
Expand Down Expand Up @@ -458,6 +459,8 @@ export const Explorer = ({
return 0;
}, [countDistribution?.data]);

const dateRange = getDateRange(startTime, endTime, query);

const mainContent = useMemo(() => {
return (
<>
Expand Down Expand Up @@ -507,37 +510,26 @@ export const Explorer = ({
<div className="dscResults">
{countDistribution?.data && !isLiveTailOnRef.current && (
<>
<EuiFlexGroup justifyContent="center" alignItems="center">
<EuiFlexItem grow={false}>
<HitsCounter
hits={reduce(
paulstn marked this conversation as resolved.
Show resolved Hide resolved
countDistribution.data['count()'],
(sum, n) => {
return sum + n;
},
0
)}
showResetButton={false}
onResetQuery={() => {}}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<TimechartHeader
dateFormat={'MMM D, YYYY @ HH:mm:ss.SSS'}
options={timeIntervalOptions}
onChangeInterval={(selectedIntrv) => {
const intervalOptionsIndex = timeIntervalOptions.findIndex(
(item) => item.value === selectedIntrv
);
const intrv = selectedIntrv.replace(/^auto_/, '');
getCountVisualizations(intrv);
selectedIntervalRef.current = timeIntervalOptions[intervalOptionsIndex];
getPatterns(intrv, getErrorHandler('Error fetching patterns'));
}}
stateInterval={selectedIntervalRef.current?.value}
/>
</EuiFlexItem>
</EuiFlexGroup>
<HitsCounter
hits={_.sum(countDistribution.data['count()'])}
showResetButton={false}
onResetQuery={() => {}}
/>
<TimechartHeader
options={timeIntervalOptions}
onChangeInterval={(selectedIntrv) => {
const intervalOptionsIndex = timeIntervalOptions.findIndex(
(item) => item.value === selectedIntrv
);
const intrv = selectedIntrv.replace(/^auto_/, '');
getCountVisualizations(intrv);
selectedIntervalRef.current = timeIntervalOptions[intervalOptionsIndex];
getPatterns(intrv, getErrorHandler('Error fetching patterns'));
}}
stateInterval={selectedIntervalRef.current?.value}
startTime={appLogEvents ? startTime : dateRange[0]}
endTime={appLogEvents ? endTime : dateRange[1]}
/>
<CountDistribution countDistribution={countDistribution} />
<EuiHorizontalRule margin="xs" />
<LogPatterns
Expand Down Expand Up @@ -884,8 +876,6 @@ export const Explorer = ({
);
});

const dateRange = getDateRange(startTime, endTime, query);

const handleLiveTailSearch = useCallback(
async (startingTime: string, endingTime: string) => {
await updateQueryInStore(tempQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Time chart header component Renders Time chart header component 1`] = `
<TimechartHeader
dateFormat="MMM D, YYYY @ HH:mm:ss.SSS"
endTime="Aug 28, 2023 @ 20:00:00.408"
onChangeInterval={[MockFunction]}
options={
Array [
Expand Down Expand Up @@ -32,6 +32,7 @@ exports[`Time chart header component Renders Time chart header component 1`] = `
},
]
}
startTime="Aug 28, 2023 @ 20:00:00.406"
stateInterval="w"
>
<I18nProvider>
Expand Down Expand Up @@ -157,7 +158,9 @@ exports[`Time chart header component Renders Time chart header component 1`] = `
data-test-subj="discoverIntervalDateRange"
onBlur={[Function]}
onFocus={[Function]}
/>
>
Aug 28, 2023 @ 20:00:00.406 - Aug 28, 2023 @ 20:00:00.408
</div>
</EuiText>
</span>
</EuiToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import React from 'react';
import { waitFor } from '@testing-library/react';
import { TimechartHeader } from '../timechart_header';
import { TIME_INTERVAL_OPTIONS } from '../../../../../../common/constants/explorer';
import {
EXPLORER_START_TIME,
EXPLORER_END_TIME,
} from '../../../../../../test/event_analytics_constants';

describe('Time chart header component', () => {
configure({ adapter: new Adapter() });
Expand All @@ -18,10 +22,11 @@ describe('Time chart header component', () => {

const wrapper = mount(
<TimechartHeader
dateFormat={'MMM D, YYYY @ HH:mm:ss.SSS'}
onChangeInterval={onChangeInterval}
options={TIME_INTERVAL_OPTIONS}
stateInterval="w"
startTime={EXPLORER_START_TIME}
endTime={EXPLORER_END_TIME}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiText, EuiSelect } from '@elastic/eui';
import { I18nProvider } from '@osd/i18n/react';
import { i18n } from '@osd/i18n';
import moment from 'moment';
import datemath from '@elastic/datemath';
import {
DATE_DISPLAY_FORMAT,
DEFAULT_DATETIME_STRING,
} from '../../../../../common/constants/explorer';

function reformatDate(inputDate: string | undefined) {
return moment(datemath.parse(inputDate ?? DEFAULT_DATETIME_STRING)).format(DATE_DISPLAY_FORMAT);
}

export interface TimechartHeaderProps {
/**
* Format of date to be displayed
*/
dateFormat?: string;
/**
* Range of dates to be displayed
*/
timeRange?: {
from: string;
to: string;
};
/**
* Interval Options
*/
Expand All @@ -32,14 +31,20 @@ export interface TimechartHeaderProps {
* selected interval
*/
stateInterval?: string | undefined;
/**
* current time span being displayed on the count distribution
*/
startTime?: string;
endTime?: string;
}

export function TimechartHeader({
options,
onChangeInterval,
stateInterval,
startTime,
endTime,
}: TimechartHeaderProps) {

const handleIntervalChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
onChangeInterval(e.target.value);
};
Expand All @@ -54,7 +59,9 @@ export function TimechartHeader({
})}
delay="long"
>
<EuiText data-test-subj="discoverIntervalDateRange" size="s"></EuiText>
<EuiText data-test-subj="discoverIntervalDateRange" size="s">
{reformatDate(startTime) + ' - ' + reformatDate(endTime)}
</EuiText>
</EuiToolTip>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ exports[`Count distribution component Renders count distribution component with
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"title": Object {
"text": "Count",
},
"zeroline": false,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ exports[`Service breakdown panel component renders service breakdown panel 1`] =
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"title": Object {
"text": "Count",
},
"zeroline": false,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,9 @@ exports[`Histogram component Renders histogram component 1`] = `
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"title": Object {
"text": "Count",
},
"zeroline": false,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ exports[`Pie component Renders pie component 1`] = `
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"title": Object {
"text": "Count",
},
"zeroline": false,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ exports[`Treemap component Renders treemap component 1`] = `
"yaxis": Object {
"rangemode": "normal",
"showgrid": true,
"title": Object {
"text": "Count",
},
"zeroline": false,
},
}
Expand Down
3 changes: 3 additions & 0 deletions public/components/visualizations/plotly/plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export function Plt(props: PltProps) {
automargin: true,
},
yaxis: {
title: {
text: 'Count',
},
showgrid: true,
zeroline: false,
rangemode: 'normal',
Expand Down
4 changes: 4 additions & 0 deletions test/event_analytics_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,7 @@ export const HORIZONTAL_BAR_TEST_VISUALIZATIONS_DATA = {
type: VIS_CHART_TYPES.HorizontalBar,
}),
};

export const EXPLORER_START_TIME = 'Aug 28, 2023 @ 20:00:00.406';

export const EXPLORER_END_TIME = 'Aug 28, 2023 @ 20:00:00.408';
Loading