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.jsx b/src/component/modals/Loader.jsx deleted file mode 100644 index 56db7bb..0000000 --- a/src/component/modals/Loader.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import BeatLoader from 'react-spinners/BeatLoader'; -import ParentModal from './ParentModal'; - -const Loader = ({ superState }) => ( - - - -); - -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) => (