diff --git a/src/GraphArea.jsx b/src/GraphArea.jsx index ccc6aee..f855635 100644 --- a/src/GraphArea.jsx +++ b/src/GraphArea.jsx @@ -56,11 +56,12 @@ function Graph({ }, [active, instance, graphID, dispatcher]); useEffect(() => { - if (!ref.current) return; - setContainerDim(ref.current); const handleResize = () => setContainerDim(ref.current); - window.addEventListener('resize', handleResize); - setInstance(initialiseNewGraph()); + if (ref.current) { + setContainerDim(ref.current); + window.addEventListener('resize', handleResize); + setInstance(initialiseNewGraph()); + } return () => window.removeEventListener('resize', handleResize); }, [ref]); diff --git a/src/graph-builder/graph-core/6-server.js b/src/graph-builder/graph-core/6-server.js index 827e867..e3fc1d3 100644 --- a/src/graph-builder/graph-core/6-server.js +++ b/src/graph-builder/graph-core/6-server.js @@ -51,7 +51,6 @@ class GraphServer extends GraphLoadSave { // this.setGraphML(graphXML); // }); // } else { - // // eslint-disable-next-line no-toast.success // toast.success('Not on server'); // } // } @@ -65,7 +64,6 @@ class GraphServer extends GraphLoadSave { // }); // } else { - // // eslint-disable-next-line no-toast.success // toast.success('Not on server'); // } // } @@ -119,7 +117,6 @@ class GraphServer extends GraphLoadSave { toast.error(err.response?.data?.message || err.message); }); } else { - // eslint-disable-next-line no-toast.success toast.success('Not on server'); } } @@ -133,7 +130,6 @@ class GraphServer extends GraphLoadSave { }); } else { - // eslint-disable-next-line no-toast.success toast.success('Not on server'); } } @@ -170,12 +166,16 @@ class GraphServer extends GraphLoadSave { build() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/build/${this.superState.uploadedDirName}` - + `?fetch=${graphName}&unlock=${this.superState.unlockCheck}` - + `&docker=${this.superState.dockerCheck}` - + `&maxtime=${this.superState.maxTime}` - + `¶ms=${this.superState.params}` - + `&octave=${this.superState.octave}`; + const query = new URLSearchParams({ + fetch: graphName, + unlock: this.superState.unlockCheck, + docker: this.superState.dockerCheck, + maxtime: this.superState.maxTime, + params: this.superState.params, + octave: this.superState.octave, + }); + const url = `${EXECUTION_ENGINE_URL}/build/${encodeURIComponent(this.superState.uploadedDirName)}` + + `?${query.toString()}`; this.serverAction('post', url, { built: false, ran: true, debugged: true, cleared: false, stopped: false, destroyed: true, }, (res) => { @@ -186,7 +186,7 @@ class GraphServer extends GraphLoadSave { debug() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/debug/${graphName}`; + const url = `${EXECUTION_ENGINE_URL}/debug/${encodeURIComponent(graphName)}`; this.serverAction('post', url, { built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true, }); @@ -195,7 +195,7 @@ class GraphServer extends GraphLoadSave { run() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/run/${graphName}`; + const url = `${EXECUTION_ENGINE_URL}/run/${encodeURIComponent(graphName)}`; this.serverAction('post', url, { built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true, }); @@ -204,10 +204,13 @@ class GraphServer extends GraphLoadSave { clear() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/clear/${graphName}` - + `?unlock=${this.superState.unlockCheck}` - + `&maxtime=${this.superState.maxTime}` - + `¶ms=${this.superState.params}`; + const query = new URLSearchParams({ + unlock: this.superState.unlockCheck, + maxtime: this.superState.maxTime, + params: this.superState.params, + }); + const url = `${EXECUTION_ENGINE_URL}/clear/${encodeURIComponent(graphName)}` + + `?${query.toString()}`; this.serverAction('post', url, { built: false, ran: true, debugged: true, cleared: false, stopped: true, destroyed: true, }); @@ -216,7 +219,7 @@ class GraphServer extends GraphLoadSave { stop() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/stop/${graphName}`; + const url = `${EXECUTION_ENGINE_URL}/stop/${encodeURIComponent(graphName)}`; this.serverAction('post', url, { built: false, ran: false, debugged: false, cleared: true, stopped: false, destroyed: true, }); @@ -225,15 +228,19 @@ class GraphServer extends GraphLoadSave { destroy() { const graphName = this.getCurrentGraphName(); if (!graphName) return; - const url = `${EXECUTION_ENGINE_URL}/destroy/${graphName}`; + const url = `${EXECUTION_ENGINE_URL}/destroy/${encodeURIComponent(graphName)}`; this.serverAction('delete', url, { built: true, ran: false, debugged: false, cleared: false, stopped: false, destroyed: false, }); } library(fileName) { - const url = `${EXECUTION_ENGINE_URL}/library/${this.superState.uploadedDirName}` - + `?filename=${fileName}&path=${this.superState.library}`; + const query = new URLSearchParams({ + filename: fileName, + path: this.superState.library, + }); + const url = `${EXECUTION_ENGINE_URL}/library/${encodeURIComponent(this.superState.uploadedDirName)}` + + `?${query.toString()}`; this.serverAction('post', url, null); }