Skip to content

Commit 9baa6c7

Browse files
committed
Add legacy submission
1 parent b1a5d29 commit 9baa6c7

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

client/src/components/Tool/ToolForm.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,23 @@ export default {
450450
}
451451
452452
const nJobs = jobResponse.jobs ? jobResponse.jobs.length : 0;
453-
if (nJobs > 0) {
453+
const nErrors = jobResponse.errors?.length || 0;
454+
if (nJobs > 0 && nErrors === 0) {
454455
this.showForm = false;
455456
this.saveLatestResponse({
456457
jobDef,
457458
jobResponse,
458459
toolName: this.toolName,
459460
});
461+
} else if (nErrors > 0) {
462+
this.showError = true;
463+
this.showForm = true;
464+
this.errorTitle =
465+
nJobs > 0
466+
? `Job submission for ${nErrors} out of ${nJobs + nErrors} jobs failed.`
467+
: "Job submission rejected.";
468+
this.errorContent = jobResponse.errors;
469+
return;
460470
}
461471
462472
if (prevRoute === this.$route.fullPath) {
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
export { submitToolJob } from "./submitAsync";
1+
import { useConfigStore } from "@/stores/configurationStore";
2+
3+
import { submitToolJob as submitAsync } from "./submitAsync";
4+
import { submitToolJob as submitLegacy } from "./submitLegacy";
5+
6+
export async function submitToolJob(params) {
7+
const configStore = useConfigStore();
8+
if (configStore.config?.enable_celery_tasks) {
9+
return submitAsync(params);
10+
}
11+
return submitLegacy(params);
12+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import axios from "axios";
2+
3+
import { getAppRoot } from "@/onload/loadConfig";
4+
5+
export async function submitToolJob({ jobDef, formData }) {
6+
const legacyPayload = toLegacyPayload(jobDef, formData);
7+
const { data } = await axios.post(`${getAppRoot()}api/tools`, legacyPayload);
8+
return data;
9+
}
10+
11+
function toLegacyPayload(jobDef, formData) {
12+
const inputs = { ...formData };
13+
if (jobDef.send_email_notification) {
14+
inputs["send_email_notification"] = true;
15+
}
16+
if (jobDef.rerun_remap_job_id !== undefined) {
17+
inputs["rerun_remap_job_id"] = jobDef.rerun_remap_job_id;
18+
}
19+
if (jobDef.use_cached_jobs) {
20+
inputs["use_cached_job"] = true;
21+
}
22+
const payload = {
23+
tool_id: jobDef.tool_id,
24+
tool_uuid: jobDef.tool_uuid,
25+
tool_version: jobDef.tool_version,
26+
history_id: jobDef.history_id,
27+
inputs,
28+
};
29+
if (jobDef.tags?.length) {
30+
payload.__tags = jobDef.tags;
31+
}
32+
if (jobDef.preferred_object_store_id) {
33+
payload.preferred_object_store_id = jobDef.preferred_object_store_id;
34+
}
35+
if (jobDef.data_manager_mode) {
36+
payload.data_manager_mode = jobDef.data_manager_mode;
37+
}
38+
if (jobDef.credentials_context) {
39+
payload.credentials_context = jobDef.credentials_context;
40+
}
41+
return payload;
42+
}

0 commit comments

Comments
 (0)