diff --git a/public/index.scss b/public/index.scss index a7dac9456..0f6b83de4 100644 --- a/public/index.scss +++ b/public/index.scss @@ -10,4 +10,8 @@ /* components */ // event analytics -@import 'components/event_analytics/index'; \ No newline at end of file +@import 'components/event_analytics/index'; + +/* plugins */ + +@import 'plugins/index.scss'; \ No newline at end of file diff --git a/public/plugins/data_explorer/data_explorer_plugin.ts b/public/plugins/data_explorer/data_explorer_plugin.ts new file mode 100644 index 000000000..eced5b0c7 --- /dev/null +++ b/public/plugins/data_explorer/data_explorer_plugin.ts @@ -0,0 +1,24 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export type KeyValue = Record; + +export enum PluginType { + datasource = 'DATASOURCE', +} + +export interface IPluginMeta { + name: string; + type: PluginType; +} + +export abstract class DataExplorerPlugin { + metadata: T; // plugin meta data + hasError?: boolean; // if there's error when loading plugin + + constructor() { + this.metadata = {} as T; + } +} diff --git a/public/plugins/datasources/datasource_plugin/datasource.ts b/public/plugins/datasources/datasource_plugin/datasource.ts new file mode 100644 index 000000000..512d1d171 --- /dev/null +++ b/public/plugins/datasources/datasource_plugin/datasource.ts @@ -0,0 +1,16 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export abstract class Datasource { + readonly name: string; + readonly type: string; + readonly metadata: any; + + constructor(datasourceSettings: any) { + this.name = datasourceSettings.name; + this.type = datasourceSettings.type; + this.metadata = datasourceSettings.metadata; + } +} diff --git a/public/plugins/datasources/datasource_plugin/datasource_plugin.ts b/public/plugins/datasources/datasource_plugin/datasource_plugin.ts new file mode 100644 index 000000000..084e4c94e --- /dev/null +++ b/public/plugins/datasources/datasource_plugin/datasource_plugin.ts @@ -0,0 +1,24 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { DataExplorerPlugin, IPluginMeta } from '../../data_explorer/data_explorer_plugin'; + +export type IDatasourcePluginMeta = IPluginMeta; + +export interface IDatasourcePluginComponents { + QueryEditor: any; +} + +export class DatasourcePlugin extends DataExplorerPlugin { + components: IDatasourcePluginComponents | null = null; + + constructor() { + super(); + } + + setQueryEditor(QueryEditor: any) { + this.components.QueryEditor = QueryEditor; + } +} diff --git a/public/plugins/datasources/sparksql/editor/spark_sql_editor.tsx b/public/plugins/datasources/sparksql/editor/spark_sql_editor.tsx new file mode 100644 index 000000000..da45dfbf0 --- /dev/null +++ b/public/plugins/datasources/sparksql/editor/spark_sql_editor.tsx @@ -0,0 +1,51 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { EuiIcon, EuiSpacer } from '@elastic/eui'; +import { + SqlRawQueryEditor, + SqlVisualBuilder, + QueryHeader, +} from '../../../../plugins/query_editors'; + +const ROW_OPTIONS = [ + { + value: 'host', + inputDisplay: ( + <> + + host + + ), + 'data-test-subj': 'option-host', + disabled: false, + }, + { + value: 'tags', + inputDisplay: ( + <> + + tags + + ), + 'data-test-subj': 'option-tags', + disabled: false, + }, +]; + +export const SparkSqlQueryEditor = ({ datasource, query }) => { + return ( + <> + + + {query.editorMode !== 'query_editor' && } + + + + {query.editorMode === 'query_editor' && {}} />} + + ); +}; diff --git a/public/plugins/index.scss b/public/plugins/index.scss new file mode 100644 index 000000000..8efb677b1 --- /dev/null +++ b/public/plugins/index.scss @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +@import './query_editors/query_header.scss'; \ No newline at end of file diff --git a/public/plugins/query_editors/index.ts b/public/plugins/query_editors/index.ts new file mode 100644 index 000000000..38f612050 --- /dev/null +++ b/public/plugins/query_editors/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { SqlVisualBuilder } from './sql/visual_builder/sql_visual_builder'; +export { SqlRawQueryEditor } from './sql/sql_raw_query_editor'; +export { MonacoRawQueryEditor } from './monaco_raw_query_editor'; +export { QueryHeader } from './query_header'; diff --git a/public/plugins/query_editors/monaco_raw_query_editor.tsx b/public/plugins/query_editors/monaco_raw_query_editor.tsx new file mode 100644 index 000000000..51713363c --- /dev/null +++ b/public/plugins/query_editors/monaco_raw_query_editor.tsx @@ -0,0 +1,17 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * This component should include functionalities related to Monaco specifically, + * for example adding lazy loading, error handings and other enhancements or overriding + * features. + */ + +import React from 'react'; +import MonacoEditor, { MonacoEditorProps } from 'react-monaco-editor'; + +export const MonacoRawQueryEditor = React.memo((props: MonacoEditorProps) => { + return ; +}); diff --git a/public/plugins/query_editors/query_header.scss b/public/plugins/query_editors/query_header.scss new file mode 100644 index 000000000..1ce60bda7 --- /dev/null +++ b/public/plugins/query_editors/query_header.scss @@ -0,0 +1,4 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ \ No newline at end of file diff --git a/public/plugins/query_editors/query_header.tsx b/public/plugins/query_editors/query_header.tsx new file mode 100644 index 000000000..e892dd25b --- /dev/null +++ b/public/plugins/query_editors/query_header.tsx @@ -0,0 +1,55 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useState } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiButtonGroup } from '@elastic/eui'; + +const QUERY_MODE_OPTIONS = [ + { label: 'Builder', id: 'visual_builder' }, + { label: 'Code', id: 'query_editor' }, +]; + +export const QueryModeSwitcher = () => { + const [toggleCompressedIdSelected, setToggleCompressedIdSelected] = useState('query_editor'); + + const onModeChange = (modeId: string) => { + setToggleCompressedIdSelected(modeId); + }; + + return ( + + ); +}; + +export const QueryHeader = (props) => { + return ( + <> + + + + + Run + + + + + + + + ); +}; diff --git a/public/plugins/query_editors/sql/sql_raw_query_editor.tsx b/public/plugins/query_editors/sql/sql_raw_query_editor.tsx new file mode 100644 index 000000000..1bd13037c --- /dev/null +++ b/public/plugins/query_editors/sql/sql_raw_query_editor.tsx @@ -0,0 +1,17 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { EuiSpacer } from '@elastic/eui'; +import { MonacoRawQueryEditor } from '../monaco_raw_query_editor'; +import { QueryHeader } from '../query_header'; + +export const SqlRawQueryEditor = (props) => { + return ( + <> + + + ); +}; diff --git a/public/plugins/query_editors/sql/visual_builder/sql_select_row.tsx b/public/plugins/query_editors/sql/visual_builder/sql_select_row.tsx new file mode 100644 index 000000000..ba478624a --- /dev/null +++ b/public/plugins/query_editors/sql/visual_builder/sql_select_row.tsx @@ -0,0 +1,17 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useState } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiButtonGroup, EuiSuperSelect } from '@elastic/eui'; + +export const SqlSelectRow = ({ colRaw }) => { + return ( + + + + + + ); +}; diff --git a/public/plugins/query_editors/sql/visual_builder/sql_visual_builder.tsx b/public/plugins/query_editors/sql/visual_builder/sql_visual_builder.tsx new file mode 100644 index 000000000..ef109d6c0 --- /dev/null +++ b/public/plugins/query_editors/sql/visual_builder/sql_visual_builder.tsx @@ -0,0 +1,17 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ +import React from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiButtonGroup } from '@elastic/eui'; +import { SqlSelectRow } from './sql_select_row'; + +export const SqlVisualBuilder = (props) => { + return ( + + + + + + ); +}; diff --git a/public/services/datasources/datasource_services/datasource_service.ts b/public/services/datasources/datasource_services/datasource_service.ts new file mode 100644 index 000000000..3e7223c74 --- /dev/null +++ b/public/services/datasources/datasource_services/datasource_service.ts @@ -0,0 +1,23 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Datasource } from 'public/plugins/datasources/datasource_plugin/datasource'; +import { IDatasourceService } from './types/datasource_service'; + +export class DatasourceService implements IDatasourceService { + private datasources: Record = {}; + private settingsByName: Record = {}; + private settingsByType: Record = {}; + + constructor() {} + + init(settingsByName: Record) {} + + getList(filters: any) {} + + getInstance(dsRef: any) {} + + getSettings(dsRef: any) {} +} diff --git a/public/services/datasources/datasource_services/types/datasource_service.ts b/public/services/datasources/datasource_services/types/datasource_service.ts new file mode 100644 index 000000000..8623d4449 --- /dev/null +++ b/public/services/datasources/datasource_services/types/datasource_service.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export interface IDatasourceService { + getInstance: (dsRef: any) => any; + getList: (filters: any) => any; +}