mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #4993 from guerler/replace_history_import
Replace history import form
This commit is contained in:
@@ -13,6 +13,7 @@ import Tours from "mvc/tours";
|
||||
import GridView from "mvc/grid/grid-view";
|
||||
import GridShared from "mvc/grid/grid-shared";
|
||||
import Workflows from "mvc/workflow/workflow";
|
||||
import HistoryImport from "components/history-import.vue";
|
||||
import HistoryList from "mvc/history/history-list";
|
||||
import ToolFormComposite from "mvc/tool/tool-form-composite";
|
||||
import QueryStringParsing from "utils/query-string-parsing";
|
||||
@@ -58,6 +59,7 @@ window.app = function app(options, bootstrapped) {
|
||||
"(/)workflows/create(/)": "show_workflows_create",
|
||||
"(/)histories(/)citations(/)": "show_history_citations",
|
||||
"(/)histories(/)rename(/)": "show_histories_rename",
|
||||
"(/)histories(/)import(/)": "show_histories_import",
|
||||
"(/)histories(/)permissions(/)": "show_histories_permissions",
|
||||
"(/)histories(/)(:action_id)": "show_histories",
|
||||
"(/)datasets(/)list(/)": "show_datasets",
|
||||
@@ -139,6 +141,13 @@ window.app = function app(options, bootstrapped) {
|
||||
);
|
||||
},
|
||||
|
||||
show_histories_import: function() {
|
||||
var historyImportInstance = Vue.extend(HistoryImport);
|
||||
var vm = document.createElement("div");
|
||||
this.page.display(vm);
|
||||
new historyImportInstance().$mount(vm);
|
||||
},
|
||||
|
||||
show_histories_permissions: function() {
|
||||
this.page.display(
|
||||
new FormWrapper.View({
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<div class="ui-portlet-limited">
|
||||
<div class="portlet-header">
|
||||
<div class="portlet-title">
|
||||
<i class="portlet-title-icon fa fa-upload"></i>
|
||||
<span class="portlet-title-text"><b>Import a History from an Archive</b></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-content">
|
||||
<div v-if="errormessage" class="ui-message alert alert-danger">
|
||||
{{ errormessage }}
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
<form ref="form">
|
||||
<div class="ui-form-element">
|
||||
<div class="ui-form-title">Archived History URL</div>
|
||||
<input class="ui-input" type="text" name="archive_source"/>
|
||||
</div>
|
||||
<div class="ui-form-element">
|
||||
<div class="ui-form-title">Archived History file</div>
|
||||
<input type="file" name="archive_file"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="portlet-buttons">
|
||||
<input class="btn btn-primary" type="button" value="Import History" @click="submit"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
errormessage: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit: function() {
|
||||
$.ajax({
|
||||
url: `${Galaxy.root}api/histories`,
|
||||
data: new FormData(this.$refs.form),
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
method: "POST"
|
||||
})
|
||||
.done(response => {
|
||||
window.location = `${Galaxy.root}histories/list?message=${response.message}&status=success`
|
||||
})
|
||||
.fail(response => {
|
||||
let message = response.responseJSON && response.responseJSON.err_msg;
|
||||
this.errormessage = message || "Import failed for unkown reason.";
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.ui-message {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -169,7 +169,8 @@ var menu = [
|
||||
},
|
||||
{
|
||||
html: _l("Import from File"),
|
||||
href: "history/import_archive"
|
||||
href: "histories/import",
|
||||
target: "_top"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@
|
||||
position: relative;
|
||||
clear: both;
|
||||
width: auto;
|
||||
height: 100%;
|
||||
height: auto;
|
||||
.portlet-header {
|
||||
background: @form-heading-bg;
|
||||
border-bottom: solid @form-border 1px;
|
||||
@@ -550,8 +550,8 @@
|
||||
width : 100%;
|
||||
}
|
||||
.portlet-buttons {
|
||||
margin-top: @ui-margin-vertical;
|
||||
margin-bottom: @ui-margin-vertical;
|
||||
margin-top: @ui-margin-vertical-large;
|
||||
margin-bottom: @ui-margin-vertical-large;
|
||||
> .btn {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<tool id="__IMPORT_HISTORY__" name="Import History" version="0.1" tool_type="import_history">
|
||||
<type class="ImportHistoryTool" module="galaxy.tools"/>
|
||||
<action module="galaxy.tools.actions.history_imp_exp" class="ImportHistoryToolAction"/>
|
||||
<command interpreter="python">unpack_tar_gz_archive.py "${ str( $__ARCHIVE_SOURCE__ ).encode( 'base64' ) }" "${ str( $__DEST_DIR__ ).encode( 'base64' ) }" --$__ARCHIVE_TYPE__ --encoded</command>
|
||||
<command>python '$__tool_directory__/unpack_tar_gz_archive.py' '${ str( $__ARCHIVE_SOURCE__ ).encode( 'base64' ) }' '${ str( $__DEST_DIR__ ).encode( 'base64' ) }' --$__ARCHIVE_TYPE__ --encoded</command>
|
||||
<inputs>
|
||||
<param name="__ARCHIVE_SOURCE__" type="text">
|
||||
<sanitizer sanitize="False"/>
|
||||
|
||||
@@ -49,7 +49,7 @@ def check_archive(archive_file, dest_dir):
|
||||
Ensure that a tar archive has no absolute paths or relative paths outside
|
||||
the archive.
|
||||
"""
|
||||
with tarfile.open(archive_file, mode='r:gz') as archive_fp:
|
||||
with tarfile.open(archive_file, mode='r') as archive_fp:
|
||||
for arc_path in archive_fp.getnames():
|
||||
assert os.path.normpath(
|
||||
os.path.join(
|
||||
@@ -64,7 +64,7 @@ def unpack_archive(archive_file, dest_dir):
|
||||
"""
|
||||
Unpack a tar and/or gzipped archive into a destination directory.
|
||||
"""
|
||||
archive_fp = tarfile.open(archive_file, mode='r:gz')
|
||||
archive_fp = tarfile.open(archive_file, mode='r')
|
||||
archive_fp.extractall(path=dest_dir)
|
||||
archive_fp.close()
|
||||
|
||||
|
||||
@@ -317,9 +317,16 @@ class HistoriesController(BaseAPIController, ExportsHistoryMixin, ImportsHistory
|
||||
|
||||
if "archive_source" in payload:
|
||||
archive_source = payload["archive_source"]
|
||||
archive_type = payload.get("archive_type", "url")
|
||||
archive_file = payload.get("archive_file")
|
||||
if archive_source:
|
||||
archive_type = payload.get("archive_type", "url")
|
||||
elif hasattr(archive_file, "file"):
|
||||
archive_source = payload["archive_file"].file.name
|
||||
archive_type = "file"
|
||||
else:
|
||||
raise exceptions.MessageException("Please provide a url or file.")
|
||||
self.queue_history_import(trans, archive_type=archive_type, archive_source=archive_source)
|
||||
return {}
|
||||
return {"message": "Importing history from source '%s'. This history will be visible when the import is complete." % archive_source}
|
||||
|
||||
new_history = None
|
||||
# if a history id was passed, copy that history
|
||||
|
||||
@@ -115,6 +115,7 @@ def app_factory(global_conf, load_app_kwds={}, **kwargs):
|
||||
webapp.add_client_route('/pages/edit')
|
||||
webapp.add_client_route('/histories/citations')
|
||||
webapp.add_client_route('/histories/list')
|
||||
webapp.add_client_route('/histories/import')
|
||||
webapp.add_client_route('/histories/list_published')
|
||||
webapp.add_client_route('/histories/list_shared')
|
||||
webapp.add_client_route('/histories/rename')
|
||||
|
||||
@@ -1185,33 +1185,6 @@ class HistoryController(BaseUIController, SharableMixin, UsesAnnotations, UsesIt
|
||||
return self.get_ave_item_rating_data(trans.sa_session, history)
|
||||
# TODO: used in display_base.mako
|
||||
|
||||
@web.expose
|
||||
# TODO: Remove require_login when users are warned that, if they are not
|
||||
# logged in, this will remove their current history.
|
||||
@web.require_login("use Galaxy histories")
|
||||
def import_archive(self, trans, **kwargs):
|
||||
""" Import a history from a file archive. """
|
||||
# Set archive source and type.
|
||||
archive_file = kwargs.get('archive_file', None)
|
||||
archive_url = kwargs.get('archive_url', None)
|
||||
archive_source = None
|
||||
if hasattr(archive_file, 'file'):
|
||||
archive_source = archive_file.file.name
|
||||
archive_type = 'file'
|
||||
elif archive_url:
|
||||
archive_source = archive_url
|
||||
archive_type = 'url'
|
||||
# If no source to create archive from, show form to upload archive or specify URL.
|
||||
if not archive_source:
|
||||
form = web.FormBuilder(web.url_for(controller='history', action='import_archive'), "Import a History from an Archive", submit_text="Submit")
|
||||
form.add_input("text", "Archived History URL", "archive_url", value="", error=None)
|
||||
form.add_input("file", "Archived History File", "archive_file", value="", error=None)
|
||||
return trans.show_form(form)
|
||||
self.queue_history_import(trans, archive_type=archive_type, archive_source=archive_source)
|
||||
return trans.show_message("Importing history from '%s'. \
|
||||
This history will be visible when the import is complete" % archive_source)
|
||||
# TODO: used in this file and index.mako
|
||||
|
||||
@web.expose
|
||||
def export_archive(self, trans, id=None, gzip=True, include_hidden=False, include_deleted=False, preview=False):
|
||||
""" Export a history to an archive. """
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
define("mvc/history/options-menu",["exports","mvc/ui/popup-menu","mvc/history/copy-dialog","mvc/base-mvc","utils/localization","mvc/webhooks"],function(e,t,a,r,l,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e,t,a){return _.clone(y).filter(function(r){return!(e&&!r.anon)&&(!(!t&&r.purge)&&(r.href&&(r.href=a+r.href,r.target=r.target||"galaxy_main"),r.confirm&&(r.func=function(){confirm(r.confirm)&&(galaxy_main.location=r.href)}),!0))})}Object.defineProperty(e,"__esModule",{value:!0});var i=n(t),s=n(a),d=(n(r),n(l)),f=n(o),y=[{html:(0,d.default)("History Lists"),header:!0},{html:(0,d.default)("Saved Histories"),href:"histories/list",target:"_top"},{html:(0,d.default)("Histories Shared with Me"),href:"histories/list_shared",target:"_top"},{html:(0,d.default)("Current History"),header:!0,anon:!0},{html:(0,d.default)("Create New"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.createNewHistory()}},{html:(0,d.default)("Copy History"),func:function(){(0,s.default)(Galaxy.currHistoryPanel.model).done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Share or Publish"),href:"history/sharing"},{html:(0,d.default)("Show Structure"),href:"history/display_structured",anon:!0},{html:(0,d.default)("Extract Workflow"),href:"workflow/build_from_current_history"},{html:(0,d.default)("Delete"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete the current history?"))&&Galaxy.currHistoryPanel.model._delete().done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Delete Permanently"),purge:!0,anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete the current history permanently? This cannot be undone."))&&Galaxy.currHistoryPanel.model.purge().done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Dataset Actions"),header:!0,anon:!0},{html:(0,d.default)("Copy Datasets"),href:"dataset/copy_datasets"},{html:(0,d.default)("Dataset Security"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.router&&Galaxy.router.push("/histories/permissions?id="+Galaxy.currHistoryPanel.model.id)}},{html:(0,d.default)("Resume Paused Jobs"),href:"history/resume_paused_jobs?current=True",anon:!0},{html:(0,d.default)("Collapse Expanded Datasets"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.collapseAll()}},{html:(0,d.default)("Unhide Hidden Datasets"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really unhide all hidden datasets?"))&&$.post(Galaxy.root+"history/adjust_hidden",{user_action:"unhide"},function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Delete Hidden Datasets"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete all hidden datasets?"))&&$.post(Galaxy.root+"history/adjust_hidden",{user_action:"delete"},function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Purge Deleted Datasets"),confirm:(0,d.default)("Really delete all deleted datasets permanently? This cannot be undone."),href:"history/purge_deleted_datasets",purge:!0,anon:!0},{html:(0,d.default)("Downloads"),header:!0},{html:(0,d.default)("Export Tool Citations"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.router&&Galaxy.router.push("/histories/citations?id="+Galaxy.currHistoryPanel.model.id)}},{html:(0,d.default)("Export History to File"),href:"history/export_archive?preview=True",anon:!0},{html:(0,d.default)("Other Actions"),header:!0},{html:(0,d.default)("Import from File"),href:"history/import_archive"}];f.default.add({url:"api/webhooks/history-menu/all",async:!1,callback:function(e){var t=[];$.each(e.models,function(e,a){var r=a.toJSON();r.activate&&t.push({html:(0,d.default)(r.config.title),anon:!0})}),t.length>0&&(t.unshift({html:(0,d.default)("Webhooks"),header:!0}),$.merge(y,t))}});e.default=function(e,t){var a=u(void 0===(t=t||{}).anonymous||t.anonymous,t.purgeAllowed||!1,Galaxy.root);return new i.default(e,a)}});
|
||||
define("mvc/history/options-menu",["exports","mvc/ui/popup-menu","mvc/history/copy-dialog","mvc/base-mvc","utils/localization","mvc/webhooks"],function(e,t,a,r,l,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e,t,a){return _.clone(y).filter(function(r){return!(e&&!r.anon)&&(!(!t&&r.purge)&&(r.href&&(r.href=a+r.href,r.target=r.target||"galaxy_main"),r.confirm&&(r.func=function(){confirm(r.confirm)&&(galaxy_main.location=r.href)}),!0))})}Object.defineProperty(e,"__esModule",{value:!0});var i=n(t),s=n(a),d=(n(r),n(l)),f=n(o),y=[{html:(0,d.default)("History Lists"),header:!0},{html:(0,d.default)("Saved Histories"),href:"histories/list",target:"_top"},{html:(0,d.default)("Histories Shared with Me"),href:"histories/list_shared",target:"_top"},{html:(0,d.default)("Current History"),header:!0,anon:!0},{html:(0,d.default)("Create New"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.createNewHistory()}},{html:(0,d.default)("Copy History"),func:function(){(0,s.default)(Galaxy.currHistoryPanel.model).done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Share or Publish"),href:"history/sharing"},{html:(0,d.default)("Show Structure"),href:"history/display_structured",anon:!0},{html:(0,d.default)("Extract Workflow"),href:"workflow/build_from_current_history"},{html:(0,d.default)("Delete"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete the current history?"))&&Galaxy.currHistoryPanel.model._delete().done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Delete Permanently"),purge:!0,anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete the current history permanently? This cannot be undone."))&&Galaxy.currHistoryPanel.model.purge().done(function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Dataset Actions"),header:!0,anon:!0},{html:(0,d.default)("Copy Datasets"),href:"dataset/copy_datasets"},{html:(0,d.default)("Dataset Security"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.router&&Galaxy.router.push("/histories/permissions?id="+Galaxy.currHistoryPanel.model.id)}},{html:(0,d.default)("Resume Paused Jobs"),href:"history/resume_paused_jobs?current=True",anon:!0},{html:(0,d.default)("Collapse Expanded Datasets"),func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.collapseAll()}},{html:(0,d.default)("Unhide Hidden Datasets"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really unhide all hidden datasets?"))&&$.post(Galaxy.root+"history/adjust_hidden",{user_action:"unhide"},function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Delete Hidden Datasets"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&confirm((0,d.default)("Really delete all hidden datasets?"))&&$.post(Galaxy.root+"history/adjust_hidden",{user_action:"delete"},function(){Galaxy.currHistoryPanel.loadCurrentHistory()})}},{html:(0,d.default)("Purge Deleted Datasets"),confirm:(0,d.default)("Really delete all deleted datasets permanently? This cannot be undone."),href:"history/purge_deleted_datasets",purge:!0,anon:!0},{html:(0,d.default)("Downloads"),header:!0},{html:(0,d.default)("Export Tool Citations"),anon:!0,func:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.router&&Galaxy.router.push("/histories/citations?id="+Galaxy.currHistoryPanel.model.id)}},{html:(0,d.default)("Export History to File"),href:"history/export_archive?preview=True",anon:!0},{html:(0,d.default)("Other Actions"),header:!0},{html:(0,d.default)("Import from File"),href:"histories/import",target:"_top"}];f.default.add({url:"api/webhooks/history-menu/all",async:!1,callback:function(e){var t=[];$.each(e.models,function(e,a){var r=a.toJSON();r.activate&&t.push({html:(0,d.default)(r.config.title),anon:!0})}),t.length>0&&(t.unshift({html:(0,d.default)("Webhooks"),header:!0}),$.merge(y,t))}});e.default=function(e,t){var a=u(void 0===(t=t||{}).anonymous||t.anonymous,t.purgeAllowed||!1,Galaxy.root);return new i.default(e,a)}});
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user