diff --git a/client/galaxy/scripts/galaxy.library.js b/client/galaxy/scripts/galaxy.library.js index f45f2ee32b3..3f5277fb90d 100644 --- a/client/galaxy/scripts/galaxy.library.js +++ b/client/galaxy/scripts/galaxy.library.js @@ -36,7 +36,7 @@ var LibraryRouter = Backbone.Router.extend({ initialize: function() { this.routesHit = 0; //keep count of number of routes handled by the application - Backbone.history.on('route', function() { this.routesHit++; }, this); + Backbone.history.on( 'route', function() { this.routesHit++; }, this ); }, routes: { @@ -45,6 +45,7 @@ routes: { "library/:library_id/permissions" : "library_permissions", "folders/:folder_id/permissions" : "folder_permissions", "folders/:id" : "folder_content", + "folders/:id/page/:show_page" : "folder_page", "folders/:folder_id/datasets/:dataset_id" : "dataset_detail", "folders/:folder_id/datasets/:dataset_id/permissions" : "dataset_permissions", "folders/:folder_id/datasets/:dataset_id/versions/:ldda_id" : "dataset_version", @@ -53,13 +54,13 @@ routes: { }, back: function() { - if(this.routesHit > 1) { + if( this.routesHit > 1 ) { //more than one route hit -> user did not land to current page directly window.history.back(); } else { //otherwise go to the home page. Use replaceState if available so //the navigation doesn't create an extra history entry - this.navigate('#', {trigger:true, replace:true}); + this.navigate( '#', { trigger:true, replace:true } ); } } }); @@ -71,7 +72,8 @@ var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ with_deleted : false, sort_order : 'asc', sort_by : 'name', - library_page_size : 20 + library_page_size : 20, + folder_page_size : 15 } }); @@ -94,10 +96,10 @@ var GalaxyLibrary = Backbone.View.extend({ this.library_router = new LibraryRouter(); - this.library_router.on('route:libraries', function() { - Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); - Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); - }); + this.library_router.on( 'route:libraries', function() { + Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); + Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); + }); this.library_router.on('route:libraries_page', function( show_page ) { if ( Galaxy.libraries.libraryToolbarView === null ){ @@ -108,66 +110,77 @@ var GalaxyLibrary = Backbone.View.extend({ } }); - this.library_router.on('route:folder_content', function(id) { + this.library_router.on( 'route:folder_content', function( id ) { if (Galaxy.libraries.folderToolbarView){ - Galaxy.libraries.folderToolbarView.$el.unbind('click'); - } - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: id}); - }); + Galaxy.libraries.folderToolbarView.$el.unbind( 'click' ); + } + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id } ); + }); - this.library_router.on('route:download', function(folder_id, format) { - if ($('#folder_list_body').find(':checked').length === 0) { - mod_toastr.info( 'You must select at least one dataset to download' ); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: true, replace: true}); - } else { - Galaxy.libraries.folderToolbarView.download(folder_id, format); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: false, replace: true}); - } - }); + this.library_router.on( 'route:folder_page', function( id, show_page ) { + if ( Galaxy.libraries.folderToolbarView === null ){ + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( {id: id} ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id, show_page: show_page } ); + } else { + Galaxy.libraries.folderListView.render( { id: id, show_page: parseInt( show_page ) } ) + } + }); - this.library_router.on('route:dataset_detail', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); - }); - this.library_router.on('route:dataset_version', function(folder_id, dataset_id, ldda_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); - }); + this.library_router.on( 'route:download', function( folder_id, format ) { + if ( $( '#folder_list_body' ).find( ':checked' ).length === 0 ) { + mod_toastr.info( 'You must select at least one dataset to download' ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: true, replace: true } ); + } else { + Galaxy.libraries.folderToolbarView.download( folder_id, format ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: false, replace: true } ); + } + }); - this.library_router.on('route:dataset_permissions', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_detail', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); + }); - this.library_router.on('route:library_permissions', function(library_id){ - if (Galaxy.libraries.libraryView){ - Galaxy.libraries.libraryView.$el.unbind('click'); - } - Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_version', function(folder_id, dataset_id, ldda_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); + }); - this.library_router.on('route:folder_permissions', function(folder_id){ - if (Galaxy.libraries.folderView){ - Galaxy.libraries.folderView.$el.unbind('click'); - } - Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); - }); - this.library_router.on('route:import_datasets', function(folder_id, source){ - if (Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView){ - Galaxy.libraries.folderToolbarView.showImportModal({source:source}); - } else { - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: folder_id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: folder_id}); - Galaxy.libraries.folderToolbarView.showImportModal({source: source}); - } - }); + this.library_router.on( 'route:dataset_permissions', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); + }); + + this.library_router.on( 'route:library_permissions', function(library_id){ + if (Galaxy.libraries.libraryView){ + Galaxy.libraries.libraryView.$el.unbind('click'); + } + Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); + }); + + this.library_router.on( 'route:folder_permissions', function(folder_id){ + if (Galaxy.libraries.folderView){ + Galaxy.libraries.folderView.$el.unbind('click'); + } + Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); + }); + + this.library_router.on( 'route:import_datasets', function( folder_id, source ){ + if ( Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView ){ + Galaxy.libraries.folderToolbarView.showImportModal( { source:source } ); + } else { + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: folder_id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: folder_id } ); + Galaxy.libraries.folderToolbarView.showImportModal( { source: source } ); + } + }); Backbone.history.start({pushState: false}); } diff --git a/client/galaxy/scripts/mvc/library/library-folderlist-view.js b/client/galaxy/scripts/mvc/library/library-folderlist-view.js index b361c7ea459..8ea1fe0831e 100644 --- a/client/galaxy/scripts/mvc/library/library-folderlist-view.js +++ b/client/galaxy/scripts/mvc/library/library-folderlist-view.js @@ -15,322 +15,359 @@ function(mod_masthead, ) { var FolderListView = Backbone.View.extend({ - el : '#folder_items_element', - defaults: { - 'include_deleted' : false - }, - // progress percentage - progress: 0, - // progress rate per one item - progressStep: 1, - // self modal - modal : null, + el : '#folder_items_element', + // progress percentage + progress: 0, + // progress rate per one item + progressStep: 1, - folderContainer: null, + folderContainer: null, - sort: 'asc', + sort: 'asc', - events: { - 'click #select-all-checkboxes' : 'selectAll', - 'click .dataset_row' : 'selectClickedRow', - 'click .sort-folder-link' : 'sortColumnClicked' - }, + events: { + 'click #select-all-checkboxes' : 'selectAll', + 'click .dataset_row' : 'selectClickedRow', + 'click .sort-folder-link' : 'sortColumnClicked' + }, - // cache of rendered views - rowViews: {}, - - initialize : function(options){ - this.options = _.defaults(this.options || {}, options); - this.fetchFolder(); - }, + collection: null, - fetchFolder: function(options){ - var options = options || {}; - this.options.include_deleted = options.include_deleted; - var that = this; + defaults: { + include_deleted: false, + page_count: null, + show_page: null + }, - this.collection = new mod_library_model.Folder(); + /** + * Initialize and fetch the folder from the server. + * @param {object} options an object with options + */ + initialize : function( options ){ + this.options = _.defaults( this.options || {}, this.defaults, options ); + this.modal = null; + // map of folder item ids to item views = cache + this.rowViews = {}; - // start to listen if someone modifies collection - this.listenTo(this.collection, 'add', this.renderOne); - this.listenTo(this.collection, 'remove', this.removeOne); + // create a collection of folder items for this view + this.collection = new mod_library_model.Folder(); - this.folderContainer = new mod_library_model.FolderContainer({id: this.options.id}); - this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; - if (this.options.include_deleted){ - this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; - } - this.folderContainer.fetch({ - success: function(folder_container) { - that.folder_container = folder_container; - that.render(); - that.addAll(folder_container.get('folder').models); - if (that.options.dataset_id){ - row = _.findWhere(that.rowViews, {id: that.options.dataset_id}); - if (row) { + // start to listen if someone modifies the collection + this.listenTo( this.collection, 'add', this.renderOne ); + this.listenTo( this.collection, 'remove', this.removeOne ); + + this.fetchFolder(); + }, + + fetchFolder: function( options ){ + var options = options || {}; + this.options.include_deleted = options.include_deleted; + var that = this; + + this.folderContainer = new mod_library_model.FolderContainer( { id: this.options.id } ); + this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; + + if ( this.options.include_deleted ){ + this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; + } + this.folderContainer.fetch({ + success: function( folder_container ) { + that.folder_container = folder_container; + that.render(); + }, + error: function( model, response ){ + if ( typeof response.responseJSON !== "undefined" ){ + mod_toastr.error( response.responseJSON.err_msg + ' Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } else { + mod_toastr.error( 'An error ocurred. Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } + } + }); + }, + + render: function ( options ){ + this.options = _.extend( this.options, options ); + var template = this.templateFolder(); + $(".tooltip").hide(); + + // find the upper id in the full path + var path = this.folderContainer.attributes.metadata.full_path; + var upper_folder_id; + if ( path.length === 1 ){ // the library is above us + upper_folder_id = 0; + } else { + upper_folder_id = path[ path.length-2 ][ 0 ]; + } + + this.$el.html( template( { + path: this.folderContainer.attributes.metadata.full_path, + parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, + id: this.options.id, + upper_folder_id: upper_folder_id, + order: this.sort + } ) ); + + // when dataset_id is present render its details too + if ( this.options.dataset_id ){ + row = _.findWhere( that.rowViews, { id: this.options.dataset_id } ); + if ( row ) { row.showDatasetDetails(); } else { - mod_toastr.error('Dataset not found. Showing folder instead.'); + mod_toastr.error( 'Requested dataset not found. Showing folder instead.' ); } - } - }, - error: function(model, response){ - if (typeof response.responseJSON !== "undefined"){ - mod_toastr.error(response.responseJSON.err_msg + ' Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } else { - mod_toastr.error('An error ocurred. Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } + } else { + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.paginate(); } - }); - }, + $("#center [data-toggle]").tooltip(); + $("#center").css('overflow','auto'); + }, - render: function (options) { - this.options = _.defaults(this.options, options); - var template = this.templateFolder(); - $(".tooltip").hide(); + paginate: function( options ){ + this.options = _.extend( this.options, options ); - // TODO move to server - // find the upper id in the full path - var path = this.folderContainer.attributes.metadata.full_path; - var upper_folder_id; - if (path.length === 1){ // the library is above us - upper_folder_id = 0; - } else { - upper_folder_id = path[path.length-2][0]; - } + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.options.total_items_count = this.folder_container.get( 'folder' ).models.length; + this.options.page_count = Math.ceil( this.options.total_items_count / Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + var page_start = ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * ( this.options.show_page - 1 ) ); + var items_to_render = null; + items_to_render = this.folder_container.get( 'folder' ).models.slice( page_start, page_start + Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + this.options.items_shown = items_to_render.length; + // User requests page with no items + if ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * this.options.show_page > ( this.options.total_items_count + Galaxy.libraries.preferences.get( 'folder_page_size' ) ) ){ + items_to_render = []; + } + Galaxy.libraries.folderToolbarView.renderPaginator( this.options ); + this.collection.reset(); + this.addAll( items_to_render ) + }, - this.$el.html(template({ path: this.folderContainer.attributes.metadata.full_path, parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, id: this.options.id, upper_folder_id: upper_folder_id, order: this.sort})); + /** + * Adds all given models to the collection. + * @param {array of Item or FolderAsModel} array of models that should + * be added to the view's collection. + */ + addAll: function( models ){ + _.each(models, function( model ) { + Galaxy.libraries.folderListView.collection.add( model ); + }); + $( "#center [data-toggle]" ).tooltip(); + this.checkEmptiness(); + this.postRender(); + }, - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - //hack to show scrollbars - $("#center").css('overflow','auto'); - }, + /** + * Call this after all models are added to the collection + * to ensure that the folder toolbar will show proper options + * and that event will be bound on all subviews. + */ + postRender: function(){ + var fetched_metadata = this.folderContainer.attributes.metadata; + fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; + Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, - /** - * Call this after all models are added to the collection - * to ensure that the folder toolbar will show proper options - * and that event will be bound on all subviews. - */ - postRender: function(){ - var fetched_metadata = this.folderContainer.attributes.metadata; - fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; - Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, + /** + * Iterates this view's collection and calls the render + * function for each. Also binds the hover behavior. + */ + renderAll: function(){ + var that = this; + _.each( this.collection.models.reverse(), function( model ) { + that.renderOne( model ); + }); + this.postRender(); + }, - /** - * Adds all given models to the collection. - * @param {array of Item or FolderAsModel} array of models that should - * be added to the view's collection. - */ - addAll: function(models){ - _.each(models.reverse(), function(model) { - Galaxy.libraries.folderListView.collection.add(model); - }); - - $("#center [data-toggle]").tooltip(); - this.checkEmptiness(); - - this.postRender(); - }, - - /** - * Iterates this view's collection and calls the render - * function for each. Also binds the hover behavior. - */ - renderAll: function(){ - var that = this; - _.each(this.collection.models.reverse(), function(model) { - that.renderOne(model); - }); - this.postRender(); - }, - - /** - * Creates a view for the given model and adds it to the folder view. - * @param {Item or FolderAsModel} model of the view that will be rendered - */ - renderOne: function(model){ - if (model.get('type') !== 'folder'){ - this.options.contains_file = true; - // model.set('readable_size', this.size_to_string(model.get('file_size'))); - } - model.set('folder_id', this.id); - var rowView = new mod_library_folderrow_view.FolderRowView(model); - - // save new rowView to cache - this.rowViews[model.get('id')] = rowView; - - this.$el.find('#first_folder_item').after(rowView.el); - - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, - - /** - * removes the view of the given model from the DOM - * @param {Item or FolderAsModel} model of the view that will be removed - */ - removeOne: function(model){ - this.$el.find('#' + model.id).remove(); - }, - - /** Checks whether the list is empty and adds/removes the message */ - checkEmptiness : function(){ - if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ - this.$el.find('.empty-folder-message').show(); - } else { - this.$el.find('.empty-folder-message').hide(); - } - }, - - /** User clicked the table heading = he wants to sort stuff */ - sortColumnClicked : function(event){ - event.preventDefault(); - if (this.sort === 'asc'){ - this.sortFolder('name','desc'); - this.sort = 'desc'; - } else { - this.sortFolder('name','asc'); - this.sort = 'asc'; - } - this.render(); - this.renderAll(); - this.checkEmptiness(); - }, - - /** - * Sorts the underlying collection according to the parameters received. - * Currently supports only sorting by name. - */ - sortFolder: function(sort_by, order){ - if (sort_by === 'name'){ - if (order === 'asc'){ - return this.collection.sortByNameAsc(); - } else if (order === 'desc'){ - return this.collection.sortByNameDesc(); + /** + * Creates a view for the given model and adds it to the folder view. + * @param {Item or FolderAsModel} model of the view that will be rendered + */ + renderOne: function(model){ + if (model.get('type') !== 'folder'){ + this.options.contains_file = true; + // model.set('readable_size', this.size_to_string(model.get('file_size'))); } - } - }, + model.set('folder_id', this.id); + var rowView = new mod_library_folderrow_view.FolderRowView(model); - /** - * User clicked the checkbox in the table heading - * @param {context} event - */ - selectAll : function (event) { - var selected = event.target.checked; - that = this; - // Iterate each checkbox - $(':checkbox', '#folder_list_body').each(function() { - this.checked = selected; - $row = $(this.parentElement.parentElement); - // Change color of selected/unselected - if (selected) { - that.makeDarkRow($row); - } else { - that.makeWhiteRow($row); - } - }); - }, + // save new rowView to cache + this.rowViews[model.get('id')] = rowView; - /** - * Check checkbox if user clicks on the whole row or - * on the checkbox itself - */ - selectClickedRow : function (event) { - var checkbox = ''; - var $row; - var source; - if (event.target.localName === 'input'){ - checkbox = event.target; - $row = $(event.target.parentElement.parentElement); - source = 'input'; - } else if (event.target.localName === 'td') { - checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; - $row = $(event.target.parentElement); - source = 'td'; - } - if (checkbox.checked){ - if (source==='td'){ - checkbox.checked = ''; - this.makeWhiteRow($row); - } else if (source==='input') { - this.makeDarkRow($row); + this.$el.find('#first_folder_item').after(rowView.el); + + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, + + /** + * removes the view of the given model from the DOM + * @param {Item or FolderAsModel} model of the view that will be removed + */ + removeOne: function( model ){ + this.$el.find( '#' + model.id ).remove(); + }, + + /** Checks whether the list is empty and adds/removes the message */ + checkEmptiness : function(){ + if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ + this.$el.find('.empty-folder-message').show(); + } else { + this.$el.find('.empty-folder-message').hide(); } - } else { - if (source==='td'){ - checkbox.checked = 'selected'; - this.makeDarkRow($row); - } else if (source==='input') { - this.makeWhiteRow($row); + }, + + /** User clicked the table heading = he wants to sort stuff */ + sortColumnClicked : function(event){ + event.preventDefault(); + if (this.sort === 'asc'){ + this.sortFolder('name','desc'); + this.sort = 'desc'; + } else { + this.sortFolder('name','asc'); + this.sort = 'asc'; } + this.render(); + this.renderAll(); + this.checkEmptiness(); + }, + + /** + * Sorts the underlying collection according to the parameters received. + * Currently supports only sorting by name. + */ + sortFolder: function(sort_by, order){ + if (sort_by === 'name'){ + if (order === 'asc'){ + return this.collection.sortByNameAsc(); + } else if (order === 'desc'){ + return this.collection.sortByNameDesc(); + } + } + }, + + /** + * User clicked the checkbox in the table heading + * @param {context} event + */ + selectAll : function (event) { + var selected = event.target.checked; + that = this; + // Iterate each checkbox + $(':checkbox', '#folder_list_body').each(function() { + this.checked = selected; + $row = $(this.parentElement.parentElement); + // Change color of selected/unselected + if (selected) { + that.makeDarkRow($row); + } else { + that.makeWhiteRow($row); + } + }); + }, + + /** + * Check checkbox if user clicks on the whole row or + * on the checkbox itself + */ + selectClickedRow : function (event) { + var checkbox = ''; + var $row; + var source; + if (event.target.localName === 'input'){ + checkbox = event.target; + $row = $(event.target.parentElement.parentElement); + source = 'input'; + } else if (event.target.localName === 'td') { + checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; + $row = $(event.target.parentElement); + source = 'td'; + } + if (checkbox.checked){ + if (source==='td'){ + checkbox.checked = ''; + this.makeWhiteRow($row); + } else if (source==='input') { + this.makeDarkRow($row); + } + } else { + if (source==='td'){ + checkbox.checked = 'selected'; + this.makeDarkRow($row); + } else if (source==='input') { + this.makeWhiteRow($row); + } + } + }, + + makeDarkRow: function($row){ + $row.removeClass('light').addClass('dark'); + $row.find('a').removeClass('light').addClass('dark'); + $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); + }, + + makeWhiteRow: function($row){ + $row.removeClass('dark').addClass('light'); + $row.find('a').removeClass('dark').addClass('light'); + $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); + }, + + templateFolder : function (){ + var tmpl_array = []; + + // BREADCRUMBS + tmpl_array.push(''); + + // FOLDER CONTENT + tmpl_array.push(''); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + + tmpl_array.push(' '); + tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); + tmpl_array.push(''); + + return _.template(tmpl_array.join('')); } - }, - - makeDarkRow: function($row){ - $row.removeClass('light').addClass('dark'); - $row.find('a').removeClass('light').addClass('dark'); - $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); - }, - - makeWhiteRow: function($row){ - $row.removeClass('dark').addClass('light'); - $row.find('a').removeClass('dark').addClass('light'); - $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); - }, - - templateFolder : function (){ - var tmpl_array = []; - - // BREADCRUMBS - tmpl_array.push(''); - - // FOLDER CONTENT - tmpl_array.push(''); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - - tmpl_array.push(' '); - tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); - tmpl_array.push(''); - - return _.template(tmpl_array.join('')); - } - + }); return { diff --git a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js index ec532b71d74..d5f3b9a6d20 100644 --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -20,7 +20,9 @@ var FolderToolbarView = Backbone.View.extend({ 'click #toolbtn_bulk_import' : 'modalBulkImport', 'click #include_deleted_datasets_chk' : 'checkIncludeDeleted', 'click #toolbtn_show_libinfo' : 'showLibInfo', - 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets' + 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets', + 'click #page_size_prompt' : 'showPageSizePrompt' + }, defaults: { @@ -90,6 +92,22 @@ var FolderToolbarView = Backbone.View.extend({ this.$el.html(toolbar_template(template_defaults)); }, + /** + * Called from FolderListView when needed. + * @param {object} options common options + */ + renderPaginator: function( options ){ + this.options = _.extend( this.options, options ); + var paginator_template = this.templatePaginator(); + this.$el.find( '#folder_paginator' ).html( paginator_template({ + id: this.options.id, + show_page: parseInt( this.options.show_page ), + page_count: parseInt( this.options.page_count ), + total_items_count: this.options.total_items_count, + items_shown: this.options.items_shown + })); + }, + configureElements: function(options){ this.options = _.extend(this.options, options); @@ -833,11 +851,11 @@ var FolderToolbarView = Backbone.View.extend({ var popped_item = lddas_set.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ - mod_toastr.success( 'Selected datasets deleted' ); + mod_toastr.success( 'Selected datasets were deleted.' ); } else if ( this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number ){ - mod_toastr.error( 'There was an error and no datasets were deleted.' ); + mod_toastr.error( 'There was an error and no datasets were deleted. Please make sure you have sufficient permissions.' ); } else if ( this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number ){ - mod_toastr.warning( 'Some of the datasets could not be deleted' ); + mod_toastr.warning( 'Some of the datasets could not be deleted. Please make sure you have sufficient permissions.' ); } Galaxy.modal.hide(); return this.deleted_lddas; @@ -976,6 +994,14 @@ var FolderToolbarView = Backbone.View.extend({ } }, + showPageSizePrompt: function(){ + var folder_page_size = prompt( 'How many items per page do you want to see?', Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + if ( ( folder_page_size != null ) && ( folder_page_size == parseInt( folder_page_size ) ) ) { + Galaxy.libraries.preferences.set( { 'folder_page_size': parseInt( folder_page_size ) } ); + Galaxy.libraries.folderListView.render( { id: this.options.id, show_page: 1 } ); + } + }, + templateToolBar: function(){ tmpl_array = []; @@ -1016,7 +1042,6 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(' '); tmpl_array.push('<% } %>'); - tmpl_array.push(' '); tmpl_array.push(' '); // TOOLBAR END tmpl_array.push('
'); @@ -1239,7 +1268,41 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(''); return _.template(tmpl_array.join('')); - } + }, + + templatePaginator: function(){ + tmpl_array = []; + + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items'); + tmpl_array.push(' '); + + return _.template(tmpl_array.join('')); + }, }); diff --git a/client/galaxy/scripts/mvc/library/library-librarylist-view.js b/client/galaxy/scripts/mvc/library/library-librarylist-view.js index 65ddfc85c1a..e229395a340 100644 --- a/client/galaxy/scripts/mvc/library/library-librarylist-view.js +++ b/client/galaxy/scripts/mvc/library/library-librarylist-view.js @@ -21,20 +21,19 @@ var LibraryListView = Backbone.View.extend({ 'click .sort-libraries-link' : 'sort_clicked' }, - /** - * Initialize and fetch the libraries from server. - * Async render afterwards. - * @param {object} options an options object - */ defaults: { page_count: null, show_page: null }, + /** + * Initialize and fetch the libraries from server. + * Async render afterwards. + * @param {object} options an object with options + */ initialize : function( options ){ this.options = _.defaults( this.options || {}, this.defaults, options ); - - var that = this; + var that = this; this.modal = null; // map of library model ids to library views = cache this.rowViews = {}; @@ -61,19 +60,10 @@ var LibraryListView = Backbone.View.extend({ */ render: function ( options ) { this.options = _.extend( this.options, options ); - - if ( ( this.options.page_size != null ) && ( this.options.page_size == parseInt( this.options.page_size ) ) ) { - Galaxy.libraries.preferences.set( { 'library_page_size': parseInt( this.options.page_size ) } ); - } - - $( ".tooltip" ).hide(); - // this.options.show_page = this.options.show_page || 1; var template = this.templateLibraryList(); var libraries_to_render = null; var models = null; - if ( this.options.show_page === null || this.options.show_page < 1 ){ - this.options.show_page = 1; - } + $( ".tooltip" ).hide(); if ( typeof options !== 'undefined' ){ models = typeof options.models !== 'undefined' ? options.models : null; } @@ -89,6 +79,10 @@ var LibraryListView = Backbone.View.extend({ } else { libraries_to_render = []; } + // pagination + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } this.options.total_libraries_count = libraries_to_render.length var page_start = ( Galaxy.libraries.preferences.get( 'library_page_size' ) * ( this.options.show_page - 1 ) ); this.options.page_count = Math.ceil( this.options.total_libraries_count / Galaxy.libraries.preferences.get( 'library_page_size' ) ); diff --git a/client/galaxy/scripts/mvc/tools/tools-tree.js b/client/galaxy/scripts/mvc/tools/tools-tree.js index 13d9a0a8eec..2ae5238713d 100644 --- a/client/galaxy/scripts/mvc/tools/tools-tree.js +++ b/client/galaxy/scripts/mvc/tools/tools-tree.js @@ -126,7 +126,7 @@ return Backbone.Model.extend({ // handle default value if (!field.skip) { if (input.optional && field.validate && !field.validate()) { - value = 'None'; + value = null; } add (job_input_id, input.id, value); } diff --git a/lib/galaxy/managers/folders.py b/lib/galaxy/managers/folders.py index 8093d38d177..1a21fd029b1 100644 --- a/lib/galaxy/managers/folders.py +++ b/lib/galaxy/managers/folders.py @@ -16,14 +16,14 @@ class FolderManager( object ): Interface/service object for interacting with folders. """ - def get( self, trans, decoded_folder_id, check_ownership=False, check_accessible=True): + def get( self, trans, decoded_folder_id, check_manageable=False, check_accessible=True): """ Get the folder from the DB. :param decoded_folder_id: decoded folder id :type decoded_folder_id: int - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether the check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -38,17 +38,17 @@ class FolderManager( object ): raise exceptions.RequestParameterInvalidException( 'No folder found with the id provided.' ) except Exception, e: raise exceptions.InternalServerError( 'Error loading from the database.' + str( e ) ) - folder = self.secure( trans, folder, check_ownership, check_accessible ) + folder = self.secure( trans, folder, check_manageable, check_accessible ) return folder - def secure( self, trans, folder, check_ownership=True, check_accessible=True ): + def secure( self, trans, folder, check_manageable=True, check_accessible=True ): """ - Check if (a) user owns folder or (b) folder is accessible to user. + Check if (a) user can manage folder or (b) folder is accessible to user. :param folder: folder item :type folder: LibraryFolder - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether to check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -58,23 +58,26 @@ class FolderManager( object ): # all folders are accessible to an admin if trans.user_is_admin(): return folder - if check_ownership: - folder = self.check_ownership( trans, folder ) + if check_manageable: + folder = self.check_manageable( trans, folder ) if check_accessible: folder = self.check_accessible( trans, folder ) return folder - def check_ownership( self, trans, folder ): + def check_manageable( self, trans, folder ): """ - Check whether the user is owner of the folder. + Check whether the user can manage the folder. :returns: the original folder :rtype: LibraryFolder + + :raises: AuthenticationRequired, InsufficientPermissionsException """ if not trans.user: - raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items", type='error' ) - if folder.user != trans.user: - raise exceptions.ItemOwnershipException( "Folder is not owned by the current user", type='error' ) + raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items.", type='error' ) + current_user_roles = trans.get_current_user_roles() + if not trans.app.security_agent.can_manage_library_item( current_user_roles, folder ): + raise exceptions.InsufficientPermissionsException( "You don't have permissions to manage this folder.", type='error' ) else: return folder @@ -135,6 +138,22 @@ class FolderManager( object ): trans.app.security_agent.copy_library_permissions( trans, parent_folder, new_folder ) return new_folder + def delete( self, trans, folder, undelete=False ): + """ + Mark given folder deleted/undeleted based on the flag. + + :raises: ItemAccessibilityException + """ + if not trans.user_is_admin(): + folder = self.check_manageable( trans, folder ) + if undelete: + folder.deleted = False + else: + folder.deleted = True + trans.sa_session.add( folder ) + trans.sa_session.flush() + return folder + def get_current_roles( self, trans, folder ): """ Find all roles currently connected to relevant permissions diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index e0984d8288a..c4bfd5523ef 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2192,7 +2192,7 @@ class Library( object, Dictifiable, HasName ): return roles class LibraryFolder( object, Dictifiable, HasName ): - dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time' ) + dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time', 'deleted' ) def __init__( self, name=None, description=None, item_count=0, order_id=None ): self.name = name or "Unnamed folder" self.description = description diff --git a/lib/galaxy/tools/test.py b/lib/galaxy/tools/test.py index 243f1d5523f..333c90f3b9a 100644 --- a/lib/galaxy/tools/test.py +++ b/lib/galaxy/tools/test.py @@ -196,12 +196,37 @@ class ToolTestBuilder( object ): if not isinstance(param_value, list): param_value = [ param_value ] processed_value = [ self.__add_uploaded_dataset( context.for_state(), v, param_extra, value ) for v in param_value ] - if isinstance( value, basic.DataCollectionToolParameter ): + elif isinstance( value, basic.DataCollectionToolParameter ): assert 'collection' in param_extra collection_def = param_extra[ 'collection' ] for ( name, value, extra ) in collection_def.collect_inputs(): require_file( name, value, extra, self.required_files ) processed_value = collection_def + elif isinstance( value, basic.SelectToolParameter ): + # Tests may specify values as either raw value or the value + # as they appear in the list - the API doesn't and shouldn't + # accept the text value - so we need to convert the text + # into the form value. + def process_param_value( param_value ): + found_value = False + value_for_text = None + if value.static_options: + for (text, opt_value, selected) in value.static_options: + if param_value == opt_value: + found_value = True + if value_for_text is None and param_value == text: + value_for_text = opt_value + if not found_value and value_for_text is not None: + processed_value = value_for_text + else: + processed_value = param_value + return processed_value + # Do replacement described above for lists or singleton + # values. + if isinstance( param_value, list ): + processed_value = map( process_param_value, param_value ) + else: + processed_value = process_param_value( param_value ) else: processed_value = param_value expanded_inputs[ context.for_state() ] = processed_value diff --git a/lib/galaxy/webapps/galaxy/api/folders.py b/lib/galaxy/webapps/galaxy/api/folders.py index 283c7dc98ff..89c79c35888 100644 --- a/lib/galaxy/webapps/galaxy/api/folders.py +++ b/lib/galaxy/webapps/galaxy/api/folders.py @@ -44,7 +44,7 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt :rtype: dict """ folder_id = self.folder_manager.cut_and_decode( trans, id ) - folder = self.folder_manager.get( trans, folder_id, check_ownership=False, check_accessible=True ) + folder = self.folder_manager.get( trans, folder_id, check_manageable=False, check_accessible=True ) return_dict = self.folder_manager.get_folder_dict( trans, folder ) return return_dict @@ -229,6 +229,32 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt 'Allowed values are: "set_permissions"' ) return self.folder_manager.get_current_roles( trans, folder ) + @expose_api + def delete( self, trans, id, **kwd ): + """ + delete( self, trans, id, **kwd ) + * DELETE /api/folders/{id} + marks the folder with the given ``id`` as `deleted` (or removes the `deleted` mark if the `undelete` param is true) + + .. note:: Currently, only admin users can un/delete folders. + + :param id: the encoded id of the folder to un/delete + :type id: an encoded id string + + :param undelete: (optional) flag specifying whether the item should be deleted or undeleted, defaults to false: + :type undelete: bool + + :returns: detailed folder information + :rtype: dictionary + + :raises: ItemAccessibilityException, MalformedId, ObjectNotFound + """ + folder = self.folder_manager.get( trans, self.folder_manager.cut_and_decode( trans, id ), True ) + undelete = util.string_as_bool( kwd.get( 'undelete', False ) ) + folder = self.folder_manager.delete( trans, folder, undelete ) + folder_dict = self.folder_manager.get_folder_dict( trans, folder ) + return folder_dict + @web.expose_api def update( self, trans, id, library_id, payload, **kwd ): """ diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index 8fd5af87c39..191a6e4c6e1 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -932,11 +932,14 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistoryMixin, Use @web.expose def show_params( self, trans, dataset_id=None, from_noframe=None, **kwd ): """ - Show the parameters used for an HDA + Show the parameters used for the job associated with an HDA """ - hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + try: + hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + except ValueError: + hda = None if not hda: - raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % str( dataset_id ) ) + raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % escape( str( dataset_id ) ) ) if not self._can_access_dataset( trans, hda ): return trans.show_error_message( "You are not allowed to access this dataset" ) @@ -961,19 +964,30 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistoryMixin, Use toolbox = self.get_toolbox() tool = toolbox.get_tool( job.tool_id ) assert tool is not None, 'Requested tool has not been loaded.' - #Load parameter objects, if a parameter type has changed, it's possible for the value to no longer be valid + # Load parameter objects, if a parameter type has changed, it's possible for the value to no longer be valid try: params_objects = job.get_param_values( trans.app, ignore_errors=False ) except: params_objects = job.get_param_values( trans.app, ignore_errors=True ) - upgrade_messages = tool.check_and_update_param_values( job.get_param_values( trans.app, ignore_errors=True ), trans, update_values=False ) #use different param_objects here, since we want to display original values as much as possible + # use different param_objects in the following line, since we want to display original values as much as possible + upgrade_messages = tool.check_and_update_param_values( job.get_param_values( trans.app, ignore_errors=True ), + trans, + update_values=False ) has_parameter_errors = True except: pass if job is None: return trans.show_error_message( "Job information is not available for this dataset." ) - #TODO: we should provide the basic values along with the objects, in order to better handle reporting of old values during upgrade - return trans.fill_template( "show_params.mako", inherit_chain=inherit_chain, history=trans.get_history(), hda=hda, job=job, tool=tool, params_objects=params_objects, upgrade_messages=upgrade_messages, has_parameter_errors=has_parameter_errors ) + # TODO: we should provide the basic values along with the objects, in order to better handle reporting of old values during upgrade + return trans.fill_template( "show_params.mako", + inherit_chain=inherit_chain, + history=trans.get_history(), + hda=hda, + job=job, + tool=tool, + params_objects=params_objects, + upgrade_messages=upgrade_messages, + has_parameter_errors=has_parameter_errors ) @web.expose def copy_datasets( self, trans, source_history=None, source_content_ids="", target_history_id=None, target_history_ids="", new_history_name="", do_copy=False, **kwd ): diff --git a/lib/galaxy/webapps/galaxy/controllers/search.py b/lib/galaxy/webapps/galaxy/controllers/search.py index 25e2f8c0e8c..4b33deb74e1 100644 --- a/lib/galaxy/webapps/galaxy/controllers/search.py +++ b/lib/galaxy/webapps/galaxy/controllers/search.py @@ -1,4 +1,3 @@ - """ Contains a basic search interface for Galaxy """ @@ -8,7 +7,13 @@ from galaxy.web.base.controller import BaseUIController log = logging.getLogger( __name__ ) + class SearchController( BaseUIController ): + @web.expose def index(self, trans): - return trans.fill_template( "search/index.mako") + """ + Per the message, this is not ready for human consumption, yet. Power + users can still use the search API. + """ + return trans.show_message("Sorry, the search interface isn't quite ready for use, yet. Watch the release notes and check back later!") diff --git a/static/scripts/galaxy.library.js b/static/scripts/galaxy.library.js index f45f2ee32b3..3f5277fb90d 100644 --- a/static/scripts/galaxy.library.js +++ b/static/scripts/galaxy.library.js @@ -36,7 +36,7 @@ var LibraryRouter = Backbone.Router.extend({ initialize: function() { this.routesHit = 0; //keep count of number of routes handled by the application - Backbone.history.on('route', function() { this.routesHit++; }, this); + Backbone.history.on( 'route', function() { this.routesHit++; }, this ); }, routes: { @@ -45,6 +45,7 @@ routes: { "library/:library_id/permissions" : "library_permissions", "folders/:folder_id/permissions" : "folder_permissions", "folders/:id" : "folder_content", + "folders/:id/page/:show_page" : "folder_page", "folders/:folder_id/datasets/:dataset_id" : "dataset_detail", "folders/:folder_id/datasets/:dataset_id/permissions" : "dataset_permissions", "folders/:folder_id/datasets/:dataset_id/versions/:ldda_id" : "dataset_version", @@ -53,13 +54,13 @@ routes: { }, back: function() { - if(this.routesHit > 1) { + if( this.routesHit > 1 ) { //more than one route hit -> user did not land to current page directly window.history.back(); } else { //otherwise go to the home page. Use replaceState if available so //the navigation doesn't create an extra history entry - this.navigate('#', {trigger:true, replace:true}); + this.navigate( '#', { trigger:true, replace:true } ); } } }); @@ -71,7 +72,8 @@ var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ with_deleted : false, sort_order : 'asc', sort_by : 'name', - library_page_size : 20 + library_page_size : 20, + folder_page_size : 15 } }); @@ -94,10 +96,10 @@ var GalaxyLibrary = Backbone.View.extend({ this.library_router = new LibraryRouter(); - this.library_router.on('route:libraries', function() { - Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); - Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); - }); + this.library_router.on( 'route:libraries', function() { + Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); + Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); + }); this.library_router.on('route:libraries_page', function( show_page ) { if ( Galaxy.libraries.libraryToolbarView === null ){ @@ -108,66 +110,77 @@ var GalaxyLibrary = Backbone.View.extend({ } }); - this.library_router.on('route:folder_content', function(id) { + this.library_router.on( 'route:folder_content', function( id ) { if (Galaxy.libraries.folderToolbarView){ - Galaxy.libraries.folderToolbarView.$el.unbind('click'); - } - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: id}); - }); + Galaxy.libraries.folderToolbarView.$el.unbind( 'click' ); + } + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id } ); + }); - this.library_router.on('route:download', function(folder_id, format) { - if ($('#folder_list_body').find(':checked').length === 0) { - mod_toastr.info( 'You must select at least one dataset to download' ); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: true, replace: true}); - } else { - Galaxy.libraries.folderToolbarView.download(folder_id, format); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: false, replace: true}); - } - }); + this.library_router.on( 'route:folder_page', function( id, show_page ) { + if ( Galaxy.libraries.folderToolbarView === null ){ + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( {id: id} ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id, show_page: show_page } ); + } else { + Galaxy.libraries.folderListView.render( { id: id, show_page: parseInt( show_page ) } ) + } + }); - this.library_router.on('route:dataset_detail', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); - }); - this.library_router.on('route:dataset_version', function(folder_id, dataset_id, ldda_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); - }); + this.library_router.on( 'route:download', function( folder_id, format ) { + if ( $( '#folder_list_body' ).find( ':checked' ).length === 0 ) { + mod_toastr.info( 'You must select at least one dataset to download' ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: true, replace: true } ); + } else { + Galaxy.libraries.folderToolbarView.download( folder_id, format ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: false, replace: true } ); + } + }); - this.library_router.on('route:dataset_permissions', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_detail', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); + }); - this.library_router.on('route:library_permissions', function(library_id){ - if (Galaxy.libraries.libraryView){ - Galaxy.libraries.libraryView.$el.unbind('click'); - } - Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_version', function(folder_id, dataset_id, ldda_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); + }); - this.library_router.on('route:folder_permissions', function(folder_id){ - if (Galaxy.libraries.folderView){ - Galaxy.libraries.folderView.$el.unbind('click'); - } - Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); - }); - this.library_router.on('route:import_datasets', function(folder_id, source){ - if (Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView){ - Galaxy.libraries.folderToolbarView.showImportModal({source:source}); - } else { - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: folder_id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: folder_id}); - Galaxy.libraries.folderToolbarView.showImportModal({source: source}); - } - }); + this.library_router.on( 'route:dataset_permissions', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); + }); + + this.library_router.on( 'route:library_permissions', function(library_id){ + if (Galaxy.libraries.libraryView){ + Galaxy.libraries.libraryView.$el.unbind('click'); + } + Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); + }); + + this.library_router.on( 'route:folder_permissions', function(folder_id){ + if (Galaxy.libraries.folderView){ + Galaxy.libraries.folderView.$el.unbind('click'); + } + Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); + }); + + this.library_router.on( 'route:import_datasets', function( folder_id, source ){ + if ( Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView ){ + Galaxy.libraries.folderToolbarView.showImportModal( { source:source } ); + } else { + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: folder_id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: folder_id } ); + Galaxy.libraries.folderToolbarView.showImportModal( { source: source } ); + } + }); Backbone.history.start({pushState: false}); } diff --git a/static/scripts/mvc/library/library-folderlist-view.js b/static/scripts/mvc/library/library-folderlist-view.js index b361c7ea459..8ea1fe0831e 100644 --- a/static/scripts/mvc/library/library-folderlist-view.js +++ b/static/scripts/mvc/library/library-folderlist-view.js @@ -15,322 +15,359 @@ function(mod_masthead, ) { var FolderListView = Backbone.View.extend({ - el : '#folder_items_element', - defaults: { - 'include_deleted' : false - }, - // progress percentage - progress: 0, - // progress rate per one item - progressStep: 1, - // self modal - modal : null, + el : '#folder_items_element', + // progress percentage + progress: 0, + // progress rate per one item + progressStep: 1, - folderContainer: null, + folderContainer: null, - sort: 'asc', + sort: 'asc', - events: { - 'click #select-all-checkboxes' : 'selectAll', - 'click .dataset_row' : 'selectClickedRow', - 'click .sort-folder-link' : 'sortColumnClicked' - }, + events: { + 'click #select-all-checkboxes' : 'selectAll', + 'click .dataset_row' : 'selectClickedRow', + 'click .sort-folder-link' : 'sortColumnClicked' + }, - // cache of rendered views - rowViews: {}, - - initialize : function(options){ - this.options = _.defaults(this.options || {}, options); - this.fetchFolder(); - }, + collection: null, - fetchFolder: function(options){ - var options = options || {}; - this.options.include_deleted = options.include_deleted; - var that = this; + defaults: { + include_deleted: false, + page_count: null, + show_page: null + }, - this.collection = new mod_library_model.Folder(); + /** + * Initialize and fetch the folder from the server. + * @param {object} options an object with options + */ + initialize : function( options ){ + this.options = _.defaults( this.options || {}, this.defaults, options ); + this.modal = null; + // map of folder item ids to item views = cache + this.rowViews = {}; - // start to listen if someone modifies collection - this.listenTo(this.collection, 'add', this.renderOne); - this.listenTo(this.collection, 'remove', this.removeOne); + // create a collection of folder items for this view + this.collection = new mod_library_model.Folder(); - this.folderContainer = new mod_library_model.FolderContainer({id: this.options.id}); - this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; - if (this.options.include_deleted){ - this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; - } - this.folderContainer.fetch({ - success: function(folder_container) { - that.folder_container = folder_container; - that.render(); - that.addAll(folder_container.get('folder').models); - if (that.options.dataset_id){ - row = _.findWhere(that.rowViews, {id: that.options.dataset_id}); - if (row) { + // start to listen if someone modifies the collection + this.listenTo( this.collection, 'add', this.renderOne ); + this.listenTo( this.collection, 'remove', this.removeOne ); + + this.fetchFolder(); + }, + + fetchFolder: function( options ){ + var options = options || {}; + this.options.include_deleted = options.include_deleted; + var that = this; + + this.folderContainer = new mod_library_model.FolderContainer( { id: this.options.id } ); + this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; + + if ( this.options.include_deleted ){ + this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; + } + this.folderContainer.fetch({ + success: function( folder_container ) { + that.folder_container = folder_container; + that.render(); + }, + error: function( model, response ){ + if ( typeof response.responseJSON !== "undefined" ){ + mod_toastr.error( response.responseJSON.err_msg + ' Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } else { + mod_toastr.error( 'An error ocurred. Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } + } + }); + }, + + render: function ( options ){ + this.options = _.extend( this.options, options ); + var template = this.templateFolder(); + $(".tooltip").hide(); + + // find the upper id in the full path + var path = this.folderContainer.attributes.metadata.full_path; + var upper_folder_id; + if ( path.length === 1 ){ // the library is above us + upper_folder_id = 0; + } else { + upper_folder_id = path[ path.length-2 ][ 0 ]; + } + + this.$el.html( template( { + path: this.folderContainer.attributes.metadata.full_path, + parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, + id: this.options.id, + upper_folder_id: upper_folder_id, + order: this.sort + } ) ); + + // when dataset_id is present render its details too + if ( this.options.dataset_id ){ + row = _.findWhere( that.rowViews, { id: this.options.dataset_id } ); + if ( row ) { row.showDatasetDetails(); } else { - mod_toastr.error('Dataset not found. Showing folder instead.'); + mod_toastr.error( 'Requested dataset not found. Showing folder instead.' ); } - } - }, - error: function(model, response){ - if (typeof response.responseJSON !== "undefined"){ - mod_toastr.error(response.responseJSON.err_msg + ' Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } else { - mod_toastr.error('An error ocurred. Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } + } else { + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.paginate(); } - }); - }, + $("#center [data-toggle]").tooltip(); + $("#center").css('overflow','auto'); + }, - render: function (options) { - this.options = _.defaults(this.options, options); - var template = this.templateFolder(); - $(".tooltip").hide(); + paginate: function( options ){ + this.options = _.extend( this.options, options ); - // TODO move to server - // find the upper id in the full path - var path = this.folderContainer.attributes.metadata.full_path; - var upper_folder_id; - if (path.length === 1){ // the library is above us - upper_folder_id = 0; - } else { - upper_folder_id = path[path.length-2][0]; - } + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.options.total_items_count = this.folder_container.get( 'folder' ).models.length; + this.options.page_count = Math.ceil( this.options.total_items_count / Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + var page_start = ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * ( this.options.show_page - 1 ) ); + var items_to_render = null; + items_to_render = this.folder_container.get( 'folder' ).models.slice( page_start, page_start + Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + this.options.items_shown = items_to_render.length; + // User requests page with no items + if ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * this.options.show_page > ( this.options.total_items_count + Galaxy.libraries.preferences.get( 'folder_page_size' ) ) ){ + items_to_render = []; + } + Galaxy.libraries.folderToolbarView.renderPaginator( this.options ); + this.collection.reset(); + this.addAll( items_to_render ) + }, - this.$el.html(template({ path: this.folderContainer.attributes.metadata.full_path, parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, id: this.options.id, upper_folder_id: upper_folder_id, order: this.sort})); + /** + * Adds all given models to the collection. + * @param {array of Item or FolderAsModel} array of models that should + * be added to the view's collection. + */ + addAll: function( models ){ + _.each(models, function( model ) { + Galaxy.libraries.folderListView.collection.add( model ); + }); + $( "#center [data-toggle]" ).tooltip(); + this.checkEmptiness(); + this.postRender(); + }, - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - //hack to show scrollbars - $("#center").css('overflow','auto'); - }, + /** + * Call this after all models are added to the collection + * to ensure that the folder toolbar will show proper options + * and that event will be bound on all subviews. + */ + postRender: function(){ + var fetched_metadata = this.folderContainer.attributes.metadata; + fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; + Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, - /** - * Call this after all models are added to the collection - * to ensure that the folder toolbar will show proper options - * and that event will be bound on all subviews. - */ - postRender: function(){ - var fetched_metadata = this.folderContainer.attributes.metadata; - fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; - Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, + /** + * Iterates this view's collection and calls the render + * function for each. Also binds the hover behavior. + */ + renderAll: function(){ + var that = this; + _.each( this.collection.models.reverse(), function( model ) { + that.renderOne( model ); + }); + this.postRender(); + }, - /** - * Adds all given models to the collection. - * @param {array of Item or FolderAsModel} array of models that should - * be added to the view's collection. - */ - addAll: function(models){ - _.each(models.reverse(), function(model) { - Galaxy.libraries.folderListView.collection.add(model); - }); - - $("#center [data-toggle]").tooltip(); - this.checkEmptiness(); - - this.postRender(); - }, - - /** - * Iterates this view's collection and calls the render - * function for each. Also binds the hover behavior. - */ - renderAll: function(){ - var that = this; - _.each(this.collection.models.reverse(), function(model) { - that.renderOne(model); - }); - this.postRender(); - }, - - /** - * Creates a view for the given model and adds it to the folder view. - * @param {Item or FolderAsModel} model of the view that will be rendered - */ - renderOne: function(model){ - if (model.get('type') !== 'folder'){ - this.options.contains_file = true; - // model.set('readable_size', this.size_to_string(model.get('file_size'))); - } - model.set('folder_id', this.id); - var rowView = new mod_library_folderrow_view.FolderRowView(model); - - // save new rowView to cache - this.rowViews[model.get('id')] = rowView; - - this.$el.find('#first_folder_item').after(rowView.el); - - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, - - /** - * removes the view of the given model from the DOM - * @param {Item or FolderAsModel} model of the view that will be removed - */ - removeOne: function(model){ - this.$el.find('#' + model.id).remove(); - }, - - /** Checks whether the list is empty and adds/removes the message */ - checkEmptiness : function(){ - if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ - this.$el.find('.empty-folder-message').show(); - } else { - this.$el.find('.empty-folder-message').hide(); - } - }, - - /** User clicked the table heading = he wants to sort stuff */ - sortColumnClicked : function(event){ - event.preventDefault(); - if (this.sort === 'asc'){ - this.sortFolder('name','desc'); - this.sort = 'desc'; - } else { - this.sortFolder('name','asc'); - this.sort = 'asc'; - } - this.render(); - this.renderAll(); - this.checkEmptiness(); - }, - - /** - * Sorts the underlying collection according to the parameters received. - * Currently supports only sorting by name. - */ - sortFolder: function(sort_by, order){ - if (sort_by === 'name'){ - if (order === 'asc'){ - return this.collection.sortByNameAsc(); - } else if (order === 'desc'){ - return this.collection.sortByNameDesc(); + /** + * Creates a view for the given model and adds it to the folder view. + * @param {Item or FolderAsModel} model of the view that will be rendered + */ + renderOne: function(model){ + if (model.get('type') !== 'folder'){ + this.options.contains_file = true; + // model.set('readable_size', this.size_to_string(model.get('file_size'))); } - } - }, + model.set('folder_id', this.id); + var rowView = new mod_library_folderrow_view.FolderRowView(model); - /** - * User clicked the checkbox in the table heading - * @param {context} event - */ - selectAll : function (event) { - var selected = event.target.checked; - that = this; - // Iterate each checkbox - $(':checkbox', '#folder_list_body').each(function() { - this.checked = selected; - $row = $(this.parentElement.parentElement); - // Change color of selected/unselected - if (selected) { - that.makeDarkRow($row); - } else { - that.makeWhiteRow($row); - } - }); - }, + // save new rowView to cache + this.rowViews[model.get('id')] = rowView; - /** - * Check checkbox if user clicks on the whole row or - * on the checkbox itself - */ - selectClickedRow : function (event) { - var checkbox = ''; - var $row; - var source; - if (event.target.localName === 'input'){ - checkbox = event.target; - $row = $(event.target.parentElement.parentElement); - source = 'input'; - } else if (event.target.localName === 'td') { - checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; - $row = $(event.target.parentElement); - source = 'td'; - } - if (checkbox.checked){ - if (source==='td'){ - checkbox.checked = ''; - this.makeWhiteRow($row); - } else if (source==='input') { - this.makeDarkRow($row); + this.$el.find('#first_folder_item').after(rowView.el); + + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, + + /** + * removes the view of the given model from the DOM + * @param {Item or FolderAsModel} model of the view that will be removed + */ + removeOne: function( model ){ + this.$el.find( '#' + model.id ).remove(); + }, + + /** Checks whether the list is empty and adds/removes the message */ + checkEmptiness : function(){ + if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ + this.$el.find('.empty-folder-message').show(); + } else { + this.$el.find('.empty-folder-message').hide(); } - } else { - if (source==='td'){ - checkbox.checked = 'selected'; - this.makeDarkRow($row); - } else if (source==='input') { - this.makeWhiteRow($row); + }, + + /** User clicked the table heading = he wants to sort stuff */ + sortColumnClicked : function(event){ + event.preventDefault(); + if (this.sort === 'asc'){ + this.sortFolder('name','desc'); + this.sort = 'desc'; + } else { + this.sortFolder('name','asc'); + this.sort = 'asc'; } + this.render(); + this.renderAll(); + this.checkEmptiness(); + }, + + /** + * Sorts the underlying collection according to the parameters received. + * Currently supports only sorting by name. + */ + sortFolder: function(sort_by, order){ + if (sort_by === 'name'){ + if (order === 'asc'){ + return this.collection.sortByNameAsc(); + } else if (order === 'desc'){ + return this.collection.sortByNameDesc(); + } + } + }, + + /** + * User clicked the checkbox in the table heading + * @param {context} event + */ + selectAll : function (event) { + var selected = event.target.checked; + that = this; + // Iterate each checkbox + $(':checkbox', '#folder_list_body').each(function() { + this.checked = selected; + $row = $(this.parentElement.parentElement); + // Change color of selected/unselected + if (selected) { + that.makeDarkRow($row); + } else { + that.makeWhiteRow($row); + } + }); + }, + + /** + * Check checkbox if user clicks on the whole row or + * on the checkbox itself + */ + selectClickedRow : function (event) { + var checkbox = ''; + var $row; + var source; + if (event.target.localName === 'input'){ + checkbox = event.target; + $row = $(event.target.parentElement.parentElement); + source = 'input'; + } else if (event.target.localName === 'td') { + checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; + $row = $(event.target.parentElement); + source = 'td'; + } + if (checkbox.checked){ + if (source==='td'){ + checkbox.checked = ''; + this.makeWhiteRow($row); + } else if (source==='input') { + this.makeDarkRow($row); + } + } else { + if (source==='td'){ + checkbox.checked = 'selected'; + this.makeDarkRow($row); + } else if (source==='input') { + this.makeWhiteRow($row); + } + } + }, + + makeDarkRow: function($row){ + $row.removeClass('light').addClass('dark'); + $row.find('a').removeClass('light').addClass('dark'); + $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); + }, + + makeWhiteRow: function($row){ + $row.removeClass('dark').addClass('light'); + $row.find('a').removeClass('dark').addClass('light'); + $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); + }, + + templateFolder : function (){ + var tmpl_array = []; + + // BREADCRUMBS + tmpl_array.push(''); + + // FOLDER CONTENT + tmpl_array.push(''); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + + tmpl_array.push(' '); + tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); + tmpl_array.push(''); + + return _.template(tmpl_array.join('')); } - }, - - makeDarkRow: function($row){ - $row.removeClass('light').addClass('dark'); - $row.find('a').removeClass('light').addClass('dark'); - $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); - }, - - makeWhiteRow: function($row){ - $row.removeClass('dark').addClass('light'); - $row.find('a').removeClass('dark').addClass('light'); - $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); - }, - - templateFolder : function (){ - var tmpl_array = []; - - // BREADCRUMBS - tmpl_array.push(''); - - // FOLDER CONTENT - tmpl_array.push(''); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - - tmpl_array.push(' '); - tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); - tmpl_array.push(''); - - return _.template(tmpl_array.join('')); - } - + }); return { diff --git a/static/scripts/mvc/library/library-foldertoolbar-view.js b/static/scripts/mvc/library/library-foldertoolbar-view.js index ec532b71d74..d5f3b9a6d20 100644 --- a/static/scripts/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/mvc/library/library-foldertoolbar-view.js @@ -20,7 +20,9 @@ var FolderToolbarView = Backbone.View.extend({ 'click #toolbtn_bulk_import' : 'modalBulkImport', 'click #include_deleted_datasets_chk' : 'checkIncludeDeleted', 'click #toolbtn_show_libinfo' : 'showLibInfo', - 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets' + 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets', + 'click #page_size_prompt' : 'showPageSizePrompt' + }, defaults: { @@ -90,6 +92,22 @@ var FolderToolbarView = Backbone.View.extend({ this.$el.html(toolbar_template(template_defaults)); }, + /** + * Called from FolderListView when needed. + * @param {object} options common options + */ + renderPaginator: function( options ){ + this.options = _.extend( this.options, options ); + var paginator_template = this.templatePaginator(); + this.$el.find( '#folder_paginator' ).html( paginator_template({ + id: this.options.id, + show_page: parseInt( this.options.show_page ), + page_count: parseInt( this.options.page_count ), + total_items_count: this.options.total_items_count, + items_shown: this.options.items_shown + })); + }, + configureElements: function(options){ this.options = _.extend(this.options, options); @@ -833,11 +851,11 @@ var FolderToolbarView = Backbone.View.extend({ var popped_item = lddas_set.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ - mod_toastr.success( 'Selected datasets deleted' ); + mod_toastr.success( 'Selected datasets were deleted.' ); } else if ( this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number ){ - mod_toastr.error( 'There was an error and no datasets were deleted.' ); + mod_toastr.error( 'There was an error and no datasets were deleted. Please make sure you have sufficient permissions.' ); } else if ( this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number ){ - mod_toastr.warning( 'Some of the datasets could not be deleted' ); + mod_toastr.warning( 'Some of the datasets could not be deleted. Please make sure you have sufficient permissions.' ); } Galaxy.modal.hide(); return this.deleted_lddas; @@ -976,6 +994,14 @@ var FolderToolbarView = Backbone.View.extend({ } }, + showPageSizePrompt: function(){ + var folder_page_size = prompt( 'How many items per page do you want to see?', Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + if ( ( folder_page_size != null ) && ( folder_page_size == parseInt( folder_page_size ) ) ) { + Galaxy.libraries.preferences.set( { 'folder_page_size': parseInt( folder_page_size ) } ); + Galaxy.libraries.folderListView.render( { id: this.options.id, show_page: 1 } ); + } + }, + templateToolBar: function(){ tmpl_array = []; @@ -1016,7 +1042,6 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(' '); tmpl_array.push('<% } %>'); - tmpl_array.push(' '); tmpl_array.push(' '); // TOOLBAR END tmpl_array.push('
'); @@ -1239,7 +1268,41 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(''); return _.template(tmpl_array.join('')); - } + }, + + templatePaginator: function(){ + tmpl_array = []; + + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items'); + tmpl_array.push(' '); + + return _.template(tmpl_array.join('')); + }, }); diff --git a/static/scripts/mvc/library/library-librarylist-view.js b/static/scripts/mvc/library/library-librarylist-view.js index 65ddfc85c1a..e229395a340 100644 --- a/static/scripts/mvc/library/library-librarylist-view.js +++ b/static/scripts/mvc/library/library-librarylist-view.js @@ -21,20 +21,19 @@ var LibraryListView = Backbone.View.extend({ 'click .sort-libraries-link' : 'sort_clicked' }, - /** - * Initialize and fetch the libraries from server. - * Async render afterwards. - * @param {object} options an options object - */ defaults: { page_count: null, show_page: null }, + /** + * Initialize and fetch the libraries from server. + * Async render afterwards. + * @param {object} options an object with options + */ initialize : function( options ){ this.options = _.defaults( this.options || {}, this.defaults, options ); - - var that = this; + var that = this; this.modal = null; // map of library model ids to library views = cache this.rowViews = {}; @@ -61,19 +60,10 @@ var LibraryListView = Backbone.View.extend({ */ render: function ( options ) { this.options = _.extend( this.options, options ); - - if ( ( this.options.page_size != null ) && ( this.options.page_size == parseInt( this.options.page_size ) ) ) { - Galaxy.libraries.preferences.set( { 'library_page_size': parseInt( this.options.page_size ) } ); - } - - $( ".tooltip" ).hide(); - // this.options.show_page = this.options.show_page || 1; var template = this.templateLibraryList(); var libraries_to_render = null; var models = null; - if ( this.options.show_page === null || this.options.show_page < 1 ){ - this.options.show_page = 1; - } + $( ".tooltip" ).hide(); if ( typeof options !== 'undefined' ){ models = typeof options.models !== 'undefined' ? options.models : null; } @@ -89,6 +79,10 @@ var LibraryListView = Backbone.View.extend({ } else { libraries_to_render = []; } + // pagination + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } this.options.total_libraries_count = libraries_to_render.length var page_start = ( Galaxy.libraries.preferences.get( 'library_page_size' ) * ( this.options.show_page - 1 ) ); this.options.page_count = Math.ceil( this.options.total_libraries_count / Galaxy.libraries.preferences.get( 'library_page_size' ) ); diff --git a/static/scripts/mvc/tools/tools-tree.js b/static/scripts/mvc/tools/tools-tree.js index 13d9a0a8eec..2ae5238713d 100644 --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -126,7 +126,7 @@ return Backbone.Model.extend({ // handle default value if (!field.skip) { if (input.optional && field.validate && !field.validate()) { - value = 'None'; + value = null; } add (job_input_id, input.id, value); } diff --git a/static/scripts/packed/galaxy.library.js b/static/scripts/packed/galaxy.library.js index f1235f884d0..b2d085183f9 100644 --- a/static/scripts/packed/galaxy.library.js +++ b/static/scripts/packed/galaxy.library.js @@ -1 +1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/base-mvc","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view","mvc/library/library-foldertoolbar-view","mvc/library/library-dataset-view","mvc/library/library-library-view","mvc/library/library-folder-view"],function(h,e,j,n,k,c,i,g,l,f,b,a){var o=Backbone.Router.extend({initialize:function(){this.routesHit=0;Backbone.history.on("route",function(){this.routesHit++},this)},routes:{"":"libraries","page/:show_page":"libraries_page","library/:library_id/permissions":"library_permissions","folders/:folder_id/permissions":"folder_permissions","folders/:id":"folder_content","folders/:folder_id/datasets/:dataset_id":"dataset_detail","folders/:folder_id/datasets/:dataset_id/permissions":"dataset_permissions","folders/:folder_id/datasets/:dataset_id/versions/:ldda_id":"dataset_version","folders/:folder_id/download/:format":"download","folders/:folder_id/import/:source":"import_datasets"},back:function(){if(this.routesHit>1){window.history.back()}else{this.navigate("#",{trigger:true,replace:true})}}});var m=n.SessionStorageModel.extend({defaults:{with_deleted:false,sort_order:"asc",sort_by:"name",library_page_size:20}});var d=Backbone.View.extend({libraryToolbarView:null,libraryListView:null,library_router:null,libraryView:null,folderToolbarView:null,folderListView:null,datasetView:null,initialize:function(){Galaxy.libraries=this;this.preferences=new m({id:"global-lib-prefs"});this.library_router=new o();this.library_router.on("route:libraries",function(){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView()});this.library_router.on("route:libraries_page",function(p){if(Galaxy.libraries.libraryToolbarView===null){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView({show_page:p})}else{Galaxy.libraries.libraryListView.render({show_page:p})}});this.library_router.on("route:folder_content",function(p){if(Galaxy.libraries.folderToolbarView){Galaxy.libraries.folderToolbarView.$el.unbind("click")}Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p})});this.library_router.on("route:download",function(p,q){if($("#folder_list_body").find(":checked").length===0){j.info("You must select at least one dataset to download");Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:true,replace:true})}else{Galaxy.libraries.folderToolbarView.download(p,q);Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:false,replace:true})}});this.library_router.on("route:dataset_detail",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p})});this.library_router.on("route:dataset_version",function(q,p,r){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,ldda_id:r,show_version:true})});this.library_router.on("route:dataset_permissions",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,show_permissions:true})});this.library_router.on("route:library_permissions",function(p){if(Galaxy.libraries.libraryView){Galaxy.libraries.libraryView.$el.unbind("click")}Galaxy.libraries.libraryView=new b.LibraryView({id:p,show_permissions:true})});this.library_router.on("route:folder_permissions",function(p){if(Galaxy.libraries.folderView){Galaxy.libraries.folderView.$el.unbind("click")}Galaxy.libraries.folderView=new a.FolderView({id:p,show_permissions:true})});this.library_router.on("route:import_datasets",function(p,q){if(Galaxy.libraries.folderToolbarView&&Galaxy.libraries.folderListView){Galaxy.libraries.folderToolbarView.showImportModal({source:q})}else{Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p});Galaxy.libraries.folderToolbarView.showImportModal({source:q})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:d}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/base-mvc","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view","mvc/library/library-foldertoolbar-view","mvc/library/library-dataset-view","mvc/library/library-library-view","mvc/library/library-folder-view"],function(h,e,j,n,k,c,i,g,l,f,b,a){var o=Backbone.Router.extend({initialize:function(){this.routesHit=0;Backbone.history.on("route",function(){this.routesHit++},this)},routes:{"":"libraries","page/:show_page":"libraries_page","library/:library_id/permissions":"library_permissions","folders/:folder_id/permissions":"folder_permissions","folders/:id":"folder_content","folders/:id/page/:show_page":"folder_page","folders/:folder_id/datasets/:dataset_id":"dataset_detail","folders/:folder_id/datasets/:dataset_id/permissions":"dataset_permissions","folders/:folder_id/datasets/:dataset_id/versions/:ldda_id":"dataset_version","folders/:folder_id/download/:format":"download","folders/:folder_id/import/:source":"import_datasets"},back:function(){if(this.routesHit>1){window.history.back()}else{this.navigate("#",{trigger:true,replace:true})}}});var m=n.SessionStorageModel.extend({defaults:{with_deleted:false,sort_order:"asc",sort_by:"name",library_page_size:20,folder_page_size:15}});var d=Backbone.View.extend({libraryToolbarView:null,libraryListView:null,library_router:null,libraryView:null,folderToolbarView:null,folderListView:null,datasetView:null,initialize:function(){Galaxy.libraries=this;this.preferences=new m({id:"global-lib-prefs"});this.library_router=new o();this.library_router.on("route:libraries",function(){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView()});this.library_router.on("route:libraries_page",function(p){if(Galaxy.libraries.libraryToolbarView===null){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView({show_page:p})}else{Galaxy.libraries.libraryListView.render({show_page:p})}});this.library_router.on("route:folder_content",function(p){if(Galaxy.libraries.folderToolbarView){Galaxy.libraries.folderToolbarView.$el.unbind("click")}Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p})});this.library_router.on("route:folder_page",function(q,p){if(Galaxy.libraries.folderToolbarView===null){Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:q});Galaxy.libraries.folderListView=new c.FolderListView({id:q,show_page:p})}else{Galaxy.libraries.folderListView.render({id:q,show_page:parseInt(p)})}});this.library_router.on("route:download",function(p,q){if($("#folder_list_body").find(":checked").length===0){j.info("You must select at least one dataset to download");Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:true,replace:true})}else{Galaxy.libraries.folderToolbarView.download(p,q);Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:false,replace:true})}});this.library_router.on("route:dataset_detail",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p})});this.library_router.on("route:dataset_version",function(q,p,r){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,ldda_id:r,show_version:true})});this.library_router.on("route:dataset_permissions",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,show_permissions:true})});this.library_router.on("route:library_permissions",function(p){if(Galaxy.libraries.libraryView){Galaxy.libraries.libraryView.$el.unbind("click")}Galaxy.libraries.libraryView=new b.LibraryView({id:p,show_permissions:true})});this.library_router.on("route:folder_permissions",function(p){if(Galaxy.libraries.folderView){Galaxy.libraries.folderView.$el.unbind("click")}Galaxy.libraries.folderView=new a.FolderView({id:p,show_permissions:true})});this.library_router.on("route:import_datasets",function(p,q){if(Galaxy.libraries.folderToolbarView&&Galaxy.libraries.folderListView){Galaxy.libraries.folderToolbarView.showImportModal({source:q})}else{Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p});Galaxy.libraries.folderToolbarView.showImportModal({source:q})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:d}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-folderlist-view.js b/static/scripts/packed/mvc/library/library-folderlist-view.js index c495703b784..661a2f96c12 100644 --- a/static/scripts/packed/mvc/library/library-folderlist-view.js +++ b/static/scripts/packed/mvc/library/library-folderlist-view.js @@ -1 +1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderrow-view","mvc/library/library-dataset-view"],function(d,f,g,e,a,c){var b=Backbone.View.extend({el:"#folder_items_element",defaults:{include_deleted:false},progress:0,progressStep:1,modal:null,folderContainer:null,sort:"asc",events:{"click #select-all-checkboxes":"selectAll","click .dataset_row":"selectClickedRow","click .sort-folder-link":"sortColumnClicked"},rowViews:{},initialize:function(h){this.options=_.defaults(this.options||{},h);this.fetchFolder()},fetchFolder:function(h){var h=h||{};this.options.include_deleted=h.include_deleted;var i=this;this.collection=new e.Folder();this.listenTo(this.collection,"add",this.renderOne);this.listenTo(this.collection,"remove",this.removeOne);this.folderContainer=new e.FolderContainer({id:this.options.id});this.folderContainer.url=this.folderContainer.attributes.urlRoot+this.options.id+"/contents";if(this.options.include_deleted){this.folderContainer.url=this.folderContainer.url+"?include_deleted=true"}this.folderContainer.fetch({success:function(j){i.folder_container=j;i.render();i.addAll(j.get("folder").models);if(i.options.dataset_id){row=_.findWhere(i.rowViews,{id:i.options.dataset_id});if(row){row.showDatasetDetails()}else{g.error("Dataset not found. Showing folder instead.")}}},error:function(k,j){if(typeof j.responseJSON!=="undefined"){g.error(j.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{g.error("An error ocurred. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(h){this.options=_.defaults(this.options,h);var i=this.templateFolder();$(".tooltip").hide();var j=this.folderContainer.attributes.metadata.full_path;var k;if(j.length===1){k=0}else{k=j[j.length-2][0]}this.$el.html(i({path:this.folderContainer.attributes.metadata.full_path,parent_library_id:this.folderContainer.attributes.metadata.parent_library_id,id:this.options.id,upper_folder_id:k,order:this.sort}));$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},postRender:function(){var h=this.folderContainer.attributes.metadata;h.contains_file=typeof this.collection.findWhere({type:"file"})!=="undefined";Galaxy.libraries.folderToolbarView.configureElements(h);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},addAll:function(h){_.each(h.reverse(),function(i){Galaxy.libraries.folderListView.collection.add(i)});$("#center [data-toggle]").tooltip();this.checkEmptiness();this.postRender()},renderAll:function(){var h=this;_.each(this.collection.models.reverse(),function(i){h.renderOne(i)});this.postRender()},renderOne:function(i){if(i.get("type")!=="folder"){this.options.contains_file=true}i.set("folder_id",this.id);var h=new a.FolderRowView(i);this.rowViews[i.get("id")]=h;this.$el.find("#first_folder_item").after(h.el);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},removeOne:function(h){this.$el.find("#"+h.id).remove()},checkEmptiness:function(){if((this.$el.find(".dataset_row").length===0)&&(this.$el.find(".folder_row").length===0)){this.$el.find(".empty-folder-message").show()}else{this.$el.find(".empty-folder-message").hide()}},sortColumnClicked:function(h){h.preventDefault();if(this.sort==="asc"){this.sortFolder("name","desc");this.sort="desc"}else{this.sortFolder("name","asc");this.sort="asc"}this.render();this.renderAll();this.checkEmptiness()},sortFolder:function(i,h){if(i==="name"){if(h==="asc"){return this.collection.sortByNameAsc()}else{if(h==="desc"){return this.collection.sortByNameDesc()}}}},selectAll:function(i){var h=i.target.checked;that=this;$(":checkbox","#folder_list_body").each(function(){this.checked=h;$row=$(this.parentElement.parentElement);if(h){that.makeDarkRow($row)}else{that.makeWhiteRow($row)}})},selectClickedRow:function(i){var k="";var h;var j;if(i.target.localName==="input"){k=i.target;h=$(i.target.parentElement.parentElement);j="input"}else{if(i.target.localName==="td"){k=$("#"+i.target.parentElement.id).find(":checkbox")[0];h=$(i.target.parentElement);j="td"}}if(k.checked){if(j==="td"){k.checked="";this.makeWhiteRow(h)}else{if(j==="input"){this.makeDarkRow(h)}}}else{if(j==="td"){k.checked="selected";this.makeDarkRow(h)}else{if(j==="input"){this.makeWhiteRow(h)}}}},makeDarkRow:function(h){h.removeClass("light").addClass("dark");h.find("a").removeClass("light").addClass("dark");h.find(".fa-file-o").removeClass("fa-file-o").addClass("fa-file")},makeWhiteRow:function(h){h.removeClass("dark").addClass("light");h.find("a").removeClass("dark").addClass("light");h.find(".fa-file").removeClass("fa-file").addClass("fa-file-o")},templateFolder:function(){var h=[];h.push('");h.push('');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push("
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
");h.push('');return _.template(h.join(""))}});return{FolderListView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderrow-view","mvc/library/library-dataset-view"],function(d,f,g,e,a,c){var b=Backbone.View.extend({el:"#folder_items_element",progress:0,progressStep:1,folderContainer:null,sort:"asc",events:{"click #select-all-checkboxes":"selectAll","click .dataset_row":"selectClickedRow","click .sort-folder-link":"sortColumnClicked"},collection:null,defaults:{include_deleted:false,page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);this.modal=null;this.rowViews={};this.collection=new e.Folder();this.listenTo(this.collection,"add",this.renderOne);this.listenTo(this.collection,"remove",this.removeOne);this.fetchFolder()},fetchFolder:function(h){var h=h||{};this.options.include_deleted=h.include_deleted;var i=this;this.folderContainer=new e.FolderContainer({id:this.options.id});this.folderContainer.url=this.folderContainer.attributes.urlRoot+this.options.id+"/contents";if(this.options.include_deleted){this.folderContainer.url=this.folderContainer.url+"?include_deleted=true"}this.folderContainer.fetch({success:function(j){i.folder_container=j;i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){g.error(j.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{g.error("An error ocurred. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(h){this.options=_.extend(this.options,h);var i=this.templateFolder();$(".tooltip").hide();var j=this.folderContainer.attributes.metadata.full_path;var k;if(j.length===1){k=0}else{k=j[j.length-2][0]}this.$el.html(i({path:this.folderContainer.attributes.metadata.full_path,parent_library_id:this.folderContainer.attributes.metadata.parent_library_id,id:this.options.id,upper_folder_id:k,order:this.sort}));if(this.options.dataset_id){row=_.findWhere(that.rowViews,{id:this.options.dataset_id});if(row){row.showDatasetDetails()}else{g.error("Requested dataset not found. Showing folder instead.")}}else{if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.paginate()}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},paginate:function(j){this.options=_.extend(this.options,j);if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.options.total_items_count=this.folder_container.get("folder").models.length;this.options.page_count=Math.ceil(this.options.total_items_count/Galaxy.libraries.preferences.get("folder_page_size"));var i=(Galaxy.libraries.preferences.get("folder_page_size")*(this.options.show_page-1));var h=null;h=this.folder_container.get("folder").models.slice(i,i+Galaxy.libraries.preferences.get("folder_page_size"));this.options.items_shown=h.length;if(Galaxy.libraries.preferences.get("folder_page_size")*this.options.show_page>(this.options.total_items_count+Galaxy.libraries.preferences.get("folder_page_size"))){h=[]}Galaxy.libraries.folderToolbarView.renderPaginator(this.options);this.collection.reset();this.addAll(h)},addAll:function(h){_.each(h,function(i){Galaxy.libraries.folderListView.collection.add(i)});$("#center [data-toggle]").tooltip();this.checkEmptiness();this.postRender()},postRender:function(){var h=this.folderContainer.attributes.metadata;h.contains_file=typeof this.collection.findWhere({type:"file"})!=="undefined";Galaxy.libraries.folderToolbarView.configureElements(h);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},renderAll:function(){var h=this;_.each(this.collection.models.reverse(),function(i){h.renderOne(i)});this.postRender()},renderOne:function(i){if(i.get("type")!=="folder"){this.options.contains_file=true}i.set("folder_id",this.id);var h=new a.FolderRowView(i);this.rowViews[i.get("id")]=h;this.$el.find("#first_folder_item").after(h.el);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},removeOne:function(h){this.$el.find("#"+h.id).remove()},checkEmptiness:function(){if((this.$el.find(".dataset_row").length===0)&&(this.$el.find(".folder_row").length===0)){this.$el.find(".empty-folder-message").show()}else{this.$el.find(".empty-folder-message").hide()}},sortColumnClicked:function(h){h.preventDefault();if(this.sort==="asc"){this.sortFolder("name","desc");this.sort="desc"}else{this.sortFolder("name","asc");this.sort="asc"}this.render();this.renderAll();this.checkEmptiness()},sortFolder:function(i,h){if(i==="name"){if(h==="asc"){return this.collection.sortByNameAsc()}else{if(h==="desc"){return this.collection.sortByNameDesc()}}}},selectAll:function(i){var h=i.target.checked;that=this;$(":checkbox","#folder_list_body").each(function(){this.checked=h;$row=$(this.parentElement.parentElement);if(h){that.makeDarkRow($row)}else{that.makeWhiteRow($row)}})},selectClickedRow:function(i){var k="";var h;var j;if(i.target.localName==="input"){k=i.target;h=$(i.target.parentElement.parentElement);j="input"}else{if(i.target.localName==="td"){k=$("#"+i.target.parentElement.id).find(":checkbox")[0];h=$(i.target.parentElement);j="td"}}if(k.checked){if(j==="td"){k.checked="";this.makeWhiteRow(h)}else{if(j==="input"){this.makeDarkRow(h)}}}else{if(j==="td"){k.checked="selected";this.makeDarkRow(h)}else{if(j==="input"){this.makeWhiteRow(h)}}}},makeDarkRow:function(h){h.removeClass("light").addClass("dark");h.find("a").removeClass("light").addClass("dark");h.find(".fa-file-o").removeClass("fa-file-o").addClass("fa-file")},makeWhiteRow:function(h){h.removeClass("dark").addClass("light");h.find("a").removeClass("dark").addClass("light");h.find(".fa-file").removeClass("fa-file").addClass("fa-file-o")},templateFolder:function(){var h=[];h.push('");h.push('');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push("
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
");h.push('');return _.template(h.join(""))}});return{FolderListView:b}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js index 261ca796839..663f15f446e 100644 --- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js @@ -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,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+=''});$('
'+g+"
").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({url:galaxy_config.root+"api/datatypes?extension_only=False",success: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.idi.id?1:j.id=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=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('
');tmpl_array.push('
');tmpl_array.push(" DATA LIBRARIES");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' ");tmpl_array.push("<% } else { %>");tmpl_array.push(' ');tmpl_array.push("<% } %>");tmpl_array.push(' ');tmpl_array.push(' ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("
");tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("

Library name:

");tmpl_array.push('

<%- library.get("name") %>

');tmpl_array.push("

Library description:

");tmpl_array.push('

<%- library.get("description") %>

');tmpl_array.push("

Library synopsis:

");tmpl_array.push('

<%- library.get("synopsis") %>

');tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('');g.push("Select history: ");g.push('");g.push("");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('
');g.push("Importing selected datasets to history <%= _.escape(history_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("Adding selected datasets to library folder <%= _.escape(folder_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('
');g.push('
All files you select will be imported into the current folder.
');g.push('');g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push("
");g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('
');g.push('
All files within the given folders and their subfolders will be imported into the current folder.
');g.push('
');g.push('");g.push('");g.push("
");g.push('');g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('
');g.push('
');g.push("Select history: ");g.push('");g.push("
");g.push("
");g.push('
');g.push("
");g.push("
");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("Choose the datasets to import:");g.push("
    ");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push('
  • ">');g.push(' <%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push("
  • ");g.push(" <% }); %>");g.push("
");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","click #page_size_prompt":"showPageSizePrompt"},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))},renderPaginator:function(h){this.options=_.extend(this.options,h);var g=this.templatePaginator();this.$el.find("#folder_paginator").html(g({id:this.options.id,show_page:parseInt(this.options.show_page),page_count:parseInt(this.options.page_count),total_items_count:this.options.total_items_count,items_shown:this.options.items_shown}))},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+=''});$('
'+g+"
").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({url:galaxy_config.root+"api/datatypes?extension_only=False",success: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.idi.id?1:j.id=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=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}},showPageSizePrompt:function(){var g=prompt("How many items per page do you want to see?",Galaxy.libraries.preferences.get("folder_page_size"));if((g!=null)&&(g==parseInt(g))){Galaxy.libraries.preferences.set({folder_page_size:parseInt(g)});Galaxy.libraries.folderListView.render({id:this.options.id,show_page:1})}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push('
');tmpl_array.push(" DATA LIBRARIES");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' ");tmpl_array.push("<% } else { %>");tmpl_array.push(' ');tmpl_array.push("<% } %>");tmpl_array.push(' ');tmpl_array.push(' ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
");tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("

Library name:

");tmpl_array.push('

<%- library.get("name") %>

');tmpl_array.push("

Library description:

");tmpl_array.push('

<%- library.get("description") %>

');tmpl_array.push("

Library synopsis:

");tmpl_array.push('

<%- library.get("synopsis") %>

');tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('');g.push("Select history: ");g.push('");g.push("");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('
');g.push("Importing selected datasets to history <%= _.escape(history_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("Adding selected datasets to library folder <%= _.escape(folder_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('
');g.push('
All files you select will be imported into the current folder.
');g.push('');g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push("
");g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('
');g.push('
All files within the given folders and their subfolders will be imported into the current folder.
');g.push('
');g.push('");g.push('");g.push("
");g.push('');g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('
');g.push('
');g.push("Select history: ");g.push('");g.push("
");g.push("
");g.push('
');g.push("
");g.push("
");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("Choose the datasets to import:");g.push("
    ");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push('
  • ">');g.push(' <%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push("
  • ");g.push(" <% }); %>");g.push("
