3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7fa4a243b126/ Changeset: 7fa4a243b126 Branch: docker-work User: kell...@gmail.com Date: 2014-10-12 04:40:15+00:00 Summary: Adding docker_set_user option so that docker jobs will be run with the '-u <current user>' flag so docker container commands don't run as root. Affected #: 3 files diff -r db93990f8def9e20c979337dbca0ef1e7e06f400 -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 config/job_conf.xml.sample_advanced --- a/config/job_conf.xml.sample_advanced +++ b/config/job_conf.xml.sample_advanced @@ -196,7 +196,8 @@ adding the '--rm' flag to the command line, the container will be removed automatically after the program is complete. --> - <!-- <param id="docker_auto_rm">false</param> --> + <!-- <param id="docker_auto_rm">true</param> --> + <!-- <param id="docker_set_user">true</param> --><!-- Following command can be used to tweak docker command. --><!-- <param id="docker_cmd">/usr/local/custom_docker/docker</param> --><!-- Following can be used to connect to docke server in different diff -r db93990f8def9e20c979337dbca0ef1e7e06f400 -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 lib/galaxy/tools/deps/containers.py --- a/lib/galaxy/tools/deps/containers.py +++ b/lib/galaxy/tools/deps/containers.py @@ -208,7 +208,8 @@ env_directives=env_directives, working_directory=working_directory, net=prop("net", "none"), # By default, docker instance has networking disabled - auto_rm=prop("auto_rm", docker_util.DEFAULT_AUTO_REMOVE), + auto_rm=asbool(prop("auto_rm", docker_util.DEFAULT_AUTO_REMOVE)), + set_user=asbool(prop("set_user", docker_util.DEFAULT_SET_USER)), **docker_host_props ) return "%s\n%s" % (cache_command, run_command) diff -r db93990f8def9e20c979337dbca0ef1e7e06f400 -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 lib/galaxy/tools/deps/docker_util.py --- a/lib/galaxy/tools/deps/docker_util.py +++ b/lib/galaxy/tools/deps/docker_util.py @@ -1,3 +1,5 @@ + +import os DEFAULT_DOCKER_COMMAND = "docker" DEFAULT_SUDO = True @@ -9,6 +11,7 @@ DEFAULT_MEMORY = None DEFAULT_VOLUMES_FROM = None DEFAULT_AUTO_REMOVE = True +DEFAULT_SET_USER = True class DockerVolume(object): @@ -84,6 +87,7 @@ sudo=DEFAULT_SUDO, sudo_cmd=DEFAULT_SUDO_COMMAND, auto_rm=DEFAULT_AUTO_REMOVE, + set_user=DEFAULT_SET_USER, host=DEFAULT_HOST, ): command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host) @@ -104,6 +108,8 @@ command_parts.extend(["--net", net]) if auto_rm: command_parts.append("--rm") + if set_user: + command_parts.extend(["-u", str(os.geteuid())]) full_image = image if tag: full_image = "%s:%s" % (full_image, tag) https://bitbucket.org/galaxy/galaxy-central/commits/ba656141a2d7/ Changeset: ba656141a2d7 Branch: docker-work User: kell...@gmail.com Date: 2014-10-12 04:48:02+00:00 Summary: Merging default Affected #: 89 files diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 .hgtags --- a/.hgtags +++ b/.hgtags @@ -19,3 +19,5 @@ 2a756ca2cb1826db7796018e77d12e2dd7b67603 latest_2014.02.10 ca45b78adb4152fc6e7395514d46eba6b7d0b838 release_2014.08.11 548ab24667d6206780237bd807f7d857a484c461 latest_2014.08.11 +2092948937ac30ef82f71463a235c66d34987088 release_2014.10.06 +0f70d302b85e2a74d6c0c9ec7d4ccc6f11787eac latest_2014.10.06 diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/galaxy.library.js --- a/client/galaxy/scripts/galaxy.library.js +++ b/client/galaxy/scripts/galaxy.library.js @@ -16,19 +16,19 @@ "mvc/library/library-library-view", "mvc/library/library-folder-view" ], -function(mod_masthead, - mod_utils, - mod_toastr, - mod_baseMVC, - mod_library_model, - mod_folderlist_view, - mod_librarylist_view, - mod_librarytoolbar_view, - mod_foldertoolbar_view, - mod_library_dataset_view, - mod_library_library_view, - mod_library_folder_view - ) { + function(mod_masthead, + mod_utils, + mod_toastr, + mod_baseMVC, + mod_library_model, + mod_folderlist_view, + mod_librarylist_view, + mod_librarytoolbar_view, + mod_foldertoolbar_view, + mod_library_dataset_view, + mod_library_library_view, + mod_library_folder_view + ) { // ============================================================================ // ROUTER @@ -37,10 +37,11 @@ this.routesHit = 0; //keep count of number of routes handled by the application Backbone.history.on('route', function() { this.routesHit++; }, this); - }, +}, - routes: { +routes: { "" : "libraries", + "page/:show_page" : "libraries_page", "library/:library_id/permissions" : "library_permissions", "folders/:folder_id/permissions" : "folder_permissions", "folders/:id" : "folder_content", @@ -49,27 +50,28 @@ "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() { +back: function() { if(this.routesHit > 1) { //more than one route hit -> user did not land to current page directly window.history.back(); - } else { + } 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}); - } } +} }); // ============================================================================ /** session storage for library preferences */ var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ defaults : { - with_deleted : false, - sort_order : 'asc', - sort_by : 'name' + with_deleted : false, + sort_order : 'asc', + sort_by : 'name', + library_page_size : 20 } }); @@ -88,77 +90,86 @@ initialize : function(){ Galaxy.libraries = this; - this.preferences = new LibraryPrefs( {id: 'global-lib-prefs'} ); + this.preferences = new LibraryPrefs( { id: 'global-lib-prefs' } ); 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_page', function( show_page ) { + if ( Galaxy.libraries.libraryToolbarView === null ){ + Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); + Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView( { show_page: show_page } ); + } else { + Galaxy.libraries.libraryListView.render( { show_page: show_page } ) + } }); 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 = 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) { + 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 { + } 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_detail', function(folder_id, dataset_id){ + 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){ + } + 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}); - }); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); + }); - this.library_router.on('route:dataset_permissions', function(folder_id, dataset_id){ + 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}); - }); + } + 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){ + 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}); - }); + } + 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){ + 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){ + } + 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 { + } 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}); + Backbone.history.start({pushState: false}); } }); diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -72,7 +72,7 @@ }, render: function(options){ - this.options = _.extend(this.options, options); + this.options = _.extend( this.options, options ); var toolbar_template = this.templateToolBar(); var template_defaults = { id: this.options.id, @@ -346,18 +346,18 @@ this.modal = Galaxy.modal; var template_modal = this.templateImportPathModal(); this.modal.show({ - closing_events : true, - title : 'Please enter paths to import', - body : template_modal({}), - buttons : { - 'Import' : function() {that.importFromPathsClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} - }, - closing_callback: function(){ - // TODO: should not trigger routes outside of the router - Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); - } - }); + closing_events : true, + title : 'Please enter paths to import', + body : template_modal({}), + buttons : { + 'Import' : function() { that.importFromPathsClicked(that); }, + 'Close' : function() { Galaxy.modal.hide(); } + }, + closing_callback: function(){ + // TODO: should not trigger routes outside of the router + Galaxy.libraries.library_router.navigate( 'folders/' + that.id, { trigger: true } ); + } + }); this.renderSelectBoxes(); }, @@ -367,34 +367,37 @@ */ fetchExtAndGenomes: function(){ var that = this; - mod_utils.get(galaxy_config.root + "api/datatypes?extension_only=False", - function(datatypes) { - for (key in datatypes) { - that.list_extensions.push({ - id : datatypes[key].extension, - text : datatypes[key].extension, - description : datatypes[key].description, - description_url : datatypes[key].description_url - }); - } - that.list_extensions.sort(function(a, b) { - return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; - }); - that.list_extensions.unshift(that.auto); - - }); - mod_utils.get(galaxy_config.root + "api/genomes", - function(genomes) { - for (key in genomes) { - that.list_genomes.push({ - id : genomes[key][1], - text : genomes[key][0] - }); - } - that.list_genomes.sort(function(a, b) { - return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; - }); - }); + mod_utils.get({ + url : galaxy_config.root + "api/datatypes?extension_only=False", + success : function( datatypes ) { + for (key in datatypes) { + that.list_extensions.push({ + id : datatypes[key].extension, + text : datatypes[key].extension, + description : datatypes[key].description, + description_url : datatypes[key].description_url + }); + } + that.list_extensions.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + that.list_extensions.unshift(that.auto); + } + }); + mod_utils.get({ + url: galaxy_config.root + "api/genomes", + success: function( genomes ) { + for ( key in genomes ) { + that.list_genomes.push({ + id : genomes[key][1], + text : genomes[key][0] + }); + } + that.list_genomes.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + } + }); }, renderSelectBoxes: function(){ @@ -1027,7 +1030,7 @@ tmpl_array.push(' </div>'); tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>'); tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>'); - tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>'); + tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>'); tmpl_array.push(' </div>'); // TOOLBAR END diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/library/library-librarylist-view.js --- a/client/galaxy/scripts/mvc/library/library-librarylist-view.js +++ b/client/galaxy/scripts/mvc/library/library-librarylist-view.js @@ -4,13 +4,15 @@ "utils/utils", "libs/toastr", "mvc/library/library-model", - "mvc/library/library-libraryrow-view"], -function(mod_masthead, - mod_baseMVC, - mod_utils, - mod_toastr, - mod_library_model, - mod_library_libraryrow_view) { + "mvc/library/library-libraryrow-view" +], function( + mod_masthead, + mod_baseMVC, + mod_utils, + mod_toastr, + mod_library_model, + mod_library_libraryrow_view +){ var LibraryListView = Backbone.View.extend({ el: '#libraries_element', @@ -19,104 +21,135 @@ 'click .sort-libraries-link' : 'sort_clicked' }, - modal: null, + /** + * Initialize and fetch the libraries from server. + * Async render afterwards. + * @param {object} options an options object + */ + defaults: { + page_count: null, + show_page: null + }, - // collection of {Item}s - collection: null, + initialize : function( options ){ + this.options = _.defaults( this.options || {}, this.defaults, options ); - // map of library model ids to library views = cache - rowViews: {}, - - initialize : function(options){ - this.options = _.defaults(this.options || {}, options); - var that = this; + var that = this; + this.modal = null; + // map of library model ids to library views = cache this.rowViews = {}; + // collection of {Item}s this.collection = new mod_library_model.Libraries(); this.collection.fetch({ success: function(){ that.render(); }, - error: function(model, response){ - if (typeof response.responseJSON !== "undefined"){ - mod_toastr.error(response.responseJSON.err_msg); + error: function( model, response ){ + if ( typeof response.responseJSON !== "undefined" ){ + mod_toastr.error( response.responseJSON.err_msg ); } else { - mod_toastr.error('An error ocurred.'); + mod_toastr.error( 'An error ocurred.' ); } } }); }, - /** Renders the libraries table either from the object's own collection, - * or from a given array of library models, - * or renders an empty list in case no data is given. */ - render: function (options) { - $(".tooltip").hide(); + /** + * Render the libraries table either from the object's own collection, + * or from a given array of library models, + * or render an empty list in case no data is given. + */ + 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 include_deleted = Galaxy.libraries.preferences.get('with_deleted'); var models = null; - if (typeof options !== 'undefined'){ - include_deleted = typeof options.with_deleted !== 'undefined' ? options.with_deleted : false; + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + if ( typeof options !== 'undefined' ){ models = typeof options.models !== 'undefined' ? options.models : null; } - - if (this.collection !== null && models === null){ + if ( this.collection !== null && models === null ){ this.sortLibraries(); - if (include_deleted){ // show all the libraries + if ( Galaxy.libraries.preferences.get( 'with_deleted' ) ){ libraries_to_render = this.collection.models; - } else{ // show only undeleted libraries - libraries_to_render = this.collection.where({deleted: false}); + } else { + libraries_to_render = this.collection.where( { deleted: false } ); } - } else if (models !== null){ + } else if ( models !== null ){ libraries_to_render = models; } else { libraries_to_render = []; + } + 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' ) ); + if ( this.options.total_libraries_count > 0 && ( page_start < this.options.total_libraries_count ) ){ + libraries_to_render = libraries_to_render.slice( page_start, page_start + Galaxy.libraries.preferences.get( 'library_page_size' ) ); + this.options.libraries_shown = libraries_to_render.length; + // User requests page with no libraries + if ( Galaxy.libraries.preferences.get( 'library_page_size' ) * this.options.show_page > ( this.options.total_libraries_count + Galaxy.libraries.preferences.get( 'library_page_size' ) ) ){ + libraries_to_render = []; } - - this.$el.html(template({length: libraries_to_render.length, order: Galaxy.libraries.preferences.get('sort_order') })); - - if (libraries_to_render.length > 0){ - this.renderRows(libraries_to_render); + this.$el.html( template({ + length: 1, + order: Galaxy.libraries.preferences.get( 'sort_order' ) + })); + Galaxy.libraries.libraryToolbarView.renderPaginator( this.options ); + this.renderRows( libraries_to_render ); + } else { + this.$el.html( template({ + length: 0, + order: Galaxy.libraries.preferences.get( 'sort_order' ) + })); + Galaxy.libraries.libraryToolbarView.renderPaginator( this.options ); } - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - // modification of upper DOM element to show scrollbars due - // to the #center element inheritance - $("#center").css('overflow','auto'); + $( "#center [data-toggle]" ).tooltip(); + $( "#center" ).css( 'overflow','auto' ); }, - /** Renders all given models as rows in the library list */ - renderRows: function(libraries_to_render){ - for (var i = 0; i < libraries_to_render.length; i++) { + /** + * Render all given models as rows in the library list + * @param {array} libraries_to_render array of library models to render + */ + renderRows: function( libraries_to_render ){ + for ( var i = 0; i < libraries_to_render.length; i++ ) { var library = libraries_to_render[i]; - var cachedView = _.findWhere(this.rowViews, {id: library.get('id')}); - if (cachedView !== undefined && this instanceof Backbone.View){ + // search whether we have the item cached + var cachedView = _.findWhere( this.rowViews, { id: library.get( 'id' ) } ); + if ( cachedView !== undefined && this instanceof Backbone.View ){ cachedView.delegateEvents(); - this.$el.find('#library_list_body').append(cachedView.el); + this.$el.find( '#library_list_body' ).append( cachedView.el ); } else { - this.renderOne({library:library}) + this.renderOne( { library: library } ) } } }, /** - * Creates a view for the given model and adds it to the libraries view. + * Create a view for the given model and add it to the libraries view. * @param {Library} model of the view that will be rendered */ - renderOne: function(options){ + renderOne: function( options ){ var library = options.library; - var rowView = new mod_library_libraryrow_view.LibraryRowView(library); - // we want to prepend new item - if (options.prepend){ - this.$el.find('#library_list_body').prepend(rowView.el); - } else { - this.$el.find('#library_list_body').append(rowView.el); - } + var rowView = new mod_library_libraryrow_view.LibraryRowView( library ); + this.$el.find( '#library_list_body' ).append( rowView.el ); // save new rowView to cache - this.rowViews[library.get('id')] = rowView; + this.rowViews[ library.get( 'id' ) ] = rowView; }, - /** Table heading was clicked, update sorting preferences and re-render */ + /** + * Table heading was clicked, update sorting preferences and re-render. + * @return {[type]} [description] + */ sort_clicked : function(){ if (Galaxy.libraries.preferences.get('sort_order') === 'asc'){ Galaxy.libraries.preferences.set({'sort_order': 'desc'}); @@ -126,8 +159,10 @@ this.render(); }, - /** Sorts the underlying collection according to the parameters received. - Currently supports only sorting by name. */ + /** + * Sort the underlying collection according to the parameters received. + * Currently supports only sorting by name. + */ sortLibraries: function(){ if (Galaxy.libraries.preferences.get('sort_by') === 'name'){ if (Galaxy.libraries.preferences.get('sort_order') === 'asc'){ @@ -138,6 +173,13 @@ } }, + redirectToHome: function(){ + window.location = '../'; + }, + redirectToLogin: function(){ + window.location = '/user/login'; + }, + // MMMMMMMMMMMMMMMMMM // === TEMPLATES ==== // MMMMMMMMMMMMMMMMMM @@ -147,14 +189,14 @@ tmpl_array.push('<div class="library_container table-responsive">'); tmpl_array.push('<% if(length === 0) { %>'); - tmpl_array.push('<div>There are no libraries visible to you. If you expected some to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/">Galaxy support site</a>.</div>'); + tmpl_array.push('<div>There are no libraries visible to you here. If you expected some to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>'); tmpl_array.push('<% } else{ %>'); tmpl_array.push('<table class="grid table table-condensed">'); tmpl_array.push(' <thead>'); tmpl_array.push(' <th style="width:30%;"><a class="sort-libraries-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>'); tmpl_array.push(' <th style="width:22%;">description</th>'); tmpl_array.push(' <th style="width:22%;">synopsis</th> '); - tmpl_array.push(' <th style="width:26%;"></th> '); + tmpl_array.push(' <th style="width:26%;"></th>'); tmpl_array.push(' </thead>'); tmpl_array.push(' <tbody id="library_list_body">'); // library item views will attach here @@ -166,14 +208,6 @@ return _.template(tmpl_array.join('')); }, - - redirectToHome: function(){ - window.location = '../'; - }, - redirectToLogin: function(){ - window.location = '/user/login'; - }, - }); return { diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/library/library-librarytoolbar-view.js --- a/client/galaxy/scripts/mvc/library/library-librarytoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-librarytoolbar-view.js @@ -11,11 +11,13 @@ el: '#center', events: { - 'click #create_new_library_btn' : 'show_library_modal', - 'click #include_deleted_chk' : 'check_include_deleted' + 'click #create_new_library_btn' : 'showLibraryModal', + 'click #include_deleted_chk' : 'includeDeletedChecked', + 'click #page_size_prompt' : 'showPageSizePrompt' }, - initialize: function(){ + initialize: function( options ){ + this.options = _.defaults( this.options || {}, options ); this.render(); }, @@ -23,21 +25,34 @@ var toolbar_template = this.templateToolBar(); var is_admin = false; var is_anonym = true; - if (Galaxy.currUser){ + if ( Galaxy.currUser ){ is_admin = Galaxy.currUser.isAdmin(); is_anonym = Galaxy.currUser.isAnonymous(); } - this.$el.html(toolbar_template({admin_user: is_admin, anon_user: is_anonym})); - if (is_admin){ - this.$el.find('#include_deleted_chk')[0].checked = Galaxy.libraries.preferences.get('with_deleted'); + this.$el.html(toolbar_template( { admin_user: is_admin, anon_user: is_anonym } ) ); + if ( is_admin ){ + this.$el.find( '#include_deleted_chk' )[0].checked = Galaxy.libraries.preferences.get( 'with_deleted' ); } }, - show_library_modal : function (event){ + /** + * Called from LibraryListView when needed. + * @param {object} options common options + */ + renderPaginator: function( options ){ + this.options = _.extend( this.options, options ); + var paginator_template = this.templatePaginator(); + this.$el.find( '#library_paginator' ).html( paginator_template({ + show_page: parseInt( this.options.show_page ), + page_count: parseInt( this.options.page_count ), + total_libraries_count: this.options.total_libraries_count, + libraries_shown: this.options.libraries_shown + })); + }, + + showLibraryModal : function (event){ event.preventDefault(); event.stopPropagation(); - - // create modal var self = this; this.modal = Galaxy.modal; this.modal.show({ @@ -45,22 +60,22 @@ title : 'Create New Library', body : this.templateNewLibraryInModal(), buttons : { - 'Create' : function() {self.create_new_library_event();}, - 'Close' : function() {self.modal.hide();} + 'Create' : function() { self.createNewLibrary(); }, + 'Close' : function() { self.modal.hide(); } } }); }, - create_new_library_event: function(){ - var libraryDetails = this.serialize_new_library(); - if (this.validate_new_library(libraryDetails)){ + createNewLibrary: function(){ + var libraryDetails = this.serializeNewLibrary(); + if (this.valdiateNewLibrary(libraryDetails)){ var library = new mod_library_model.Library(); var self = this; library.save(libraryDetails, { success: function (library) { Galaxy.libraries.libraryListView.collection.add(library); self.modal.hide(); - self.clear_library_modal(); + self.clearLibraryModal(); Galaxy.libraries.libraryListView.render(); mod_toastr.success('Library created.'); }, @@ -78,15 +93,22 @@ return false; }, + showPageSizePrompt: function(){ + var library_page_size = prompt( 'How many libraries per page do you want to see?', Galaxy.libraries.preferences.get( 'library_page_size' ) ); + if ( ( library_page_size != null ) && ( library_page_size == parseInt( library_page_size ) ) ) { + Galaxy.libraries.preferences.set( { 'library_page_size': parseInt( library_page_size ) } ); + Galaxy.libraries.libraryListView.render(); + } + }, + // clear the library modal once saved - clear_library_modal : function(){ + clearLibraryModal : function(){ $("input[name='Name']").val(''); $("input[name='Description']").val(''); $("input[name='Synopsis']").val(''); }, - // serialize data from the new library form - serialize_new_library : function(){ + serializeNewLibrary : function(){ return { name: $("input[name='Name']").val(), description: $("input[name='Description']").val(), @@ -94,18 +116,20 @@ }; }, - // validate new library info - validate_new_library: function(libraryDetails){ + valdiateNewLibrary: function( libraryDetails ){ return libraryDetails.name !== ''; }, - // include or exclude deleted libraries from the view - check_include_deleted: function(event){ + /** + * Include or exclude deleted libraries in the view. + * @param {object} event common event + */ + includeDeletedChecked: function( event ){ if (event.target.checked){ - Galaxy.libraries.preferences.set({'with_deleted': true}); + Galaxy.libraries.preferences.set( { 'with_deleted': true } ); Galaxy.libraries.libraryListView.render(); } else{ - Galaxy.libraries.preferences.set({'with_deleted': false}); + Galaxy.libraries.preferences.set( { 'with_deleted': false } ); Galaxy.libraries.libraryListView.render(); } }, @@ -113,22 +137,26 @@ templateToolBar: function(){ tmpl_array = []; + tmpl_array.push('<div class="library_style_container">'); - // TOOLBAR tmpl_array.push(' <div id="toolbar_form">'); tmpl_array.push(' <div id="library_toolbar">'); - tmpl_array.push(' <span><strong>DATA LIBRARIES</strong></span>'); - tmpl_array.push(' <% if(admin_user === true) { %>'); - tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Include deleted libraries"> | <input id="include_deleted_chk" style="margin: 0;" type="checkbox"> include deleted |</input></span>'); - tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Create New Library"><button id="create_new_library_btn" class="primary-button btn-xs" type="button"><span class="fa fa-plus"></span> New Library</button></span>'); - tmpl_array.push(' <% } %>'); - tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/ListOfLibraries" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>'); - tmpl_array.push(' </div>'); - - tmpl_array.push(' <div>'); - tmpl_array.push(' '); - tmpl_array.push(' </div>'); - + tmpl_array.push(' <form class="form-inline" role="form">'); + tmpl_array.push(' <span><strong><a href="#" title="Go to first page">DATA LIBRARIES</a></strong></span>'); + tmpl_array.push(' <% if(admin_user === true) { %>'); + tmpl_array.push(' <div class="checkbox" style="height: 20px;">'); + tmpl_array.push(' <label>'); + tmpl_array.push(' <input id="include_deleted_chk" type="checkbox"> include deleted </input>'); + tmpl_array.push(' </label>'); + tmpl_array.push(' </div>'); + tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Create New Library"><button id="create_new_library_btn" class="primary-button btn-xs" type="button"><span class="fa fa-plus"></span> New Library</button></span>'); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/ListOfLibraries" target="_blank"><button class="primary-button" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>'); + tmpl_array.push(' <span id="library_paginator" class="library-paginator">'); + // paginator will append here + tmpl_array.push(' </span>'); + tmpl_array.push(' </form>'); + tmpl_array.push(' </div>'); tmpl_array.push(' </div>'); tmpl_array.push(' <div id="libraries_element">'); // table with libraries will append here @@ -138,6 +166,39 @@ return _.template(tmpl_array.join('')); }, + templatePaginator: function(){ + tmpl_array = []; + + tmpl_array.push(' <ul class="pagination pagination-sm">'); + tmpl_array.push(' <% if ( ( show_page - 1 ) > 0 ) { %>'); + tmpl_array.push(' <% if ( ( show_page - 1 ) > page_count ) { %>'); // we are on higher page than total page count + tmpl_array.push(' <li><a href="#page/1"><span class="fa fa-angle-double-left"></span></a></li>'); + tmpl_array.push(' <li class="disabled"><a href="#page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>'); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push(' <li><a href="#page/1"><span class="fa fa-angle-double-left"></span></a></li>'); + tmpl_array.push(' <li><a href="#page/<% print( show_page - 1 ) %>"><% print( show_page - 1 ) %></a></li>'); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' <% } else { %>'); // we are on the first page + tmpl_array.push(' <li class="disabled"><a href="#page/1"><span class="fa fa-angle-double-left"></span></a></li>'); + tmpl_array.push(' <li class="disabled"><a href="#page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>'); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' <li class="active">'); + tmpl_array.push(' <a href="#page/<% print( show_page ) %>"><% print( show_page ) %></a>'); + tmpl_array.push(' </li>'); + tmpl_array.push(' <% if ( ( show_page ) < page_count ) { %>'); + tmpl_array.push(' <li><a href="#page/<% print( show_page + 1 ) %>"><% print( show_page + 1 ) %></a></li>'); + tmpl_array.push(' <li><a href="#page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>'); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push(' <li class="disabled"><a href="#page/<% print( show_page ) %>"><% print( show_page + 1 ) %></a></li>'); + tmpl_array.push(' <li class="disabled"><a href="#page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>'); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' </ul>'); + tmpl_array.push(' <span>'); + tmpl_array.push(' showing <a data-toggle="tooltip" data-placement="top" title="Click to change the number of libraries on page" id="page_size_prompt"><%- libraries_shown %></a> of <%- total_libraries_count %> libraries'); + tmpl_array.push(' </span>'); + + return _.template(tmpl_array.join('')); + }, templateNewLibraryInModal: function(){ tmpl_array = []; diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-content.js --- /dev/null +++ b/client/galaxy/scripts/mvc/tools/tools-content.js @@ -0,0 +1,142 @@ +define(['utils/utils'], function(Utils){ + return Backbone.Model.extend({ + // initialize + initialize: function(options) { + // backup basic url + this.base_url = galaxy_config.root + 'api/histories/' + options.history_id + '/contents'; + + // prepare content obects + this.datatypes = {}; + this.summary = {}; + + // link this + var self = this; + + // request datatypes + Utils.get({ + url : galaxy_config.root + 'api/datatypes/mapping', + cache : true, + success : function(response) { + // backup datatype dictionary + self.datatypes = response; + + // get history summary + Utils.get({ + url : self.base_url + '?deleted=false', + success : function(response) { + // backup summary + self.summary = response; + + // log + console.debug('tools-content::initialize() - Completed.'); + + // callback + options.success && options.success(); + }, + error : function(response) { + // log request failure + console.debug('tools-content::initialize() - Ajax request for summary failed.'); + console.debug(response); + } + }); + }, + error : function(response) { + // log request failure + console.debug('tools-content::initialize() - Ajax request for datatypes failed.'); + console.debug(response); + } + }); + }, + + /** + * Filters contents by data type. + */ + filterType: function(options) { + // initialize parameters + options = options || {}; + var result = []; + + // identify content type + var history_content_type = 'dataset'; + if (options.src== 'hdca') { + history_content_type = 'dataset_collection'; + } + + // search in summary + for (var i in this.summary) { + var content = this.summary[i]; + + // match datatypes + var found = false; + for (var i in options.extensions) { + if (this._matchType(options.extensions[i], content.extension)) { + found = true; + break; + } + } + + // final match result + if ((content.history_content_type === history_content_type) && (found || !options.extensions)) { + result.push(content); + } + } + return result; + }, + + /** Get details of a content by id. + */ + getDetails: function(options) { + // check id + if (!options.id || options.id === 'null') { + options.success && options.success(); + return; + } + + // create url + var api_url = this.base_url + '/datasets/' + options.id; + if (options.src == 'hdca') { + api_url = this.base_url + '/dataset_collections/' + options.id; + } + + // request details + Utils.get({ + url : api_url, + success : function(response) { + options.success && options.success(response); + }, + error : function(response) { + options.success && options.success(); + console.debug('tools-content::getDetails() - Ajax request for content failed.'); + console.debug(response); + } + }); + }, + + /** Check if datatypes match + */ + _matchType: function(target, reference) { + // check if target class is available + var target_class = this.datatypes.ext_to_class_name[target]; + if (!target_class) { + console.debug('tools-content::_matchType() - Specific target class unavailable. Accepting all formats.'); + return true; + } + + // check if reference class is available + var reference_class = this.datatypes.ext_to_class_name[reference]; + if (!reference_class) { + console.debug('tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.'); + return true; + } + + // check reference group + var reference_group = this.datatypes.class_to_classes[reference_class]; + if (reference_group[target_class]) { + return true; + } + + // classes do not match + return false; + } + }); +}); \ No newline at end of file diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-datasets.js --- a/client/galaxy/scripts/mvc/tools/tools-datasets.js +++ /dev/null @@ -1,117 +0,0 @@ -define(['utils/utils'], function(Utils){ - return Backbone.Model.extend({ - // initialize - initialize: function(options) { - // prepare datasets obects - this.datatypes = {}; - this.summary = {}; - - // link this - var self = this; - - // request datatypes - Utils.get({ - url : galaxy_config.root + 'api/datatypes/mapping', - cache : true, - success : function(response) { - // backup datatype dictionary - self.datatypes = response; - - // get history summary - Utils.get({ - url : galaxy_config.root + 'api/histories/' + options.history_id + '/contents?deleted=false', - success : function(response) { - // backup summary - self.summary = response; - - // log - console.debug('tools-datasets::initialize() - Completed.'); - - // callback - options.success && options.success(); - }, - error : function(response) { - // log request failure - console.debug('tools-datasets::initialize() - Ajax request for summary failed.'); - console.debug(response); - } - }); - }, - error : function(response) { - // log request failure - console.debug('tools-datasets::initialize() - Ajax request for datatypes failed.'); - console.debug(response); - } - }); - }, - - /** - * Filters datasets by data type. - */ - filterType: function(options) { - options = options || {}; - var result = []; - for (var i in this.summary) { - var dataset = this.summary[i]; - - // match datatypes - var found = false; - for (var i in options.data_types) { - if (this._matchType(options.data_types[i], dataset.extension)) { - found = true; - break; - } - } - - // final match result - if ((dataset.history_content_type === options.content_type || !options.content_type) && (found || !options.data_types)) { - result.push(dataset); - } - } - return result; - }, - - /** Get details of a dataset by id. - * @param{String} Dataset id - */ - getDetails: function(dataset_id, callback) { - Utils.get({ - url : galaxy_config.root + 'api/datasets/' + dataset_id, - success : function(response) { - callback && callback(response); - }, - error : function(response) { - console.debug('tools-datasets::getDetails() - Ajax request for dataset failed.'); - console.debug(response); - } - }); - }, - - /** Check if datatypes match - */ - _matchType: function(target, reference) { - // check if target class is available - var target_class = this.datatypes.ext_to_class_name[target]; - if (!target_class) { - console.debug('tools-datasets::_matchType() - Specific target class unavailable. Accepting all formats.'); - return true; - } - - // check if reference class is available - var reference_class = this.datatypes.ext_to_class_name[reference]; - if (!reference_class) { - console.debug('tools-datasets::_matchType() - Specific reference class unavailable. Accepting all formats.'); - return true; - } - - // check reference group - var reference_group = this.datatypes.class_to_classes[reference_class]; - if (reference_group[target_class]) { - return true; - } - - // classes do not match - return false; - } - }); -}); \ No newline at end of file diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-form.js --- a/client/galaxy/scripts/mvc/tools/tools-form.js +++ b/client/galaxy/scripts/mvc/tools/tools-form.js @@ -1,11 +1,11 @@ /** This is the main class of the tool form plugin. It is referenced as 'app' in all lower level modules. */ -define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc', +define(['utils/utils', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', 'mvc/citation/citation-model', 'mvc/citation/citation-view', - 'mvc/tools', 'mvc/tools/tools-template', 'mvc/tools/tools-datasets', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'], - function(Portlet, Ui, CitationModel, CitationView, - Tools, ToolTemplate, ToolDatasets, ToolSection, ToolTree, ToolJobs) { + 'mvc/tools', 'mvc/tools/tools-template', 'mvc/tools/tools-content', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'], + function(Utils, Portlet, Ui, CitationModel, CitationView, + Tools, ToolTemplate, ToolContent, ToolSection, ToolTree, ToolJobs) { // create tool model var Model = Backbone.Model.extend({ @@ -42,7 +42,7 @@ // load tool model this.model = new Model({ - id : options.id + id : options.id }); // creates a tree/json structure from the input form @@ -60,8 +60,8 @@ // reset input element list, which contains the dom elements of each input element (includes also the input field) this.element_list = {}; - // initialize datasets - this.datasets = new ToolDatasets({ + // initialize contents + this.content = new ToolContent({ history_id : this.options.history_id, success : function() { self._initializeToolForm(); @@ -93,7 +93,7 @@ } // log - console.debug('tools-form::refresh() - Recreated tree structure. Refresh.'); + console.debug('tools-form::refresh() - Recreated data structure. Refresh.'); }, // initialize tool form @@ -101,6 +101,37 @@ // link this var self = this; + // fetch model and render form + this.model.fetch({ + error: function(response) { + console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); + }, + success: function() { + // backup inputs + self.inputs = self.model.get('inputs'); + + // update inputs with job parameters + if (self.options.job_id) { + Utils.get({ + url: galaxy_config.root + 'api/jobs/' + self.options.job_id, + success: function(parameters) { + // TODO: Update input parameters + //self._updateInputs(self.inputs, parameters); + self._buildForm(); + } + }); + } else { + self._buildForm(); + } + } + }); + }, + + // builds the tool form + _buildForm: function() { + // link this + var self = this; + // create question button var button_question = new Ui.ButtonIcon({ icon : 'fa-question-circle', @@ -127,89 +158,94 @@ title : 'Share', tooltip : 'Share this tool', onclick : function() { - prompt('Copy to clipboard: Ctrl+C, Enter', galaxy_config.root + 'root?tool_id=' + self.options.id); + prompt('Copy to clipboard: Ctrl+C, Enter', window.location.origin + galaxy_config.root + 'root?tool_id=' + self.options.id); } }); - // fetch model and render form - this.model.fetch({ - error: function(response) { - console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); - }, - success: function() { - // create tool form section - self.section = new ToolSection.View(self, { - inputs : self.model.get('inputs'), - cls : 'ui-table-plain' - }); - - // TEMPORARY SWITCH - // switch to classic tool form mako if the form definition is incompatible - if (self.incompatible) { - self.$el.hide(); - $('#tool-form-classic').show(); - return; + // default operations + var operations = { + button_question: button_question, + button_search: button_search, + button_share: button_share + } + + // add admin operations + if (Galaxy.currUser.get('is_admin')) { + // create download button + operations['button_download'] = new Ui.ButtonIcon({ + icon : 'fa-download', + title : 'Download', + tooltip : 'Download this tool', + onclick : function() { + window.location.href = galaxy_config.root + 'api/tools/' + self.options.id + '/download'; } - - // create portlet - self.portlet = new Portlet.View({ - icon : 'fa-wrench', - title: '<b>' + self.model.get('name') + '</b> ' + self.model.get('description'), - buttons: { - execute: new Ui.ButtonIcon({ - icon : 'fa-check', - tooltip : 'Execute the tool', - title : 'Execute', - floating : 'clear', - onclick : function() { - self.job_handler.submit(); - } - }) - }, - operations: { - button_question: button_question, - button_search: button_search, - button_share: button_share + }); + } + + // create tool form section + this.section = new ToolSection.View(self, { + inputs : this.inputs, + cls : 'ui-table-plain' + }); + + // switch to classic tool form mako if the form definition is incompatible + if (this.incompatible) { + this.$el.hide(); + $('#tool-form-classic').show(); + return; + } + + // create portlet + this.portlet = new Portlet.View({ + icon : 'fa-wrench', + title: '<b>' + this.model.get('name') + '</b> ' + this.model.get('description'), + operations: operations, + buttons: { + execute: new Ui.Button({ + icon : 'fa-check', + tooltip : 'Execute the tool', + title : 'Execute', + cls : 'btn btn-primary', + floating : 'clear', + onclick : function() { + self.job_handler.submit(); } - }); - - // configure button selection - if(!self.options.biostar_url) { - button_question.$el.hide(); - button_search.$el.hide(); - } - - // append form - self.$el.append(self.portlet.$el); - - // append help - if (self.options.help != '') { - self.$el.append(ToolTemplate.help(self.options.help)); - } - - // append citations - if (self.options.citations) { - // append html - self.$el.append(ToolTemplate.citations()); - - // fetch citations - var citations = new CitationModel.ToolCitationCollection(); - citations.tool_id = self.options.id; - var citation_list_view = new CitationView.CitationListView({ collection: citations } ); - citation_list_view.render(); - citations.fetch(); - } - - // configure portlet and form table - self.setElement(self.portlet.content()); - - // append tool section - self.portlet.append(self.section.$el); - - // trigger refresh - self.refresh(); + }) } }); + + // configure button selection + if(!this.options.biostar_url) { + button_question.$el.hide(); + button_search.$el.hide(); + } + + // append form + this.$el.append(this.portlet.$el); + + // append help + if (this.options.help != '') { + this.$el.append(ToolTemplate.help(this.options.help)); + } + + // append citations + if (this.options.citations) { + // append html + this.$el.append(ToolTemplate.citations()); + + // fetch citations + var citations = new CitationModel.ToolCitationCollection(); + citations.tool_id = this.options.id; + var citation_list_view = new CitationView.CitationListView({ collection: citations } ); + citation_list_view.render(); + citations.fetch(); + } + + // append tool section + this.portlet.append(this.section.$el); + + // trigger refresh + this.refresh(); } }); diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-input.js --- /dev/null +++ b/client/galaxy/scripts/mvc/tools/tools-input.js @@ -0,0 +1,108 @@ +/** + This class creates a tool form input element wrapper +*/ +define([], function() { + + // input field element wrapper + return Backbone.View.extend({ + // initialize input wrapper + initialize: function(options) { + // link field + this.field = options.field; + + // set element + this.setElement(this._template(options)); + + // link elements + this.$field = this.$el.find('.ui-table-form-field'); + this.$title_optional = this.$el.find('.ui-table-form-title-optional'); + this.$error_text = this.$el.find('.ui-table-form-error-text'); + this.$error = this.$el.find('.ui-table-form-error'); + + // add field element + this.$field.prepend(this.field.$el); + + // hide optional field on initialization + if (options.optional) { + this.field.skip = true; + } else { + this.field.skip = false; + } + + // refresh view + this._refresh(); + + // add optional hide/show + var self = this; + this.$title_optional.on('click', function() { + // flip flag + self.field.skip = !self.field.skip; + + // refresh view + self._refresh(); + }); + }, + + /** Set error text + */ + error: function(text) { + this.$error_text.html(text); + this.$error.fadeIn(); + this.$el.addClass('ui-error'); + }, + + /** Reset this view + */ + reset: function() { + this.$error.hide(); + this.$el.removeClass('ui-error'); + }, + + /** Refresh element + */ + _refresh: function() { + // show/hide field element + if (!this.field.skip) { + this.$field.fadeIn('fast'); + this.$title_optional.html('Disable'); + } else { + this.$field.hide(); + this.$title_optional.html('Enable'); + } + }, + + /** Main Template + */ + _template: function(options) { + // create table element + var tmp = '<div class="ui-table-form-element">' + + '<div class="ui-table-form-error ui-error">' + + '<span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/>' + + '</div>' + + '<div class="ui-table-form-title-strong">'; + + // is optional + if (options.optional) { + tmp += 'Optional: ' + options.label + + '<span> [<span class="ui-table-form-title-optional"/>]</span>'; + } else { + tmp += options.label; + } + + // finalize title + tmp += '</div>' + + '<div class="ui-table-form-field">'; + // add help + if (options.help) { + tmp += '<div class="ui-table-form-info">' + options.help + '</div>'; + } + + // finalize + tmp += '</div>' + + '</div>'; + + // return input element + return tmp; + } + }); +}); diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-jobs.js --- a/client/galaxy/scripts/mvc/tools/tools-jobs.js +++ b/client/galaxy/scripts/mvc/tools/tools-jobs.js @@ -37,7 +37,7 @@ console.debug(job_def); // show progress modal - this.app.modal.show({title: 'Please wait...', body: 'progress'}); + this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }}); // post job Utils.request({ @@ -57,17 +57,9 @@ self._foundError(input_id, error_messages[input_id]); } } else { - // show modal with error message - self.app.modal.show({ - title: response_full.statusText, - body: ToolTemplate.error(job_def), - closing_events: true, - buttons: { - 'Close': function() { - self.app.modal.hide(); - } - } - }); + // show error message with details + console.debug(job_def); + console.debug(response); } } }); @@ -81,17 +73,11 @@ // mark error input_element.error(message || 'Please verify this parameter.'); - - // set flag - if (this.valid) { - // scroll to first input element - $(this.app.container).animate({ - scrollTop: input_element.$el.offset().top - 20 - }, 500); - - // set error flag - this.valid = false; - } + + // scroll to first input element + $(this.app.container).animate({ + scrollTop: input_element.$el.offset().top - 20 + }, 500); }, /** Validate job definition @@ -100,9 +86,6 @@ // get input parameters var job_inputs = job_def.inputs; - // validation flag - this.valid = true; - // counter for values declared in batch mode var n_values = -1; @@ -115,10 +98,11 @@ var input_id = this.app.tree.match(job_input_id); var input_field = this.app.field_list[input_id]; var input_def = this.app.input_list[input_id]; - + // check basic field validation - if (input_def && !input_def.optional && input_field && input_field.validate && !input_field.validate()) { + if (input_def && input_field && input_field.validate && !input_field.validate()) { this._foundError(input_id); + return false; } // check if input field is in batch mode @@ -129,6 +113,7 @@ } else { if (n_values !== n) { this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); + return false; } } } @@ -136,7 +121,7 @@ } // return validation result - return this.valid; + return true; }, /** Refreshes the history panel diff -r 7fa4a243b126c4a1d5dbbfc600899763b55a6d82 -r ba656141a2d7db82b9ed060cb5bbb06d9d071bf7 client/galaxy/scripts/mvc/tools/tools-section.js --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -1,58 +1,8 @@ /** This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function. */ -define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-dataset'], - function(Utils, Table, Ui, Repeat, SelectDataset) { - - // input field element wrapper - var InputElement = Backbone.View.extend({ - // initialize input wrapper - initialize: function(options) { - this.setElement(this._template(options)); - }, - - /** Set error text - */ - error: function(text) { - // set text - this.$el.find('.ui-table-form-error-text').html(text); - this.$el.find('.ui-table-form-error').fadeIn(); - this.$el.addClass('ui-error'); - }, - - /** Reset this view - */ - reset: function() { - this.$el.find('.ui-table-form-error').hide(); - this.$el.removeClass('ui-error'); - }, - - /** Main Template - */ - _template: function(options) { - // create table element - var $input = $('<div class="ui-table-element"/>'); - - // add error - $input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>'); - - // add label - if (options.label) { - $input.append('<div class="ui-table-form-title-strong">' + options.label + '</div>'); - } - - // add input element - $input.append(options.$el); - - // add help - if (options.help) { - $input.append('<div class="ui-table-form-info">' + options.help + '</div>'); - } - - // return input element - return $input; - } - }); +define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content', 'mvc/tools/tools-input'], + function(Utils, Table, Ui, Repeat, SelectContent, InputElement) { // create form view var View = Backbone.View.extend({ @@ -234,7 +184,7 @@ var input_element = new InputElement({ label : input_def.title, help : input_def.help, - $el : repeat.$el + field : repeat }); // displays as grouped subsection @@ -268,13 +218,14 @@ field = this._fieldSelect(input_def); break; - // dataset + // data selector case 'data': field = this._fieldData(input_def); break; - // dataset column + // data column case 'data_column': + input_def.is_dynamic = false; field = this._fieldSelect(input_def); break; @@ -308,7 +259,7 @@ field = this._fieldSelect(input_def); break; - // flag as incompatible + // field not found default: // flag this.app.incompatible = true; @@ -336,9 +287,10 @@ // create input field wrapper var input_element = new InputElement({ - label : input_def.label, - help : input_def.help, - $el : field.$el + label : input_def.label, + optional : input_def.optional, + help : input_def.help, + field : field }); // add to element list @@ -417,13 +369,15 @@ var id = input_def.id; // select field - return new SelectDataset.View(this.app, { + return new SelectContent.View(this.app, { id : 'field-' + id, extensions : input_def.extensions, multiple : input_def.multiple, onchange : function(dict) { - // pick the first dataset only (todo: maybe collect multiple meta information) - var value = dict.values[0].id; + // pick the first content only (todo: maybe collect multiple meta information) + var content_def = dict.values[0]; + var content_id = content_def.id; + var content_src = content_def.src; // get referenced columns var column_list = self.app.tree.references(id, 'data_column'); @@ -440,71 +394,80 @@ column_field.wait && column_field.wait(); } - // find selected dataset - self.app.datasets.getDetails(value, function(dataset) { - // meta data - var meta = null; - - // check dataset - if (dataset) { - // log selection - console.debug('tool-form::field_data() - Selected dataset ' + value + '.'); - - // get meta data - meta = dataset.metadata_column_types; - - // check meta data - if (!meta) { - console.debug('tool-form::field_data() - FAILED: Could not find metadata for dataset ' + value + '.'); + // find selected content + self.app.content.getDetails({ + id : content_id, + src : content_src, + success : function(content) { + // meta data + var meta = null; + + // check content + if (content) { + // log selection + console.debug('tool-form::field_data() - Selected content ' + content_id + '.'); + + // select the first dataset to represent collections + if (content_src == 'hdca' && content.elements && content.elements.length > 0) { + content = content.elements[0].object; + } + + // get meta data + meta = content.metadata_column_types; + + // check meta data + if (!meta) { + console.debug('tool-form::field_data() - FAILED: Could not find metadata for content ' + content_id + '.'); + } + } else { + console.debug('tool-form::field_data() - FAILED: Could not find content ' + content_id + '.'); } - } else { - console.debug('tool-form::field_data() - FAILED: Could not find dataset ' + value + '.'); - } - - // update referenced columns - for (var i in column_list) { - // get column input/field - var column_input = self.app.input_list[column_list[i]]; - var column_field = self.app.field_list[column_list[i]]; - if (!column_input || !column_field) { - console.debug('tool-form::field_data() - FAILED: Column not found.'); - } - - // is numerical? - var numerical = column_input.numerical; - // identify column options - var columns = []; - for (var key in meta) { - // get column type - var column_type = meta[key]; + // update referenced columns + for (var i in column_list) { + // get column input/field + var column_input = self.app.input_list[column_list[i]]; + var column_field = self.app.field_list[column_list[i]]; + if (!column_input || !column_field) { + console.debug('tool-form::field_data() - FAILED: Column not found.'); + } + + // is numerical? + var numerical = column_input.numerical; - // column index - var column_index = (parseInt(key) + 1); - - // column type label - var column_label = 'Text'; - if (column_type == 'int' || column_type == 'float') { - column_label = 'Number'; + // identify column options + var columns = []; + for (var key in meta) { + // get column type + var column_type = meta[key]; + + // column index + var column_index = (parseInt(key) + 1); + + // column type label + var column_label = 'Text'; + if (column_type == 'int' || column_type == 'float') { + column_label = 'Number'; + } + + // add to selection + if (column_type == 'int' || column_type == 'float' || !numerical) { + columns.push({ + 'label' : 'Column: ' + column_index + ' [' + column_label + ']', + 'value' : column_index + }); + } } - // add to selection - if (column_type == 'int' || column_type == 'float' || !numerical) { - columns.push({ - 'label' : 'Column: ' + column_index + ' [' + column_label + ']', - 'value' : column_index - }); + // update field + if (column_field) { + column_field.update(columns); + if (!column_field.exists(column_field.value())) { + column_field.value(column_field.first()); + } + column_field.show(); } } - - // update field - if (column_field) { - column_field.update(columns); - if (!column_field.exists(column_field.value())) { - column_field.value(column_field.first()); - } - column_field.show(); - } } }); } @@ -514,6 +477,11 @@ /** Select/Checkbox/Radio options field */ _fieldSelect : function (input_def) { + // check compatibility + if (input_def.is_dynamic) { + this.app.incompatible = true; + } + // configure options fields var options = []; for (var i in input_def.options) { This diff is so big that we needed to truncate the remainder. https://bitbucket.org/galaxy/galaxy-central/commits/82ce88b096ff/ Changeset: 82ce88b096ff User: dannon Date: 2014-10-13 15:23:42+00:00 Summary: Merged in kellrott/galaxy-farm/docker-work (pull request #525) Adding 'set user' flag to docker calls Affected #: 3 files diff -r 16425b81c25e3d806a9e5594773612599e68b785 -r 82ce88b096ffb95246e2b6832454ef64b1b2f477 config/job_conf.xml.sample_advanced --- a/config/job_conf.xml.sample_advanced +++ b/config/job_conf.xml.sample_advanced @@ -196,7 +196,8 @@ adding the '\-\-rm' flag to the command line, the container will be removed automatically after the program is complete. --> - <!-- <param id="docker_auto_rm">false</param> --> + <!-- <param id="docker_auto_rm">true</param> --> + <!-- <param id="docker_set_user">true</param> --><!-- Following command can be used to tweak docker command. --><!-- <param id="docker_cmd">/usr/local/custom_docker/docker</param> --><!-- Following can be used to connect to docke server in different diff -r 16425b81c25e3d806a9e5594773612599e68b785 -r 82ce88b096ffb95246e2b6832454ef64b1b2f477 lib/galaxy/tools/deps/containers.py --- a/lib/galaxy/tools/deps/containers.py +++ b/lib/galaxy/tools/deps/containers.py @@ -243,7 +243,8 @@ env_directives=env_directives, working_directory=working_directory, net=prop("net", "none"), # By default, docker instance has networking disabled - auto_rm=prop("auto_rm", docker_util.DEFAULT_AUTO_REMOVE), + auto_rm=asbool(prop("auto_rm", docker_util.DEFAULT_AUTO_REMOVE)), + set_user=asbool(prop("set_user", docker_util.DEFAULT_SET_USER)), **docker_host_props ) return "%s\n%s" % (cache_command, run_command) diff -r 16425b81c25e3d806a9e5594773612599e68b785 -r 82ce88b096ffb95246e2b6832454ef64b1b2f477 lib/galaxy/tools/deps/docker_util.py --- a/lib/galaxy/tools/deps/docker_util.py +++ b/lib/galaxy/tools/deps/docker_util.py @@ -10,6 +10,7 @@ DEFAULT_MEMORY = None DEFAULT_VOLUMES_FROM = None DEFAULT_AUTO_REMOVE = True +DEFAULT_SET_USER = True class DockerVolume(object): @@ -119,6 +120,7 @@ sudo=DEFAULT_SUDO, sudo_cmd=DEFAULT_SUDO_COMMAND, auto_rm=DEFAULT_AUTO_REMOVE, + set_user=DEFAULT_SET_USER, host=DEFAULT_HOST, ): command_parts = __docker_prefix( @@ -146,6 +148,8 @@ command_parts.extend(["--net", net]) if auto_rm: command_parts.append("--rm") + if set_user: + command_parts.extend(["-u", str(os.geteuid())]) full_image = image if tag: full_image = "%s:%s" % (full_image, tag) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.