Skip to content

Commit a352d42

Browse files
authored
Merge pull request #173 from Rahuljagwani/EditNode
Library Implementation
2 parents 40eca65 + 2587db5 commit a352d42

7 files changed

Lines changed: 65 additions & 4 deletions

File tree

src/component/modals/GraphCompDetails.jsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ const ModalComp = ({ closeModal, superState, dispatcher }) => {
109109
}
110110
};
111111

112+
const createLibrary = () => {
113+
const fileName = data.label.split(':')[1];
114+
if (fileName === undefined || fileName === '') {
115+
toast.error('Enter File Name');
116+
return;
117+
}
118+
superState.curGraphInstance.library(fileName);
119+
};
120+
112121
return (
113122
<ParentModal closeModal={closeModal} ModelOpen={ModelOpen} title={title}>
114123
<form onSubmit={submit}>
@@ -145,6 +154,17 @@ const ModalComp = ({ closeModal, superState, dispatcher }) => {
145154
Create Help
146155
</button>
147156
)}
157+
{ title === 'Edit Node'
158+
? ''
159+
: (
160+
<button
161+
className="btn btn-primary"
162+
type="button"
163+
onClick={createLibrary}
164+
>
165+
Create Library
166+
</button>
167+
)}
148168
</>
149169
) : '' }
150170
</div>

src/component/modals/NodeDetails.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ const NodeDetails = ({
158158
if (item.key.toString().includes('.md')) {
159159
return null;
160160
}
161+
if (item.key.toString().split('/').length > 2) {
162+
return null;
163+
}
161164
// eslint-disable-next-line max-len
162165
if ((acceptedTypes.some((substring) => item.key.toString().includes(substring)))) {
163166
const fileName = item.key.toString().split('.')[0].concat('.md');

src/component/modals/OptionsModal.jsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const OptionsModal = ({ superState, dispatcher }) => {
99
const [octave, setOctave] = useState(false);
1010
const [param, setParam] = useState('');
1111
const [maxT, setmaxT] = useState('');
12+
const [library, setLibrary] = useState('');
1213
const close = () => {
1314
dispatcher({ type: T.SET_OPTIONS_MODAL, payload: false });
1415
dispatcher(
@@ -20,6 +21,7 @@ const OptionsModal = ({ superState, dispatcher }) => {
2021
maxT,
2122
param,
2223
octave,
24+
library,
2325
},
2426
},
2527
);
@@ -40,6 +42,9 @@ const OptionsModal = ({ superState, dispatcher }) => {
4042
const handleMaxtimeChange = (e) => {
4143
setmaxT(e.target.value);
4244
};
45+
const handleLibraryChange = (e) => {
46+
setLibrary(e.target.value);
47+
};
4348

4449
const Options = 'Options';
4550
return (
@@ -58,7 +63,7 @@ const OptionsModal = ({ superState, dispatcher }) => {
5863
<input type="checkbox" checked={unlock} onChange={handleUnlockChange} />
5964
</label>
6065
<label htmlFor="Maxtime" className="main-div-comp">
61-
Max Time&nbsp;
66+
Max Time:&nbsp;
6267
<input
6368
type="text"
6469
value={maxT}
@@ -69,6 +74,20 @@ const OptionsModal = ({ superState, dispatcher }) => {
6974
/>
7075
</label>
7176
<br />
77+
<br />
78+
<span>Library Path:&nbsp;&nbsp;</span>
79+
<label htmlFor="librarypath">
80+
<input
81+
size="59"
82+
type="text"
83+
value={library}
84+
placeholder="Enter library path"
85+
onChange={(e) => {
86+
handleLibraryChange(e);
87+
}}
88+
/>
89+
</label>
90+
7291
<br />
7392
<br />
7493
<span>Params:</span>
@@ -77,7 +96,6 @@ const OptionsModal = ({ superState, dispatcher }) => {
7796
cols="80"
7897
rows="10"
7998
value={param}
80-
placeholder="//Write Script"
8199
onChange={(e) => {
82100
handleParamsChange(e);
83101
}}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ class GraphServer extends GraphLoadSave {
212212
if (this.serverID);
213213
}
214214

215+
library(fileName) {
216+
// TODO
217+
const toastId = toast.info('LOADING.......', {
218+
position: 'bottom-left',
219+
autoClose: false,
220+
});
221+
// this.dispatcher({ type: T.SET_LOGS, payload: false });
222+
Axios.post(`http://127.0.0.1:5000/library/${this.superState.uploadedDirName}?filename=${fileName}&path=${this.superState.library}`)
223+
.then((res) => { // eslint-disable-next-line
224+
toast.info(res.data['message'])
225+
toast.dismiss(toastId);
226+
}).catch((err) => { // eslint-disable-next-line
227+
toast.error(err.message);
228+
toast.dismiss(toastId);
229+
});
230+
if (this.serverID);
231+
}
232+
215233
setCurStatus() {
216234
super.setCurStatus();
217235
this.dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: Boolean(this.serverID) });

src/reducer/initialState.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const initialState = {
3131
inputFile: '',
3232
params: '',
3333
maxTime: '',
34+
library: '',
3435
dockerCheck: false,
3536
unlockCheck: false,
3637
octave: false,

src/reducer/reducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ const reducer = (state, action) => {
169169
params: action.payload.param,
170170
maxTime: action.payload.maxT,
171171
octave: action.payload.octave,
172+
library: action.payload.library,
172173
};
173174
}
174175

src/toolbarActions/toolbarList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-alert */
22
import {
33
FaSave, FaUndo, FaRedo, FaTrash, FaFileImport, FaPlus, FaDownload, FaEdit, FaRegTimesCircle, FaHistory,
4-
FaHammer, FaBug, FaBomb, FaToggleOn, FaThermometerEmpty, FaTrashRestore, FaCogs, FaPencilAlt,
4+
FaHammer, FaBug, FaBomb, FaToggleOn, FaThermometerEmpty, FaTrashRestore, FaCogs, FaPencilAlt, FaTerminal,
55
} from 'react-icons/fa';
66

77
import {
@@ -130,7 +130,7 @@ const toolbarList = (state, dispatcher) => [
130130
{
131131
type: 'action',
132132
text: 'Logs',
133-
icon: FaBomb,
133+
icon: FaTerminal,
134134
action: toggleLogs,
135135
active: true,
136136
visibility: true,

0 commit comments

Comments
 (0)