-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dacaf50
commit a9ab9db
Showing
4 changed files
with
48 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
35 changes: 35 additions & 0 deletions
35
packages/studio-explore/src/components/CypherQuery/index.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,35 @@ | ||
import * as React from 'react'; | ||
import { Input, Flex, Typography, Space, Button, InputRef } from 'antd'; | ||
import { PlayCircleOutlined } from '@ant-design/icons'; | ||
import { useContext, type IQueryStatement } from '@graphscope/studio-graph'; | ||
interface IStatementQueryProps {} | ||
|
||
const CypherQuery: React.FunctionComponent<IStatementQueryProps> = props => { | ||
const inputRef = React.useRef<InputRef>(null); | ||
const { store, updateStore } = useContext(); | ||
const { getService } = store; | ||
const handleQuery = async () => { | ||
if (inputRef.current) { | ||
//@ts-ignore | ||
const { value } = inputRef.current.resizableTextArea.textArea; | ||
const data = await getService<IQueryStatement>('queryStatement')(value); | ||
updateStore(draft => { | ||
draft.data = data; | ||
draft.source = data; | ||
}); | ||
} | ||
}; | ||
return ( | ||
<Flex vertical gap={12}> | ||
<Typography.Text italic>You can write Cypher queries here to retrieve data.</Typography.Text> | ||
<Input.TextArea rows={10} ref={inputRef} defaultValue={`Match (n) return n limit 100`}></Input.TextArea> | ||
<Space> | ||
<Button icon={<PlayCircleOutlined />} block onClick={handleQuery}> | ||
Query | ||
</Button> | ||
</Space> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default CypherQuery; |
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