Skip to content

Commit d44b160

Browse files
authored
Merge pull request #169 from Rahuljagwani/EditNode
Frontend still accessible while concore functions execute
2 parents 24e43ed + 1a3f63b commit d44b160

6 files changed

Lines changed: 36 additions & 37 deletions

File tree

src/App.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import LocalFileBrowser from './component/fileBrowser';
1616
import FileEditModal from './component/modals/FileEdit';
1717
import MarkDown from './component/modals/markDown';
1818
import OptionsModal from './component/modals/OptionsModal';
19-
import Loader from './component/modals/Loader';
2019

2120
const app = () => {
2221
const [superState, dispatcher] = useReducer(reducer, initialState);
@@ -38,7 +37,6 @@ const app = () => {
3837
<HistoryModal superState={superState} dispatcher={dispatcher} />
3938
<FileEditModal superState={superState} dispatcher={dispatcher} />
4039
<OptionsModal superState={superState} dispatcher={dispatcher} />
41-
<Loader superState={superState} />
4240
<GraphCompDetails
4341
closeModal={() => dispatcher({ type: T.Model_Close })}
4442
superState={superState}

src/component/modals/Loader.jsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/graph-builder/graph-core/6-server.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ class GraphServer extends GraphLoadSave {
6868

6969
build() {
7070
// TODO
71-
this.dispatcher({ type: T.SET_LOADER, payload: true });
71+
const toastId = toast.info('LOADING.......', {
72+
position: 'bottom-left',
73+
autoClose: false, // Disable auto-close
74+
});
7275
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}`)
7376
.then((res) => { // eslint-disable-next-line
7477
toast.success(res.data['message'])
@@ -78,17 +81,20 @@ class GraphServer extends GraphLoadSave {
7881
built: false, ran: false, debugged: true, cleared: false, stopped: false, destroyed: true,
7982
},
8083
});
81-
this.dispatcher({ type: T.SET_LOADER, payload: false });
84+
toast.dismiss(toastId);
8285
}).catch((err) => { // eslint-disable-next-line
8386
toast.error(err.message);
84-
this.dispatcher({ type: T.SET_LOADER, payload: false });
87+
toast.dismiss(toastId);
8588
});
8689
if (this.serverID);
8790
}
8891

8992
debug() {
9093
// TODO
91-
this.dispatcher({ type: T.SET_LOADER, payload: true });
94+
const toastId = toast.info('LOADING.......', {
95+
position: 'bottom-left',
96+
autoClose: false, // Disable auto-close
97+
});
9298
Axios.post(`http://127.0.0.1:5000/debug/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`)
9399
.then((res) => { // eslint-disable-next-line
94100
toast.success(res.data['message'])
@@ -98,17 +104,20 @@ class GraphServer extends GraphLoadSave {
98104
built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true,
99105
},
100106
});
101-
this.dispatcher({ type: T.SET_LOADER, payload: false });
107+
toast.dismiss(toastId);
102108
}).catch((err) => { // eslint-disable-next-line
103109
toast.error(err.message);
104-
this.dispatcher({ type: T.SET_LOADER, payload: false });
110+
toast.dismiss(toastId);
105111
});
106112
if (this.serverID);
107113
}
108114

109115
run() {
110116
// TODO
111-
this.dispatcher({ type: T.SET_LOADER, payload: true });
117+
const toastId = toast.info('LOADING.......', {
118+
position: 'bottom-left',
119+
autoClose: false, // Disable auto-close
120+
});
112121
Axios.post(`http://127.0.0.1:5000/run/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`)
113122
.then((res) => { // eslint-disable-next-line
114123
toast.success(res.data['message'])
@@ -118,17 +127,20 @@ class GraphServer extends GraphLoadSave {
118127
built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true,
119128
},
120129
});
121-
this.dispatcher({ type: T.SET_LOADER, payload: false });
130+
toast.dismiss(toastId);
122131
}).catch((err) => { // eslint-disable-next-line
123132
toast.error(err.message);
124-
this.dispatcher({ type: T.SET_LOADER, payload: false });
133+
toast.dismiss(toastId);
125134
});
126135
if (this.serverID);
127136
}
128137

