Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 3 additions & 1 deletion dashboards-observability/common/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
export const RAW_QUERY = 'rawQuery';
export const FINAL_QUERY = 'finalQuery';
export const SELECTED_DATE_RANGE = 'selectedDateRange';
export const INDEX = 'indexPattern';
export const INDEX = 'index';
export const SELECTED_TIMESTAMP = 'selectedTimestamp';
export const SELECTED_FIELDS = 'selectedFields';
export const UNSELECTED_FIELDS = 'unselectedFields';
export const AVAILABLE_FIELDS = 'availableFields';
Expand All @@ -23,6 +24,7 @@ export const TAB_CHART_TITLE = 'Visualizations';
export const TAB_EVENT_TITLE = 'Events';
export const TAB_EVENT_ID_TXT_PFX = 'main-content-events-';
export const TAB_CHART_ID_TXT_PFX = 'main-content-vis-';
export const HAS_SAVED_TIMESTAMP = 'hasSavedTimestamp';

export const DATE_PICKER_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const TIME_INTERVAL_OPTIONS = [
Expand Down
12 changes: 10 additions & 2 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import {
SELECTED_FIELDS,
UNSELECTED_FIELDS,
AVAILABLE_FIELDS,
QUERIED_FIELDS
QUERIED_FIELDS,
INDEX,
FINAL_QUERY,
SELECTED_TIMESTAMP,
SELECTED_DATE_RANGE
} from '../constants/explorer';
import SavedObjects from '../../public/services/saved_objects/event_analytics/saved_objects';

Expand All @@ -38,7 +42,11 @@ export interface ITabQueries {
}

export interface IQuery {
[RAW_QUERY]: string
[RAW_QUERY]: string;
[FINAL_QUERY]: string;
[INDEX]: string;
[SELECTED_DATE_RANGE]: Array<string>;
[SELECTED_TIMESTAMP]: string;
}

export interface IExplorerTabFields {
Expand Down
2 changes: 1 addition & 1 deletion dashboards-observability/common/utils/query_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const insertDateRangeToQuery = ({
rawQuery,
startTime,
endTime,
timeField = 'utc_time',
timeField,
}: {
rawQuery: string;
startTime: string;
Expand Down
5 changes: 4 additions & 1 deletion dashboards-observability/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ interface ObservabilityAppDeps {
pplService: any;
dslService: any;
savedObjects: any;
timestampUtils: any;
}

export const App = ({
CoreStart,
DepsStart,
pplService,
dslService,
savedObjects
savedObjects,
timestampUtils
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is a double commit as many changes like timestamp are already part of PR 152

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, some of the changes are based on #152 PR, I was planning to rebase and merge that PR once it was merged to main and update current PR.

}: ObservabilityAppDeps) => {

const { chrome, http, notifications } = CoreStart;
Expand Down Expand Up @@ -107,6 +109,7 @@ export const App = ({
pplService={ pplService }
dslService={ dslService }
savedObjects={ savedObjects }
timestampUtils={ timestampUtils }
http={ http }
{ ...props }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function Autocomplete(props: IQueryBarProps) {
render({ children }, root) {
render(children, root);
},
initialState: { query: query[RAW_QUERY] },
initialState: { query: query },
openOnFocus: true,
placeholder: 'Enter PPL query to retrieve log, traces, and metrics',
plugins: [PPLSuggestionPlugin],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export function createPPLSuggestionsPlugin(
): AutocompletePlugin<PPLSuggestion, undefined> {
return {
onStateChange: ({ state }) => {
if (options.query.rawQuery !== state.query) {
if (options.query !== state.query) {
options.handleQueryChange(state.query, currIndex);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import {
EuiPopoverFooter,
} from '@elastic/eui';
import _ from 'lodash';
import { IQuery } from '../../../../common/types/explorer';
import { DatePicker } from './date_picker';
import '@algolia/autocomplete-theme-classic';
import { Autocomplete } from './autocomplete';
import { SavePanel } from '../../explorer/save_panel';
import { useCallback } from 'react';

export interface IQueryBarProps {
query: any;
query: IQuery;
handleQueryChange: (query: string, index: string) => void;
handleQuerySearch: () => void;
dslService: any;
Expand Down Expand Up @@ -67,7 +68,8 @@ export const Search = (props: any) => {
isPanelTextFieldInvalid,
savedObjects,
showSavePanelOptionsList,
showSaveButton = true
showSaveButton = true,
setToast
} = props;

const [isSavePanelOpen, setIsSavePanelOpen] = useState<boolean>(false);
Expand All @@ -90,7 +92,7 @@ export const Search = (props: any) => {
<Autocomplete
query={query}
handleQueryChange={handleQueryChange}
handleQuerySearch={handleQuerySearch}
handleQuerySearch={memorizedHandleQuerySearch}
dslService={dslService}
/>
);
Expand All @@ -115,7 +117,14 @@ export const Search = (props: any) => {
<div className="globalQueryBar">
<EuiFlexGroup gutterSize="s" justifyContent="flexEnd">
<div className="autocomplete">
{renderAutocomplete({ query, handleQueryChange, handleQuerySearch, dslService })}
{
renderAutocomplete({
query,
handleQueryChange,
handleQuerySearch: memorizedHandleQuerySearch,
dslService
})
}
</div>
<DatePicker
startTime={startTime}
Expand Down Expand Up @@ -176,7 +185,10 @@ export const Search = (props: any) => {
<EuiButton
size="s"
fill
onClick={() => handleSavingObject()}>
onClick={() => {
handleSavingObject();
setIsSavePanelOpen(false);
}}>
{ "Save" }
</EuiButton>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* GitHub history for details.
*/

import React from 'react';
import React, { useState, ReactChild } from 'react';
import { HashRouter, Route, Switch } from 'react-router-dom';
import { Toast } from '@elastic/eui/src/components/toast/global_toast_list';
import { EuiGlobalToastList } from '@elastic/eui';
import { LogExplorer } from './log_explorer';
import { Home as EventExplorerHome } from './home';
import { renderPageWithSidebar } from '../common/side_nav';
Expand All @@ -21,17 +23,33 @@ export const EventAnalytics = ({
pplService,
dslService,
savedObjects,
timestampUtils,
http,
...props
}: any) => {

const [toasts, setToasts] = useState<Array<Toast>>([]);

const eventAnalyticsBreadcrumb = {
text: 'Event analytics',
href: '#/event_analytics',
};

const setToast = (title: string, color = 'success', text?: ReactChild, side?: string) => {
if (!text) text = '';
setToasts([...toasts, { id: new Date().toISOString(), title, text, color } as Toast]);
};

return (
<HashRouter>
<>
<EuiGlobalToastList
toasts={toasts}
dismissToast={(removedToast) => {
setToasts(toasts.filter((toast) => toast.id !== removedToast.id));
}}
toastLifeTimeMs={6000}
/>
<HashRouter>
<Switch>
<Route
path={`${props.match.path}/explorer`}
Expand All @@ -49,7 +67,9 @@ export const EventAnalytics = ({
pplService={ pplService }
dslService={ dslService }
savedObjects={ savedObjects }
timestampUtils={ timestampUtils }
http={ http }
setToast={ setToast }
/>
);
}}
Expand All @@ -65,10 +85,18 @@ export const EventAnalytics = ({
href: '#/event_analytics',
}
]);
return renderPageWithSidebar(<EventExplorerHome http={ http } savedObjects={ savedObjects } />);
return renderPageWithSidebar(
<EventExplorerHome
http={ http }
savedObjects={ savedObjects }
dslService={ dslService }
timestampUtils={ timestampUtils }
/>
);
}}
/>
</Switch>
</HashRouter>
</>
);
}
Loading