diff --git a/packages/studio-explore/src/components/Searchbar/PropertyChart.tsx b/packages/studio-explore/src/components/Searchbar/PropertyChart.tsx index 13829fef..edebcc46 100644 --- a/packages/studio-explore/src/components/Searchbar/PropertyChart.tsx +++ b/packages/studio-explore/src/components/Searchbar/PropertyChart.tsx @@ -7,7 +7,7 @@ import Chart from '../ChartView/index'; import { Illustration } from '@graphscope/studio-components'; export interface IQueryPropertyStatics { id: 'queryPropertyStatics'; - query: (property: string) => Promise<{ [key: string]: any }>; + query: (label: string, property: string) => Promise<{ [key: string]: any }>; } interface ITableViewProps { @@ -49,7 +49,7 @@ const ChartView: React.FunctionComponent = props => { }); try { - const data = await getService('queryPropertyStatics')(property); + const data = await getService('queryPropertyStatics')(label, property); setState(preState => { return { ...preState, diff --git a/packages/studio-explore/src/components/Searchbar/index.tsx b/packages/studio-explore/src/components/Searchbar/index.tsx index 3e191bef..172f5d2d 100644 --- a/packages/studio-explore/src/components/Searchbar/index.tsx +++ b/packages/studio-explore/src/components/Searchbar/index.tsx @@ -220,7 +220,11 @@ const Searchbar: React.FunctionComponent = props => { /> {state.onEnter && ( - + <> diff --git a/packages/studio-explore/src/services/cypher/queryPropertyStatics.tsx b/packages/studio-explore/src/services/cypher/queryPropertyStatics.tsx index 434b9955..eee5384f 100644 --- a/packages/studio-explore/src/services/cypher/queryPropertyStatics.tsx +++ b/packages/studio-explore/src/services/cypher/queryPropertyStatics.tsx @@ -1,10 +1,14 @@ import { queryStatement } from './queryStatement'; -export const queryPropertyStatics = async (property: string) => { +export const queryPropertyStatics = async (label: string, property: string) => { + const match = ['year', 'month']; + if (!match.includes(property)) { + return []; + } + const data = await queryStatement(` - MATCH(a) where a.${property} IS NOT NULL + MATCH(a:${label}) where a.${property} IS NOT NULL WITH a.${property} AS ${property} return ${property},COUNT(${property}) as counts `); - return data.table; }; diff --git a/packages/studio-graph/src/components/BasicInteraction/useNodeClick.ts b/packages/studio-graph/src/components/BasicInteraction/useNodeClick.ts index 90df662e..5a234ac3 100644 --- a/packages/studio-graph/src/components/BasicInteraction/useNodeClick.ts +++ b/packages/studio-graph/src/components/BasicInteraction/useNodeClick.ts @@ -1,14 +1,33 @@ import { useEffect } from 'react'; import { useContext, getDataMap } from '../../'; +let isCtrlPressed = false; + const useNodeClick = () => { const { store, updateStore } = useContext(); const { emitter, data, graph } = store; useEffect(() => { const dataMap = getDataMap(data); + + const handleKeydown = (event: KeyboardEvent) => { + if (event.key === 'Shift') { + isCtrlPressed = true; + } + }; + const handleKeyup = (event: KeyboardEvent) => { + if (event.key === 'Shift') { + isCtrlPressed = false; + } + }; + const applyStatus = () => {}; + + document.addEventListener('keydown', handleKeydown); + document.addEventListener('keyup', handleKeyup); + const handleClick = (node: any) => { const { id } = node; + console.log(isCtrlPressed); const { outNeighbors = [], @@ -66,6 +85,8 @@ const useNodeClick = () => { emitter?.on('node:click', handleClick); return () => { emitter?.off('node:click', handleClick); + document.removeEventListener('keydown', handleKeydown); + document.removeEventListener('keyup', handleKeyup); }; }, [emitter, data, graph]); };