129138
clear() {
130139
// TODO
131-
this.dispatcher({ type: T.SET_LOADER, payload: true });
140+
const toastId = toast.info('LOADING.......', {
141+
position: 'bottom-left',
142+
autoClose: false, // Disable auto-close
143+
});
132144
Axios.post(`http://127.0.0.1:5000/clear/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}
133145
?unlock=${this.superState.unlockCheck}&maxtime=${this.superState.maxTime}&params=${this.superState.params}`)
134146
.then((res) => { // eslint-disable-next-line
@@ -139,17 +151,20 @@ class GraphServer extends GraphLoadSave {
139151
built: false, ran: true, debugged: true, cleared: false, stopped: true, destroyed: true,
140152
},
141153
});
142-
this.dispatcher({ type: T.SET_LOADER, payload: false });
154+
toast.dismiss(toastId);
143155
}).catch((err) => { // eslint-disable-next-line
144156
toast.error(err.message);
145-
this.dispatcher({ type: T.SET_LOADER, payload: false });
157+
toast.dismiss(toastId);
146158
});
147159
if (this.serverID);
148160
}
149161

150162
stop() {
151163
// TODO
152-
this.dispatcher({ type: T.SET_LOADER, payload: true });
164+
const toastId = toast.info('LOADING.......', {
165+
position: 'bottom-left',
166+
autoClose: false, // Disable auto-close
167+
});
153168
Axios.post(`http://127.0.0.1:5000/stop/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`)
154169
.then((res) => { // eslint-disable-next-line
155170
toast.success(res.data['message'])
@@ -159,17 +174,20 @@ class GraphServer extends GraphLoadSave {
159174
built: false, ran: false, debugged: false, cleared: true, stopped: false, destroyed: true,
160175
},
161176
});
162-
this.dispatcher({ type: T.SET_LOADER, payload: false });
177+
toast.dismiss(toastId);
163178
}).catch((err) => { // eslint-disable-next-line
164179
toast.error(err.message);
165-
this.dispatcher({ type: T.SET_LOADER, payload: false });
180+
toast.dismiss(toastId);
166181
});
167182
if (this.serverID);
168183
}
169184

170185
destroy() {
171186
// TODO
172-
this.dispatcher({ type: T.SET_LOADER, payload: true });
187+
const toastId = toast.info('LOADING.......', {
188+
position: 'bottom-left',
189+
autoClose: false, // Disable auto-close
190+
});
173191
Axios.delete(`http://127.0.0.1:5000/destroy/${this.superState.graphs[this.superState.curGraphIndex].fileName.split('.')[0]}`)
174192
.then((res) => { // eslint-disable-next-line
175193
toast.success(res.data['message'])
@@ -179,10 +197,10 @@ class GraphServer extends GraphLoadSave {
179197
built: true, ran: false, debugged: false, cleared: false, stopped: false, destroyed: false,
180198
},
181199
});
182-
this.dispatcher({ type: T.SET_LOADER, payload: false });
200+
toast.dismiss(toastId);
183201
}).catch((err) => { // eslint-disable-next-line
184202
toast.error(err.message);
185-
this.dispatcher({ type: T.SET_LOADER, payload: false });
203+
toast.dismiss(toastId);
186204
});
187205
if (this.serverID);
188206
}

src/reducer/actionType.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const actionType = {
4040
SET_FILE_STATE: 'SET_FILE_STATE',
4141
SET_INPUT_FILE: 'SET_INPUT_FILE',
4242
SET_OPTIONS: 'SET_OPTIONS',
43-
SET_LOADER: 'SET_LOADER',
4443
SET_FUNCTIONS: 'SET_FUNCTIONS',
4544
};
4645

src/reducer/initialState.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const initialState = {
3333
maxTime: '',
3434
dockerCheck: false,
3535
unlockCheck: false,
36-
loader: false,
3736
octave: false,
3837
};
3938

src/reducer/reducer.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ const reducer = (state, action) => {
185185
return { ...state, viewHistory: action.payload };
186186
}
187187

188-
case T.SET_LOADER: {
189-
return { ...state, loader: action.payload };
190-
}
191-
192188
case T.SET_AUTHOR: {
193189
const newState = { ...state };
194190
newState.graphs = newState.graphs.map((g) => (

0 commit comments

Comments
 (0)