From 840c63292b76d2bd06536bf4ba38b1997ad2a8ed Mon Sep 17 00:00:00 2001 From: pomelo-nwu Date: Mon, 16 Dec 2024 18:52:08 +0800 Subject: [PATCH] feat: connect insight engine --- .../studio-components/src/layout/sidebar.tsx | 8 ++-- packages/studio-website/src/layouts/index.tsx | 42 +++++++++---------- .../src/pages/modeling/save-modeling.tsx | 6 +-- .../src/pages/modeling/services.tsx | 8 ++-- .../studio-website/src/pages/query/index.tsx | 3 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/packages/studio-components/src/layout/sidebar.tsx b/packages/studio-components/src/layout/sidebar.tsx index 9a0403b56..3b11c83b7 100644 --- a/packages/studio-components/src/layout/sidebar.tsx +++ b/packages/studio-components/src/layout/sidebar.tsx @@ -30,11 +30,11 @@ const Sidebar: React.FunctionComponent = props => { const activeKey = getCurrentNav(); const onClick: MenuProps['onClick'] = e => { - const params = getAllSearchParams(); navigate(e.key); - if (params && typeof params === 'object') { - setSearchParams(params); - } + // const params = getAllSearchParams(); + // if (params && typeof params === 'object') { + // setSearchParams(params); + // } if (onMenuClick) { onMenuClick(e.key); } diff --git a/packages/studio-website/src/layouts/index.tsx b/packages/studio-website/src/layouts/index.tsx index 27f91dcd7..41e22f99a 100644 --- a/packages/studio-website/src/layouts/index.tsx +++ b/packages/studio-website/src/layouts/index.tsx @@ -1,12 +1,12 @@ import React, { useEffect, useState } from 'react'; import { useContext, IGraph } from './useContext'; -import { Layout, LogoText, Utils, useCustomToken, GlobalSpin } from '@graphscope/studio-components'; +import { Layout, Utils, useCustomToken, GlobalSpin } from '@graphscope/studio-components'; import { DeploymentApiFactory } from '@graphscope/studio-server'; import { SIDE_MENU, SETTING_MENU } from './const'; -import { notification } from 'antd'; + import { listGraphs } from '../pages/instance/lists/service'; -import { SLOTS, getSlots } from '../slots'; +import { getSlots } from '../slots'; export default function StudioLayout() { const { store, updateStore } = useContext(); @@ -42,27 +42,17 @@ export default function StudioLayout() { return listGraphs().then(res => { let matchGraph: any; if (res) { - if (graphId) { - matchGraph = res.find(item => item.id === graphId); - if (!matchGraph) { - if (graphId !== draftId) { - notification.error({ - message: 'Graph Instance Not Found', - description: `Graph Instance ${graphId} Not Found`, - duration: 3, - }); - } - } - } else { + matchGraph = res.find(item => item.id === graphId); + if (!matchGraph) { matchGraph = res.find(item => { return item.status === 'Running'; }); } - return { - graphs: res, - graphId: (matchGraph && matchGraph.id) || graphId, - }; } + return { + graphs: res, + graphId: (matchGraph && matchGraph.id) || '', + }; }); }; const setQueryConfig = () => { @@ -114,9 +104,17 @@ export default function StudioLayout() { const { layoutBackground } = useCustomToken(); const handleMenuClick = key => { - updateStore(draft => { - draft.currentnNav = key; - }); + if (key === '/querying' || key === '/importing' || key === '/modeling') { + updateStore(draft => { + draft.currentnNav = key; + }); + const graph_id = Utils.getSearchParams('graph_id') || graphId || ''; + Utils.setSearchParams({ graph_id }); + } else { + updateStore(draft => { + draft.currentnNav = key; + }); + } }; if (isReady) { return ( diff --git a/packages/studio-website/src/pages/modeling/save-modeling.tsx b/packages/studio-website/src/pages/modeling/save-modeling.tsx index 2193f2606..2112586e8 100644 --- a/packages/studio-website/src/pages/modeling/save-modeling.tsx +++ b/packages/studio-website/src/pages/modeling/save-modeling.tsx @@ -63,10 +63,9 @@ const SaveModeling: React.FunctionComponent = props => { goot_graph_id, ) .then((res: any) => { - if (res.status === 200 || res === 'Import schema successfully') { + if (res.status === 200) { _status = 'success'; _message = `The graph model contains ${schema.nodes.length} types of nodes and ${schema.edges.length} types of edges.`; - return res.data && res.data.graph_id; } _status = 'error'; @@ -76,9 +75,10 @@ const SaveModeling: React.FunctionComponent = props => { _status = 'error'; _message = error.response.data; }); + /** 修改 URL */ Utils.storage.set('DRAFT_GRAPH', {}); - Utils.setSearchParams({ graph_id: state.id }); + Utils.setSearchParams({ graph_id: graph_id }); /** 设置Schema */ await localforage.setItem(`GRAPH_SCHEMA_OPTIONS_${graph_id}`, Utils.fakeSnapshot(schema)); //@ts-ignore diff --git a/packages/studio-website/src/pages/modeling/services.tsx b/packages/studio-website/src/pages/modeling/services.tsx index 0d81d57d3..897cdfe87 100644 --- a/packages/studio-website/src/pages/modeling/services.tsx +++ b/packages/studio-website/src/pages/modeling/services.tsx @@ -25,9 +25,11 @@ export const createGraph = async (params: { graphName: string; nodes: any[]; edg graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL) .importSchemaById(graph_id, schemaJSON) .then(res => { - if (res.status === 200) { - debugger; - return res.data; + if (res.status === 200 && res.data === 'Import schema successfully') { + return { + status: 200, + data: { graph_id }, + }; } return []; }) diff --git a/packages/studio-website/src/pages/query/index.tsx b/packages/studio-website/src/pages/query/index.tsx index 5be08cf5e..04cc73efc 100644 --- a/packages/studio-website/src/pages/query/index.tsx +++ b/packages/studio-website/src/pages/query/index.tsx @@ -1,12 +1,13 @@ import React, { lazy, Suspense } from 'react'; import LoadingProgress from './loading-progress'; +import { GlobalSpin } from '@graphscope/studio-components'; const StudioQuery = lazy(() => import('./app')); const QueryModule = () => { return ( <> - }> + }>