diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/package.json b/plugins/mindstudio-insight-plugins/ModelVis/app/package.json
index 978913d203da8550ec5f4c35e347a76f480ded50..cc8b94ff53967dba94041d9006b9861e06a3b284 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/package.json
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/package.json
@@ -24,6 +24,7 @@
"@tauri-apps/plugin-dialog": "^2.2.1",
"gl-matrix": "^3.4.3",
"jotai": "^2.12.4",
+ "lodash": "^4.17.21",
"lucide-react": "^0.511.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
@@ -39,6 +40,7 @@
"@tailwindcss/postcss": "^4.1.7",
"@tauri-apps/cli": "^2.5.0",
"@types/bun": "^1.2.13",
+ "@types/lodash": "^4.17.20",
"@types/node": "^22.15.19",
"@types/react": "^18.3.21",
"@types/react-dom": "^18.3.7",
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
index a30014afc3bf807a2b4786d1cc8625b4f13dd862..54ee45b6a34ce0f34ca67209ae544c71d10d1b28 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
@@ -13,20 +13,64 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import { useAtomValue } from "jotai"
+import { useAtom, useAtomValue } from "jotai"
import { Toaster } from "sonner"
-import { modelPathAtom } from "stores"
+import { modelDataAtom, modelPathAtom, nodesEdgesAtom, currentGraphAtom, subgraphesAtom } from "stores"
import FileUpload from "./FileUpload"
import ModelStructure from "./ModelStructure"
import { Toolbar } from "./features"
import { Loading } from "./ui"
import useWorkerMessage from "./useWorkerMessage"
+import { useEffect } from "react";
+import { cloneDeep } from "lodash";
+
+const SUBGRAPH_NODE_HEIGHT = 40
+const SUBGRAPH_NODE_WIDTH = 120
+const SUBGRAPH_NODE_SPACE = 30
+const SUBGRAPH_ROW_COUNT = 10
const App = () => {
const modelPath = useAtomValue(modelPathAtom)
+ const [modelData, setModelData] = useAtom(modelDataAtom)
+ const [nodesEdges, setNodesEdges] = useAtom(nodesEdgesAtom)
+ const currentGraph = useAtomValue(currentGraphAtom)
+ const subgraphs = useAtomValue(subgraphesAtom)
useWorkerMessage()
+ useEffect(() => {
+ if (!currentGraph) {
+ return
+ }
+ const currentGraphData = subgraphs[currentGraph.name]
+ if (currentGraphData) {
+ const maxY = currentGraphData.nodes.reduce((max: number, current: any) => {
+ return (current.y > max) ? current.y : max
+ }, 0)
+ currentGraph.children.forEach((subgraph, index) => {
+ const foundItem = currentGraphData.nodes.find(item => item.id === subgraph.name)
+ if (foundItem) {
+ foundItem.completed = Object.keys(subgraphs).includes(subgraph.name)
+ } else {
+ currentGraphData.nodes.push({
+ id: subgraph.name,
+ x: (index % SUBGRAPH_ROW_COUNT) * (SUBGRAPH_NODE_WIDTH + SUBGRAPH_NODE_SPACE),
+ y: maxY + SUBGRAPH_NODE_SPACE + Math.floor(index / SUBGRAPH_ROW_COUNT) * (SUBGRAPH_NODE_HEIGHT + SUBGRAPH_NODE_SPACE),
+ height: SUBGRAPH_NODE_HEIGHT,
+ width: SUBGRAPH_NODE_WIDTH,
+ opType: `subgraph`,
+ dynamic: false,
+ completed: Object.keys(subgraphs).includes(subgraph.name)
+ })
+ }
+ })
+ if (!modelData || !nodesEdges || JSON.stringify(currentGraphData.nodes) !== JSON.stringify(nodesEdges.nodes)) {
+ setModelData(cloneDeep(currentGraphData.model))
+ setNodesEdges({ nodes: cloneDeep(currentGraphData.nodes), edges: cloneDeep(currentGraphData.edges) });
+ }
+ }
+ }, [currentGraph, JSON.stringify(subgraphs)]);
+
return
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/FileUpload.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/FileUpload.tsx
index 748ae3e119c901bce660fd99b7df4298786bf192..33704bf070c6bfcc5a4d5d09ad86ade6c66049ca 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/FileUpload.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/FileUpload.tsx
@@ -15,25 +15,40 @@
import { useNewPathForLayout } from "hooks"
import { openDialog } from "./libs"
+import { useRecentProjectStorage } from "stores/useRecentProjectStorage";
+import { RecentProj } from "features/Project";
const FileUpload = () => {
+ const { recentProjectList } = useRecentProjectStorage();
const layoutNewPath = useNewPathForLayout()
const handleUpload = async () => {
const path = await openDialog()
await layoutNewPath(path)
}
+ const toggle = async (path: string) => {
+ await layoutNewPath(path)
+ }
- return
-
-
+ return <>
+
+
+
+
+ {recentProjectList.map(p => (
+
+ ))}
+
+
+
+ >
}
export default FileUpload
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/FsgControl.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/FsgControl.tsx
index 8bb21c1b7adfd6439a09568bfe6c317b8edeaf9c..31a1d347513f9313c69b63da64d31007c02bccf6 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/FsgControl.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/FsgControl.tsx
@@ -30,7 +30,7 @@ const FsgControl = () => {
setVisible(!visible)
}
- return