@@ -67,154 +67,71 @@ class GraphServer extends GraphLoadSave {
6767 // }
6868 // }
6969
70- build ( ) {
71- // TODO
70+ serverAction ( method , url , successPayload , onSuccess ) {
7271 const toastId = toast . info ( 'LOADING.......' , {
7372 position : 'bottom-left' ,
7473 autoClose : false ,
7574 } ) ;
7675 this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
77- Axios . post ( ` ${ EXECUTION_ENGINE_URL } /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 } ` )
76+ Axios [ method ] ( url )
7877 . then ( ( res ) => { // eslint-disable-next-line
7978 toast . success ( res . data [ 'message' ] ) ;
80- this . dispatcher ( {
81- type : T . SET_FUNCTIONS ,
82- payload : {
83- built : false , ran : true , debugged : true , cleared : false , stopped : false , destroyed : true ,
84- } ,
85- } ) ;
86- this . dispatcher ( { type : T . SET_LOGS_MESSAGE , payload : this . superState . logsmessage + res . data . output } ) ;
79+ if ( successPayload ) {
80+ this . dispatcher ( { type : T . SET_FUNCTIONS , payload : successPayload } ) ;
81+ }
82+ if ( onSuccess ) onSuccess ( res ) ;
8783 toast . dismiss ( toastId ) ;
8884 } ) . catch ( ( err ) => { // eslint-disable-next-line
8985 toast . error ( err . response ?. data ?. message || err . message ) ;
9086 toast . dismiss ( toastId ) ;
9187 } ) ;
92- if ( this . serverID ) ;
88+ }
89+
90+ build ( ) {
91+ const url = `${ EXECUTION_ENGINE_URL } /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 } ` ;
92+ this . serverAction ( 'post' , url , {
93+ built : false , ran : true , debugged : true , cleared : false , stopped : false , destroyed : true ,
94+ } , ( res ) => {
95+ this . dispatcher ( { type : T . SET_LOGS_MESSAGE , payload : this . superState . logsmessage + res . data . output } ) ;
96+ } ) ;
9397 }
9498
9599 debug ( ) {
96- // TODO
97- const toastId = toast . info ( 'LOADING.......' , {
98- position : 'bottom-left' ,
99- autoClose : false ,
100+ const url = `${ EXECUTION_ENGINE_URL } /debug/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` ;
101+ this . serverAction ( 'post' , url , {
102+ built : false , ran : false , debugged : false , cleared : true , stopped : true , destroyed : true ,
100103 } ) ;
101- this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
102- Axios . post ( `${ EXECUTION_ENGINE_URL } /debug/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` )
103- . then ( ( res ) => { // eslint-disable-next-line
104- toast . success ( res . data [ 'message' ] )
105- this . dispatcher ( {
106- type : T . SET_FUNCTIONS ,
107- payload : {
108- built : false , ran : false , debugged : false , cleared : true , stopped : true , destroyed : true ,
109- } ,
110- } ) ;
111- toast . dismiss ( toastId ) ;
112- } ) . catch ( ( err ) => { // eslint-disable-next-line
113- toast . error ( err . response ?. data ?. message || err . message ) ;
114- toast . dismiss ( toastId ) ;
115- } ) ;
116- if ( this . serverID ) ;
117104 }
118105
119106 run ( ) {
120- // TODO
121- const toastId = toast . info ( 'LOADING.......' , {
122- position : 'bottom-left' ,
123- autoClose : false ,
107+ const url = `${ EXECUTION_ENGINE_URL } /run/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` ;
108+ this . serverAction ( 'post' , url , {
109+ built : false , ran : false , debugged : false , cleared : true , stopped : true , destroyed : true ,
124110 } ) ;
125- this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
126- Axios . post ( `${ EXECUTION_ENGINE_URL } /run/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` )
127- . then ( ( res ) => { // eslint-disable-next-line
128- toast . success ( res . data [ 'message' ] )
129- this . dispatcher ( {
130- type : T . SET_FUNCTIONS ,
131- payload : {
132- built : false , ran : false , debugged : false , cleared : true , stopped : true , destroyed : true ,
133- } ,
134- } ) ;
135- toast . dismiss ( toastId ) ;
136- } ) . catch ( ( err ) => { // eslint-disable-next-line
137- toast . error ( err . response ?. data ?. message || err . message ) ;
138- toast . dismiss ( toastId ) ;
139- } ) ;
140- if ( this . serverID ) ;
141111 }
142112
143113 clear ( ) {
144- // TODO
145- const toastId = toast . info ( 'LOADING.......' , {
146- position : 'bottom-left' ,
147- autoClose : false ,
114+ const url = `${ EXECUTION_ENGINE_URL } /clear/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ?unlock=${ this . superState . unlockCheck } &maxtime=${ this . superState . maxTime } ¶ms=${ this . superState . params } ` ;
115+ this . serverAction ( 'post' , url , {
116+ built : false , ran : true , debugged : true , cleared : false , stopped : true , destroyed : true ,
148117 } ) ;
149- this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
150- Axios . post ( `${ EXECUTION_ENGINE_URL } /clear/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] }
151- ?unlock=${ this . superState . unlockCheck } &maxtime=${ this . superState . maxTime } ¶ms=${ this . superState . params } ` )
152- . then ( ( res ) => { // eslint-disable-next-line
153- toast . success ( res . data [ 'message' ] ) ;
154- this . dispatcher ( {
155- type : T . SET_FUNCTIONS ,
156- payload : {
157- built : false , ran : true , debugged : true , cleared : false , stopped : true , destroyed : true ,
158- } ,
159- } ) ;
160- toast . dismiss ( toastId ) ;
161- } ) . catch ( ( err ) => { // eslint-disable-next-line
162- toast . error ( err . response ?. data ?. message || err . message ) ;
163- toast . dismiss ( toastId ) ;
164- } ) ;
165- if ( this . serverID ) ;
166118 }
167119
168120 stop ( ) {
169- // TODO
170- const toastId = toast . info ( 'LOADING.......' , {
171- position : 'bottom-left' ,
172- autoClose : false ,
121+ const url = `${ EXECUTION_ENGINE_URL } /stop/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` ;
122+ this . serverAction ( 'post' , url , {
123+ built : false , ran : false , debugged : false , cleared : true , stopped : false , destroyed : true ,
173124 } ) ;
174- this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
175- Axios . post ( `${ EXECUTION_ENGINE_URL } /stop/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` )
176- . then ( ( res ) => { // eslint-disable-next-line
177- toast . success ( res . data [ 'message' ] )
178- this . dispatcher ( {
179- type : T . SET_FUNCTIONS ,
180- payload : {
181- built : false , ran : false , debugged : false , cleared : true , stopped : false , destroyed : true ,
182- } ,
183- } ) ;
184- toast . dismiss ( toastId ) ;
185- } ) . catch ( ( err ) => { // eslint-disable-next-line
186- toast . error ( err . response ?. data ?. message || err . message ) ;
187- toast . dismiss ( toastId ) ;
188- } ) ;
189- if ( this . serverID ) ;
190125 }
191126
192127 destroy ( ) {
193- // TODO
194- const toastId = toast . info ( 'LOADING.......' , {
195- position : 'bottom-left' ,
196- autoClose : false ,
128+ const url = `${ EXECUTION_ENGINE_URL } /destroy/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` ;
129+ this . serverAction ( 'delete' , url , {
130+ built : true , ran : false , debugged : false , cleared : false , stopped : false , destroyed : false ,
197131 } ) ;
198- this . dispatcher ( { type : T . SET_LOGS , payload : false } ) ;
199- Axios . delete ( `${ EXECUTION_ENGINE_URL } /destroy/${ this . superState . graphs [ this . superState . curGraphIndex ] . fileName . split ( '.' ) [ 0 ] } ` )
200- . then ( ( res ) => { // eslint-disable-next-line
201- toast . success ( res . data [ 'message' ] )
202- this . dispatcher ( {
203- type : T . SET_FUNCTIONS ,
204- payload : {
205- built : true , ran : false , debugged : false , cleared : false , stopped : false , destroyed : false ,
206- } ,
207- } ) ;
208- toast . dismiss ( toastId ) ;
209- } ) . catch ( ( err ) => { // eslint-disable-next-line
210- toast . error ( err . response ?. data ?. message || err . message ) ;
211- toast . dismiss ( toastId ) ;
212- } ) ;
213- if ( this . serverID ) ;
214132 }
215133
216134 library ( fileName ) {
217- // TODO
218135 const toastId = toast . info ( 'LOADING.......' , {
219136 position : 'bottom-left' ,
220137 autoClose : false ,
@@ -228,7 +145,6 @@ class GraphServer extends GraphLoadSave {
228145 toast . error ( err . response ?. data ?. message || err . message ) ;
229146 toast . dismiss ( toastId ) ;
230147 } ) ;
231- if ( this . serverID ) ;
232148 }
233149
234150 setCurStatus ( ) {
0 commit comments