");return _.template(g.join(""))},templatePaginator:function(){tmpl_array=[];tmpl_array.push('
    ');tmpl_array.push(" <% if ( ( show_page - 1 ) > 0 ) { %>");tmpl_array.push(" <% if ( ( show_page - 1 ) > page_count ) { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } %>");tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } %>");tmpl_array.push('
  • ');tmpl_array.push(' <% print( show_page ) %>');tmpl_array.push("
  • ");tmpl_array.push(" <% if ( ( show_page ) < page_count ) { %>");tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • ');tmpl_array.push('
  • ');tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • ');tmpl_array.push('
  • ');tmpl_array.push(" <% } %>");tmpl_array.push("
");tmpl_array.push(" ");tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items');tmpl_array.push(" ");return _.template(tmpl_array.join(""))},});return{FolderToolbarView:b}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-librarylist-view.js b/static/scripts/packed/mvc/library/library-librarylist-view.js index 71457da652e..e6a94a1e132 100644 --- a/static/scripts/packed/mvc/library/library-librarylist-view.js +++ b/static/scripts/packed/mvc/library/library-librarylist-view.js @@ -1 +1 @@ -define(["galaxy.masthead","mvc/base-mvc","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view"],function(b,g,d,e,c,a){var f=Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);var i=this;this.modal=null;this.rowViews={};this.collection=new c.Libraries();this.collection.fetch({success:function(){i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){e.error(j.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},render:function(i){this.options=_.extend(this.options,i);if((this.options.page_size!=null)&&(this.options.page_size==parseInt(this.options.page_size))){Galaxy.libraries.preferences.set({library_page_size:parseInt(this.options.page_size)})}$(".tooltip").hide();var j=this.templateLibraryList();var k=null;var l=null;if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}if(typeof i!=="undefined"){l=typeof i.models!=="undefined"?i.models:null}if(this.collection!==null&&l===null){this.sortLibraries();if(Galaxy.libraries.preferences.get("with_deleted")){k=this.collection.models}else{k=this.collection.where({deleted:false})}}else{if(l!==null){k=l}else{k=[]}}this.options.total_libraries_count=k.length;var h=(Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1));this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size"));if(this.options.total_libraries_count>0&&(h(this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size"))){k=[]}this.$el.html(j({length:1,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options);this.renderRows(k)}else{this.$el.html(j({length:0,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},renderRows:function(l){for(var k=0;k');tmpl_array.push("<% if(length === 0) { %>");tmpl_array.push('
There are no libraries visible to you here. If you expected some to show up please consult the library security wikipage or visit the Galaxy support site.
');tmpl_array.push("<% } else{ %>");tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
name descriptionsynopsis
");tmpl_array.push("<% }%>");tmpl_array.push("
");return _.template(tmpl_array.join(""))},});return{LibraryListView:f}}); \ No newline at end of file +define(["galaxy.masthead","mvc/base-mvc","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view"],function(b,g,d,e,c,a){var f=Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);var i=this;this.modal=null;this.rowViews={};this.collection=new c.Libraries();this.collection.fetch({success:function(){i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){e.error(j.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},render:function(i){this.options=_.extend(this.options,i);var j=this.templateLibraryList();var k=null;var l=null;$(".tooltip").hide();if(typeof i!=="undefined"){l=typeof i.models!=="undefined"?i.models:null}if(this.collection!==null&&l===null){this.sortLibraries();if(Galaxy.libraries.preferences.get("with_deleted")){k=this.collection.models}else{k=this.collection.where({deleted:false})}}else{if(l!==null){k=l}else{k=[]}}if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.options.total_libraries_count=k.length;var h=(Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1));this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size"));if(this.options.total_libraries_count>0&&(h(this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size"))){k=[]}this.$el.html(j({length:1,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options);this.renderRows(k)}else{this.$el.html(j({length:0,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},renderRows:function(l){for(var k=0;k');tmpl_array.push("<% if(length === 0) { %>");tmpl_array.push('
There are no libraries visible to you here. If you expected some to show up please consult the library security wikipage or visit the Galaxy support site.
');tmpl_array.push("<% } else{ %>");tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
name descriptionsynopsis
");tmpl_array.push("<% }%>");tmpl_array.push("
");return _.template(tmpl_array.join(""))},});return{LibraryListView:f}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-tree.js b/static/scripts/packed/mvc/tools/tools-tree.js index 314ed98ae5a..1ef4764692e 100644 --- a/static/scripts/packed/mvc/tools/tools-tree.js +++ b/static/scripts/packed/mvc/tools/tools-tree.js @@ -1 +1 @@ -define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("
");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r="None"}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.app.tree.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('
');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("
");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r=null}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.app.tree.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('
');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ No newline at end of file diff --git a/templates/base/base_panels.mako b/templates/base/base_panels.mako index 64e1fd0d598..2e735c391ae 100644 --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -13,7 +13,7 @@ self.body_class="" self.require_javascript=False %> - + <%def name="init()"> ## Override @@ -45,7 +45,7 @@ %endif @@ -62,7 +62,7 @@ 'libs/require', "mvc/ui" )} - + ## Handle AJAX (actually hidden iframe) upload tool + <%def name="center_panel()"> -${search_init()} - -
-${search_dialog("search_format_output")} -
- - diff --git a/templates/search/search.mako b/templates/search/search.mako deleted file mode 100644 index 01cf4981ca2..00000000000 --- a/templates/search/search.mako +++ /dev/null @@ -1,68 +0,0 @@ - -<%def name="search_init()"> - - ${h.js( - 'libs/jquery/jquery', -)} - - - -<%def name="search_dialog(output_format)"> - - - - -
- -
- -
- - - diff --git a/templates/webapps/galaxy/cloud/index.mako b/templates/webapps/galaxy/cloud/index.mako index 309526fd651..3dbb0fa22e5 100644 --- a/templates/webapps/galaxy/cloud/index.mako +++ b/templates/webapps/galaxy/cloud/index.mako @@ -218,7 +218,7 @@ Credentials section of the AWS Console.
%if share_string: - + %else: %endif %if ami: - + %endif %if bucket_default: - + %endif
diff --git a/templates/webapps/galaxy/cloud/run.mako b/templates/webapps/galaxy/cloud/run.mako deleted file mode 100644 index 98d1424a716..00000000000 --- a/templates/webapps/galaxy/cloud/run.mako +++ /dev/null @@ -1,41 +0,0 @@ -<%inherit file="/webapps/galaxy/base_panels.mako"/> - -<%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.active_view="shared" - self.message_box_visible=False -%> - - - -<%def name="center_panel()"> -
-
-

Launching a Galaxy Cloud Instance

-%if error: -

${error}

-%elif instance: - %if kp_material: -

Very Important Key Pair Information

-

A new key pair named '${kp_name}' has been created in your AWS - account and will be used to access this instance via ssh. It is - very important that you save the following private key - as it is not saved on this Galaxy instance and will be permanently lost - once you leave this page. To do this, save the following key block as - a plain text file named '${kp_name}'.

-
${kp_material}
- %endif -

The instance '${instance.id} has been successfully launched using the - '${instance.image_id}' AMI.
Access it at http://${instance.public_dns_name}

-

SSH access is available using your private key '${kp_name}'.

-%else: -

Unknown failure, no instance. Please refer to your AWS console at https://console.aws.amazon.com

-%endif -
-
- - diff --git a/test/functional/tools/multi_select.xml b/test/functional/tools/multi_select.xml index 5f940609e94..0c5fd5635aa 100644 --- a/test/functional/tools/multi_select.xml +++ b/test/functional/tools/multi_select.xml @@ -33,5 +33,13 @@ + + + + + + + +