Skip to content

Commit

Permalink
querymanager type added, renamed to qm
Browse files Browse the repository at this point in the history
Signed-off-by: Ramneet Chopra <ramneet_chopra@persistent.com>
  • Loading branch information
ramneet-persistent committed Sep 20, 2022
1 parent d0603e7 commit 1b73715
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 32 deletions.
6 changes: 3 additions & 3 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { History } from 'history';
import Plotly from 'plotly.js-dist';
import { QueryManager } from 'common/query_manager';
import {
RAW_QUERY,
SELECTED_FIELDS,
Expand All @@ -21,7 +22,6 @@ import SavedObjects from '../../public/services/saved_objects/event_analytics/sa
import TimestampUtils from '../../public/services/timestamp/timestamp';
import PPLService from '../../public/services/requests/ppl';
import DSLService from '../../public/services/requests/dsl';

export interface IQueryTab {
id: string;
name: React.ReactNode | string;
Expand Down Expand Up @@ -90,7 +90,7 @@ export interface ILogExplorerProps {
) => void;
savedObjectId: string;
getExistingEmptyTab: (params: EmptyTabParams) => string;
queryManager: any;
qm: QueryManager;
}

export interface IExplorerProps {
Expand Down Expand Up @@ -121,7 +121,7 @@ export interface IExplorerProps {
appBaseQuery?: string;
callback?: any;
callbackInApp?: any;
queryManager: any;
qm: QueryManager;
}

export interface SavedQuery {
Expand Down
7 changes: 4 additions & 3 deletions dashboards-observability/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { I18nProvider } from '@osd/i18n/react';
import React from 'react';
import { Provider } from 'react-redux';
import { HashRouter, Route, Switch } from 'react-router-dom';
import { QueryManager } from 'common/query_manager';
import { CoreStart } from '../../../../src/core/public';
import { observabilityID, observabilityTitle } from '../../common/constants/shared';
import store from '../framework/redux/store';
Expand All @@ -24,7 +25,7 @@ interface ObservabilityAppDeps {
dslService: any;
savedObjects: any;
timestampUtils: any;
queryManagerInstance: any;
queryManager: QueryManager;
}

// for cypress to test redux store
Expand All @@ -39,7 +40,7 @@ export const App = ({
dslService,
savedObjects,
timestampUtils,
queryManagerInstance,
qm,
}: ObservabilityAppDeps) => {
const { chrome, http, notifications } = CoreStartProp;
const parentBreadcrumb = {
Expand Down Expand Up @@ -132,7 +133,7 @@ export const App = ({
timestampUtils={timestampUtils}
http={http}
notifications={notifications}
queryManager={queryManagerInstance}
qm={qm}
{...props}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const Explorer = ({
setEndTime,
callback,
callbackInApp,
queryManager,
qm,
}: IExplorerProps) => {
const dispatch = useDispatch();
const requestParams = { tabId };
Expand Down Expand Up @@ -764,7 +764,7 @@ export const Explorer = ({
handleOverrideTimestamp={handleOverrideTimestamp}
callback={callbackForConfig}
changeIsValidConfigOptionState={changeIsValidConfigOptionState}
queryManager={queryManager}
qm={qm}
/>
);
};
Expand Down Expand Up @@ -842,7 +842,7 @@ export const Explorer = ({

if (selectedContentTabId === TAB_CHART_ID) {
// parse stats section on every search
const statsTokens = queryManager.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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const LogExplorer = ({
history,
notifications,
http,
queryManager,
qm,
}: ILogExplorerProps) => {
const dispatch = useDispatch();
const tabIds = useSelector(selectQueryTabs).queryTabIds.filter(
Expand Down Expand Up @@ -185,7 +185,7 @@ export const LogExplorer = ({
curSelectedTabId={curSelectedTabIdRef}
http={http}
searchBarConfigs={searchBarConfigs}
queryManager={queryManager}
qm={qm}
/>
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const initialMetricEntry = {
aggregation: 'count',
};

export const DataConfigPanelItem = ({ fieldOptionList, visualizations, queryManager }: any) => {
export const DataConfigPanelItem = ({ fieldOptionList, visualizations, qm }: any) => {
const dispatch = useDispatch();
const { tabId, handleQuerySearch, handleQueryChange, setTempQuery, fetchData } = useContext<any>(
TabContext
Expand Down Expand Up @@ -119,8 +119,8 @@ export const DataConfigPanelItem = ({ fieldOptionList, visualizations, queryMana
};

const updateChart = (updatedConfigList = configList) => {
const statsTokens = queryManager.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = queryManager
const statsTokens = qm.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = qm
.queryBuilder()
.build(data.query.rawQuery, composeAggregations(updatedConfigList, statsTokens));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ import { numericalTypes, RAW_QUERY } from '../../../../../../../../common/consta
import { TabContext } from '../../../../../hooks';
import { composeAggregations } from '../../../../../../../../common/query_manager/utils';

export const TreemapConfigPanelItem = ({
fieldOptionList,
visualizations,
tabID,
queryManager,
}: any) => {
export const TreemapConfigPanelItem = ({ fieldOptionList, visualizations, tabID, qm }: any) => {
const dispatch = useDispatch();
const { tabId, curVisId, changeVisualizationConfig, fetchData, handleQueryChange } = useContext<
any
Expand Down Expand Up @@ -72,8 +67,8 @@ export const TreemapConfigPanelItem = ({
};

const updateChart = (updatedConfigList = configList) => {
const statsTokens = queryManager.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = queryManager
const statsTokens = qm.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = qm
.queryBuilder()
.build(data.query.rawQuery, composeAggregations(updatedConfigList, statsTokens));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IExplorerVisualizationsProps {
handleOverrideTimestamp: (field: IField) => void;
callback?: any;
changeIsValidConfigOptionState: (isValidConfigOptionSelected: boolean) => void;
queryManager: any;
qm: any;
}

export const ExplorerVisualizations = ({
Expand All @@ -53,7 +53,7 @@ export const ExplorerVisualizations = ({
handleOverrideTimestamp,
callback,
changeIsValidConfigOptionState,
queryManager,
qm,
}: IExplorerVisualizationsProps) => {
const { tabId } = useContext<any>(TabContext);
const { data, vis } = visualizations;
Expand All @@ -71,7 +71,7 @@ export const ExplorerVisualizations = ({
fieldOptionList={fieldOptionList}
visualizations={visualizations}
tabID={tabId}
queryManager={queryManager}
qm={qm}
/>
);
case visChartTypes.LogsView:
Expand All @@ -88,7 +88,7 @@ export const ExplorerVisualizations = ({
fieldOptionList={fieldOptionList}
visualizations={visualizations}
tabID={tabId}
queryManager={queryManager}
qm={qm}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const EventAnalytics = ({
timestampUtils,
http,
notifications,
queryManager,
qm,
...props
}: any) => {
const history = useHistory();
Expand Down Expand Up @@ -85,7 +85,7 @@ export const EventAnalytics = ({
getExistingEmptyTab={getExistingEmptyTab}
history={history}
notifications={notifications}
queryManager={queryManager}
qm={qm}
/>
);
}}
Expand Down
5 changes: 3 additions & 2 deletions dashboards-observability/public/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { QueryManager } from 'common/query_manager';
import { AppMountParameters, CoreStart } from '../../../../src/core/public';
import { AppPluginStartDependencies } from '../types';
import { App } from './app';
Expand All @@ -17,7 +18,7 @@ export const Observability = (
dslService: any,
savedObjects: any,
timestampUtils: any,
queryManagerInstance: any
qm: QueryManager
) => {
ReactDOM.render(
<App
Expand All @@ -27,7 +28,7 @@ export const Observability = (
dslService={dslService}
savedObjects={savedObjects}
timestampUtils={timestampUtils}
queryManagerInstance={queryManagerInstance}
qm={qm}
/>,
AppMountParametersProp.element
);
Expand Down
4 changes: 2 additions & 2 deletions dashboards-observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ObservabilityPlugin implements Plugin<ObservabilitySetup, Observabi
const dslService = new DSLService(coreStart.http);
const savedObjects = new SavedObjects(coreStart.http);
const timestampUtils = new TimestampUtils(dslService);
const queryManagerInstance = new QueryManager();
const qm = new QueryManager();
return Observability(
coreStart,
depsStart as AppPluginStartDependencies,
Expand All @@ -57,7 +57,7 @@ export class ObservabilityPlugin implements Plugin<ObservabilitySetup, Observabi
dslService,
savedObjects,
timestampUtils,
queryManagerInstance
qm
);
},
});
Expand Down

0 comments on commit 1b73715

Please sign in to comment.