From 6c3cb3ab7528b634d53acc51ef0d6c579ca554b2 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 6 Jul 2023 00:29:17 +0530 Subject: [PATCH 1/4] stop button added in loader --- src/component/modals/Loader.css | 14 ++++++++++++++ src/component/modals/Loader.jsx | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/component/modals/Loader.css diff --git a/src/component/modals/Loader.css b/src/component/modals/Loader.css new file mode 100644 index 0000000..3fa09ac --- /dev/null +++ b/src/component/modals/Loader.css @@ -0,0 +1,14 @@ +.loader-main { + display: flex; + align-items: center; +} +.loader-items { + position: relative; + margin: 10px 25px; +} +.loader-btn { + margin-left: 20px; + background-color: #1e88e5; + color: white; + font-weight: 200; +} \ No newline at end of file diff --git a/src/component/modals/Loader.jsx b/src/component/modals/Loader.jsx index 56db7bb..4061f08 100644 --- a/src/component/modals/Loader.jsx +++ b/src/component/modals/Loader.jsx @@ -1,10 +1,24 @@ import React from 'react'; import BeatLoader from 'react-spinners/BeatLoader'; import ParentModal from './ParentModal'; +import './Loader.css'; const Loader = ({ superState }) => ( - - + +
+ + + + + + + +
+
+
+ { superState.dockerCheck && superState.graphs[superState.curGraphIndex].built + ? + : '' }
); From ccb36861d73d703dca5ceb91267ac43b7aa6dd38 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 6 Jul 2023 00:41:59 +0530 Subject: [PATCH 2/4] stop workable in loader --- src/component/modals/Loader.jsx | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/component/modals/Loader.jsx b/src/component/modals/Loader.jsx index 4061f08..67f3e44 100644 --- a/src/component/modals/Loader.jsx +++ b/src/component/modals/Loader.jsx @@ -3,23 +3,28 @@ import BeatLoader from 'react-spinners/BeatLoader'; import ParentModal from './ParentModal'; import './Loader.css'; -const Loader = ({ superState }) => ( - -
- - - - - - - -
-
-
- { superState.dockerCheck && superState.graphs[superState.curGraphIndex].built - ? - : '' } -
-); +const Loader = ({ superState }) => { + const stopDocker = () => { + superState.curGraphInstance.stop(); + }; + return ( + +
+ + + + + + + +
+
+
+ { superState.dockerCheck && superState.graphs[superState.curGraphIndex].built + ? + : '' } +
+ ); +}; export default Loader; From 5abd8847b98317304e4d89ec3b9a59ab000ca1be Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 6 Jul 2023 00:55:12 +0530 Subject: [PATCH 3/4] Loader.jsx modified --- src/component/modals/Loader.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/component/modals/Loader.jsx b/src/component/modals/Loader.jsx index 67f3e44..39b3267 100644 --- a/src/component/modals/Loader.jsx +++ b/src/component/modals/Loader.jsx @@ -20,7 +20,7 @@ const Loader = ({ superState }) => {

- { superState.dockerCheck && superState.graphs[superState.curGraphIndex].built + { superState.curGraphInstance && superState.dockerCheck && superState.graphs[superState.curGraphIndex].built ? : '' }
From 1a3f63bcde354cdf594e6e7a1129454137911c6e Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 14 Jul 2023 13:25:04 +0530 Subject: [PATCH 4/4] loader removed instead toast added --- src/App.jsx | 2 - src/component/modals/Loader.css | 14 ------ src/component/modals/Loader.jsx | 30 ------------- src/graph-builder/graph-core/6-server.js | 54 ++++++++++++++++-------- src/reducer/actionType.js | 1 - src/reducer/initialState.js | 1 - src/reducer/reducer.js | 4 -- 7 files changed, 36 insertions(+), 70 deletions(-) delete mode 100644 src/component/modals/Loader.css delete mode 100644 src/component/modals/Loader.jsx diff --git a/src/App.jsx b/src/App.jsx index 64eab7d..ad7cc44 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -16,7 +16,6 @@ import LocalFileBrowser from './component/fileBrowser'; import FileEditModal from './component/modals/FileEdit'; import MarkDown from './component/modals/markDown'; import OptionsModal from './component/modals/OptionsModal'; -import Loader from './component/modals/Loader'; const app = () => { const [superState, dispatcher] = useReducer(reducer, initialState); @@ -38,7 +37,6 @@ const app = () => { - dispatcher({ type: T.Model_Close })} superState={superState} diff --git a/src/component/modals/Loader.css b/src/component/modals/Loader.css deleted file mode 100644 index 3fa09ac..0000000 --- a/src/component/modals/Loader.css +++ /dev/null @@ -1,14 +0,0 @@ -.loader-main { - display: flex; - align-items: center; -} -.loader-items { - position: relative; - margin: 10px 25px; -} -.loader-btn { - margin-left: 20px; - background-color: #1e88e5; - color: white; - font-weight: 200; -} \ No newline at end of file diff --git a/src/component/modals/Loader.jsx b/src/component/modals/Loader.jsx deleted file mode 100644 index 39b3267..0000000 --- a/src/component/modals/Loader.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import BeatLoader from 'react-spinners/BeatLoader'; -import ParentModal from './ParentModal'; -import './Loader.css'; - -const Loader = ({ superState }) => { - const stopDocker = () => { - superState.curGraphInstance.stop(); - }; - return ( - -
- - - - - - - -
-
-
- { superState.curGraphInstance && superState.dockerCheck && superState.graphs[superState.curGraphIndex].built - ? - : '' } -
- ); -}; - -export default Loader; diff --git a/src/graph-builder/graph-core/6-server.js b/src/graph-builder/graph-core/6-server.js index 0201162..0db25e6 100644 --- a/src/graph-builder/graph-core/6-server.js +++ b/src/graph-builder/graph-core/6-server.js @@ -68,7 +68,10 @@ class GraphServer extends GraphLoadSave { build() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.post(`http://127.0.0.1:5000/build/${this.superState.uploadedDirName}?fetch=${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}&unlock=${this.superState.unlockCheck}&docker=${this.superState.dockerCheck}&maxtime=${this.superState.maxTime}¶ms=${this.superState.params}&octave=${this.superState.octave}`) .then((res) => { // eslint-disable-next-line toast.success(res.data['message']) @@ -78,17 +81,20 @@ class GraphServer extends GraphLoadSave { built: false, ran: false, debugged: true, cleared: false, stopped: false, destroyed: true, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } debug() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.post(`http://127.0.0.1:5000/debug/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`) .then((res) => { // eslint-disable-next-line toast.success(res.data['message']) @@ -98,17 +104,20 @@ class GraphServer extends GraphLoadSave { built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } run() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.post(`http://127.0.0.1:5000/run/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`) .then((res) => { // eslint-disable-next-line toast.success(res.data['message']) @@ -118,17 +127,20 @@ class GraphServer extends GraphLoadSave { built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } clear() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.post(`http://127.0.0.1:5000/clear/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]} ?unlock=${this.superState.unlockCheck}&maxtime=${this.superState.maxTime}¶ms=${this.superState.params}`) .then((res) => { // eslint-disable-next-line @@ -139,17 +151,20 @@ class GraphServer extends GraphLoadSave { built: false, ran: true, debugged: true, cleared: false, stopped: true, destroyed: true, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } stop() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.post(`http://127.0.0.1:5000/stop/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`) .then((res) => { // eslint-disable-next-line toast.success(res.data['message']) @@ -159,17 +174,20 @@ class GraphServer extends GraphLoadSave { built: false, ran: false, debugged: false, cleared: true, stopped: false, destroyed: true, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } destroy() { // TODO - this.dispatcher({ type: T.SET_LOADER, payload: true }); + const toastId = toast.info('LOADING.......', { + position: 'bottom-left', + autoClose: false, // Disable auto-close + }); Axios.delete(`http://127.0.0.1:5000/destroy/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`) .then((res) => { // eslint-disable-next-line toast.success(res.data['message']) @@ -179,10 +197,10 @@ class GraphServer extends GraphLoadSave { built: true, ran: false, debugged: false, cleared: false, stopped: false, destroyed: false, }, }); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }).catch((err) => { // eslint-disable-next-line toast.error(err.message); - this.dispatcher({ type: T.SET_LOADER, payload: false }); + toast.dismiss(toastId); }); if (this.serverID); } diff --git a/src/reducer/actionType.js b/src/reducer/actionType.js index 56ba940..44d6e24 100644 --- a/src/reducer/actionType.js +++ b/src/reducer/actionType.js @@ -40,7 +40,6 @@ const actionType = { SET_FILE_STATE: 'SET_FILE_STATE', SET_INPUT_FILE: 'SET_INPUT_FILE', SET_OPTIONS: 'SET_OPTIONS', - SET_LOADER: 'SET_LOADER', SET_FUNCTIONS: 'SET_FUNCTIONS', }; diff --git a/src/reducer/initialState.js b/src/reducer/initialState.js index 5768401..ab2125b 100644 --- a/src/reducer/initialState.js +++ b/src/reducer/initialState.js @@ -33,7 +33,6 @@ const initialState = { maxTime: '', dockerCheck: false, unlockCheck: false, - loader: false, octave: false, }; diff --git a/src/reducer/reducer.js b/src/reducer/reducer.js index 1afdb7f..b6432e7 100644 --- a/src/reducer/reducer.js +++ b/src/reducer/reducer.js @@ -185,10 +185,6 @@ const reducer = (state, action) => { return { ...state, viewHistory: action.payload }; } - case T.SET_LOADER: { - return { ...state, loader: action.payload }; - } - case T.SET_AUTHOR: { const newState = { ...state }; newState.graphs = newState.graphs.map((g) => (