Remove jobId from ToolForm success page

This commit is contained in:
Ahmed Awan
2023-02-03 01:53:26 +05:00
parent c8c6026871
commit b7ce288e87
6 changed files with 67 additions and 77 deletions
+3 -4
View File
@@ -229,7 +229,7 @@ export default {
});
},
methods: {
...mapActions(useJobStore, ["saveResponseForJobId"]),
...mapActions(useJobStore, ["saveLatestResponse"]),
emailAllowed(config, user) {
return config.server_mail_configured && !user.isAnonymous;
},
@@ -325,14 +325,13 @@ export default {
this.showForm = false;
this.jobDef = jobDef;
this.jobResponse = jobResponse;
const refJobId = this.jobResponse.jobs[0].id;
const response = {
jobDef: this.jobDef,
jobResponse: this.jobResponse,
toolName: this.toolName,
};
this.saveResponseForJobId(refJobId, response);
this.$router.push(`/jobs/${refJobId}/success`);
this.saveLatestResponse(response);
this.$router.push(`/jobs/submission/success`);
} else {
this.showError = true;
this.showForm = true;
+8 -34
View File
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { computed, onMounted } from "vue";
import type { ComputedRef } from "vue";
import { useJobStore } from "@/stores/jobStore";
import { useRouter } from "vue-router/composables";
import { getGalaxyInstance } from "@/app";
@@ -12,44 +11,19 @@ import Webhook from "@/components/Common/Webhook.vue";
const jobStore = useJobStore();
const router = useRouter();
/* interfaces */
interface Job {
id: string;
}
interface JobDef {
tool_id: string;
}
interface JobResponse {
produces_entry_points: boolean;
jobs: Array<Job>;
}
interface ResponseVal {
jobDef: JobDef;
jobResponse: JobResponse;
toolName: string;
}
/* props */
const props = defineProps({
jobId: {
type: String,
required: true,
},
});
const responseVal: ComputedRef<ResponseVal> = computed(() => jobStore.getResponseForJobId(props.jobId));
const responseVal = computed(() => jobStore.getLatestResponse);
/* lifecyle */
onMounted(() => {
// no response means no tool produced this job in this session (nothing in store)
if (!responseVal.value) {
router.push(`/jobs/${props.jobId}/view`);
// no response means no ToolForm ran in this session (nothing in store)
if (Object.keys(responseVal.value).length === 0) {
router.push(`/`);
}
});
const jobDef: ComputedRef<JobDef> = computed(() => responseVal.value.jobDef);
const jobResponse: ComputedRef<JobResponse> = computed(() => responseVal.value.jobResponse);
const toolName: ComputedRef<string> = computed(() => responseVal.value.toolName);
const jobDef = computed(() => responseVal.value.jobDef);
const jobResponse = computed(() => responseVal.value.jobResponse);
const toolName = computed(() => responseVal.value.toolName);
// getGalaxyInstance is not reactive
const configEnableRecommendations = getGalaxyInstance().config.enable_tool_recommendations;
@@ -57,7 +31,7 @@ const showRecommendation: boolean = [true, "true"].includes(configEnableRecommen
</script>
<template>
<section v-if="responseVal">
<section v-if="jobResponse && jobDef">
<div v-if="jobResponse.produces_entry_points">
<ToolEntryPoints v-for="job in jobResponse.jobs" :key="job.id" :job-id="job.id" />
</div>
+1 -1
View File
@@ -254,7 +254,7 @@ export function getRouter(Galaxy) {
component: InteractiveTools,
},
{
path: "jobs/:jobId/success",
path: "jobs/submission/success",
component: ToolSuccess,
props: true,
},
-37
View File
@@ -1,37 +0,0 @@
/**
* Requests jobs
* Requests response generated by a tool run
*/
import { defineStore } from "pinia";
import Vue from "vue";
import { getAppRoot } from "onload/loadConfig";
import axios from "axios";
export const useJobStore = defineStore("jobStore", {
state: () => ({
job: {},
responses: {},
}),
getters: {
getJob: (state) => {
return (jobId) => state.job[jobId];
},
getResponseForJobId: (state) => {
return (jobId) => state.responses[jobId];
},
},
actions: {
async fetchJob(jobId) {
const { data } = await axios.get(`${getAppRoot()}api/jobs/${jobId}?full=true`);
this.saveJobForJobId(jobId, data);
},
// Setters
saveJobForJobId(jobId, job) {
Vue.set(this.job, jobId, job);
},
saveResponseForJobId(jobId, response) {
Vue.set(this.responses, jobId, response);
},
},
});
+54
View File
@@ -0,0 +1,54 @@
/**
* Requests jobs
* Requests response generated by a tool run
*/
import { defineStore } from "pinia";
import Vue from "vue";
import { getAppRoot } from "@/onload/loadConfig";
import axios from "axios";
/* interfaces */
interface Job {
id: string;
}
interface JobDef {
tool_id: string;
}
interface JobResponse {
produces_entry_points: boolean;
jobs: Array<Job>;
}
interface ResponseVal {
jobDef: JobDef;
jobResponse: JobResponse;
toolName: string;
}
export const useJobStore = defineStore("jobStore", {
state: () => ({
jobs: {} as { [index: string]: Job },
response: {} as ResponseVal,
}),
getters: {
getJob: (state) => {
return (jobId: string) => state.jobs[jobId];
},
getLatestResponse: (state) => {
return state.response;
},
},
actions: {
async fetchJob(jobId: string) {
const { data } = await axios.get(`${getAppRoot()}api/jobs/${jobId}?full=true`);
this.saveJobForJobId(jobId, data);
},
// Setters
saveJobForJobId(jobId: string, job: Job) {
Vue.set(this.jobs, jobId, job);
},
saveLatestResponse(response: ResponseVal) {
this.response = response;
},
},
});
+1 -1
View File
@@ -251,7 +251,7 @@ def app_pair(global_conf, load_app_kwds=None, wsgi_preflight=True, **kwargs):
webapp.add_client_route("/datasets/{dataset_id}/preview")
webapp.add_client_route("/datasets/{dataset_id}/show_params")
webapp.add_client_route("/collection/{collection_id}/edit")
webapp.add_client_route("/jobs/{job_id}/success")
webapp.add_client_route("/jobs/submission/success")
webapp.add_client_route("/jobs/{job_id}/view")
webapp.add_client_route("/workflows/list")
webapp.add_client_route("/workflows/list_published")