Skip to content

Commit

Permalink
feat: connect insight engine
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Dec 16, 2024
1 parent 882bf1b commit 840c632
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
8 changes: 4 additions & 4 deletions packages/studio-components/src/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const Sidebar: React.FunctionComponent<ISidebar> = 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);
}
Expand Down
42 changes: 20 additions & 22 deletions packages/studio-website/src/layouts/index.tsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions packages/studio-website/src/pages/modeling/save-modeling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ const SaveModeling: React.FunctionComponent<SaveModelingProps> = 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';
Expand All @@ -76,9 +75,10 @@ const SaveModeling: React.FunctionComponent<SaveModelingProps> = 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
Expand Down
8 changes: 5 additions & 3 deletions packages/studio-website/src/pages/modeling/services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
})
Expand Down
3 changes: 2 additions & 1 deletion packages/studio-website/src/pages/query/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Suspense fallback={<LoadingProgress />}>
<Suspense fallback={<GlobalSpin />}>
<StudioQuery />
</Suspense>
</>
Expand Down

0 comments on commit 840c632

Please sign in to comment.