Skip to content

Commit

Permalink
Lnse/dataset selector 4 rocky (#69)
Browse files Browse the repository at this point in the history
* initial implementation for dataset dropdown

Signed-off-by: Sean Li <[email protected]>

* initial metadata commit

Signed-off-by: Sean Li <[email protected]>

* bug fixes

Signed-off-by: Sean Li <[email protected]>

* hiding datasource cluster selctor and other bug fixes

Signed-off-by: Sean Li <[email protected]>

* refactoring and fixing datasource selector button

Signed-off-by: Sean Li <[email protected]>

* fix breaking loop

Signed-off-by: Sean Li <[email protected]>

* last working commit

Signed-off-by: Sean Li <[email protected]>

* WIP indices

Signed-off-by: Sean Li <[email protected]>

* refactor to query editor

Signed-off-by: Sean Li <[email protected]>

* cleanup dataset dropdown

Signed-off-by: Sean Li <[email protected]>

* running linter

Signed-off-by: Sean Li <[email protected]>

* removing exports for deleted components

Signed-off-by: Sean Li <[email protected]>

* Changeset file for PR opensearch-project#7289 created/updated

* running linter

Signed-off-by: Sean Li <[email protected]>

* removing connections bar component

Signed-off-by: Sean Li <[email protected]>

* remove unused property

Signed-off-by: Sean Li <[email protected]>

* use default search interceptor for get indices

Signed-off-by: Sean Li <[email protected]>

* removing unused file

Signed-off-by: Sean Li <[email protected]>

* adding onselect for dataset navigator

Signed-off-by: Sean Li <[email protected]>

* trying to make a commponetto call

Signed-off-by: Kawika Avilla <[email protected]>

* no clue if it works

Signed-off-by: Kawika Avilla <[email protected]>

* trying out changes

Signed-off-by: Sean Li <[email protected]>

* initial commit for external datasources work

Signed-off-by: Sean Li <[email protected]>

* caching recently used and external datasources

Signed-off-by: Sean Li <[email protected]>

* still porting over

Signed-off-by: Kawika Avilla <[email protected]>

* more ported over

Signed-off-by: Kawika Avilla <[email protected]>

* no linter complaints

Signed-off-by: Kawika Avilla <[email protected]>

* update to sidebar

Signed-off-by: Kawika Avilla <[email protected]>

* handle import errors

Signed-off-by: Kawika Avilla <[email protected]>

* rebased

Signed-off-by: Kawika Avilla <[email protected]>

* fix a messy merge for package.json

Signed-off-by: Kawika Avilla <[email protected]>

* so lnse for catching this

Signed-off-by: Kawika Avilla <[email protected]>

* fix nav

Signed-off-by: Kawika Avilla <[email protected]>

* no recalling

Signed-off-by: Kawika Avilla <[email protected]>

* number panels

Signed-off-by: Kawika Avilla <[email protected]>

* add wait

Signed-off-by: Kawika Avilla <[email protected]>

* index patterns worknig agan

Signed-off-by: Kawika Avilla <[email protected]>

* fix and clearing it df out

Signed-off-by: Kawika Avilla <[email protected]>

* disable hooks dependency

Signed-off-by: Kawika Avilla <[email protected]>

* fix the issue with import

Signed-off-by: Kawika Avilla <[email protected]>

* fixed passing the data source id

Signed-off-by: Kawika Avilla <[email protected]>

* loading spinner

Signed-off-by: Kawika Avilla <[email protected]>

* pading

Signed-off-by: Kawika Avilla <[email protected]>

* conditionally show s3

Signed-off-by: Kawika Avilla <[email protected]>

* remove sql

Signed-off-by: Kawika Avilla <[email protected]>

* let it fail

Signed-off-by: Kawika Avilla <[email protected]>

* s3 datasources

Signed-off-by: Kawika Avilla <[email protected]>

* set data set for table

Signed-off-by: Kawika Avilla <[email protected]>

* pass it in the options

Signed-off-by: Kawika Avilla <[email protected]>

* run query different

Signed-off-by: Kawika Avilla <[email protected]>

* dont parse query string

Signed-off-by: Kawika Avilla <[email protected]>

* not capitalization

Signed-off-by: Kawika Avilla <[email protected]>

* Changeset file for PR opensearch-project#7368 created/updated

* connections imported right

Signed-off-by: Kawika Avilla <[email protected]>

* handle select external

Signed-off-by: Kawika Avilla <[email protected]>

* initial implementation for url state

Signed-off-by: Sean Li <[email protected]>

* restore the dataset metadata stuff

Signed-off-by: Kawika Avilla <[email protected]>

* build dataset in state

Signed-off-by: Kawika Avilla <[email protected]>

* null pointer

Signed-off-by: Kawika Avilla <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Kawika Avilla <[email protected]>
Co-authored-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent faaa45c commit be89380
Show file tree
Hide file tree
Showing 70 changed files with 3,279 additions and 556 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7289.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add DataSet dropdown with index patterns and indices ([#7289](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7289))
2 changes: 2 additions & 0 deletions changelogs/fragments/7368.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Discover] Adds a dataset selector for Discover ([#7368](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7368))
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"start": "scripts/use_node scripts/opensearch_dashboards --dev",
"start:docker": "scripts/use_node scripts/opensearch_dashboards --dev --opensearch.hosts=$OPENSEARCH_HOSTS --opensearch.ignoreVersionMismatch=true --server.host=$SERVER_HOST",
"start:security": "scripts/use_node scripts/opensearch_dashboards --dev --security",
"start:enhancements": "scripts/use_node scripts/opensearch_dashboards --dev --uiSettings.overrides['query:enhancements:enabled']=true",
"start:enhancements": "scripts/use_node scripts/opensearch_dashboards --dev --uiSettings.overrides['query:enhancements:enabled']=true --uiSettings.overrides['home:useNewHomePage']=true",
"debug": "scripts/use_node --nolazy --inspect scripts/opensearch_dashboards --dev",
"debug-break": "scripts/use_node --nolazy --inspect-brk scripts/opensearch_dashboards --dev",
"lint": "yarn run lint:es && yarn run lint:style",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './create_extension';
export * from './types';
37 changes: 37 additions & 0 deletions src/plugins/data/common/data_sets/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

/** @public **/
export enum SIMPLE_DATA_SOURCE_TYPES {
DEFAULT = 'data-source',
EXTERNAL = 'external-source',
}

/** @public **/
export enum SIMPLE_DATA_SET_TYPES {
INDEX_PATTERN = 'index-pattern',
TEMPORARY = 'temporary',
TEMPORARY_ASYNC = 'temporary-async',
}

export interface SimpleObject {
id?: string;
title?: string;
dataSourceRef?: SimpleDataSource;
}

export interface SimpleDataSource {
id: string;
name: string;
indices?: SimpleObject[];
type: SIMPLE_DATA_SOURCE_TYPES;
}

export interface SimpleDataSet extends SimpleObject {
fields?: any[];
timeFieldName?: string;
timeFields?: any[];
type?: SIMPLE_DATA_SET_TYPES;
}
1 change: 1 addition & 0 deletions src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
export * from './constants';
export * from './opensearch_query';
export * from './data_frames';
export * from './data_sets';
export * from './field_formats';
export * from './field_mapping';
export * from './index_patterns';
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/common/search/opensearch_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export interface ISearchOptions {
* Use this option to enable support for long numerals.
*/
withLongNumeralsSupport?: boolean;
/**
* Use this option to enable support for async.
*/
isAsync?: boolean;
}

export type ISearchRequestParams<T = Record<string, any>> = {
Expand Down
11 changes: 10 additions & 1 deletion src/plugins/data/common/search/search_source/search_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@ export class SearchSource {
const dataFrame = createDataFrame({
name: searchRequest.index.title || searchRequest.index,
fields: [],
...(rawQueryString && { meta: { queryConfig: parseRawQueryString(rawQueryString) } }),
...(rawQueryString && {
meta: {
queryConfig: parseRawQueryString(rawQueryString),
...(searchRequest.dataSourceId && { dataSource: searchRequest.dataSourceId }),
},
}),
});
await this.setDataFrame(dataFrame);
return this.getDataFrame();
Expand Down Expand Up @@ -353,6 +358,10 @@ export class SearchSource {
if (getConfig(UI_SETTINGS.COURIER_BATCH_SEARCHES)) {
response = await this.legacyFetch(searchRequest, options);
} else if (this.isUnsupportedRequest(searchRequest)) {
const indexPattern = this.getField('index');
searchRequest.dataSourceId = indexPattern?.dataSourceRef?.id;

options = { ...options, isAsync: this.getField('type')?.includes('async') };
response = await this.fetchExternalSearch(searchRequest, options);
} else {
const indexPattern = this.getField('index');
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export * from './query/types';
export * from './osd_field_types/types';
export * from './index_patterns/types';
export * from './data_frames/types';
export * from './data_sets/types';

/**
* If a service is being shared on both the client and the server, and
Expand Down
24 changes: 14 additions & 10 deletions src/plugins/data/public/antlr/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IDataSourceRequestHandlerParams {
}

export const getRawSuggestionData$ = (
connectionsService,
connectionsService: { getSelectedConnection$: any },
dataSourceReuqstHandler: ({
dataSourceId,
title,
Expand All @@ -21,11 +21,11 @@ export const getRawSuggestionData$ = (
) =>
connectionsService.getSelectedConnection$().pipe(
distinctUntilChanged(),
switchMap((connection) => {
switchMap((connection: any) => {
if (connection === undefined) {
return from(defaultReuqstHandler());
}
const dataSourceId = connection?.id;
const dataSourceId = connection?.dataSource?.id;
const title = connection?.attributes?.title;
return from(dataSourceReuqstHandler({ dataSourceId, title }));
})
Expand All @@ -34,8 +34,8 @@ export const getRawSuggestionData$ = (
export const fetchData = (
tables: string[],
queryFormatter: (table: string, dataSourceId?: string, title?: string) => any,
api,
connectionService
api: any,
connectionService: any
): Promise<any[]> => {
return new Promise((resolve, reject) => {
getRawSuggestionData$(
Expand Down Expand Up @@ -65,16 +65,20 @@ export const fetchData = (
);
}
).subscribe({
next: (dataFrames) => resolve(dataFrames),
error: (err) => {
next: (dataFrames: any) => resolve(dataFrames),
error: (err: any) => {
// TODO: pipe error to UI
reject(err);
},
});
});
};

export const fetchTableSchemas = (tables: string[], api, connectionService): Promise<any[]> => {
export const fetchTableSchemas = (
tables: string[],
api: any,
connectionService: any
): Promise<any[]> => {
return fetchData(
tables,
(table, dataSourceId, title) => ({
Expand All @@ -96,8 +100,8 @@ export const fetchTableSchemas = (tables: string[], api, connectionService): Pro
export const fetchColumnValues = (
tables: string[],
column: string,
api,
connectionService
api: any,
connectionService: any
): Promise<any[]> => {
return fetchData(
tables,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ export {
QueryEditorTopRow,
// for BWC, keeping the old name
IUiStart as DataPublicPluginStartUi,
DataSetNavigator,
DataSetOption,
} from './ui';

/**
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/ui/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
@import "./typeahead/index";
@import "./saved_query_management/index";
@import "./query_string_input/index";
@import "./dataset_navigator/index";
@import "./query_editor/index";
@import "./shard_failure_modal/shard_failure_modal";
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
.datasetNavigator {
min-width: 350px;
border-bottom: $euiBorderThin !important;
}

.dataSetNavigatorFormWrapper {
padding: $euiSizeS;
}

.dataSetNavigator__loading {
padding: $euiSizeS;
}
1 change: 1 addition & 0 deletions src/plugins/data/public/ui/dataset_navigator/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "./dataset_navigator";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { HttpStart, SavedObjectsClientContract } from 'opensearch-dashboards/public';
import { DataSetNavigator, DataSetNavigatorProps } from './';

// Updated function signature to include additional dependencies
export function createDataSetNavigator(
savedObjectsClient: SavedObjectsClientContract,
http: HttpStart
) {
// Return a function that takes props, omitting the dependencies from the props type
return (props: Omit<DataSetNavigatorProps, 'savedObjectsClient' | 'http'>) => (
<DataSetNavigator {...props} savedObjectsClient={savedObjectsClient} http={http} />
);
}
Loading

0 comments on commit be89380

Please sign in to comment.