11import axios from "axios" ;
2- import { replace , push } from "react-router-redux" ;
2+ import { push } from "react-router-redux" ;
33import { fetchAndAssignSchema } from "./common" ;
44
55export const PUBLISHED_REQUEST = "PUBLISHED_REQUEST" ;
@@ -10,29 +10,21 @@ export const PUBLISHED_ITEM_REQUEST = "PUBLISHED_ITEM_REQUEST";
1010export const PUBLISHED_ITEM_SUCCESS = "PUBLISHED_ITEM_SUCCESS" ;
1111export const PUBLISHED_ITEM_ERROR = "PUBLISHED_ITEM_ERROR" ;
1212
13- export const RERUN_PUBLISHED_REQUEST = "RERUN_PUBLISHED_REQUEST" ;
14- export const RERUN_PUBLISHED_SUCCESS = "RERUN_PUBLISHED_SUCCESS" ;
15- export const RERUN_PUBLISHED_ERROR = "RERUN_PUBLISHED_ERROR" ;
16-
1713export const RERUN_STATUS_REQUEST = "RERUN_STATUS_REQUEST" ;
1814export const RERUN_STATUS_SUCCESS = "RERUN_STATUS_SUCCESS" ;
1915export const RERUN_STATUS_ERROR = "RERUN_STATUS_ERROR" ;
2016
21- export const RERUN_OUTPUTS_REQUEST = "RERUN_OUTPUTS_REQUEST" ;
22- export const RERUN_OUTPUTS_SUCCESS = "RERUN_OUTPUTS_SUCCESS" ;
23- export const RERUN_OUTPUTS_ERROR = "RERUN_OUTPUTS_ERROR" ;
24-
25- export const REANA_GET_WORKFLOWS_REQUEST = "REANA_GET_WORKFLOWS_REQUEST" ;
26- export const REANA_GET_WORKFLOWS_SUCCESS = "REANA_GET_WORKFLOWS_SUCCESS" ;
27- export const REANA_GET_WORKFLOWS_ERROR = "REANA_GET_WORKFLOWS_ERROR" ;
17+ export const RERUN_GET_WORKFLOWS_REQUEST = "RERUN_GET_WORKFLOWS_REQUEST" ;
18+ export const RERUN_GET_WORKFLOWS_SUCCESS = "RERUN_GET_WORKFLOWS_SUCCESS" ;
19+ export const RERUN_GET_WORKFLOWS_ERROR = "RERUN_GET_WORKFLOWS_ERROR" ;
2820
29- export const REANA_CREATE_WORKFLOW_REQUEST = "REANA_CREATE_WORKFLOW_REQUEST " ;
30- export const REANA_CREATE_WORKFLOW_SUCCESS = "REANA_CREATE_WORKFLOW_SUCCESS " ;
31- export const REANA_CREATE_WORKFLOW_ERROR = "REANA_CREATE_WORKFLOW_ERROR " ;
21+ export const RERUN_CREATE_WORKFLOW_REQUEST = "RERUN_CREATE_WORKFLOW_REQUEST " ;
22+ export const RERUN_CREATE_WORKFLOW_SUCCESS = "RERUN_CREATE_WORKFLOW_SUCCESS " ;
23+ export const RERUN_CREATE_WORKFLOW_ERROR = "RERUN_CREATE_WORKFLOW_ERROR " ;
3224
33- export const REANA_START_WORKFLOW_REQUEST = "REANA_START_WORKFLOW_REQUEST " ;
34- export const REANA_START_WORKFLOW_SUCCESS = "REANA_START_WORKFLOW_SUCCESS " ;
35- export const REANA_START_WORKFLOW_ERROR = "REANA_START_WORKFLOW_ERROR " ;
25+ export const RERUN_START_WORKFLOW_REQUEST = "RERUN_START_WORKFLOW_REQUEST " ;
26+ export const RERUN_START_WORKFLOW_SUCCESS = "RERUN_START_WORKFLOW_SUCCESS " ;
27+ export const RERUN_START_WORKFLOW_ERROR = "RERUN_START_WORKFLOW_ERROR " ;
3628
3729export function publishedRequest ( ) {
3830 return {
@@ -74,26 +66,6 @@ export function publishedItemError(error) {
7466 } ;
7567}
7668
77- export function rerunPublishedRequest ( ) {
78- return {
79- type : RERUN_PUBLISHED_REQUEST
80- } ;
81- }
82-
83- export function rerunPublishedSuccess ( data ) {
84- return {
85- type : RERUN_PUBLISHED_SUCCESS ,
86- data
87- } ;
88- }
89-
90- export function rerunPublishedError ( error ) {
91- return {
92- type : RERUN_PUBLISHED_ERROR ,
93- error
94- } ;
95- }
96-
9769export function rerunStatusRequest ( ) {
9870 return {
9971 type : RERUN_STATUS_REQUEST
@@ -115,144 +87,66 @@ export function rerunStatusError(error) {
11587 } ;
11688}
11789
118- export function rerunOutputsRequest ( ) {
90+ export function rerunCreateWorkflowRequest ( ) {
11991 return {
120- type : RERUN_OUTPUTS_REQUEST
92+ type : RERUN_CREATE_WORKFLOW_REQUEST
12193 } ;
12294}
12395
124- export function rerunOutputsSuccess ( data ) {
96+ export function rerunCreateWorkflowSuccess ( data ) {
12597 return {
126- type : RERUN_OUTPUTS_SUCCESS ,
98+ type : RERUN_CREATE_WORKFLOW_SUCCESS ,
12799 data
128100 } ;
129101}
130102
131- export function rerunOutputsError ( error ) {
103+ export function rerunCreateWorkflowError ( error ) {
132104 return {
133- type : RERUN_OUTPUTS_ERROR ,
105+ type : RERUN_CREATE_WORKFLOW_ERROR ,
134106 error
135107 } ;
136108}
137109
138- export function REANACreateWorkflowRequest ( ) {
110+ export function rerunStartWorkflowRequest ( ) {
139111 return {
140- type : REANA_CREATE_WORKFLOW_REQUEST
112+ type : RERUN_START_WORKFLOW_REQUEST
141113 } ;
142114}
143115
144- export function REANACreateWorkflowSuccess ( data ) {
116+ export function rerunStartWorkflowSuccess ( data ) {
145117 return {
146- type : REANA_CREATE_WORKFLOW_SUCCESS ,
118+ type : RERUN_START_WORKFLOW_SUCCESS ,
147119 data
148120 } ;
149121}
150122
151- export function REANACreateWorkflowError ( error ) {
123+ export function rerunStartWorkflowError ( error ) {
152124 return {
153- type : REANA_CREATE_WORKFLOW_ERROR ,
125+ type : RERUN_START_WORKFLOW_ERROR ,
154126 error
155127 } ;
156128}
157129
158- export function REANAStartWorkflowRequest ( ) {
130+ export function rerunGetWorkflowsRequest ( ) {
159131 return {
160- type : REANA_START_WORKFLOW_REQUEST
132+ type : RERUN_GET_WORKFLOWS_REQUEST
161133 } ;
162134}
163135
164- export function REANAStartWorkflowSuccess ( data ) {
136+ export function rerunGetWorkflowsSuccess ( data ) {
165137 return {
166- type : REANA_START_WORKFLOW_SUCCESS ,
138+ type : RERUN_GET_WORKFLOWS_SUCCESS ,
167139 data
168140 } ;
169141}
170142
171- export function REANAStartWorkflowError ( error ) {
143+ export function rerunGetWorkflowsError ( error ) {
172144 return {
173- type : REANA_START_WORKFLOW_ERROR ,
145+ type : RERUN_GET_WORKFLOWS_ERROR ,
174146 error
175147 } ;
176148}
177149
178- export function REANAGetWorkflowsRequest ( ) {
179- return {
180- type : REANA_GET_WORKFLOWS_REQUEST
181- } ;
182- }
183-
184- export function REANAGetWorkflowsSuccess ( data ) {
185- return {
186- type : REANA_GET_WORKFLOWS_SUCCESS ,
187- data
188- } ;
189- }
190-
191- export function REANAGetWorkflowsError ( error ) {
192- return {
193- type : REANA_GET_WORKFLOWS_ERROR ,
194- error
195- } ;
196- }
197-
198- export function REANACreateWorkflow ( workflow , published_id ) {
199- return dispatch => {
200- dispatch ( REANACreateWorkflowRequest ( ) ) ;
201- let uri = "/api/reana/create" ;
202-
203- axios
204- . post ( uri , {
205- workflow_json : workflow . workflow ,
206- workflow_name : workflow . workflow_title ,
207- record_id : published_id
208- } )
209- . then ( response => {
210- dispatch ( REANACreateWorkflowSuccess ( response . data ) ) ;
211- let { workflow_id } = response . data ;
212- dispatch ( REANAStartWorkflow ( workflow_id ) ) ;
213- dispatch ( push ( `/published/${ published_id } /runs` ) ) ;
214- } )
215- . catch ( error => {
216- dispatch ( REANACreateWorkflowError ( error ) ) ;
217- } ) ;
218- } ;
219- }
220-
221- export function REANAStartWorkflow ( workflow_id ) {
222- return dispatch => {
223- dispatch ( REANAStartWorkflowRequest ( ) ) ;
224- let uri = `/api/reana/start/${ workflow_id } ` ;
225-
226- axios
227- . get ( uri )
228- . then ( response => {
229- dispatch ( REANAStartWorkflowSuccess ( response . data ) ) ;
230- } )
231- . catch ( error => {
232- dispatch ( REANAStartWorkflowError ( error ) ) ;
233- } ) ;
234- } ;
235- }
236-
237- export function REANAWorkflowsGet ( published_id ) {
238- return dispatch => {
239- dispatch ( REANAGetWorkflowsRequest ( ) ) ;
240- let uri = `/api/reana/jobs/${ published_id } ` ;
241-
242- axios
243- . get ( uri )
244- . then ( response => {
245- let _jobs = { } ;
246- response . data . map ( job => ( _jobs [ job . params . reana_id ] = job ) ) ;
247- dispatch ( REANAGetWorkflowsSuccess ( _jobs ) ) ;
248- // dispatch(push(`/published/${published_id}/runs`));
249- } )
250- . catch ( error => {
251- dispatch ( REANAGetWorkflowsError ( error ) ) ;
252- } ) ;
253- } ;
254- }
255-
256150export function getPublished ( ) {
257151 return dispatch => {
258152 dispatch ( publishedRequest ( ) ) ;
@@ -286,54 +180,76 @@ export function getPublishedItem(id) {
286180 } ;
287181}
288182
289- export function rerunPublished ( workflow_id , pid ) {
183+ export function rerunCreateWorkflow ( workflow , published_id ) {
290184 return dispatch => {
291- dispatch ( rerunPublishedRequest ( ) ) ;
292-
293- let uri = `/api/reana/start/${ workflow_id } ` ;
185+ dispatch ( rerunCreateWorkflowRequest ( ) ) ;
186+ let uri = "/api/reana/create" ;
294187
295188 axios
296- . get ( uri )
189+ . post ( uri , {
190+ workflow_json : workflow . workflow ,
191+ workflow_name : workflow . workflow_title ,
192+ record_id : published_id
193+ } )
297194 . then ( response => {
298- dispatch ( rerunPublishedSuccess ( response . data ) ) ;
299- dispatch ( replace ( `/published/${ pid } /status/${ workflow_id } ` ) ) ;
195+ dispatch ( rerunCreateWorkflowSuccess ( response . data ) ) ;
196+ let { workflow_id } = response . data ;
197+ dispatch ( rerunStartWorkflow ( workflow_id ) ) ;
198+ dispatch ( push ( `/published/${ published_id } /runs` ) ) ;
300199 } )
301200 . catch ( error => {
302- dispatch ( rerunPublishedSuccess ( error ) ) ;
201+ dispatch ( rerunCreateWorkflowError ( error ) ) ;
303202 } ) ;
304203 } ;
305204}
306205
307- export function REANAWorkflowStatus ( workflow_id ) {
206+ export function rerunStartWorkflow ( workflow_id ) {
308207 return dispatch => {
309- dispatch ( rerunStatusRequest ( ) ) ;
310-
311- let uri = `/api/reana/status/${ workflow_id } ` ;
208+ dispatch ( rerunStartWorkflowRequest ( ) ) ;
209+ let uri = `/api/reana/start/${ workflow_id } ` ;
312210
313211 axios
314212 . get ( uri )
315213 . then ( response => {
316- dispatch ( rerunStatusSuccess ( workflow_id , response . data ) ) ;
214+ dispatch ( rerunStartWorkflowSuccess ( response . data ) ) ;
317215 } )
318216 . catch ( error => {
319- dispatch ( rerunStatusError ( error ) ) ;
217+ dispatch ( rerunStartWorkflowError ( error ) ) ;
320218 } ) ;
321219 } ;
322220}
323221
324- export function getAnalysisOutputs ( workflow_id ) {
222+ export function rerunGetWorkflows ( published_id ) {
325223 return dispatch => {
326- dispatch ( rerunOutputsRequest ( ) ) ;
327-
328- let uri = `/api/reana/status/${ workflow_id } /outputs` ;
224+ dispatch ( rerunGetWorkflowsRequest ( ) ) ;
225+ let uri = `/api/reana/jobs/${ published_id } ` ;
329226
330227 axios
331228 . get ( uri )
332229 . then ( response => {
333- dispatch ( rerunOutputsSuccess ( response . data ) ) ;
230+ let _jobs = { } ;
231+ response . data . map ( job => ( _jobs [ job . params . reana_id ] = job ) ) ;
232+ dispatch ( rerunGetWorkflowsSuccess ( _jobs ) ) ;
334233 } )
335234 . catch ( error => {
336- dispatch ( rerunOutputsError ( error ) ) ;
235+ dispatch ( rerunGetWorkflowsError ( error ) ) ;
337236 } ) ;
338237 } ;
339238}
239+
240+ // export function rerunWorkflowStatus(workflow_id) {
241+ // return dispatch => {
242+ // dispatch(rerunStatusRequest());
243+
244+ // let uri = `/api/reana/status/${workflow_id}`;
245+
246+ // axios
247+ // .get(uri)
248+ // .then(response => {
249+ // dispatch(rerunStatusSuccess(workflow_id, response.data));
250+ // })
251+ // .catch(error => {
252+ // dispatch(rerunStatusError(error));
253+ // });
254+ // };
255+ // }
0 commit comments