mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Merge pull request #10619 from OlegZharkov/trs-auto-import
auto-import workflow with trs
This commit is contained in:
@@ -1,22 +1,29 @@
|
||||
<template>
|
||||
<b-card title="GA4GH Tool Registry Server (TRS) Workflow Import">
|
||||
<b-alert :show="hasErrorMessage" variant="danger">{{ errorMessage }}</b-alert>
|
||||
<div>
|
||||
<b>TRS Server:</b>
|
||||
<TrsServerSelection
|
||||
:query-trs-server="queryTrsServer"
|
||||
:query-trs-id="queryTrsId"
|
||||
@onTrsSelection="onTrsSelection"
|
||||
@onError="onTrsSelectionError"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<b>TRS ID:</b>
|
||||
<b-form-input v-model="toolId" />
|
||||
</div>
|
||||
|
||||
<trs-tool :trs-tool="trsTool" v-if="trsTool != null" @onImport="importVersion(trsTool.id, $event)" />
|
||||
</b-card>
|
||||
<div>
|
||||
<b-card title="GA4GH Tool Registry Server (TRS) Workflow Import">
|
||||
<b-alert :show="hasErrorMessage" variant="danger">{{ errorMessage }}</b-alert>
|
||||
<div>
|
||||
<b>TRS Server:</b>
|
||||
<TrsServerSelection
|
||||
:query-trs-server="queryTrsServer"
|
||||
:query-trs-id="queryTrsId"
|
||||
@onTrsSelection="onTrsSelection"
|
||||
@onError="onTrsSelectionError"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isAutoImport" class="text-center my-2">
|
||||
<b-spinner class="align-middle"></b-spinner>
|
||||
<strong>Loading your Workflow...</strong>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div>
|
||||
<b>TRS ID:</b>
|
||||
<b-form-input v-model="toolId" />
|
||||
</div>
|
||||
<trs-tool :trs-tool="trsTool" v-if="trsTool" @onImport="importVersion(trsTool.id, $event)" />
|
||||
</div>
|
||||
</b-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -24,6 +31,7 @@ import Vue from "vue";
|
||||
import BootstrapVue from "bootstrap-vue";
|
||||
import { Services } from "./services";
|
||||
import TrsMixin from "./trsMixin";
|
||||
import { Toast } from "ui/toast";
|
||||
|
||||
Vue.use(BootstrapVue);
|
||||
|
||||
@@ -38,6 +46,14 @@ export default {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
queryTrsVersionId: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
isRun: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.services = new Services();
|
||||
@@ -49,6 +65,7 @@ export default {
|
||||
toolId: null,
|
||||
trsTool: null,
|
||||
errorMessage: null,
|
||||
isAutoImport: this.queryTrsVersionId && this.queryTrsServer && this.queryTrsId,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -80,6 +97,15 @@ export default {
|
||||
.then((tool) => {
|
||||
this.trsTool = tool;
|
||||
this.errorMessage = null;
|
||||
if (this.isAutoImport) {
|
||||
const version = this.trsTool.versions.find((version) => version.id === this.queryTrsVersionId);
|
||||
if (version) {
|
||||
this.importVersion(this.trsTool.id, version, this.isRun);
|
||||
} else {
|
||||
Toast.warning(`Specified version: ${this.queryTrsVersionId} doesn't exist`);
|
||||
this.isAutoImport = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((errorMessage) => {
|
||||
this.trsTool = null;
|
||||
|
||||
@@ -31,6 +31,7 @@ import { getGalaxyInstance } from "app";
|
||||
import axios from "axios";
|
||||
import Vue from "vue";
|
||||
import BootstrapVue from "bootstrap-vue";
|
||||
import { redirectOnImport } from "./utils";
|
||||
|
||||
Vue.use(BootstrapVue);
|
||||
|
||||
@@ -67,9 +68,7 @@ export default {
|
||||
axios
|
||||
.post(`${getAppRoot()}api/workflows`, formData)
|
||||
.then((response) => {
|
||||
window.location = `${getAppRoot()}workflows/list?message=${
|
||||
response.data.message
|
||||
}&status=success`;
|
||||
redirectOnImport(getAppRoot(), response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
const message = error.response.data && error.response.data.err_msg;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
import TrsServerSelection from "./TrsServerSelection";
|
||||
import TrsTool from "./TrsTool";
|
||||
import { redirectOnImport } from "./utils";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -8,12 +9,11 @@ export default {
|
||||
TrsTool,
|
||||
},
|
||||
methods: {
|
||||
importVersion(toolId, version) {
|
||||
importVersion(toolId, version, isRunFormRedirect = false) {
|
||||
this.services
|
||||
.importTrsTool(this.trsSelection.id, toolId, version.name)
|
||||
.then((response_data) => {
|
||||
// copied from the WorkflowImport, de-duplicate somehow
|
||||
window.location = `${getAppRoot()}workflows/list?message=${response_data.message}&status=success`;
|
||||
redirectOnImport(getAppRoot(), response_data, isRunFormRedirect);
|
||||
})
|
||||
.catch((errorMessage) => {
|
||||
this.errorMessage = errorMessage || "Import failed for an unknown reason.";
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export function redirectOnImport(appRoot, response, isRunFormRedirect = false) {
|
||||
isRunFormRedirect
|
||||
? (window.location = `${appRoot}workflows/run?id=${response.id}`)
|
||||
: (window.location = `${appRoot}workflows/list?message=${response.message}&status=success`);
|
||||
}
|
||||
@@ -342,9 +342,13 @@ export const getAnalysisRouter = (Galaxy) =>
|
||||
show_workflows_trs_import: function () {
|
||||
const queryTrsServer = QueryStringParsing.get("trs_server");
|
||||
const queryTrsId = QueryStringParsing.get("trs_id");
|
||||
const queryTrsVersionId = QueryStringParsing.get("trs_version");
|
||||
const isRun = QueryStringParsing.get("run_form") === "true";
|
||||
const propsData = {
|
||||
queryTrsServer,
|
||||
queryTrsId,
|
||||
queryTrsVersionId,
|
||||
isRun,
|
||||
};
|
||||
this._display_vue_helper(TrsImport, propsData);
|
||||
},
|
||||
|
||||
@@ -678,14 +678,21 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
|
||||
raise exceptions.MessageException("The data content is missing.")
|
||||
raw_workflow_description = self.__normalize_workflow(trans, data)
|
||||
workflow, missing_tool_tups = self._workflow_from_dict(trans, raw_workflow_description, source=source)
|
||||
workflow_id = workflow.id
|
||||
workflow = workflow.latest_workflow
|
||||
|
||||
response = {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success",
|
||||
"id": trans.security.encode_id(workflow_id)}
|
||||
if workflow.has_errors:
|
||||
return {"message": "Imported, but some steps in this workflow have validation errors.", "status": "error"}
|
||||
response["message"] = "Imported, but some steps in this workflow have validation errors."
|
||||
response["status"] = "error"
|
||||
elif len(workflow.steps) == 0:
|
||||
return {"message": "Imported, but this workflow has no steps.", "status": "error"}
|
||||
response["message"] = "Imported, but this workflow has no steps."
|
||||
response["status"] = "error"
|
||||
elif workflow.has_cycles:
|
||||
return {"message": "Imported, but this workflow contains cycles.", "status": "error"}
|
||||
return {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success"}
|
||||
response["message"] = "Imported, but this workflow contains cycles."
|
||||
response["status"] = "error"
|
||||
return response
|
||||
|
||||
def __api_import_new_workflow(self, trans, payload, **kwd):
|
||||
data = payload['workflow']
|
||||
|
||||
Reference in New Issue
Block a user