3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/68f8568c9519/ Changeset: 68f8568c9519 User: jgoecks Date: 2014-07-17 21:44:45 Summary: Trackster: remove unused requirements. Affected #: 1 file diff -r f65eb16fdf1e0b7a6f3483373c32765107c3b2b6 -r 68f8568c95195600cb38adab95cf9fcf7d617aa3 static/scripts/viz/trackster_ui.js --- a/static/scripts/viz/trackster_ui.js +++ b/static/scripts/viz/trackster_ui.js @@ -1,13 +1,10 @@ -define( ["base","libs/underscore","viz/trackster/slotting", "viz/trackster/painters", "viz/trackster/tracks", "viz/visualization" ], - function( base, _, slotting, painters, tracks, visualization ) { +define( ["base","libs/underscore", "viz/trackster/tracks", "viz/visualization" ], + function( base, _, tracks, visualization ) { /************************************************************************ * Functions used for creating and managing the Trackster user interface. ************************************************************************/ -var object_from_template = tracks.object_from_template; - - /** * Returns an IconButtonMenuView for the provided configuration. * Configuration is a list of dictionaries where each dictionary @@ -96,7 +93,7 @@ { icon_class: 'plus-button', title: 'Add tracks', on_click: function() { visualization.select_datasets(galaxy_config.root + "visualization/list_current_history_datasets", galaxy_config.root + "api/datasets", { 'f-dbkey': view.dbkey }, function(tracks) { _.each(tracks, function(track) { - view.add_drawable( object_from_template(track, view, view) ); + view.add_drawable( tracks.object_from_template(track, view, view) ); }); }); } }, @@ -263,7 +260,7 @@ drawable_type, drawable; for (var i = 0; i < drawables_config.length; i++) { - view.add_drawable( object_from_template( drawables_config[i], view, view ) ); + view.add_drawable( tracks.object_from_template( drawables_config[i], view, view ) ); } } @@ -367,7 +364,7 @@ }); return { - object_from_template: object_from_template, + object_from_template: tracks.object_from_template, TracksterUI: TracksterUI }; https://bitbucket.org/galaxy/galaxy-central/commits/40d27b0ba43a/ Changeset: 40d27b0ba43a User: jgoecks Date: 2014-07-17 22:23:17 Summary: Trackster: merge all top-level UI code into the same file for simplicity. Affected #: 4 files diff -r 68f8568c95195600cb38adab95cf9fcf7d617aa3 -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 static/scripts/packed/viz/trackster_ui.js --- a/static/scripts/packed/viz/trackster_ui.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["base","libs/underscore","viz/trackster/slotting","viz/trackster/painters","viz/trackster/tracks","viz/visualization"],function(a,f,e,c,d,h){var j=d.object_from_template;var b=function(l,k){if(!k){k={}}var m=new IconButtonCollection(f.map(l,function(n){return new IconButton(f.extend(n,k))}));return new IconButtonMenuView({collection:m})};var g=a.Base.extend({initialize:function(k){this.baseURL=k},createButtonMenu:function(){var k=this,l=b([{icon_class:"plus-button",title:"Add tracks",on_click:function(){h.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",{"f-dbkey":view.dbkey},function(m){f.each(m,function(n){view.add_drawable(j(n,view,view))})})}},{icon_class:"block--plus",title:"Add group",on_click:function(){view.add_drawable(new d.DrawableGroup(view,view,{name:"New Group"}))}},{icon_class:"bookmarks",title:"Bookmarks",on_click:function(){force_right_panel(($("div#right").css("right")=="0px"?"hide":"show"))}},{icon_class:"globe",title:"Circster",on_click:function(){window.location=k.baseURL+"visualization/circster?id="+view.vis_id}},{icon_class:"disk--arrow",title:"Save",on_click:function(){Galaxy.modal.show({title:"Saving...",body:"progress"});var m=[];$(".bookmark").each(function(){m.push({position:$(this).children(".position").text(),annotation:$(this).children(".annotation").text()})});var n=(view.overview_drawable?view.overview_drawable.config.get_value("name"):null),o={view:view.to_dict(),viewport:{chrom:view.chrom,start:view.low,end:view.high,overview:n},bookmarks:m};$.ajax({url:galaxy_config.root+"visualization/save",type:"POST",dataType:"json",data:{id:view.vis_id,title:view.config.get_value("name"),dbkey:view.dbkey,type:"trackster",vis_json:JSON.stringify(o)}}).success(function(p){Galaxy.modal.hide();view.vis_id=p.vis_id;view.has_changes=false;window.history.pushState({},"",p.url+window.location.hash)}).error(function(){Galaxy.modal.show({title:"Could Not Save",body:"Could not save visualization. Please try again later.",buttons:{Cancel:function(){Galaxy.modal.hide()}}})})}},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location=galaxy_config.root+"visualization"}}],{tooltip_config:{placement:"bottom"}});this.buttonMenu=l;return l},add_bookmarks:function(){var k=this,l=this.baseURL;Galaxy.modal.show({title:"Select dataset for new bookmarks",body:"progress"});$.ajax({url:this.baseURL+"/visualization/list_histories",data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(m){Galaxy.modal.show({title:"Select dataset for new bookmarks",body:m,buttons:{Cancel:function(){Galaxy.modal.hide()},Insert:function(){$("input[name=id]:checked,input[name=ldda_ids]:checked").first().each(function(){var n,o=$(this).val();if($(this).attr("name")==="id"){n={hda_id:o}}else{n={ldda_id:o}}$.ajax({url:this.baseURL+"/visualization/bookmarks_from_dataset",data:n,dataType:"json"}).then(function(p){for(i=0;i<p.data.length;i++){var q=p.data[i];k.add_bookmark(q[0],q[1])}})});Galaxy.modal.hide()}}})}})},add_bookmark:function(o,m,k){var q=$("#right .unified-panel-body"),s=$("<div/>").addClass("bookmark").appendTo(q);var t=$("<div/>").addClass("position").appendTo(s),p=$("<a href=''/>").text(o).appendTo(t).click(function(){view.go_to(o);return false}),n=$("<div/>").text(m).appendTo(s);if(k){var r=$("<div/>").addClass("delete-icon-container").prependTo(s).click(function(){s.slideUp("fast");s.remove();view.has_changes=true;return false}),l=$("<a href=''/>").addClass("icon-button delete").appendTo(r);n.make_text_editable({num_rows:3,use_textarea:true,help_text:"Edit bookmark note"}).addClass("annotation")}view.has_changes=true;return s},create_visualization:function(p,k,o,q,n){var m=this,l=new d.TracksterView(f.extend(p,{header:false}));l.editor=true;$.when(l.load_chroms_deferred).then(function(B){if(k){var z=k.chrom,r=k.start,w=k.end,t=k.overview;if(z&&(r!==undefined)&&w){l.change_chrom(z,r,w)}else{l.change_chrom(B[0].chrom)}}else{l.change_chrom(B[0].chrom)}if(o){var u,s,v;for(var x=0;x<o.length;x++){l.add_drawable(j(o[x],l,l))}}l.update_intro_div();var A;for(var x=0;x<l.drawables.length;x++){if(l.drawables[x].config.get_value("name")===t){l.set_overview(l.drawables[x]);break}}if(q){var y;for(var x=0;x<q.length;x++){y=q[x];m.add_bookmark(y.position,y.annotation,n)}}l.has_changes=false});this.set_up_router({view:l});return l},set_up_router:function(k){new h.TrackBrowserRouter(k);Backbone.history.start()},init_keyboard_nav:function(k){$(document).keyup(function(l){if($(l.srcElement).is(":input")){return}switch(l.which){case 37:k.move_fraction(0.25);break;case 38:var m=Math.round(k.viewport_container.height()/15);k.viewport_container.scrollTop(k.viewport_container.scrollTop()-20);break;case 39:k.move_fraction(-0.25);break;case 40:var m=Math.round(k.viewport_container.height()/15);k.viewport_container.scrollTop(k.viewport_container.scrollTop()+20);break}})}});return{object_from_template:j,TracksterUI:g}}); \ No newline at end of file diff -r 68f8568c95195600cb38adab95cf9fcf7d617aa3 -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 static/scripts/viz/trackster.js --- a/static/scripts/viz/trackster.js +++ b/static/scripts/viz/trackster.js @@ -1,3 +1,7 @@ +/** + * Top-level trackster code, used for creating/loading visualizations and user interface elements. + */ + // global variables var ui = null; var view = null; @@ -28,15 +32,374 @@ }); // trackster viewer -define( ["libs/backbone/backbone", "viz/trackster_ui"], function(backbone, trackster_ui) { +define( ["libs/underscore", "base", "viz/trackster/tracks", "viz/visualization"], + function(_, base, tracks, visualization) { +/** + * Returns an IconButtonMenuView for the provided configuration. + * Configuration is a list of dictionaries where each dictionary + * defines an icon button. Each dictionary must have the following + * elements: icon_class, title, and on_click. + */ +var create_icon_buttons_menu = function(config, global_config) { + if (!global_config) { global_config = {}; } -var TracksterView = Backbone.View.extend( + // Create and initialize menu. + var buttons = new IconButtonCollection( + _.map(config, function(button_config) { + return new IconButton(_.extend(button_config, global_config)); + }) + ); + + return new IconButtonMenuView( {collection: buttons} ); +}; + +/** + * User interface controls for trackster + */ +var TracksterUI = base.Base.extend({ + initialize: function( baseURL ) { + this.baseURL = baseURL; + }, + + /** + * Save visualization, returning a Deferred object for the remote call to save. + */ + save_viz: function() { + // show dialog + Galaxy.modal.show({title: "Saving...", body: "progress" }); + + // Save bookmarks. + var bookmarks = []; + $(".bookmark").each(function() { + bookmarks.push({ + position: $(this).children(".position").text(), + annotation: $(this).children(".annotation").text() + }); + }); + + // FIXME: give unique IDs to Drawables and save overview as ID. + var overview_track_name = (view.overview_drawable ? view.overview_drawable.config.get_value('name') : null), + viz_config = { + 'view': view.to_dict(), + 'viewport': { 'chrom': view.chrom, 'start': view.low , 'end': view.high, 'overview': overview_track_name }, + 'bookmarks': bookmarks + }; + + // Make call to save visualization. + return $.ajax({ + url: galaxy_config.root + "visualization/save", + type: "POST", + dataType: "json", + data: { + 'id' : view.vis_id, + 'title' : view.config.get_value('name'), + 'dbkey' : view.dbkey, + 'type' : 'trackster', + 'vis_json' : JSON.stringify(viz_config) + } + }).success(function(vis_info) { + Galaxy.modal.hide(); + view.vis_id = vis_info.vis_id; + view.has_changes = false; + + // Needed to set URL when first saving a visualization. + window.history.pushState({}, "", vis_info.url + window.location.hash); + }).error(function() { + // show dialog + Galaxy.modal.show({ + title : "Could Not Save", + body : "Could not save visualization. Please try again later.", + buttons : { "Cancel": function() { Galaxy.modal.hide(); } } + }); + }); + }, + + /** + * Create button menu + */ + createButtonMenu: function() { + var self = this, + menu = create_icon_buttons_menu([ + { icon_class: 'plus-button', title: 'Add tracks', on_click: function() { + visualization.select_datasets(galaxy_config.root + "visualization/list_current_history_datasets", galaxy_config.root + "api/datasets", { 'f-dbkey': view.dbkey }, function(tracks) { + _.each(tracks, function(track) { + view.add_drawable( tracks.object_from_template(track, view, view) ); + }); + }); + } }, + { icon_class: 'block--plus', title: 'Add group', on_click: function() { + view.add_drawable( new tracks.DrawableGroup(view, view, { name: "New Group" }) ); + } }, + { icon_class: 'bookmarks', title: 'Bookmarks', on_click: function() { + // HACK -- use style to determine if panel is hidden and hide/show accordingly. + force_right_panel(($("div#right").css("right") == "0px" ? "hide" : "show")); + } }, + { + icon_class: 'globe', + title: 'Circster', + on_click: function() { + window.location = self.baseURL + 'visualization/circster?id=' + view.vis_id; + } + }, + { icon_class: 'disk--arrow', title: 'Save', on_click: function() { + self.save_viz(); + } }, + { + icon_class: 'cross-circle', + title: 'Close', + on_click: function() { + self.handle_unsaved_changes(view); + } + } + ], + { + tooltip_config: { placement: 'bottom' } + }); + this.buttonMenu = menu; + return menu; + }, + + /** + * Use a popup to select a dataset of create bookmarks from + */ + add_bookmarks: function() { + var self = this, + baseURL = this.baseURL; + + // show modal while loading history + Galaxy.modal.show({title: "Select dataset for new bookmarks", body: "progress" }); + + $.ajax({ + url: this.baseURL + "/visualization/list_histories", + data: { "f-dbkey": view.dbkey }, + error: function() { alert( "Grid failed" ); }, + success: function(table_html) { + + // show modal to select bookmarks + Galaxy.modal.show( + { + title : "Select dataset for new bookmarks", + body : table_html, + buttons : + { + "Cancel": function() + { + Galaxy.modal.hide(); + }, + + "Insert": function() + { + // Just use the first selected + $('input[name=id]:checked,input[name=ldda_ids]:checked').first().each(function() + { + var data, id = $(this).val(); + if ($(this).attr("name") === "id") + data = { hda_id: id }; + else + data = { ldda_id: id}; + + $.ajax({ + url: this.baseURL + "/visualization/bookmarks_from_dataset", + data: data, + dataType: "json" + }).then( function(data) { + for( i = 0; i < data.data.length; i++ ) { + var row = data.data[i]; + self.add_bookmark( row[0], row[1] ); + } + }); + }); + Galaxy.modal.hide(); + } + } + }); + } + }); + }, + + /** + * Add bookmark. + */ + add_bookmark: function(position, annotation, editable) { + // Create HTML. + var bookmarks_container = $("#right .unified-panel-body"), + new_bookmark = $("<div/>").addClass("bookmark").appendTo(bookmarks_container); + + var position_div = $("<div/>").addClass("position").appendTo(new_bookmark), + position_link = $("<a href=''/>").text(position).appendTo(position_div).click(function() { + view.go_to(position); + return false; + }), + annotation_div = $("<div/>").text(annotation).appendTo(new_bookmark); + + // If editable, enable bookmark deletion and annotation editing. + if (editable) { + var delete_icon_container = $("<div/>").addClass("delete-icon-container").prependTo(new_bookmark).click(function (){ + // Remove bookmark. + new_bookmark.slideUp("fast"); + new_bookmark.remove(); + view.has_changes = true; + return false; + }), + delete_icon = $("<a href=''/>").addClass("icon-button delete").appendTo(delete_icon_container); + annotation_div.make_text_editable({ + num_rows: 3, + use_textarea: true, + help_text: "Edit bookmark note" + }).addClass("annotation"); + } + + view.has_changes = true; + return new_bookmark; + }, + + /** + * Create a complete Trackster visualization. Returns view. + */ + create_visualization: function(view_config, viewport_config, drawables_config, bookmarks_config, editable) { + + // Create view. + var self = this, + view = new tracks.TracksterView(_.extend(view_config, {header: false})); + view.editor = true; + $.when( view.load_chroms_deferred ).then(function(chrom_info) { + // Viewport config. + if (viewport_config) { + var chrom = viewport_config.chrom, + start = viewport_config.start, + end = viewport_config.end, + overview_drawable_name = viewport_config.overview; + + if (chrom && (start !== undefined) && end) { + view.change_chrom(chrom, start, end); + } + else { + // No valid viewport, so use first chromosome. + view.change_chrom(chrom_info[0].chrom); + } + } + else { + // No viewport, so use first chromosome. + view.change_chrom(chrom_info[0].chrom); + } + + // Add drawables to view. + if (drawables_config) { + // FIXME: can from_dict() be used to create view and add drawables? + var drawable_config, + drawable_type, + drawable; + for (var i = 0; i < drawables_config.length; i++) { + view.add_drawable( tracks.object_from_template( drawables_config[i], view, view ) ); + } + } + + // Set overview. + var overview_drawable; + for (var i = 0; i < view.drawables.length; i++) { + if (view.drawables[i].config.get_value('name') === overview_drawable_name) { + view.set_overview(view.drawables[i]); + break; + } + } + + // Load bookmarks. + if (bookmarks_config) { + var bookmark; + for (var i = 0; i < bookmarks_config.length; i++) { + bookmark = bookmarks_config[i]; + self.add_bookmark(bookmark['position'], bookmark['annotation'], editable); + } + } + + // View has no changes as of yet. + view.has_changes = false; + }); + + // Final initialization. + this.set_up_router({view: view}); + + return view; + }, + + /** + * Set up location router to use hashes as track browser locations. + */ + set_up_router : function(options) + { + new visualization.TrackBrowserRouter(options); + Backbone.history.start(); + }, + + /** + * Set up keyboard navigation for a visualization. + */ + init_keyboard_nav: function(view) { + // Keyboard navigation. Scroll ~7% of height when scrolling up/down. + $(document).keyup(function(e) { + // Do not navigate if arrow keys used in input element. + if ($(e.srcElement).is(':input')) { + return; + } + + // Key codes: left == 37, up == 38, right == 39, down == 40 + switch(e.which) { + case 37: + view.move_fraction(0.25); + break; + case 38: + var change = Math.round(view.viewport_container.height()/15.0); + view.viewport_container.scrollTop( view.viewport_container.scrollTop() - 20); + break; + case 39: + view.move_fraction(-0.25); + break; + case 40: + var change = Math.round(view.viewport_container.height()/15.0); + view.viewport_container.scrollTop( view.viewport_container.scrollTop() + 20); + break; + } + }); + }, + + /** + * Handle unsaved changes in visualization. + */ + handle_unsaved_changes: function(view) { + if (view.has_changes) { + var self = this; + Galaxy.modal.show({ + title: "Close visualization", + body: "There are unsaved changes to your visualization which will be lost if you do not save them.", + buttons: { + "Cancel": function() { Galaxy.modal.hide(); }, + "Leave without Saving" : function() { + window.onbeforeunload = undefined; + window.location = galaxy_config.root + 'visualization'; + }, + "Save" : function() { + $.when(self.save_viz()).then(function() { + window.location = galaxy_config.root + 'visualization'; + }); + } + } + }); + + } + else { + window.location = galaxy_config.root + 'visualization'; + } + } + +}); + +var TracksterView = base.Backbone.View.extend( { // initalize trackster initialize : function () { // load ui - ui = new trackster_ui.TracksterUI(galaxy_config.root); + ui = new TracksterUI(galaxy_config.root); // create button menu ui.createButtonMenu(); @@ -197,7 +560,7 @@ url: galaxy_config.root + "api/datasets/" + galaxy_config.app.add_dataset, data: { hda_ldda: 'hda', data_type: 'track_config' }, dataType: "json", - success: function(track_data) { view.add_drawable( trackster_ui.object_from_template(track_data, view, view) ); } + success: function(track_data) { view.add_drawable( tracks.object_from_template(track_data, view, view) ); } }); // initialize icons @@ -220,10 +583,8 @@ } }); -// return return { GalaxyApp : TracksterView }; -// done }); \ No newline at end of file diff -r 68f8568c95195600cb38adab95cf9fcf7d617aa3 -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 static/scripts/viz/trackster/tracks.js --- a/static/scripts/viz/trackster/tracks.js +++ b/static/scripts/viz/trackster/tracks.js @@ -877,7 +877,7 @@ this.content_div = this.viewport_container; is_container(this.viewport_container, view); // Introduction div shown when there are no tracks. - this.intro_div = $("<div/>").addClass("intro").appendTo(this.viewport_container).hide(); + this.intro_div = $("<div/>").addClass("intro").appendTo(this.viewport_container); var add_tracks_button = $("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function () { visualization.select_datasets(galaxy_config.root + "visualization/list_current_history_datasets", galaxy_config.root + "api/datasets", { 'f-dbkey': view.dbkey }, function(tracks) { _.each(tracks, function(track) { diff -r 68f8568c95195600cb38adab95cf9fcf7d617aa3 -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 static/scripts/viz/trackster_ui.js --- a/static/scripts/viz/trackster_ui.js +++ /dev/null @@ -1,371 +0,0 @@ -define( ["base","libs/underscore", "viz/trackster/tracks", "viz/visualization" ], - function( base, _, tracks, visualization ) { - -/************************************************************************ - * Functions used for creating and managing the Trackster user interface. - ************************************************************************/ - -/** - * Returns an IconButtonMenuView for the provided configuration. - * Configuration is a list of dictionaries where each dictionary - * defines an icon button. Each dictionary must have the following - * elements: icon_class, title, and on_click. - */ -var create_icon_buttons_menu = function(config, global_config) { - if (!global_config) { global_config = {}; } - - // Create and initialize menu. - var buttons = new IconButtonCollection( - _.map(config, function(button_config) { - return new IconButton(_.extend(button_config, global_config)); - }) - ); - - return new IconButtonMenuView( {collection: buttons} ); -}; - - -var TracksterUI = base.Base.extend({ - - initialize: function( baseURL ) { - this.baseURL = baseURL; - }, - - /** - * Save visualization, returning a Deferred object for the remote call to save. - */ - save_viz: function() { - // show dialog - Galaxy.modal.show({title: "Saving...", body: "progress" }); - - // Save bookmarks. - var bookmarks = []; - $(".bookmark").each(function() { - bookmarks.push({ - position: $(this).children(".position").text(), - annotation: $(this).children(".annotation").text() - }); - }); - - // FIXME: give unique IDs to Drawables and save overview as ID. - var overview_track_name = (view.overview_drawable ? view.overview_drawable.config.get_value('name') : null), - viz_config = { - 'view': view.to_dict(), - 'viewport': { 'chrom': view.chrom, 'start': view.low , 'end': view.high, 'overview': overview_track_name }, - 'bookmarks': bookmarks - }; - - // Make call to save visualization. - return $.ajax({ - url: galaxy_config.root + "visualization/save", - type: "POST", - dataType: "json", - data: { - 'id' : view.vis_id, - 'title' : view.config.get_value('name'), - 'dbkey' : view.dbkey, - 'type' : 'trackster', - 'vis_json' : JSON.stringify(viz_config) - } - }).success(function(vis_info) { - Galaxy.modal.hide(); - view.vis_id = vis_info.vis_id; - view.has_changes = false; - - // Needed to set URL when first saving a visualization. - window.history.pushState({}, "", vis_info.url + window.location.hash); - }).error(function() { - // show dialog - Galaxy.modal.show({ - title : "Could Not Save", - body : "Could not save visualization. Please try again later.", - buttons : { "Cancel": function() { Galaxy.modal.hide(); } } - }); - }); - }, - - /** - * Create button menu - */ - createButtonMenu: function() { - var self = this, - menu = create_icon_buttons_menu([ - { icon_class: 'plus-button', title: 'Add tracks', on_click: function() { - visualization.select_datasets(galaxy_config.root + "visualization/list_current_history_datasets", galaxy_config.root + "api/datasets", { 'f-dbkey': view.dbkey }, function(tracks) { - _.each(tracks, function(track) { - view.add_drawable( tracks.object_from_template(track, view, view) ); - }); - }); - } }, - { icon_class: 'block--plus', title: 'Add group', on_click: function() { - view.add_drawable( new tracks.DrawableGroup(view, view, { name: "New Group" }) ); - } }, - { icon_class: 'bookmarks', title: 'Bookmarks', on_click: function() { - // HACK -- use style to determine if panel is hidden and hide/show accordingly. - force_right_panel(($("div#right").css("right") == "0px" ? "hide" : "show")); - } }, - { - icon_class: 'globe', - title: 'Circster', - on_click: function() { - window.location = self.baseURL + 'visualization/circster?id=' + view.vis_id; - } - }, - { icon_class: 'disk--arrow', title: 'Save', on_click: function() { - self.save_viz(); - } }, - { - icon_class: 'cross-circle', - title: 'Close', - on_click: function() { - self.handle_unsaved_changes(view); - } - } - ], - { - tooltip_config: { placement: 'bottom' } - }); - this.buttonMenu = menu; - return menu; - }, - - /** - * Use a popup to select a dataset of create bookmarks from - */ - add_bookmarks: function() { - var self = this, - baseURL = this.baseURL; - - // show modal while loading history - Galaxy.modal.show({title: "Select dataset for new bookmarks", body: "progress" }); - - $.ajax({ - url: this.baseURL + "/visualization/list_histories", - data: { "f-dbkey": view.dbkey }, - error: function() { alert( "Grid failed" ); }, - success: function(table_html) { - - // show modal to select bookmarks - Galaxy.modal.show( - { - title : "Select dataset for new bookmarks", - body : table_html, - buttons : - { - "Cancel": function() - { - Galaxy.modal.hide(); - }, - - "Insert": function() - { - // Just use the first selected - $('input[name=id]:checked,input[name=ldda_ids]:checked').first().each(function() - { - var data, id = $(this).val(); - if ($(this).attr("name") === "id") - data = { hda_id: id }; - else - data = { ldda_id: id}; - - $.ajax({ - url: this.baseURL + "/visualization/bookmarks_from_dataset", - data: data, - dataType: "json" - }).then( function(data) { - for( i = 0; i < data.data.length; i++ ) { - var row = data.data[i]; - self.add_bookmark( row[0], row[1] ); - } - }); - }); - Galaxy.modal.hide(); - } - } - }); - } - }); - }, - - /** - * Add bookmark. - */ - add_bookmark: function(position, annotation, editable) { - // Create HTML. - var bookmarks_container = $("#right .unified-panel-body"), - new_bookmark = $("<div/>").addClass("bookmark").appendTo(bookmarks_container); - - var position_div = $("<div/>").addClass("position").appendTo(new_bookmark), - position_link = $("<a href=''/>").text(position).appendTo(position_div).click(function() { - view.go_to(position); - return false; - }), - annotation_div = $("<div/>").text(annotation).appendTo(new_bookmark); - - // If editable, enable bookmark deletion and annotation editing. - if (editable) { - var delete_icon_container = $("<div/>").addClass("delete-icon-container").prependTo(new_bookmark).click(function (){ - // Remove bookmark. - new_bookmark.slideUp("fast"); - new_bookmark.remove(); - view.has_changes = true; - return false; - }), - delete_icon = $("<a href=''/>").addClass("icon-button delete").appendTo(delete_icon_container); - annotation_div.make_text_editable({ - num_rows: 3, - use_textarea: true, - help_text: "Edit bookmark note" - }).addClass("annotation"); - } - - view.has_changes = true; - return new_bookmark; - }, - - /** - * Create a complete Trackster visualization. Returns view. - */ - create_visualization: function(view_config, viewport_config, drawables_config, bookmarks_config, editable) { - - // Create view. - var self = this, - view = new tracks.TracksterView(_.extend(view_config, {header: false})); - view.editor = true; - $.when( view.load_chroms_deferred ).then(function(chrom_info) { - // Viewport config. - if (viewport_config) { - var chrom = viewport_config.chrom, - start = viewport_config.start, - end = viewport_config.end, - overview_drawable_name = viewport_config.overview; - - if (chrom && (start !== undefined) && end) { - view.change_chrom(chrom, start, end); - } - else { - // No valid viewport, so use first chromosome. - view.change_chrom(chrom_info[0].chrom); - } - } - else { - // No viewport, so use first chromosome. - view.change_chrom(chrom_info[0].chrom); - } - - // Add drawables to view. - if (drawables_config) { - // FIXME: can from_dict() be used to create view and add drawables? - var drawable_config, - drawable_type, - drawable; - for (var i = 0; i < drawables_config.length; i++) { - view.add_drawable( tracks.object_from_template( drawables_config[i], view, view ) ); - } - } - - // Set overview. - var overview_drawable; - for (var i = 0; i < view.drawables.length; i++) { - if (view.drawables[i].config.get_value('name') === overview_drawable_name) { - view.set_overview(view.drawables[i]); - break; - } - } - - // Load bookmarks. - if (bookmarks_config) { - var bookmark; - for (var i = 0; i < bookmarks_config.length; i++) { - bookmark = bookmarks_config[i]; - self.add_bookmark(bookmark['position'], bookmark['annotation'], editable); - } - } - - // View has no changes as of yet. - view.has_changes = false; - }); - - // Final initialization. - this.set_up_router({view: view}); - - return view; - }, - - /** - * Set up location router to use hashes as track browser locations. - */ - set_up_router : function(options) - { - new visualization.TrackBrowserRouter(options); - Backbone.history.start(); - }, - - /** - * Set up keyboard navigation for a visualization. - */ - init_keyboard_nav: function(view) { - // Keyboard navigation. Scroll ~7% of height when scrolling up/down. - $(document).keyup(function(e) { - // Do not navigate if arrow keys used in input element. - if ($(e.srcElement).is(':input')) { - return; - } - - // Key codes: left == 37, up == 38, right == 39, down == 40 - switch(e.which) { - case 37: - view.move_fraction(0.25); - break; - case 38: - var change = Math.round(view.viewport_container.height()/15.0); - view.viewport_container.scrollTop( view.viewport_container.scrollTop() - 20); - break; - case 39: - view.move_fraction(-0.25); - break; - case 40: - var change = Math.round(view.viewport_container.height()/15.0); - view.viewport_container.scrollTop( view.viewport_container.scrollTop() + 20); - break; - } - }); - }, - - /** - * Handle unsaved changes in visualization. - */ - handle_unsaved_changes: function(view) { - if (view.has_changes) { - var self = this; - Galaxy.modal.show({ - title: "Close visualization", - body: "There are unsaved changes to your visualization which will be lost if you do not save them.", - buttons: { - "Cancel": function() { Galaxy.modal.hide(); }, - "Leave without Saving" : function() { - window.onbeforeunload = undefined; - window.location = galaxy_config.root + 'visualization'; - }, - "Save" : function() { - $.when(self.save_viz()).then(function() { - window.location = galaxy_config.root + 'visualization'; - }); - } - } - }); - - } - else { - window.location = galaxy_config.root + 'visualization'; - } - } - -}); - -return { - object_from_template: tracks.object_from_template, - TracksterUI: TracksterUI -}; - -}); https://bitbucket.org/galaxy/galaxy-central/commits/1d578ea7ba67/ Changeset: 1d578ea7ba67 User: jgoecks Date: 2014-07-17 22:23:33 Summary: Automated merge. Affected #: 4 files diff -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 -r 1d578ea7ba67cedd9e8ce193c4cfdb581224a3df lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -169,7 +169,7 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) tool_dependency_ids = tool_dependency_util.get_tool_dependency_ids( as_string=False, **kwd ) - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_ids[ 0 ] ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_ids[ 0 ] ) if tool_dependency.in_error_state: message = "This tool dependency is not installed correctly (see the <b>Tool dependency installation error</b> below). " message += "Choose <b>Uninstall this tool dependency</b> from the <b>Repository Actions</b> menu, correct problems " @@ -806,7 +806,7 @@ tool_dependency_ids = tool_dependency_util.get_tool_dependency_ids( as_string=False, **kwd ) if tool_dependency_ids: # We need a tool_shed_repository, so get it from one of the tool_dependencies. - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_ids[ 0 ] ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_ids[ 0 ] ) tool_shed_repository = tool_dependency.tool_shed_repository else: # The user must be on the manage_repository_tool_dependencies page and clicked the button to either install or uninstall a @@ -830,7 +830,7 @@ elif operation == 'uninstall': tool_dependencies_for_uninstallation = [] for tool_dependency_id in tool_dependency_ids: - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_id ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_id ) if tool_dependency.status in [ trans.install_model.ToolDependency.installation_status.INSTALLED, trans.install_model.ToolDependency.installation_status.ERROR ]: tool_dependencies_for_uninstallation.append( tool_dependency ) @@ -845,7 +845,7 @@ if trans.app.config.tool_dependency_dir: tool_dependencies_for_installation = [] for tool_dependency_id in tool_dependency_ids: - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_id ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_id ) if tool_dependency.status in [ trans.install_model.ToolDependency.installation_status.NEVER_INSTALLED, trans.install_model.ToolDependency.installation_status.UNINSTALLED ]: tool_dependencies_for_installation.append( tool_dependency ) @@ -889,7 +889,7 @@ repository_id = kwd.get( 'repository_id', None ) if tool_dependency_ids: # We need a tool_shed_repository, so get it from one of the tool_dependencies. - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_ids[ 0 ] ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_ids[ 0 ] ) tool_shed_repository = tool_dependency.tool_shed_repository else: # The user must be on the manage_repository_tool_dependencies page and clicked the button to either install or uninstall a @@ -914,7 +914,7 @@ if trans.app.config.tool_dependency_dir: tool_dependencies_for_installation = [] for tool_dependency_id in tool_dependency_ids: - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_id ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_id ) if tool_dependency.status in [ trans.install_model.ToolDependency.installation_status.NEVER_INSTALLED, trans.install_model.ToolDependency.installation_status.UNINSTALLED ]: tool_dependencies_for_installation.append( tool_dependency ) @@ -1849,7 +1849,7 @@ tool_dependency_ids = util.listify( kwd.get( 'id', None ) ) tool_dependencies = [] for tool_dependency_id in tool_dependency_ids: - tool_dependency = tool_dependency_util.get_tool_dependency( trans, tool_dependency_id ) + tool_dependency = tool_dependency_util.get_tool_dependency( trans.app, tool_dependency_id ) tool_dependencies.append( tool_dependency ) tool_shed_repository = tool_dependencies[ 0 ].tool_shed_repository if kwd.get( 'uninstall_tool_dependencies_button', False ): diff -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 -r 1d578ea7ba67cedd9e8ce193c4cfdb581224a3df lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -1347,7 +1347,7 @@ match_tuples = [] ok = True if tool_ids or tool_names or tool_versions: - ok, match_tuples = search_util.search_repository_metadata( trans, + ok, match_tuples = search_util.search_repository_metadata( trans.app, exact_matches_checked, tool_ids=tool_ids, tool_names=tool_names, @@ -1437,9 +1437,14 @@ match_tuples = [] ok = True if workflow_names: - ok, match_tuples = search_util.search_repository_metadata( trans, exact_matches_checked, workflow_names=workflow_names ) + ok, match_tuples = search_util.search_repository_metadata( trans.app, + exact_matches_checked, + workflow_names=workflow_names ) else: - ok, match_tuples = search_util.search_repository_metadata( trans, exact_matches_checked, workflow_names=[], all_workflows=True ) + ok, match_tuples = search_util.search_repository_metadata( trans.app, + exact_matches_checked, + workflow_names=[], + all_workflows=True ) if ok: kwd[ 'match_tuples' ] = match_tuples if trans.webapp.name == 'galaxy': diff -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 -r 1d578ea7ba67cedd9e8ce193c4cfdb581224a3df lib/tool_shed/util/search_util.py --- a/lib/tool_shed/util/search_util.py +++ b/lib/tool_shed/util/search_util.py @@ -81,15 +81,17 @@ match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) ) return match_tuples -def search_repository_metadata( trans, exact_matches_checked, tool_ids='', tool_names='', tool_versions='', workflow_names='', all_workflows=False ): +def search_repository_metadata( app, exact_matches_checked, tool_ids='', tool_names='', tool_versions='', + workflow_names='', all_workflows=False ): + sa_session=app.model.context.current match_tuples = [] ok = True if tool_ids or tool_names or tool_versions: - for repository_metadata in trans.sa_session.query( trans.model.RepositoryMetadata ) \ - .filter( trans.model.RepositoryMetadata.table.c.includes_tools == True ) \ - .join( trans.model.Repository ) \ - .filter( and_( trans.model.Repository.table.c.deleted == False, - trans.model.Repository.table.c.deprecated == False ) ): + for repository_metadata in sa_session.query( app.model.RepositoryMetadata ) \ + .filter( app.model.RepositoryMetadata.table.c.includes_tools == True ) \ + .join( app.model.Repository ) \ + .filter( and_( app.model.Repository.table.c.deleted == False, + app.model.Repository.table.c.deprecated == False ) ): metadata = repository_metadata.metadata if metadata: tools = metadata.get( 'tools', [] ) @@ -140,11 +142,11 @@ else: ok = False elif workflow_names or all_workflows: - for repository_metadata in trans.sa_session.query( trans.model.RepositoryMetadata ) \ - .filter( trans.model.RepositoryMetadata.table.c.includes_workflows == True ) \ - .join( trans.model.Repository ) \ - .filter( and_( trans.model.Repository.table.c.deleted == False, - trans.model.Repository.table.c.deprecated == False ) ): + for repository_metadata in sa_session.query( app.model.RepositoryMetadata ) \ + .filter( app.model.RepositoryMetadata.table.c.includes_workflows == True ) \ + .join( app.model.Repository ) \ + .filter( and_( app.model.Repository.table.c.deleted == False, + app.model.Repository.table.c.deprecated == False ) ): metadata = repository_metadata.metadata if metadata: # metadata[ 'workflows' ] is a list of tuples where each contained tuple is diff -r 40d27b0ba43a746aeecd8e78891c270bcb513ca8 -r 1d578ea7ba67cedd9e8ce193c4cfdb581224a3df lib/tool_shed/util/tool_dependency_util.py --- a/lib/tool_shed/util/tool_dependency_util.py +++ b/lib/tool_shed/util/tool_dependency_util.py @@ -128,9 +128,9 @@ platform_dict[ 'architecture' ] = machine.lower() return platform_dict -def get_tool_dependency( trans, id ): +def get_tool_dependency( app, id ): """Get a tool_dependency from the database via id""" - return trans.install_model.context.query( trans.install_model.ToolDependency ).get( trans.security.decode_id( id ) ) + return app.install_model.context.query( app.install_model.ToolDependency ).get( app.security.decode_id( id ) ) def get_tool_dependency_by_name_type_repository( app, repository, name, type ): context = app.install_model.context 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.