Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend still accessible while concore functions execute #169

Merged
merged 6 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -38,7 +37,6 @@ const app = () => {
<HistoryModal superState={superState} dispatcher={dispatcher} />
<FileEditModal superState={superState} dispatcher={dispatcher} />
<OptionsModal superState={superState} dispatcher={dispatcher} />
<Loader superState={superState} />
<GraphCompDetails
closeModal={() => dispatcher({ type: T.Model_Close })}
superState={superState}
Expand Down
11 changes: 0 additions & 11 deletions src/component/modals/Loader.jsx

This file was deleted.

54 changes: 36 additions & 18 deletions src/graph-builder/graph-core/6-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}&params=${this.superState.params}&octave=${this.superState.octave}`)
.then((res) => { // eslint-disable-next-line
toast.success(res.data['message'])
Expand All @@ -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'])
Expand All @@ -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'])
Expand All @@ -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}&params=${this.superState.params}`)
.then((res) => { // eslint-disable-next-line
Expand All @@ -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'])
Expand All @@ -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'])
Expand All @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/reducer/actionType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down
1 change: 0 additions & 1 deletion src/reducer/initialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const initialState = {
maxTime: '',
dockerCheck: false,
unlockCheck: false,
loader: false,
octave: false,
};

Expand Down
4 changes: 0 additions & 4 deletions src/reducer/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
Expand Down
Loading