Skip to content

Commit

Permalink
Adding graphology JSON support for imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomguithereal committed Dec 4, 2024
1 parent 80ef917 commit 1f2229a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/graph/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const importFile = asyncAction(async (file: NonNullable<GraphOrigin>) =>
case "graphml":
graph = graphml.parse(Graph, content, { addMissingNodes: true });
break;
case "json":
graph = Graph.from(JSON.parse(content));
break;
default:
graph = null;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/locales/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@
"title": "Open a graph file",
"local": {
"title": "Open a local file",
"dragndrop_text": "Drag'n'drop a GEXF or GRAPHML file",
"dragndrop_text": "Drag'n'drop a GEXF, GRAPHML or JSON file",
"success": "File {{filename}} has been successfully loaded",
"error": "An error occurred while opening the file. Please check that the file is a valid."
},
"remote": {
"title": "Open an url",
"url-field": "URL of a GEXF or GRAPHML file",
"url-field": "URL of a GEXF, GRAPHML or JSON file",
"success": "File {{filename}} has been successfully loaded",
"error": "An error occurred while opening the file. Please check your connectivity and that the file is a valid."
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/graphPage/modals/open/LocalFileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const LocalFileModal: FC<ModalProps<unknown>> = ({ cancel }) => {
value={file}
onChange={(file) => setFile(file)}
helpText={t("graph.open.local.dragndrop_text").toString()}
accept={{ "application/graph": [".gexf", ".graphml"] }}
accept={{ "application/graph": [".gexf", ".graphml"], "application/json": [".json"] }}
/>
{importStateType === "loading" && <Loader />}
</>
Expand Down

0 comments on commit 1f2229a

Please sign in to comment.