diff --git a/src/core/cloud/github/provider.tsx b/src/core/cloud/github/provider.tsx index e0d6c7cc..88f2ce67 100644 --- a/src/core/cloud/github/provider.tsx +++ b/src/core/cloud/github/provider.tsx @@ -201,7 +201,9 @@ export class GithubProvider implements CloudProvider { if ( file && file.filename && - (checkFilenameExtension(file.filename, "gexf") || checkFilenameExtension(file.filename, "graphml")) + (checkFilenameExtension(file.filename, "gexf") || + checkFilenameExtension(file.filename, "graphml") || + checkFilenameExtension(file.filename, "json")) ) { result = { filename: file.filename || "Untitled", diff --git a/src/core/graph/import/index.ts b/src/core/graph/import/index.ts index 384a63e2..0b9ad775 100644 --- a/src/core/graph/import/index.ts +++ b/src/core/graph/import/index.ts @@ -63,6 +63,9 @@ export const importFile = asyncAction(async (file: NonNullable) => case "graphml": graph = graphml.parse(Graph, content, { addMissingNodes: true }); break; + case "json": + graph = Graph.from(JSON.parse(content)); + break; default: graph = null; break; diff --git a/src/locales/dev.json b/src/locales/dev.json index b8cdd1d6..54a76a8e 100644 --- a/src/locales/dev.json +++ b/src/locales/dev.json @@ -305,19 +305,19 @@ "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 Graphology 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 Graphology 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." }, "cloud": { "title": "Open a file from {{provider}}", - "no-data": "You have no GEXF or GRAPHML file saved on {{provider}}", + "no-data": "You have no GEXF, GRAPHML or Graphology JSON file saved on {{provider}}", "file-open-external": "Open {{filename}} on {{provider}}", "select-file": "Select a file", "success": "File {{filename}} has been successfully loaded", diff --git a/src/locales/en.json b/src/locales/en.json index 8da341f5..4c588f4c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -298,19 +298,19 @@ "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 Graphology 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 Graphology 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." }, "cloud": { "title": "Open a file from {{provider}}", - "no-data": "You have no GEXF or GRAPHML file saved on {{provider}}", + "no-data": "You have no GEXF, GRAPHML or Graphology JSON file saved on {{provider}}", "file-open-external": "Open {{filename}} on {{provider}}", "select-file": "Select a file", "success": "File {{filename}} has been successfully loaded", diff --git a/src/locales/fr.json b/src/locales/fr.json index 9185f768..5c8f3e38 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -295,19 +295,19 @@ "title": "Ouvrir un fichier de graphe", "local": { "title": "Ouvrir un fichier local", - "dragndrop_text": "Faites glisser-déposer un fichier GEXF ou GRAPHML", + "dragndrop_text": "Faites glisser-déposer un fichier GEXF, GRAPHML ou JSON au format Graphology", "success": "Le fichier {{filename}} a bien été ouvert", "error": "Une erreur s'est produite lors de l'ouverture du fichier. Veuillez vérifier que le fichier est valide." }, "remote": { "title": "Ouvrir une URL", - "url-field": "URL d'un fichier GEXF ou GRAPHML", + "url-field": "URL d'un fichier GEXF, GRAPHML ou JSON au format Graphology", "success": "Le fichier {{filename}} a bien été ouvert", "error": "Une erreur s'est produite lors de l'ouverture du fichier. Veuillez vérifier votre connexion et vous assurer que le fichier est valide." }, "cloud": { "title": "Ouvrir un fichier depuis {{provider}}", - "no-data": "Vous n'avez aucun fichier GEXF ou GRAPHML d'enregistré sur {{provider}}", + "no-data": "Vous n'avez aucun fichier GEXF, GRAPHML ou JSON au format Graphology d'enregistré sur {{provider}}", "file-open-external": "Ouvrir {{filename}} sur {{provider}}", "select-file": "Sélectionner un fichier", "success": "Le fichier {{filename}} a bien été ouvert", diff --git a/src/views/graphPage/modals/open/LocalFileModal.tsx b/src/views/graphPage/modals/open/LocalFileModal.tsx index 43b839ae..18479f0a 100644 --- a/src/views/graphPage/modals/open/LocalFileModal.tsx +++ b/src/views/graphPage/modals/open/LocalFileModal.tsx @@ -27,7 +27,7 @@ export const LocalFileModal: FC> = ({ 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" && }