-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commits for kicking off query editor implementations and data…
…source support (#546) * initial commit - monaco editor Signed-off-by: Eric Wei <menwe@amazon.com> * raw editor Signed-off-by: EC2 Default User <ec2-user@ip-172-31-2-58.us-east-2.compute.internal> * visual builder placeholder Signed-off-by: EC2 Default User <ec2-user@ip-172-31-2-58.us-east-2.compute.internal> * datasource intial frame Signed-off-by: EC2 Default User <ec2-user@ip-172-31-2-58.us-east-2.compute.internal> * minor changes Signed-off-by: Eric Wei <menwe@amazon.com> --------- Signed-off-by: Eric Wei <menwe@amazon.com> Signed-off-by: EC2 Default User <ec2-user@ip-172-31-2-58.us-east-2.compute.internal> Co-authored-by: EC2 Default User <ec2-user@ip-172-31-2-58.us-east-2.compute.internal>
- Loading branch information
1 parent
4ab8089
commit fe66220
Showing
15 changed files
with
294 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export type KeyValue<T = any> = Record<string, T>; | ||
|
||
export enum PluginType { | ||
datasource = 'DATASOURCE', | ||
} | ||
|
||
export interface IPluginMeta { | ||
name: string; | ||
type: PluginType; | ||
} | ||
|
||
export abstract class DataExplorerPlugin<T extends IPluginMeta> { | ||
metadata: T; // plugin meta data | ||
hasError?: boolean; // if there's error when loading plugin | ||
|
||
constructor() { | ||
this.metadata = {} as T; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
public/plugins/datasources/datasource_plugin/datasource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
public/plugins/datasources/datasource_plugin/datasource_plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IDatasourcePluginMeta> { | ||
components: IDatasourcePluginComponents | null = null; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
setQueryEditor(QueryEditor: any) { | ||
this.components.QueryEditor = QueryEditor; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
public/plugins/datasources/sparksql/editor/spark_sql_editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ( | ||
<> | ||
<EuiIcon type="string" /> | ||
host | ||
</> | ||
), | ||
'data-test-subj': 'option-host', | ||
disabled: false, | ||
}, | ||
{ | ||
value: 'tags', | ||
inputDisplay: ( | ||
<> | ||
<EuiIcon type="string" /> | ||
tags | ||
</> | ||
), | ||
'data-test-subj': 'option-tags', | ||
disabled: false, | ||
}, | ||
]; | ||
|
||
export const SparkSqlQueryEditor = ({ datasource, query }) => { | ||
return ( | ||
<> | ||
<QueryHeader /> | ||
|
||
{query.editorMode !== 'query_editor' && <SqlVisualBuilder options={ROW_OPTIONS} />} | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
{query.editorMode === 'query_editor' && <SqlRawQueryEditor onEditorChange={() => {}} />} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
@import './query_editors/query_header.scss'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <MonacoEditor theme="euiColors" {...props} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<EuiButtonGroup | ||
color="text" | ||
id="hidden" | ||
isDisabled={false} | ||
isIconOnly={false} | ||
key="1" | ||
name="Hidden" | ||
onChange={onModeChange} | ||
buttonSize="compressed" | ||
options={QUERY_MODE_OPTIONS} | ||
idSelected={toggleCompressedIdSelected} | ||
legend="" | ||
isFullWidth={false} | ||
/> | ||
); | ||
}; | ||
|
||
export const QueryHeader = (props) => { | ||
return ( | ||
<> | ||
<EuiFlexGroup gutterSize="s" justifyContent="flexStart" alignItems="flexStart"> | ||
<EuiFlexItem grow={3} /> | ||
<EuiFlexItem key="queryHeader__search-run" className="queryHeader__search-run" grow={false}> | ||
<EuiButton fill size="s" iconType="play"> | ||
Run | ||
</EuiButton> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<QueryModeSwitcher /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<MonacoRawQueryEditor width="100%" height={500} value={''} onChange={props.onEditorChange} /> | ||
</> | ||
); | ||
}; |
17 changes: 17 additions & 0 deletions
17
public/plugins/query_editors/sql/visual_builder/sql_select_row.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<EuiFlexGroup gutterSize="s" justifyContent="flexStart" alignItems="flexStart"> | ||
<EuiFlexItem key="queryHeader__search-run" className="queryHeader__search-run" grow={false}> | ||
<EuiSuperSelect options={colOptions} valueOfSelected={} /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
17 changes: 17 additions & 0 deletions
17
public/plugins/query_editors/sql/visual_builder/sql_visual_builder.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<EuiFlexGroup gutterSize="s" justifyContent="flexStart" alignItems="flexStart"> | ||
<EuiFlexItem key="queryHeader__search-run" className="queryHeader__search-run"> | ||
<SqlSelectRow options={props.options} /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
public/services/datasources/datasource_services/datasource_service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string, Datasource> = {}; | ||
private settingsByName: Record<string, Datasource> = {}; | ||
private settingsByType: Record<string, Datasource> = {}; | ||
|
||
constructor() {} | ||
|
||
init(settingsByName: Record<string, Datasource>) {} | ||
|
||
getList(filters: any) {} | ||
|
||
getInstance(dsRef: any) {} | ||
|
||
getSettings(dsRef: any) {} | ||
} |
9 changes: 9 additions & 0 deletions
9
public/services/datasources/datasource_services/types/datasource_service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export interface IDatasourceService { | ||
getInstance: (dsRef: any) => any; | ||
getList: (filters: any) => any; | ||
} |