Skip to content

Commit

Permalink
WIP: describe graph by text
Browse files Browse the repository at this point in the history
  • Loading branch information
emcelroy committed Dec 17, 2024
1 parent b0722df commit 8aa942c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"height": 680,
"width": 380
},
"mockAssistant": false,
"mockAssistant": true,
"mode": "production"
}
35 changes: 35 additions & 0 deletions src/components/developer-options.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { observer } from "mobx-react-lite";
import { codapInterface } from "@concord-consortium/codap-plugin-api";
import { AssistantModelType } from "../models/assistant-model";
import { useAppConfigContext } from "../hooks/use-app-config-context";

Expand All @@ -14,6 +15,39 @@ interface IProps {

export const DeveloperOptionsComponent = observer(function DeveloperOptions({assistantStore, onCreateThread, onDeleteThread, onMockAssistant}: IProps) {
const appConfig = useAppConfigContext();

const handleGetGraphData = async () => {
const reqGetComponents = {
action: "get",
resource: "componentList",
values: {
request: {
constraints: {
orderBy: "id"
}
}
}
};
const resGetComponents = await codapInterface.sendRequest(reqGetComponents) as any;

const graphId = resGetComponents.values.find((item: any) => item.type === "graph").id;

const reqGetGraph = {
action: "get",
resource: `component[${graphId}]`,
values: {}
};
const resGetGraph = await codapInterface.sendRequest(reqGetGraph) as any;
console.log("Graph Data:", resGetGraph.values);

Check warning on line 41 in src/components/developer-options.tsx

View workflow job for this annotation

GitHub Actions / Build and Run Jest Tests

Unexpected console statement

Check warning on line 41 in src/components/developer-options.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement

const devOptionsContainer = document.querySelector(".developer-options");
if (devOptionsContainer) {
const img = document.createElement("img");
img.src = resGetGraph.values.exportDataUri;
devOptionsContainer.appendChild(img);
}
};

return (
<div className="developer-options" data-testid="developer-options">
<label htmlFor="mock-assistant-checkbox" data-testid="mock-assistant-checkbox-label">
Expand All @@ -40,6 +74,7 @@ export const DeveloperOptionsComponent = observer(function DeveloperOptions({ass
>
New Thread
</button>
<button onClick={handleGetGraphData}>Get Graph Data</button>
</div>
);
});

0 comments on commit 8aa942c

Please sign in to comment.