Skip to content

Commit

Permalink
wfrun2vue - add invoking workflows to service layer, cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jan 30, 2020
1 parent acd0506 commit 114e4bd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
6 changes: 6 additions & 0 deletions client/galaxy/scripts/components/Workflow/Run/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as WorkflowRun } from "./WorkflowRun";

// Utilities used outside this component directory by tool-form-composite.
export { isDataStep } from "./model";

export { invokeWorkflow } from "./services";
11 changes: 11 additions & 0 deletions client/galaxy/scripts/components/Workflow/Run/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ export async function getRunData(workflowId) {
rethrowSimple(e);
}
}

/**
* Invoke the specified workflow using the supplied data.
*
* @param {String} workflowId - (Stored?) Workflow ID to fetch data for.
*/
export async function invokeWorkflow(workflowId, invocationData) {
const url = `${getAppRoot()}api/workflows/${workflowId}/invocations`;
const response = await axios.post(url, invocationData);
return response.data;
}
29 changes: 13 additions & 16 deletions client/galaxy/scripts/mvc/tool/tool-form-composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _l from "utils/localization";
import Utils from "utils/utils";
import Deferred from "utils/deferred";
import Form from "mvc/form/form-view";
import { isDataStep } from "components/Workflow/Run/model";
import { isDataStep, invokeWorkflow } from "components/Workflow/Run";

import ToolFormBase from "mvc/tool/tool-form-base";
import Modal from "mvc/ui/ui-modal";
Expand Down Expand Up @@ -377,19 +377,19 @@ var View = Backbone.View.extend({
Galaxy.emit.debug("tool-form-composite::submit()", "Validation failed.", job_def);
} else {
Galaxy.emit.debug("tool-form-composite::submit()", "Validation complete.", job_def);
Utils.request({
type: "POST",
url: `${getAppRoot()}api/workflows/${this.runWorkflowModel.workflowId}/invocations`,
data: job_def,
success: response => {
Galaxy.emit.debug("tool-form-composite::submit", "Submission successful.", response);
if ($.isArray(response) && response.length > 0) {
this.handleInvocations(response);
invokeWorkflow(this.runWorkflowModel.workflowId, job_def)
.then(invocations => {
Galaxy.emit.debug("tool-form-composite::submit", "Submission successful.", invocations);
if ($.isArray(invocations) && invocations.length > 0) {
this.handleInvocations(invocations);
} else {
this.submissionErrorModal(job_def, response);
this.submissionErrorModal(job_def, invocations);
}
},
error: response => {
this._enabled(true);
})
.catch(response => {
// TODO: Is this the same response as the Utils post would
// have had?
Galaxy.emit.debug("tool-form-composite::submit", "Submission failed.", response);
var input_found = false;
if (response && response.err_data) {
Expand All @@ -409,11 +409,8 @@ var View = Backbone.View.extend({
if (!input_found) {
this.submissionErrorModal(job_def, response);
}
},
complete: () => {
this._enabled(true);
}
});
});
}
},

Expand Down

0 comments on commit 114e4bd

Please sign in to comment.