Skip to content

Commit

Permalink
Merge pull request #167 from Rahuljagwani/EditNode
Browse files Browse the repository at this point in the history
Concore methods order implementation
  • Loading branch information
pradeeban authored Jul 4, 2023
2 parents 49659ce + ebc21b8 commit 24e43ed
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/component/TabBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const TabBar = ({ superState, dispatcher }) => {
dispatcher({ type: T.REMOVE_GRAPH, payload: i });
if (!superState.curGraphIndex && superState.graphs.length === 1) {
dispatcher({ type: T.SET_CUR_INSTANCE, payload: null });
dispatcher({ type: T.SET_CUR_INDEX, payload: -1 });
}
};
const editCur = (e) => {
Expand Down
36 changes: 36 additions & 0 deletions src/graph-builder/graph-core/6-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class GraphServer extends GraphLoadSave {
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'])
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: false, ran: false, debugged: true, cleared: false, stopped: false, destroyed: true,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand All @@ -86,6 +92,12 @@ class GraphServer extends GraphLoadSave {
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'])
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand All @@ -100,6 +112,12 @@ class GraphServer extends GraphLoadSave {
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'])
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: false, ran: false, debugged: false, cleared: true, stopped: true, destroyed: true,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand All @@ -115,6 +133,12 @@ class GraphServer extends GraphLoadSave {
?unlock=${this.superState.unlockCheck}&maxtime=${this.superState.maxTime}&params=${this.superState.params}`)
.then((res) => { // eslint-disable-next-line
toast.success(res.data['message']);
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: false, ran: true, debugged: true, cleared: false, stopped: true, destroyed: true,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand All @@ -129,6 +153,12 @@ class GraphServer extends GraphLoadSave {
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'])
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: false, ran: false, debugged: false, cleared: true, stopped: false, destroyed: true,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand All @@ -143,6 +173,12 @@ class GraphServer extends GraphLoadSave {
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'])
this.dispatcher({
type: T.SET_FUNCTIONS,
payload: {
built: true, ran: false, debugged: false, cleared: false, stopped: false, destroyed: false,
},
});
this.dispatcher({ type: T.SET_LOADER, payload: false });
}).catch((err) => { // eslint-disable-next-line
toast.error(err.message);
Expand Down
2 changes: 2 additions & 0 deletions src/reducer/actionType.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const actionType = {
SET_AUTHOR: 'SET_AUTHOR',
IS_WORKFLOW_ON_SERVER: 'IS_WORKFLOW_ON_SERVER',
SET_CUR_INSTANCE: 'SET_CUR_INSTANCE',
SET_CUR_INDEX: 'SET_CUR_INDEX',
SET_ZOOM_LEVEL: 'SET_ZOOM_LEVEL',
SET_EDIT_DETAILS_MODAL: 'SET_EDIT_DETAILS_MODAL',
SET_NEW_GRAPH_MODAL: 'SET_NEW_GRAPH_MODAL',
Expand All @@ -40,6 +41,7 @@ const actionType = {
SET_INPUT_FILE: 'SET_INPUT_FILE',
SET_OPTIONS: 'SET_OPTIONS',
SET_LOADER: 'SET_LOADER',
SET_FUNCTIONS: 'SET_FUNCTIONS',
};

export default zealit(actionType);
8 changes: 7 additions & 1 deletion src/reducer/initialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const initialState = {
undoEnabled: false,
redoEnabled: false,
graphs: [],
curGraphIndex: 0,
curGraphIndex: -1,
viewHistory: false,
isWorkflowOnServer: false,
curGraphInstance: null,
Expand Down Expand Up @@ -48,6 +48,12 @@ const initialGraphState = {
id: null,
fileHandle: null,
fileName: null,
built: true,
debugged: false,
ran: false,
destroyed: false,
cleared: false,
stopped: false,
};

export { initialState, initialGraphState };
14 changes: 14 additions & 0 deletions src/reducer/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ const reducer = (state, action) => {
case T.SET_CUR_INSTANCE: {
return { ...state, curGraphInstance: action.payload };
}
case T.SET_CUR_INDEX: {
return { ...state, curGraphIndex: action.payload };
}
case T.CHANGE_TAB: return { ...state, curGraphIndex: action.payload };

case T.NEW_GRAPH: return { ...state, newGraphModal: true };
Expand Down Expand Up @@ -223,6 +226,17 @@ const reducer = (state, action) => {
return { ...state, uploadedDirName: action.payload };
}

case T.SET_FUNCTIONS: {
const newState = { ...state };
newState.graphs[state.curGraphIndex].built = action.payload.built;
newState.graphs[state.curGraphIndex].debugged = action.payload.debugged;
newState.graphs[state.curGraphIndex].ran = action.payload.ran;
newState.graphs[state.curGraphIndex].cleared = action.payload.cleared;
newState.graphs[state.curGraphIndex].destroyed = action.payload.destroyed;
newState.graphs[state.curGraphIndex].stopped = action.payload.stopped;
return { ...newState };
}

default:
return state;
}
Expand Down
40 changes: 26 additions & 14 deletions src/toolbarActions/toolbarList.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const toolbarList = (state, dispatcher) => [
text: 'Server',
icon: state.isWorkflowOnServer ? FaToggleOn : FiToggleLeft,
action: () => toggleServer(state, dispatcher),
active: true,
active: state.curGraphInstance,
visibility: true,
},
{
Expand All @@ -141,55 +141,67 @@ const toolbarList = (state, dispatcher) => [
icon: FaCogs,
action: () => optionModalToggle(state, dispatcher),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Build',
icon: FaHammer,
action: () => state.curGraphInstance && state.curGraphInstance.build(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].built
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Debug',
icon: FaBug,
action: () => state.curGraphInstance && state.curGraphInstance.debug(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].debugged
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Run',
icon: FiPlay,
action: () => state.curGraphInstance && state.curGraphInstance.run(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].ran
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Clear',
icon: FaRegTimesCircle,
action: () => state.curGraphInstance && state.curGraphInstance.clear(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].cleared
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Stop',
icon: FiStopCircle,
action: () => state.curGraphInstance && state.curGraphInstance.stop(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].stopped
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},
{
type: 'action',
text: 'Destroy',
icon: FaBomb,
action: () => state.curGraphInstance && state.curGraphInstance.destroy(),
active: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer,
active: state.curGraphIndex !== -1
? state.isWorkflowOnServer && state.graphs[state.curGraphIndex].destroyed
: state.isWorkflowOnServer,
visibility: state.isWorkflowOnServer && state.curGraphInstance,
},

// Not being implemented in version 1
Expand Down

0 comments on commit 24e43ed

Please sign in to comment.