diff --git a/.ci/flake8_lint_include_list.txt b/.ci/flake8_lint_include_list.txt index 4789b884112..4cb3e453782 100644 --- a/.ci/flake8_lint_include_list.txt +++ b/.ci/flake8_lint_include_list.txt @@ -101,7 +101,7 @@ lib/galaxy/webapps/galaxy/api/genomes.py lib/galaxy/webapps/galaxy/api/histories.py lib/galaxy/webapps/galaxy/api/__init__.py lib/galaxy/webapps/galaxy/api/jobs.py -lib/galaxy/webapps/galaxy/api/lda_datasets.py +lib/galaxy/webapps/galaxy/api/library_datasets.py lib/galaxy/webapps/galaxy/api/requests.py lib/galaxy/webapps/galaxy/api/roles.py lib/galaxy/webapps/galaxy/api/samples.py diff --git a/client/galaxy/scripts/mvc/library/library-dataset-view.js b/client/galaxy/scripts/mvc/library/library-dataset-view.js index ddc4f556493..1a561373720 100644 --- a/client/galaxy/scripts/mvc/library/library-dataset-view.js +++ b/client/galaxy/scripts/mvc/library/library-dataset-view.js @@ -16,8 +16,10 @@ var LibraryDatasetView = Backbone.View.extend({ model: null, - options: { + options: {}, + defaults: { + edit_mode: false }, events: { @@ -25,13 +27,11 @@ var LibraryDatasetView = Backbone.View.extend({ "click .toolbtn_cancel_modifications" : "render", "click .toolbtn-download-dataset" : "downloadDataset", "click .toolbtn-import-dataset" : "importIntoHistory", - "click .toolbtn-share-dataset" : "shareDataset", "click .btn-copy-link-to-clipboard" : "copyToClipboard", "click .btn-make-private" : "makeDatasetPrivate", "click .btn-remove-restrictions" : "removeDatasetRestrictions", "click .toolbtn_save_permissions" : "savePermissions", - "click .toolbtn_save_modifications" : "comingSoon", - + "click .toolbtn_save_modifications" : "saveModifications" }, // genome select @@ -134,7 +134,10 @@ var LibraryDatasetView = Backbone.View.extend({ $(".tooltip").remove(); var template = this.templateModifyDataset(); this.$el.html(template({item: this.model})); - this.renderSelectBoxes({genome_build: this.model.get('genome_build'), file_ext: this.model.get('file_ext') }); + this.renderSelectBoxes({ + genome_build: this.model.get('genome_build'), + file_ext: this.model.get('file_ext') + }); $(".peek").html(this.model.get("peek")); $("#center [data-toggle]").tooltip(); }, @@ -245,10 +248,6 @@ var LibraryDatasetView = Backbone.View.extend({ }); }, - shareDataset: function(){ - mod_toastr.info('Feature coming soon.'); - }, - goBack: function(){ Galaxy.libraries.library_router.back(); }, @@ -457,8 +456,57 @@ var LibraryDatasetView = Backbone.View.extend({ } }, - comingSoon: function(){ - mod_toastr.warning('Feature coming soon.'); + /** + * Save the changes made to the library dataset. + */ + saveModifications: function(options){ + var is_changed = false; + var ld = this.model; + var new_name = this.$el.find('.input_dataset_name').val(); + if (typeof new_name !== 'undefined' && new_name !== ld.get('name') ){ + if (new_name.length > 0){ + ld.set("name", new_name); + is_changed = true; + } else{ + mod_toastr.warning('Library dataset name has to be at least 1 character long.'); + return; + } + } + var new_info = this.$el.find('.input_dataset_misc_info').val(); + if (typeof new_info !== 'undefined' && new_info !== ld.get('misc_info') ){ + ld.set("misc_info", new_info); + is_changed = true; + } + var new_genome_build = this.select_genome.$el.select2('data').id; + if (typeof new_genome_build !== 'undefined' && new_genome_build !== ld.get('genome_build') ){ + ld.set("genome_build", new_genome_build); + is_changed = true; + } + var new_ext = this.select_extension.$el.select2('data').id; + if (typeof new_ext !== 'undefined' && new_ext !== ld.get('file_ext') ){ + ld.set("file_ext", new_ext); + is_changed = true; + } + var dataset_view = this; + if (is_changed){ + ld.save(null, { + patch: true, + success: function(ld) { + dataset_view.render() + mod_toastr.success('Changes to library dataset saved.'); + }, + error: function(model, response){ + if (typeof response.responseJSON !== "undefined"){ + mod_toastr.error(response.responseJSON.err_msg); + } else { + mod_toastr.error('An error occured while attempting to update the library dataset.'); + } + } + }); + } else { + dataset_view.render() + mod_toastr.info('Nothing has changed.'); + } }, copyToClipboard: function(){ @@ -523,42 +571,46 @@ var LibraryDatasetView = Backbone.View.extend({ }, /** - * Request all extensions and genomes from Galaxy - * and save them sorted in arrays. + * If needed request all extensions and/or genomes from Galaxy + * and save them in sorted arrays. */ fetchExtAndGenomes: function(){ var that = this; - mod_utils.get({ - url : Galaxy.root + "api/datatypes?extension_only=False", - success : function( datatypes ) { - for (var 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); - } + if (this.list_genomes.length == 0){ + mod_utils.get({ + url : Galaxy.root + "api/datatypes?extension_only=False", + success : function( datatypes ) { + for (var 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.root + "api/genomes", + } + if (this.list_extensions.length == 0){ + mod_utils.get({ + url : Galaxy.root + "api/genomes", success : function( genomes ) { - for (var 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; - }); - } - }); + for (var 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(options){ @@ -566,6 +618,7 @@ var LibraryDatasetView = Backbone.View.extend({ // See this.fetchExtAndGenomes() // TODO switch to common resources: // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-object + var that = this; var current_genome = '?'; var current_ext = 'auto'; if (typeof options !== 'undefined'){ @@ -576,17 +629,16 @@ var LibraryDatasetView = Backbone.View.extend({ current_ext = options.file_ext; } } - var that = this; this.select_genome = new mod_select.View( { css: 'dataset-genome-select', data: that.list_genomes, - container: that.$el.find( '#dataset_genome_select' ), + container: that.$el.find('#dataset_genome_select'), value: current_genome } ); this.select_extension = new mod_select.View({ css: 'dataset-extension-select', data: that.list_extensions, - container: that.$el.find( '#dataset_extension_select' ), + container: that.$el.find('#dataset_extension_select'), value: current_ext }); }, @@ -711,13 +763,13 @@ var LibraryDatasetView = Backbone.View.extend({ '<% } %>', '<% if (item.get("misc_blurb")) { %>', '
For full editing options please import the dataset to history and use "Edit attributes" on it.
', '| ">Name | ', @@ -956,12 +1007,12 @@ var LibraryDatasetView = Backbone.View.extend({ '<%= _.escape(item.get("message")) %> | ', '||
|---|---|---|---|
| Miscellaneous information | ', - '<%= _.escape(item.get("misc_info")) %> | ', + 'Misc. blurb | ', + '<%= _.escape(item.get("misc_blurb")) %> | ', '
| Miscellaneous blurb | ', - '<%= _.escape(item.get("misc_blurb")) %> | ', + 'Misc. information | ', + '"> | ', '
| ">', - 'Name', - ' | ', - '', - '<%= _.escape(item.get("name")) %>', - ' | ', - '
|---|---|
| Data type | ', - '', - '<%= _.escape(item.get("file_ext")) %>', - ' | ', - '
| Name | ','<%= _.escape(ldda.get("name")) %> | ',"
|---|---|
| Data type | ','<%= _.escape(ldda.get("file_ext")) %> | ',"
| Genome build | ','<%= _.escape(ldda.get("genome_build")) %> | ',"
| Size | ','<%= _.escape(ldda.get("file_size")) %> | ',"
| Date uploaded (UTC) | ','<%= _.escape(ldda.get("date_uploaded")) %> | ',"
| Uploaded by | ','<%= _.escape(ldda.get("uploaded_by")) %> | ',"
| Data Lines | ','<%= _.escape(ldda.get("metadata_data_lines")) %> | ',"
| Comment Lines | ','<%= _.escape(ldda.get("metadata_comment_lines")) %> | ',"
| Number of Columns | ','<%= _.escape(ldda.get("metadata_columns")) %> | ',"
| Column Types | ','<%= _.escape(ldda.get("metadata_column_types")) %> | ',"
| Message | ','<%= _.escape(ldda.get("message")) %> | ',"
| Miscellaneous blurb | ','<%= _.escape(ldda.get("misc_blurb")) %> | ',"
| Miscellaneous information | ','<%= _.escape(ldda.get("misc_info")) %> | ',"
| Tags | ','<%= _.escape(item.get("tags")) %> | ',"
',"","
| ">Name | ','"> | ',"
|---|---|
| Data type | ',"",''," | ","
| Genome build | ',"",''," | ","
| Size | ','<%= _.escape(item.get("file_size")) %> | ',"
| Date uploaded (UTC) | ','<%= _.escape(item.get("date_uploaded")) %> | ',"
| Uploaded by | ','<%= _.escape(item.get("uploaded_by")) %> | ',"
| Data Lines | ','<%= _.escape(item.get("metadata_data_lines")) %> | ',"Comment Lines | ','<% if (item.get("metadata_comment_lines") === "") { %>','<%= _.escape(item.get("metadata_comment_lines")) %> | ',"<% } else { %>",'unknown | ',"<% } %>","","
| Number of Columns | ','<%= _.escape(item.get("metadata_columns")) %> | ',"
| Column Types | ','<%= _.escape(item.get("metadata_column_types")) %> | ',"
| Message | ','<%= _.escape(item.get("message")) %> | ',"
| Misc. blurb | ','<%= _.escape(item.get("misc_blurb")) %> | ',"
| Misc. information | ','"> | ',"
| Tags | ','<%= _.escape(item.get("tags")) %> | ',"
',"","
You can remove all access restrictions on this dataset. ",'
You can make this dataset private to you. ",'
","This dataset is unrestricted so everybody can access it. Just share the URL of this page. ",'
| ">',"Name"," | ","",'<%= _.escape(item.get("name")) %>'," | ","
|---|---|
| Data type | ',"",'<%= _.escape(item.get("file_ext")) %>'," | ","
| library | ',"","",""," |
|---|---|
| name | ",'<%- library.get("name") %> | ',"
| description | ",'<%- library.get("description") %> | ',"
| synopsis | ",'<%- library.get("synopsis") %> | ',"
| created | ",'"><%- library.get("create_time_pretty") %> | ',"
| id | ",'<%- library.get("id") %> | ',"
| folder | ',"","",""," |
|---|---|
| name | ","<%- options.folder_name %> | ","
| description | ","<%- options.folder_description %> | ","
| id | ","<%- options.id %> | ","
You can set extension type and genome for all imported datasets at once:
","You can set extension type and genome for all imported datasets at once:
","| library | ',"","",""," |
|---|---|
| name | ",'<%- library.get("name") %> | ',"
| description | ",'<%- library.get("description") %> | ',"
| synopsis | ",'<%- library.get("synopsis") %> | ',"
| created | ",'"><%- library.get("create_time_pretty") %> | ',"
| id | ",'<%- library.get("id") %> | ',"
| folder | ',"","",""," |
|---|---|
| name | ","<%- options.folder_name %> | ","
| description | ","<%- options.folder_description %> | ","
| id | ","<%- options.id %> | ","
You can set extension type and genome for all imported datasets at once:
","You can set extension type and genome for all imported datasets at once:
","","This dataset is unrestricted so everybody can access it. Just share the URL of this page. ",'
| ">',"Name"," | ","",'<%= _.escape(item.get("name")) %>'," | ","
|---|---|
| Data type | ',"",'<%= _.escape(item.get("file_ext")) %>'," | ","