commit/galaxy-central: 2 new changesets

2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/c29f651e4acc/ Changeset: c29f651e4acc User: martenson Date: 2014-09-26 19:17:35+00:00 Summary: select2 fixes and impl. of missing feature import from path Affected #: 12 files diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -54,7 +54,12 @@ auto: { id : 'auto', text : 'Auto-detect', - description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + description : 'This system will try to detect the file type automatically.' + + ' If your file is not detected properly as one of the known formats,' + + ' it most likely means that it has some format problems (e.g., different' + + ' number of columns on different rows). You can still coerce the system' + + ' to set your data to the format you think it should be.' + + ' You can also upload compressed files, which will automatically be decompressed.' }, // genomes @@ -73,15 +78,12 @@ id: this.options.id, is_admin: false, is_anonym: true, - user_library_import_dir: Galaxy.config.user_library_import_dir, - allow_library_path_paste: Galaxy.config.allow_library_path_paste, - library_import_dir: Galaxy.config.library_import_dir, mutiple_add_dataset_options: false } if (Galaxy.currUser){ template_defaults.is_admin = Galaxy.currUser.isAdmin(); template_defaults.is_anonym = Galaxy.currUser.isAnonymous(); - if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){ + if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){ template_defaults.mutiple_add_dataset_options = true; } } @@ -402,33 +404,38 @@ // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... var that = this; this.select_genome = new mod_select.View( { - css: 'genome', + css: 'library-genome-select', data: that.list_genomes, - container: Galaxy.modal.$el.find( '#genome' ), + container: Galaxy.modal.$el.find( '#library_genome_select' ), value: '?' } ); this.select_extension = new mod_select.View({ - css: 'extension', + css: 'library-extension-select', data: that.list_extensions, - container: Galaxy.modal.$el.find('#extension'), + container: Galaxy.modal.$el.find( '#library_extension_select' ), value: 'auto' }); }, + /** - * Create modal for importing form user's directory + * Create modal for importing from given directory * on Galaxy. Bind jQuery events. */ - importFilesFromUserdirModal: function(){ + importFilesFromGalaxyFolderModal: function( options ){ var that = this; + var template_modal = this.templateBrowserModal(); this.modal = Galaxy.modal; - var template_modal = this.templateBrowserModal(); this.modal.show({ closing_events : true, title : 'Please select folders or files', body : template_modal({}), buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} + 'Import' : function() { + that.importFromJstreePath( that, options ); + }, + 'Close' : function() { + Galaxy.modal.hide(); + } }, closing_callback: function(){ // TODO: should not trigger routes outside of the router @@ -437,21 +444,24 @@ }); this.renderSelectBoxes(); - this.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + this.renderJstree( options ); - $('input[type=radio]').change(function(event){ + $( 'input[type=radio]' ).change( function( event ){ if (event.target.value ==='jstree-disable-folders') { - that.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + that.renderJstree( options ); $('.jstree-folders-message').hide(); $('.jstree-preserve-structure').hide(); $('.jstree-link-files').hide(); $('.jstree-files-message').show(); - } else if (event.target.value ==='jstree-disable-files'){ + } else if ( event.target.value ==='jstree-disable-files' ){ $('.jstree-files-message').hide(); $('.jstree-folders-message').show(); $('.jstree-link-files').show(); $('.jstree-preserve-structure').show(); - that.renderJstree({disabled_jstree_element: 'files'}); + options.disabled_jstree_element = 'files'; + that.renderJstree( options ); } } ); @@ -463,12 +473,16 @@ * data. * @param {[type]} options [description] */ - renderJstree: function(options){ + renderJstree: function( options ){ var that = this; - this.options = _.extend(this.options, options); + this.options = _.extend( this.options, options ); + var target = options.source || 'userdir'; var disabled_jstree_element = this.options.disabled_jstree_element; this.jstree = new mod_library_model.Jstree(); - this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element; + this.jstree.url = this.jstree.urlRoot + + '?target=' + target + + '&format=jstree' + + '&disable=' + disabled_jstree_element; this.jstree.fetch({ success: function(model, response){ // This is to prevent double jquery load. I think. Carl is magician. @@ -579,7 +593,7 @@ * jstree.js has to be loaded before * @see renderJstree */ - importFromUserdirClicked: function ( that ){ + importFromJstreePath: function ( that, options ){ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); @@ -588,7 +602,7 @@ var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ - mod_toastr.info( 'You must select some items first.' ); + mod_toastr.info( 'Please select some items first.' ); } else { this.modal.disableButton( 'Import' ); for ( var i = selected_nodes.length - 1; i >= 0; i-- ){ @@ -598,17 +612,19 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - + var full_source = options.source + '_folder'; this.chainCallImportingFolders( { paths: paths, preserve_dirs: preserve_dirs, link_data: link_data, - source: 'userdir_folder', + source: full_source, file_type: file_type, dbkey: dbkey } ); } else if ( selection_type === 'file' ){ + var full_source = options.source + '_file'; this.chainCallImportingUserdirFiles( { paths : paths, file_type: file_type, - dbkey: dbkey } ); + dbkey: dbkey, + source: full_source } ); } } }, @@ -713,7 +729,7 @@ return true; } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=userdir_file' + + '&source=' + options.source + '&path=' + popped_item + '&file_type=' + options.file_type + '&dbkey=' + options.dbkey ) ) @@ -760,22 +776,12 @@ '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }); }, @@ -952,12 +958,13 @@ this.addFilesFromHistoryModal(); break; case "importdir": + this.importFilesFromGalaxyFolderModal( { source: 'importdir' } ); break; case "path": this.importFilesFromPathModal(); break; case "userdir": - this.importFilesFromUserdirModal(); + this.importFilesFromGalaxyFolderModal( { source: 'userdir' } ); break; default: Galaxy.libraries.library_router.back(); @@ -984,17 +991,19 @@ tmpl_array.push(' </button>'); tmpl_array.push(' <ul class="dropdown-menu" role="menu">'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>'); - tmpl_array.push('<% if(user_library_import_dir !== null) { %>'); + tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>'); tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); - // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>'); - tmpl_array.push(' <li class="divider"></li>'); - tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); - // tmpl_array.push('<% if(library_import_dir !== null) { %>'); - // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); - // tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); + + tmpl_array.push(' <li class="divider"></li>'); + tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); + + tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>'); + tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); + tmpl_array.push('<% } %>'); + + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>'); tmpl_array.push('<% } %>'); tmpl_array.push('<% } %>'); @@ -1154,8 +1163,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1184,8 +1193,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb client/galaxy/scripts/mvc/ui/ui-select.js --- a/client/galaxy/scripts/mvc/ui/ui-select.js +++ b/client/galaxy/scripts/mvc/ui/ui-select.js @@ -155,7 +155,6 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, - width : 'resolve', dropdownAutoWidth : true }; this.$el.select2(select_opt); diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb lib/galaxy/webapps/galaxy/api/ftp_files.py --- a/lib/galaxy/webapps/galaxy/api/ftp_files.py +++ b/lib/galaxy/webapps/galaxy/api/ftp_files.py @@ -49,7 +49,7 @@ userdir_jstree = self.__create_jstree( full_import_dir, disable ) response = userdir_jstree.jsonData() except Exception, exception: - log.debug(str(exception)) + log.debug( str( exception ) ) raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( full_import_dir ) ) elif format == 'ajax': raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' ) @@ -61,6 +61,26 @@ raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' ) else: raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' ) + elif target == 'importdir': + base_dir = trans.app.config.library_import_dir + if base_dir is None: + raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow usage of import directory.' ) + if format == 'jstree': + disable = kwd.get( 'disable', 'folders') + try: + importdir_jstree = self.__create_jstree( base_dir, disable ) + response = importdir_jstree.jsonData() + except Exception, exception: + log.debug( str( exception ) ) + raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( base_dir ) ) + elif format == 'ajax': + raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' ) + else: + try: + response = self.__load_all_filenames( base_dir ) + except Exception, exception: + log.error( 'Could not get user import files: %s', str( exception ), exc_info=True ) + raise exceptions.InternalServerError( 'Could not get the files from your import directory folder.' ) else: user_ftp_base_dir = trans.app.config.ftp_upload_dir if user_ftp_base_dir is None: diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb lib/galaxy/webapps/galaxy/api/lda_datasets.py --- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py +++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py @@ -429,8 +429,15 @@ folder = self.folder_manager.get( trans, folder_id ) source = kwd.get( 'source', None ) - if source not in [ 'userdir_file', 'userdir_folder', 'admin_path' ]: - raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder" and "admin_path". ') + if source not in [ 'userdir_file', 'userdir_folder', 'importdir_file', 'importdir_folder', 'admin_path' ]: + raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder", "admin_path", "importdir_file" and "importdir_folder". ') + if source in [ 'importdir_file', 'importdir_folder' ]: + if not trans.user_is_admin: + raise exceptions.AdminRequiredException( 'Only admins can import from importdir.' ) + if not trans.app.config.library_import_dir: + raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow admins to import into library from importdir.' ) + user_base_dir = trans.app.config.library_import_dir + if source in [ 'userdir_file', 'userdir_folder' ]: user_login = trans.user.email @@ -505,6 +512,7 @@ return job_dict @web.expose + # TODO convert to expose_api def download( self, trans, format, **kwd ): """ download( self, trans, format, **kwd ) diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/mvc/library/library-foldertoolbar-view.js @@ -54,7 +54,12 @@ auto: { id : 'auto', text : 'Auto-detect', - description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + description : 'This system will try to detect the file type automatically.' + + ' If your file is not detected properly as one of the known formats,' + + ' it most likely means that it has some format problems (e.g., different' + + ' number of columns on different rows). You can still coerce the system' + + ' to set your data to the format you think it should be.' + + ' You can also upload compressed files, which will automatically be decompressed.' }, // genomes @@ -73,15 +78,12 @@ id: this.options.id, is_admin: false, is_anonym: true, - user_library_import_dir: Galaxy.config.user_library_import_dir, - allow_library_path_paste: Galaxy.config.allow_library_path_paste, - library_import_dir: Galaxy.config.library_import_dir, mutiple_add_dataset_options: false } if (Galaxy.currUser){ template_defaults.is_admin = Galaxy.currUser.isAdmin(); template_defaults.is_anonym = Galaxy.currUser.isAnonymous(); - if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){ + if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){ template_defaults.mutiple_add_dataset_options = true; } } @@ -402,33 +404,38 @@ // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... var that = this; this.select_genome = new mod_select.View( { - css: 'genome', + css: 'library-genome-select', data: that.list_genomes, - container: Galaxy.modal.$el.find( '#genome' ), + container: Galaxy.modal.$el.find( '#library_genome_select' ), value: '?' } ); this.select_extension = new mod_select.View({ - css: 'extension', + css: 'library-extension-select', data: that.list_extensions, - container: Galaxy.modal.$el.find('#extension'), + container: Galaxy.modal.$el.find( '#library_extension_select' ), value: 'auto' }); }, + /** - * Create modal for importing form user's directory + * Create modal for importing from given directory * on Galaxy. Bind jQuery events. */ - importFilesFromUserdirModal: function(){ + importFilesFromGalaxyFolderModal: function( options ){ var that = this; + var template_modal = this.templateBrowserModal(); this.modal = Galaxy.modal; - var template_modal = this.templateBrowserModal(); this.modal.show({ closing_events : true, title : 'Please select folders or files', body : template_modal({}), buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} + 'Import' : function() { + that.importFromJstreePath( that, options ); + }, + 'Close' : function() { + Galaxy.modal.hide(); + } }, closing_callback: function(){ // TODO: should not trigger routes outside of the router @@ -437,21 +444,24 @@ }); this.renderSelectBoxes(); - this.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + this.renderJstree( options ); - $('input[type=radio]').change(function(event){ + $( 'input[type=radio]' ).change( function( event ){ if (event.target.value ==='jstree-disable-folders') { - that.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + that.renderJstree( options ); $('.jstree-folders-message').hide(); $('.jstree-preserve-structure').hide(); $('.jstree-link-files').hide(); $('.jstree-files-message').show(); - } else if (event.target.value ==='jstree-disable-files'){ + } else if ( event.target.value ==='jstree-disable-files' ){ $('.jstree-files-message').hide(); $('.jstree-folders-message').show(); $('.jstree-link-files').show(); $('.jstree-preserve-structure').show(); - that.renderJstree({disabled_jstree_element: 'files'}); + options.disabled_jstree_element = 'files'; + that.renderJstree( options ); } } ); @@ -463,12 +473,16 @@ * data. * @param {[type]} options [description] */ - renderJstree: function(options){ + renderJstree: function( options ){ var that = this; - this.options = _.extend(this.options, options); + this.options = _.extend( this.options, options ); + var target = options.source || 'userdir'; var disabled_jstree_element = this.options.disabled_jstree_element; this.jstree = new mod_library_model.Jstree(); - this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element; + this.jstree.url = this.jstree.urlRoot + + '?target=' + target + + '&format=jstree' + + '&disable=' + disabled_jstree_element; this.jstree.fetch({ success: function(model, response){ // This is to prevent double jquery load. I think. Carl is magician. @@ -579,7 +593,7 @@ * jstree.js has to be loaded before * @see renderJstree */ - importFromUserdirClicked: function ( that ){ + importFromJstreePath: function ( that, options ){ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); @@ -588,7 +602,7 @@ var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ - mod_toastr.info( 'You must select some items first.' ); + mod_toastr.info( 'Please select some items first.' ); } else { this.modal.disableButton( 'Import' ); for ( var i = selected_nodes.length - 1; i >= 0; i-- ){ @@ -598,17 +612,19 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - + var full_source = options.source + '_folder'; this.chainCallImportingFolders( { paths: paths, preserve_dirs: preserve_dirs, link_data: link_data, - source: 'userdir_folder', + source: full_source, file_type: file_type, dbkey: dbkey } ); } else if ( selection_type === 'file' ){ + var full_source = options.source + '_file'; this.chainCallImportingUserdirFiles( { paths : paths, file_type: file_type, - dbkey: dbkey } ); + dbkey: dbkey, + source: full_source } ); } } }, @@ -713,7 +729,7 @@ return true; } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=userdir_file' + + '&source=' + options.source + '&path=' + popped_item + '&file_type=' + options.file_type + '&dbkey=' + options.dbkey ) ) @@ -760,22 +776,12 @@ '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }); }, @@ -952,12 +958,13 @@ this.addFilesFromHistoryModal(); break; case "importdir": + this.importFilesFromGalaxyFolderModal( { source: 'importdir' } ); break; case "path": this.importFilesFromPathModal(); break; case "userdir": - this.importFilesFromUserdirModal(); + this.importFilesFromGalaxyFolderModal( { source: 'userdir' } ); break; default: Galaxy.libraries.library_router.back(); @@ -984,17 +991,19 @@ tmpl_array.push(' </button>'); tmpl_array.push(' <ul class="dropdown-menu" role="menu">'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>'); - tmpl_array.push('<% if(user_library_import_dir !== null) { %>'); + tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>'); tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); - // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>'); - tmpl_array.push(' <li class="divider"></li>'); - tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); - // tmpl_array.push('<% if(library_import_dir !== null) { %>'); - // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); - // tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); + + tmpl_array.push(' <li class="divider"></li>'); + tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); + + tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>'); + tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); + tmpl_array.push('<% } %>'); + + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>'); tmpl_array.push('<% } %>'); tmpl_array.push('<% } %>'); @@ -1154,8 +1163,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1184,8 +1193,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/mvc/ui/ui-select.js --- a/static/scripts/mvc/ui/ui-select.js +++ b/static/scripts/mvc/ui/ui-select.js @@ -155,7 +155,6 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, - width : 'resolve', dropdownAutoWidth : true }; this.$el.select2(select_opt); diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/packed/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(h.user_library_import_dir!==null||h.allow_library_path_paste!==false||h.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"genome",data:g.list_genomes,container:Galaxy.modal.$el.find("#genome"),value:"?"});this.select_extension=new a.View({css:"extension",data:g.list_extensions,container:Galaxy.modal.$el.find("#extension"),value:"auto"})},importFilesFromUserdirModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Please select folders or files",body:g({}),buttons:{Import:function(){h.importFromUserdirClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes();this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(i){if(i.target.value==="jstree-disable-folders"){h.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(i.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();h.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+h;this.jstree.fetch({success:function(k,j){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(l){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:k},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(m){var g=$("#jstree_browser").jstree().get_selected(true);var l=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var o=this.select_genome.value();var j=g[0].type;var p=[];if(g.length<1){f.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var k=g.length-1;k>=0;k--){if(g[k].li_attr.full_path!==undefined){p.push(g[k].li_attr.full_path)}}this.initChainCallControl({length:p.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders({paths:p,preserve_dirs:l,link_data:n,source:"userdir_folder",file_type:h,dbkey:o})}else{if(j==="file"){this.chainCallImportingUserdirFiles({paths:p,file_type:h,dbkey:o})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source=userdir_file&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"library-genome-select",data:g.list_genomes,container:Galaxy.modal.$el.find("#library_genome_select"),value:"?"});this.select_extension=new a.View({css:"library-extension-select",data:g.list_extensions,container:Galaxy.modal.$el.find("#library_extension_select"),value:"auto"})},importFilesFromGalaxyFolderModal:function(g){var i=this;var h=this.templateBrowserModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Please select folders or files",body:h({}),buttons:{Import:function(){i.importFromJstreePath(i,g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+i.id,{trigger:true})}});this.renderSelectBoxes();g.disabled_jstree_element="folders";this.renderJstree(g);$("input[type=radio]").change(function(j){if(j.target.value==="jstree-disable-folders"){g.disabled_jstree_element="folders";i.renderJstree(g);$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(j.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();g.disabled_jstree_element="files";i.renderJstree(g)}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var j=g.source||"userdir";var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target="+j+"&format=jstree&disable="+h;this.jstree.fetch({success:function(l,k){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(m){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:l},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error(k.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders(g)})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(Galaxy.config.user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(Galaxy.config.library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/packed/mvc/ui/ui-select.js --- a/static/scripts/packed/mvc/ui/ui-select.js +++ b/static/scripts/packed/mvc/ui/ui-select.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,width:"resolve",dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1323,6 +1323,8 @@ li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8} li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9} td.right-center{vertical-align:middle !important;text-align:right} +.library-genome-select{max-width:350px} +.library-extension-select{max-width:140px} .library_table td{border-top:1px solid #5f6990 !important} .library_table th{border-bottom:2px solid #5f6990 !important} .library_table a{color:#0A143D}.library_table a:hover{color:maroon} @@ -1574,6 +1576,7 @@ .jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==")} .jstree-default-large.jstree-rtl .jstree-last{background:transparent} @media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} #jstree-dnd.jstree-dnd-responsive>i{background:transparent;width:40px;height:40px} #jstree-dnd.jstree-dnd-responsive>.jstree-ok{background-image:url("../images/jstree/40px.png");background-position:0 -200px;background-size:120px 240px} #jstree-dnd.jstree-dnd-responsive>.jstree-er{background-image:url("../images/jstree/40px.png");background-position:-40px -200px;background-size:120px 240px} #jstree-marker.jstree-dnd-responsive{border-left-width:10px;border-top-width:10px;border-bottom-width:10px;margin-top:-10px}}@media (max-width:768px){.jstree-default-responsive{} .jstree-default-responsive .jstree-icon{background-image:url("../images/jstree/40px.png")} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-node{min-height:40px;line-height:40px;margin-left:40px;min-width:40px;white-space:nowrap} .jstree-default-responsive .jstree-anchor{line-height:40px;height:40px} .jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-icon:empty{width:40px;height:40px;line-height:40px} .jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0} .jstree-default-responsive.jstree-rtl .jstree-node{margin-left:0;margin-right:40px} .jstree-default-responsive.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0} .jstree-default-responsive .jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-size:120px 240px} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-open>.jstree-ocl{background-position:0 0px !important} .jstree-default-responsive .jstree-closed>.jstree-ocl{background-position:0 -40px !important} .jstree-default-responsive.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-40px 0 !important} .jstree-default-responsive .jstree-themeicon{background-position:-40px -40px} .jstree-default-responsive .jstree-checkbox,.jstree-default-responsive .jstree-checkbox:hover{background-position:-40px -80px} .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-responsive .jstree-checked>.jstree-checkbox,.jstree-default-responsive .jstree-checked>.jstree-checkbox:hover{background-position:0 -80px} .jstree-default-responsive .jstree-anchor>.jstree-undetermined,.jstree-default-responsive .jstree-anchor>.jstree-undetermined:hover{background-position:0 -120px} .jstree-default-responsive .jstree-anchor{font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} .jstree-default-responsive>.jstree-striped{background:transparent} .jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,0.7);border-bottom:1px solid rgba(64,64,64,0.2);background:#ebebeb;height:40px} .jstree-default-responsive .jstree-wholerow-hovered{background:#e7f4f9} .jstree-default-responsive .jstree-wholerow-clicked{background:#beebff} .jstree-default-responsive .jstree-children .jstree-last>.jstree-wholerow{box-shadow:inset 0 -6px 3px -5px #666} .jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666;border-top:0} .jstree-default-responsive .jstree-children .jstree-open+.jstree-open{box-shadow:none} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-node>.jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-image:url("../images/jstree/40px.png");background-size:120px 240px} .jstree-default-responsive .jstree-node{background-position:-80px 0;background-repeat:repeat-y} .jstree-default-responsive .jstree-last{background:transparent} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background-position:-40px -120px} .jstree-default-responsive .jstree-last>.jstree-ocl{background-position:-40px -160px} .jstree-default-responsive .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0} .jstree-default-responsive .jstree-file{background:url("../images/jstree/40px.png") 0 -160px no-repeat;background-size:120px 240px} .jstree-default-responsive .jstree-folder{background:url("../images/jstree/40px.png") -40px -40px no-repeat;background-size:120px 240px}}.jstree-default>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0} +.select2-minwidth{min-width:256px} .unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none} .parent-width{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;*width:90%} .clear:before,.clear:after{content:" ";display:table;} diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/blue/library.css --- a/static/style/blue/library.css +++ b/static/style/blue/library.css @@ -7,6 +7,8 @@ li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8} li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9} td.right-center{vertical-align:middle !important;text-align:right} +.library-genome-select{max-width:350px} +.library-extension-select{max-width:140px} .library_table td{border-top:1px solid #5f6990 !important} .library_table th{border-bottom:2px solid #5f6990 !important} .library_table a{color:#0A143D}.library_table a:hover{color:maroon} diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/src/less/base.less --- a/static/style/src/less/base.less +++ b/static/style/src/less/base.less @@ -31,6 +31,11 @@ // Mixins +/* fix for zero width select2 - remove when fixed there */ +.select2-minwidth { + min-width: 256px; +} + .unselectable { .user-select(none); } diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/src/less/library.less --- a/static/style/src/less/library.less +++ b/static/style/src/less/library.less @@ -29,13 +29,19 @@ background-color: @table-bg-accent; } -td.right-center{ +td.right-center { vertical-align: middle !important; text-align: right; - } -.library_table{ +.library-genome-select { + max-width: 350px; +} +.library-extension-select { + max-width: 140px; +} + +.library_table { td { border-top:1px solid #5f6990 !important; } https://bitbucket.org/galaxy/galaxy-central/commits/1af9145657c0/ Changeset: 1af9145657c0 Branch: next-stable User: martenson Date: 2014-09-26 19:17:35+00:00 Summary: select2 fixes and impl. of missing feature import from path Affected #: 12 files diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -54,7 +54,12 @@ auto: { id : 'auto', text : 'Auto-detect', - description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + description : 'This system will try to detect the file type automatically.' + + ' If your file is not detected properly as one of the known formats,' + + ' it most likely means that it has some format problems (e.g., different' + + ' number of columns on different rows). You can still coerce the system' + + ' to set your data to the format you think it should be.' + + ' You can also upload compressed files, which will automatically be decompressed.' }, // genomes @@ -73,15 +78,12 @@ id: this.options.id, is_admin: false, is_anonym: true, - user_library_import_dir: Galaxy.config.user_library_import_dir, - allow_library_path_paste: Galaxy.config.allow_library_path_paste, - library_import_dir: Galaxy.config.library_import_dir, mutiple_add_dataset_options: false } if (Galaxy.currUser){ template_defaults.is_admin = Galaxy.currUser.isAdmin(); template_defaults.is_anonym = Galaxy.currUser.isAnonymous(); - if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){ + if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){ template_defaults.mutiple_add_dataset_options = true; } } @@ -402,33 +404,38 @@ // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... var that = this; this.select_genome = new mod_select.View( { - css: 'genome', + css: 'library-genome-select', data: that.list_genomes, - container: Galaxy.modal.$el.find( '#genome' ), + container: Galaxy.modal.$el.find( '#library_genome_select' ), value: '?' } ); this.select_extension = new mod_select.View({ - css: 'extension', + css: 'library-extension-select', data: that.list_extensions, - container: Galaxy.modal.$el.find('#extension'), + container: Galaxy.modal.$el.find( '#library_extension_select' ), value: 'auto' }); }, + /** - * Create modal for importing form user's directory + * Create modal for importing from given directory * on Galaxy. Bind jQuery events. */ - importFilesFromUserdirModal: function(){ + importFilesFromGalaxyFolderModal: function( options ){ var that = this; + var template_modal = this.templateBrowserModal(); this.modal = Galaxy.modal; - var template_modal = this.templateBrowserModal(); this.modal.show({ closing_events : true, title : 'Please select folders or files', body : template_modal({}), buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} + 'Import' : function() { + that.importFromJstreePath( that, options ); + }, + 'Close' : function() { + Galaxy.modal.hide(); + } }, closing_callback: function(){ // TODO: should not trigger routes outside of the router @@ -437,21 +444,24 @@ }); this.renderSelectBoxes(); - this.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + this.renderJstree( options ); - $('input[type=radio]').change(function(event){ + $( 'input[type=radio]' ).change( function( event ){ if (event.target.value ==='jstree-disable-folders') { - that.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + that.renderJstree( options ); $('.jstree-folders-message').hide(); $('.jstree-preserve-structure').hide(); $('.jstree-link-files').hide(); $('.jstree-files-message').show(); - } else if (event.target.value ==='jstree-disable-files'){ + } else if ( event.target.value ==='jstree-disable-files' ){ $('.jstree-files-message').hide(); $('.jstree-folders-message').show(); $('.jstree-link-files').show(); $('.jstree-preserve-structure').show(); - that.renderJstree({disabled_jstree_element: 'files'}); + options.disabled_jstree_element = 'files'; + that.renderJstree( options ); } } ); @@ -463,12 +473,16 @@ * data. * @param {[type]} options [description] */ - renderJstree: function(options){ + renderJstree: function( options ){ var that = this; - this.options = _.extend(this.options, options); + this.options = _.extend( this.options, options ); + var target = options.source || 'userdir'; var disabled_jstree_element = this.options.disabled_jstree_element; this.jstree = new mod_library_model.Jstree(); - this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element; + this.jstree.url = this.jstree.urlRoot + + '?target=' + target + + '&format=jstree' + + '&disable=' + disabled_jstree_element; this.jstree.fetch({ success: function(model, response){ // This is to prevent double jquery load. I think. Carl is magician. @@ -579,7 +593,7 @@ * jstree.js has to be loaded before * @see renderJstree */ - importFromUserdirClicked: function ( that ){ + importFromJstreePath: function ( that, options ){ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); @@ -588,7 +602,7 @@ var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ - mod_toastr.info( 'You must select some items first.' ); + mod_toastr.info( 'Please select some items first.' ); } else { this.modal.disableButton( 'Import' ); for ( var i = selected_nodes.length - 1; i >= 0; i-- ){ @@ -598,17 +612,19 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - + var full_source = options.source + '_folder'; this.chainCallImportingFolders( { paths: paths, preserve_dirs: preserve_dirs, link_data: link_data, - source: 'userdir_folder', + source: full_source, file_type: file_type, dbkey: dbkey } ); } else if ( selection_type === 'file' ){ + var full_source = options.source + '_file'; this.chainCallImportingUserdirFiles( { paths : paths, file_type: file_type, - dbkey: dbkey } ); + dbkey: dbkey, + source: full_source } ); } } }, @@ -713,7 +729,7 @@ return true; } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=userdir_file' + + '&source=' + options.source + '&path=' + popped_item + '&file_type=' + options.file_type + '&dbkey=' + options.dbkey ) ) @@ -760,22 +776,12 @@ '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }); }, @@ -952,12 +958,13 @@ this.addFilesFromHistoryModal(); break; case "importdir": + this.importFilesFromGalaxyFolderModal( { source: 'importdir' } ); break; case "path": this.importFilesFromPathModal(); break; case "userdir": - this.importFilesFromUserdirModal(); + this.importFilesFromGalaxyFolderModal( { source: 'userdir' } ); break; default: Galaxy.libraries.library_router.back(); @@ -984,17 +991,19 @@ tmpl_array.push(' </button>'); tmpl_array.push(' <ul class="dropdown-menu" role="menu">'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>'); - tmpl_array.push('<% if(user_library_import_dir !== null) { %>'); + tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>'); tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); - // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>'); - tmpl_array.push(' <li class="divider"></li>'); - tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); - // tmpl_array.push('<% if(library_import_dir !== null) { %>'); - // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); - // tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); + + tmpl_array.push(' <li class="divider"></li>'); + tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); + + tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>'); + tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); + tmpl_array.push('<% } %>'); + + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>'); tmpl_array.push('<% } %>'); tmpl_array.push('<% } %>'); @@ -1154,8 +1163,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1184,8 +1193,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d client/galaxy/scripts/mvc/ui/ui-select.js --- a/client/galaxy/scripts/mvc/ui/ui-select.js +++ b/client/galaxy/scripts/mvc/ui/ui-select.js @@ -155,7 +155,6 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, - width : 'resolve', dropdownAutoWidth : true }; this.$el.select2(select_opt); diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d lib/galaxy/webapps/galaxy/api/ftp_files.py --- a/lib/galaxy/webapps/galaxy/api/ftp_files.py +++ b/lib/galaxy/webapps/galaxy/api/ftp_files.py @@ -49,7 +49,7 @@ userdir_jstree = self.__create_jstree( full_import_dir, disable ) response = userdir_jstree.jsonData() except Exception, exception: - log.debug(str(exception)) + log.debug( str( exception ) ) raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( full_import_dir ) ) elif format == 'ajax': raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' ) @@ -61,6 +61,26 @@ raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' ) else: raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' ) + elif target == 'importdir': + base_dir = trans.app.config.library_import_dir + if base_dir is None: + raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow usage of import directory.' ) + if format == 'jstree': + disable = kwd.get( 'disable', 'folders') + try: + importdir_jstree = self.__create_jstree( base_dir, disable ) + response = importdir_jstree.jsonData() + except Exception, exception: + log.debug( str( exception ) ) + raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( base_dir ) ) + elif format == 'ajax': + raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' ) + else: + try: + response = self.__load_all_filenames( base_dir ) + except Exception, exception: + log.error( 'Could not get user import files: %s', str( exception ), exc_info=True ) + raise exceptions.InternalServerError( 'Could not get the files from your import directory folder.' ) else: user_ftp_base_dir = trans.app.config.ftp_upload_dir if user_ftp_base_dir is None: diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d lib/galaxy/webapps/galaxy/api/lda_datasets.py --- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py +++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py @@ -429,8 +429,15 @@ folder = self.folder_manager.get( trans, folder_id ) source = kwd.get( 'source', None ) - if source not in [ 'userdir_file', 'userdir_folder', 'admin_path' ]: - raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder" and "admin_path". ') + if source not in [ 'userdir_file', 'userdir_folder', 'importdir_file', 'importdir_folder', 'admin_path' ]: + raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder", "admin_path", "importdir_file" and "importdir_folder". ') + if source in [ 'importdir_file', 'importdir_folder' ]: + if not trans.user_is_admin: + raise exceptions.AdminRequiredException( 'Only admins can import from importdir.' ) + if not trans.app.config.library_import_dir: + raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow admins to import into library from importdir.' ) + user_base_dir = trans.app.config.library_import_dir + if source in [ 'userdir_file', 'userdir_folder' ]: user_login = trans.user.email @@ -505,6 +512,7 @@ return job_dict @web.expose + # TODO convert to expose_api def download( self, trans, format, **kwd ): """ download( self, trans, format, **kwd ) diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/mvc/library/library-foldertoolbar-view.js @@ -54,7 +54,12 @@ auto: { id : 'auto', text : 'Auto-detect', - description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + description : 'This system will try to detect the file type automatically.' + + ' If your file is not detected properly as one of the known formats,' + + ' it most likely means that it has some format problems (e.g., different' + + ' number of columns on different rows). You can still coerce the system' + + ' to set your data to the format you think it should be.' + + ' You can also upload compressed files, which will automatically be decompressed.' }, // genomes @@ -73,15 +78,12 @@ id: this.options.id, is_admin: false, is_anonym: true, - user_library_import_dir: Galaxy.config.user_library_import_dir, - allow_library_path_paste: Galaxy.config.allow_library_path_paste, - library_import_dir: Galaxy.config.library_import_dir, mutiple_add_dataset_options: false } if (Galaxy.currUser){ template_defaults.is_admin = Galaxy.currUser.isAdmin(); template_defaults.is_anonym = Galaxy.currUser.isAnonymous(); - if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){ + if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){ template_defaults.mutiple_add_dataset_options = true; } } @@ -402,33 +404,38 @@ // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... var that = this; this.select_genome = new mod_select.View( { - css: 'genome', + css: 'library-genome-select', data: that.list_genomes, - container: Galaxy.modal.$el.find( '#genome' ), + container: Galaxy.modal.$el.find( '#library_genome_select' ), value: '?' } ); this.select_extension = new mod_select.View({ - css: 'extension', + css: 'library-extension-select', data: that.list_extensions, - container: Galaxy.modal.$el.find('#extension'), + container: Galaxy.modal.$el.find( '#library_extension_select' ), value: 'auto' }); }, + /** - * Create modal for importing form user's directory + * Create modal for importing from given directory * on Galaxy. Bind jQuery events. */ - importFilesFromUserdirModal: function(){ + importFilesFromGalaxyFolderModal: function( options ){ var that = this; + var template_modal = this.templateBrowserModal(); this.modal = Galaxy.modal; - var template_modal = this.templateBrowserModal(); this.modal.show({ closing_events : true, title : 'Please select folders or files', body : template_modal({}), buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} + 'Import' : function() { + that.importFromJstreePath( that, options ); + }, + 'Close' : function() { + Galaxy.modal.hide(); + } }, closing_callback: function(){ // TODO: should not trigger routes outside of the router @@ -437,21 +444,24 @@ }); this.renderSelectBoxes(); - this.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + this.renderJstree( options ); - $('input[type=radio]').change(function(event){ + $( 'input[type=radio]' ).change( function( event ){ if (event.target.value ==='jstree-disable-folders') { - that.renderJstree({disabled_jstree_element: 'folders'}); + options.disabled_jstree_element = 'folders'; + that.renderJstree( options ); $('.jstree-folders-message').hide(); $('.jstree-preserve-structure').hide(); $('.jstree-link-files').hide(); $('.jstree-files-message').show(); - } else if (event.target.value ==='jstree-disable-files'){ + } else if ( event.target.value ==='jstree-disable-files' ){ $('.jstree-files-message').hide(); $('.jstree-folders-message').show(); $('.jstree-link-files').show(); $('.jstree-preserve-structure').show(); - that.renderJstree({disabled_jstree_element: 'files'}); + options.disabled_jstree_element = 'files'; + that.renderJstree( options ); } } ); @@ -463,12 +473,16 @@ * data. * @param {[type]} options [description] */ - renderJstree: function(options){ + renderJstree: function( options ){ var that = this; - this.options = _.extend(this.options, options); + this.options = _.extend( this.options, options ); + var target = options.source || 'userdir'; var disabled_jstree_element = this.options.disabled_jstree_element; this.jstree = new mod_library_model.Jstree(); - this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element; + this.jstree.url = this.jstree.urlRoot + + '?target=' + target + + '&format=jstree' + + '&disable=' + disabled_jstree_element; this.jstree.fetch({ success: function(model, response){ // This is to prevent double jquery load. I think. Carl is magician. @@ -579,7 +593,7 @@ * jstree.js has to be loaded before * @see renderJstree */ - importFromUserdirClicked: function ( that ){ + importFromJstreePath: function ( that, options ){ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); @@ -588,7 +602,7 @@ var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ - mod_toastr.info( 'You must select some items first.' ); + mod_toastr.info( 'Please select some items first.' ); } else { this.modal.disableButton( 'Import' ); for ( var i = selected_nodes.length - 1; i >= 0; i-- ){ @@ -598,17 +612,19 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - + var full_source = options.source + '_folder'; this.chainCallImportingFolders( { paths: paths, preserve_dirs: preserve_dirs, link_data: link_data, - source: 'userdir_folder', + source: full_source, file_type: file_type, dbkey: dbkey } ); } else if ( selection_type === 'file' ){ + var full_source = options.source + '_file'; this.chainCallImportingUserdirFiles( { paths : paths, file_type: file_type, - dbkey: dbkey } ); + dbkey: dbkey, + source: full_source } ); } } }, @@ -713,7 +729,7 @@ return true; } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=userdir_file' + + '&source=' + options.source + '&path=' + popped_item + '&file_type=' + options.file_type + '&dbkey=' + options.dbkey ) ) @@ -760,22 +776,12 @@ '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders( { paths: options.paths, - preserve_dirs: options.preserve_dirs, - link_data: options.link_data, - source: options.source, - file_type: options.file_type, - dbkey: options.dbkey } ); + that.chainCallImportingFolders( options ); }); }, @@ -952,12 +958,13 @@ this.addFilesFromHistoryModal(); break; case "importdir": + this.importFilesFromGalaxyFolderModal( { source: 'importdir' } ); break; case "path": this.importFilesFromPathModal(); break; case "userdir": - this.importFilesFromUserdirModal(); + this.importFilesFromGalaxyFolderModal( { source: 'userdir' } ); break; default: Galaxy.libraries.library_router.back(); @@ -984,17 +991,19 @@ tmpl_array.push(' </button>'); tmpl_array.push(' <ul class="dropdown-menu" role="menu">'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>'); - tmpl_array.push('<% if(user_library_import_dir !== null) { %>'); + tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>'); tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); - // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>'); - tmpl_array.push(' <li class="divider"></li>'); - tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); - // tmpl_array.push('<% if(library_import_dir !== null) { %>'); - // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); - // tmpl_array.push('<% } %>'); - tmpl_array.push('<% if(allow_library_path_paste) { %>'); + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); + + tmpl_array.push(' <li class="divider"></li>'); + tmpl_array.push(' <li class="dropdown-header">Admins only</li>'); + + tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>'); + tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>'); + tmpl_array.push('<% } %>'); + + tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>'); tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>'); tmpl_array.push('<% } %>'); tmpl_array.push('<% } %>'); @@ -1154,8 +1163,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1184,8 +1193,8 @@ tmpl_array.push('<hr />'); tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); tmpl_array.push('<div>'); - tmpl_array.push('Type: <span id="extension" class="extension" />'); - tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />'); + tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/mvc/ui/ui-select.js --- a/static/scripts/mvc/ui/ui-select.js +++ b/static/scripts/mvc/ui/ui-select.js @@ -155,7 +155,6 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, - width : 'resolve', dropdownAutoWidth : true }; this.$el.select2(select_opt); diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/packed/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(h.user_library_import_dir!==null||h.allow_library_path_paste!==false||h.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"genome",data:g.list_genomes,container:Galaxy.modal.$el.find("#genome"),value:"?"});this.select_extension=new a.View({css:"extension",data:g.list_extensions,container:Galaxy.modal.$el.find("#extension"),value:"auto"})},importFilesFromUserdirModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Please select folders or files",body:g({}),buttons:{Import:function(){h.importFromUserdirClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes();this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(i){if(i.target.value==="jstree-disable-folders"){h.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(i.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();h.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+h;this.jstree.fetch({success:function(k,j){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(l){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:k},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(m){var g=$("#jstree_browser").jstree().get_selected(true);var l=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var o=this.select_genome.value();var j=g[0].type;var p=[];if(g.length<1){f.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var k=g.length-1;k>=0;k--){if(g[k].li_attr.full_path!==undefined){p.push(g[k].li_attr.full_path)}}this.initChainCallControl({length:p.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders({paths:p,preserve_dirs:l,link_data:n,source:"userdir_folder",file_type:h,dbkey:o})}else{if(j==="file"){this.chainCallImportingUserdirFiles({paths:p,file_type:h,dbkey:o})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source=userdir_file&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"library-genome-select",data:g.list_genomes,container:Galaxy.modal.$el.find("#library_genome_select"),value:"?"});this.select_extension=new a.View({css:"library-extension-select",data:g.list_extensions,container:Galaxy.modal.$el.find("#library_extension_select"),value:"auto"})},importFilesFromGalaxyFolderModal:function(g){var i=this;var h=this.templateBrowserModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Please select folders or files",body:h({}),buttons:{Import:function(){i.importFromJstreePath(i,g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+i.id,{trigger:true})}});this.renderSelectBoxes();g.disabled_jstree_element="folders";this.renderJstree(g);$("input[type=radio]").change(function(j){if(j.target.value==="jstree-disable-folders"){g.disabled_jstree_element="folders";i.renderJstree(g);$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(j.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();g.disabled_jstree_element="files";i.renderJstree(g)}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var j=g.source||"userdir";var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target="+j+"&format=jstree&disable="+h;this.jstree.fetch({success:function(l,k){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(m){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:l},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error(k.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders(g)})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(Galaxy.config.user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(Galaxy.config.library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/packed/mvc/ui/ui-select.js --- a/static/scripts/packed/mvc/ui/ui-select.js +++ b/static/scripts/packed/mvc/ui/ui-select.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,width:"resolve",dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1322,6 +1322,8 @@ li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8} li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9} td.right-center{vertical-align:middle !important;text-align:right} +.library-genome-select{max-width:350px} +.library-extension-select{max-width:140px} .library_table td{border-top:1px solid #5f6990 !important} .library_table th{border-bottom:2px solid #5f6990 !important} .library_table a{color:#0A143D}.library_table a:hover{color:maroon} @@ -1573,6 +1575,7 @@ .jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==")} .jstree-default-large.jstree-rtl .jstree-last{background:transparent} @media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} #jstree-dnd.jstree-dnd-responsive>i{background:transparent;width:40px;height:40px} #jstree-dnd.jstree-dnd-responsive>.jstree-ok{background-image:url("../images/jstree/40px.png");background-position:0 -200px;background-size:120px 240px} #jstree-dnd.jstree-dnd-responsive>.jstree-er{background-image:url("../images/jstree/40px.png");background-position:-40px -200px;background-size:120px 240px} #jstree-marker.jstree-dnd-responsive{border-left-width:10px;border-top-width:10px;border-bottom-width:10px;margin-top:-10px}}@media (max-width:768px){.jstree-default-responsive{} .jstree-default-responsive .jstree-icon{background-image:url("../images/jstree/40px.png")} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-node{min-height:40px;line-height:40px;margin-left:40px;min-width:40px;white-space:nowrap} .jstree-default-responsive .jstree-anchor{line-height:40px;height:40px} .jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-icon:empty{width:40px;height:40px;line-height:40px} .jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0} .jstree-default-responsive.jstree-rtl .jstree-node{margin-left:0;margin-right:40px} .jstree-default-responsive.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0} .jstree-default-responsive .jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-size:120px 240px} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-open>.jstree-ocl{background-position:0 0px !important} .jstree-default-responsive .jstree-closed>.jstree-ocl{background-position:0 -40px !important} .jstree-default-responsive.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-40px 0 !important} .jstree-default-responsive .jstree-themeicon{background-position:-40px -40px} .jstree-default-responsive .jstree-checkbox,.jstree-default-responsive .jstree-checkbox:hover{background-position:-40px -80px} .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-responsive .jstree-checked>.jstree-checkbox,.jstree-default-responsive .jstree-checked>.jstree-checkbox:hover{background-position:0 -80px} .jstree-default-responsive .jstree-anchor>.jstree-undetermined,.jstree-default-responsive .jstree-anchor>.jstree-undetermined:hover{background-position:0 -120px} .jstree-default-responsive .jstree-anchor{font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} .jstree-default-responsive>.jstree-striped{background:transparent} .jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,0.7);border-bottom:1px solid rgba(64,64,64,0.2);background:#ebebeb;height:40px} .jstree-default-responsive .jstree-wholerow-hovered{background:#e7f4f9} .jstree-default-responsive .jstree-wholerow-clicked{background:#beebff} .jstree-default-responsive .jstree-children .jstree-last>.jstree-wholerow{box-shadow:inset 0 -6px 3px -5px #666} .jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666;border-top:0} .jstree-default-responsive .jstree-children .jstree-open+.jstree-open{box-shadow:none} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-node>.jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-image:url("../images/jstree/40px.png");background-size:120px 240px} .jstree-default-responsive .jstree-node{background-position:-80px 0;background-repeat:repeat-y} .jstree-default-responsive .jstree-last{background:transparent} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background-position:-40px -120px} .jstree-default-responsive .jstree-last>.jstree-ocl{background-position:-40px -160px} .jstree-default-responsive .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0} .jstree-default-responsive .jstree-file{background:url("../images/jstree/40px.png") 0 -160px no-repeat;background-size:120px 240px} .jstree-default-responsive .jstree-folder{background:url("../images/jstree/40px.png") -40px -40px no-repeat;background-size:120px 240px}}.jstree-default>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0} +.select2-minwidth{min-width:256px} .unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none} .parent-width{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;*width:90%} .clear:before,.clear:after{content:" ";display:table;} diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/blue/library.css --- a/static/style/blue/library.css +++ b/static/style/blue/library.css @@ -7,6 +7,8 @@ li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8} li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9} td.right-center{vertical-align:middle !important;text-align:right} +.library-genome-select{max-width:350px} +.library-extension-select{max-width:140px} .library_table td{border-top:1px solid #5f6990 !important} .library_table th{border-bottom:2px solid #5f6990 !important} .library_table a{color:#0A143D}.library_table a:hover{color:maroon} diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/src/less/base.less --- a/static/style/src/less/base.less +++ b/static/style/src/less/base.less @@ -31,6 +31,11 @@ // Mixins +/* fix for zero width select2 - remove when fixed there */ +.select2-minwidth { + min-width: 256px; +} + .unselectable { .user-select(none); } diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/src/less/library.less --- a/static/style/src/less/library.less +++ b/static/style/src/less/library.less @@ -29,13 +29,19 @@ background-color: @table-bg-accent; } -td.right-center{ +td.right-center { vertical-align: middle !important; text-align: right; - } -.library_table{ +.library-genome-select { + max-width: 350px; +} +.library-extension-select { + max-width: 140px; +} + +.library_table { td { border-top:1px solid #5f6990 !important; } 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