commit/galaxy-central: guerler: Connect upload front end to upload tool via tools api
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/60a1b0fdccd2/ Changeset: 60a1b0fdccd2 User: guerler Date: 2013-10-10 20:41:47 Summary: Connect upload front end to upload tool via tools api Affected #: 3 files diff -r ab9f5cb3acd8dcfe30fc5b92fc4a792c9815c877 -r 60a1b0fdccd252c406d8b92ab60005456afe6e7c lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -214,69 +214,6 @@ trans.sa_session.flush() return hda.to_dict() - # copy from upload - if source == 'upload': - - # get upload specific features - dbkey = payload.get('dbkey', None) - extension = payload.get('extension', None) - space_to_tabs = payload.get('space_to_tabs', False) - - # check for filename - if content.filename is None: - trans.response.status = 400 - return "history_contents:create() : The contents parameter needs to contain the uploaded file content." - - # create a dataset - dataset = trans.app.model.Dataset() - trans.sa_session.add(dataset) - trans.sa_session.flush() - - # get file destination - file_destination = dataset.get_file_name() - - # check if the directory exists - dn = os.path.dirname(file_destination) - if not os.path.exists(dn): - os.makedirs(dn) - - # get file and directory names - fn = os.path.basename(content.filename) - - # save file locally - open(file_destination, 'wb').write(content.file.read()) - - # log - log.info ('The file "' + fn + '" was uploaded successfully.') - - # replace separation with tabs - if space_to_tabs: - log.info ('Replacing spaces with tabs.') - sniff.convert_newlines_sep2tabs(file_destination) - - # guess extension - if extension is None: - log.info ('Guessing extension.') - extension = sniff.guess_ext(file_destination) - - # create hda - hda = trans.app.model.HistoryDatasetAssociation(dataset = dataset, name = content.filename, - extension = extension, dbkey = dbkey, history = history, sa_session = trans.sa_session) - - # add status ok - hda.state = hda.states.OK - - # add dataset to history - history.add_dataset(hda, genome_build = dbkey) - permissions = trans.app.security_agent.history_get_default_permissions( history ) - trans.app.security_agent.set_all_dataset_permissions( hda.dataset, permissions ) - - # add to session - trans.sa_session.add(hda) - trans.sa_session.flush() - - # get name - return hda.to_dict() else: # other options trans.response.status = 501 diff -r ab9f5cb3acd8dcfe30fc5b92fc4a792c9815c877 -r 60a1b0fdccd252c406d8b92ab60005456afe6e7c static/scripts/galaxy.modal.js --- a/static/scripts/galaxy.modal.js +++ b/static/scripts/galaxy.modal.js @@ -38,10 +38,12 @@ this.$body.css('max-height', maxHeight); // fix height if available - if (this.options.height < maxHeight) - this.$body.css('height', this.options.height); - else - this.$body.css('height', maxHeight); + if (this.options.height) { + if (this.options.height < maxHeight) + this.$body.css('height', this.options.height); + else + this.$body.css('height', maxHeight); + } // remove scroll bar if (this.options.height) diff -r ab9f5cb3acd8dcfe30fc5b92fc4a792c9815c877 -r 60a1b0fdccd252c406d8b92ab60005456afe6e7c static/scripts/galaxy.upload.js --- a/static/scripts/galaxy.upload.js +++ b/static/scripts/galaxy.upload.js @@ -19,9 +19,7 @@ // extension types select_extension : { - 'auto' : 'Auto-detect', - 'bed' : 'bed', - 'ab1' : 'ab1' + 'auto' : 'Auto-detect' }, // states @@ -134,18 +132,31 @@ // get element var it = this.get_upload_item(index); + + // get current history + var current_history = Galaxy.currHistoryPanel.model.get('id'); - // read in configuration - var data = { - source : "upload", - space_to_tabs : it.find('#space_to_tabs').is(':checked'), - extension : it.find('#extension').val() - } + // configure tool + this.uploadbox.configure({url : galaxy_config.root + "api/tools/", paramname : "files_0|file_data"}); - // configure url - var current_history = Galaxy.currHistoryPanel.model.get('id'); - this.uploadbox.configure({url : galaxy_config.root + "api/histories/" + current_history + "/contents"}); + // get + var file_type = it.find('#extension').val(); + var space_to_tabs = it.find('#space_to_tabs').is(':checked'); + // configure tool + tool_input = {}; + tool_input['dbkey'] = '?'; + tool_input['file_type'] = file_type; + tool_input['files_0|NAME'] = file.name; + tool_input['files_0|type'] = 'upload_dataset'; + tool_input['space_to_tabs'] = space_to_tabs; + + // setup data + data = {}; + data['history_id'] = current_history; + data['tool_id'] = 'upload1'; + data['inputs'] = JSON.stringify(tool_input); + // return additional data to be send with file return data; }, Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org