diff --git a/lib/galaxy/web/framework/__init__.py b/lib/galaxy/web/framework/__init__.py index 5c479bd9f86..2557746d21c 100644 --- a/lib/galaxy/web/framework/__init__.py +++ b/lib/galaxy/web/framework/__init__.py @@ -126,6 +126,8 @@ def expose_api( func, to_json=True, key_required=True ): #If no key supplied, we use the existing session which may be an anonymous user. if key_required and not trans.user: try: + if 'key' not in kwargs: + raise NoResultFound( 'No key provided' ) provided_key = trans.sa_session.query( trans.app.model.APIKeys ).filter( trans.app.model.APIKeys.table.c.key == kwargs['key'] ).one() except NoResultFound: error_message = 'Provided API key is not valid.' diff --git a/lib/galaxy/webapps/galaxy/controllers/root.py b/lib/galaxy/webapps/galaxy/controllers/root.py index 4c471484794..5ebce370f33 100644 --- a/lib/galaxy/webapps/galaxy/controllers/root.py +++ b/lib/galaxy/webapps/galaxy/controllers/root.py @@ -134,6 +134,8 @@ class RootController( BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAsso show_hidden = util.string_as_bool_or_none( show_hidden ) params = util.Params( kwd ) message = params.get( 'message', '' ) + #TODO: ugh... + message = message if message != 'None' else '' status = params.get( 'status', 'done' ) if trans.app.config.require_login and not trans.user: diff --git a/static/scripts/galaxy.base.js b/static/scripts/galaxy.base.js index 838577b6587..aed5dd12253 100644 --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -12,7 +12,7 @@ window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; @@ -70,7 +70,7 @@ $.fn.makeAbsolute = function(rebase) { */ function make_popupmenu(button_element, initial_options) { /* Use the $.data feature to store options with the link element. - This allows options to be changed at a later time + This allows options to be changed at a later time */ var element_menu_exists = (button_element.data("menu_options")); button_element.data("menu_options", initial_options); @@ -82,7 +82,7 @@ function make_popupmenu(button_element, initial_options) { // Close existing visible menus $(".popmenu-wrapper").remove(); - // Need setTimeouts so clicks don't interfere with each other + // Need setTimeouts so clicks don't interfere with each other setTimeout( function() { // Dynamically generate the wrapper holding all the selectable options of the menu. var menu_element = $( "
" ); @@ -171,15 +171,15 @@ function make_popup_menus( parent ) { if ( !confirmtext || confirm( confirmtext ) ) { var f; // relocate the center panel - if ( target == "_parent" ) { + if ( target === "_parent" ) { window.parent.location = href; // relocate the entire window - } else if ( target == "_top" ) { + } else if ( target === "_top" ) { window.top.location = href; //??...wot? - } else if ( target == "demo" ) { + } else if ( target === "demo" ) { // Http request target is a window named // demolocal on the local box if ( f === undefined || f.closed ) { @@ -242,7 +242,7 @@ function naturalSort(a, b) { $.fn.refresh_select2 = function() { var select_elt = $(this); var options = { width: "resolve", - closeOnSelect: !select_elt.is("[MULTIPLE]"), + closeOnSelect: !select_elt.is("[MULTIPLE]") }; return select_elt.select2( options ); } @@ -263,7 +263,7 @@ function replace_big_select_inputs(min_length, max_length, select_elts) { max_length = 3000; } - var select_elts = select_elts || $('select'); + select_elts = select_elts || $('select'); select_elts.each( function() { var select_elt = $(this); @@ -278,18 +278,18 @@ function replace_big_select_inputs(min_length, max_length, select_elts) { } /* Replaced jQuery.autocomplete with select2, notes: - * - multiple selects are supported + * - multiple selects are supported * - the original element is updated with the value, convert_to_values should not be needed * - events are fired when updating the original element, so refresh_on_change should just work * - * - should we still sort dbkey fields here? + * - should we still sort dbkey fields here? */ select_elt.refresh_select2(); }); } /** - * Make an element with text editable: (a) when user clicks on text, a textbox/area + * Make an element with text editable: (a) when user clicks on text, a textbox/area * is provided for editing; (b) when enter key pressed, element's text is set and on_finish * is called. */ @@ -336,12 +336,14 @@ $.fn.make_text_editable = function(config_dict) { input_elt, button_elt; if (use_textarea) { - input_elt = $("").attr({ rows: num_rows, cols: num_cols }).text($.trim(cur_text)).keyup(function(e) { - if (e.keyCode === 27) { - // Escape key. - set_text(cur_text); - } - }); + input_elt = $("") + .attr({ rows: num_rows, cols: num_cols }).text($.trim(cur_text)) + .keyup(function(e) { + if (e.keyCode === 27) { + // Escape key. + set_text(cur_text); + } + }); button_elt = $("").text("Done").click(function() { set_text(input_elt.val()); // Return false so that click does not propogate to container. @@ -361,7 +363,7 @@ $.fn.make_text_editable = function(config_dict) { set_text($(this).val()); } }); - } + } // Replace text with input object(s) and focus & select. container.text(""); @@ -384,10 +386,11 @@ $.fn.make_text_editable = function(config_dict) { return container; }; -/** +/** * Edit and save text asynchronously. */ -function async_save_text(click_to_edit_elt, text_elt_id, save_url, text_parm_name, num_cols, use_textarea, num_rows, on_start, on_finish) { +function async_save_text( click_to_edit_elt, text_elt_id, save_url, + text_parm_name, num_cols, use_textarea, num_rows, on_start, on_finish ) { // Set defaults if necessary. if (num_cols === undefined) { num_cols = 30; @@ -431,7 +434,7 @@ function async_save_text(click_to_edit_elt, text_elt_id, save_url, text_parm_nam $.ajax({ url: save_url, data: ajax_data, - error: function() { + error: function() { alert( "Text editing for elt " + text_elt_id + " failed" ); // TODO: call finish or no? For now, let's not because error occurred. }, @@ -464,6 +467,7 @@ function async_save_text(click_to_edit_elt, text_elt_id, save_url, text_parm_nam } function init_history_items(historywrapper, noinit, nochanges) { + //NOTE: still needed for non-panel history views var action = function() { // Load saved state and show as necessary @@ -490,37 +494,38 @@ function init_history_items(historywrapper, noinit, nochanges) { var id = this.id, body = $(this).children( "div.historyItemBody" ), peek = body.find( "pre.peek" ); - $(this).find( ".historyItemTitleBar > .historyItemTitle" ).wrap( "" ).click( function() { - var prefs; - if ( body.is(":visible") ) { - // Hiding stuff here - if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ); } - body.slideUp( "fast" ); - - if (!nochanges) { // Ignore embedded item actions - // Save setting - prefs = $.jStorage.get("history_expand_state"); - if (prefs) { - delete prefs[id]; + $(this).find( ".historyItemTitleBar > .historyItemTitle" ).wrap( "" ) + .click( function() { + var prefs; + if ( body.is(":visible") ) { + // Hiding stuff here + if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ); } + body.slideUp( "fast" ); + + if (!nochanges) { // Ignore embedded item actions + // Save setting + prefs = $.jStorage.get("history_expand_state"); + if (prefs) { + delete prefs[id]; + $.jStorage.set("history_expand_state", prefs); + } + } + } else { + // Showing stuff here + body.slideDown( "fast", function() { + if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); } + }); + + if (!nochanges) { + // Save setting + prefs = $.jStorage.get("history_expand_state"); + if (!prefs) { prefs = {}; } + prefs[id] = true; $.jStorage.set("history_expand_state", prefs); } } - } else { - // Showing stuff here - body.slideDown( "fast", function() { - if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); } - }); - - if (!nochanges) { - // Save setting - prefs = $.jStorage.get("history_expand_state"); - if (!prefs) { prefs = {}; } - prefs[id] = true; - $.jStorage.set("history_expand_state", prefs); - } - } - return false; - }); + return false; + }); }); // Generate 'collapse all' link @@ -554,7 +559,7 @@ function commatize( number ) { // Reset tool search to start state. function reset_tool_search( initValue ) { - // Function may be called in top frame or in tool_menu_frame; + // Function may be called in top frame or in tool_menu_frame; // in either case, get the tool menu frame. var tool_menu_frame = $("#galaxy_tools").contents(); if (tool_menu_frame.length === 0) { @@ -570,7 +575,7 @@ function reset_tool_search( initValue ) { tool_menu_frame.find(".toolTitle").show(); tool_menu_frame.find(".toolPanelLabel").show(); tool_menu_frame.find(".toolSectionWrapper").each( function() { - if ($(this).attr('id') != 'recently_used_wrapper') { + if ($(this).attr('id') !== 'recently_used_wrapper') { // Default action. $(this).show(); } else if ($(this).hasClass("user_pref_visible")) { diff --git a/static/scripts/mvc/base-mvc.js b/static/scripts/mvc/base-mvc.js index 0ba1fc2b65b..0680a305ccb 100644 --- a/static/scripts/mvc/base-mvc.js +++ b/static/scripts/mvc/base-mvc.js @@ -1,5 +1,5 @@ /** - * Simple base model for any visible element. Includes useful attributes and ability + * Simple base model for any visible element. Includes useful attributes and ability * to set and track visibility. */ var BaseModel = Backbone.RelationalModel.extend({ @@ -38,7 +38,7 @@ var BaseView = Backbone.View.extend({ } else { this.$el.show(); } - } + } }); @@ -79,7 +79,7 @@ var LoggableMixin = /** @lends LoggableMixin# */{ log : function(){ if( this.logger ){ var log = this.logger.log; - if( typeof this.logger.log == 'object' ){ + if( typeof this.logger.log === 'object' ){ log = Function.prototype.bind.call( this.logger.log, this.logger ); } return log.apply( this.logger, arguments ); @@ -136,7 +136,7 @@ var GalaxyLocalization = jQuery.extend( {}, { }); } else { - throw( 'Localization.setLocalizedString needs either a string or object as the first argument,' + + throw( 'Localization.setLocalizedString needs either a string or object as the first argument,' + ' given: ' + str_or_obj ); } }, @@ -166,11 +166,6 @@ var GalaxyLocalization = jQuery.extend( {}, { // global localization alias window[ GalaxyLocalization.ALIAS_NAME ] = function( str ){ return GalaxyLocalization.localize( str ); }; -//TEST: setLocalizedString( string, string ), _l( string ) -//TEST: setLocalizedString( hash ), _l( string ) -//TEST: setLocalizedString( string === string ), _l( string ) -//TEST: _l( non assigned string ) - //============================================================================== /** diff --git a/static/scripts/mvc/dataset/hda-base.js b/static/scripts/mvc/dataset/hda-base.js index 8d89ab148ec..1fd3a36a1ba 100644 --- a/static/scripts/mvc/dataset/hda-base.js +++ b/static/scripts/mvc/dataset/hda-base.js @@ -2,17 +2,17 @@ // "../mvc/base-mvc" //], function(){ -/* global BaseView, LoggableMixin, HistoryDatasetAssociation, HDABaseView */ +/* global Backbone, LoggableMixin, HistoryDatasetAssociation, HDABaseView */ //============================================================================== /** @class Read only view for HistoryDatasetAssociation. * @name HDABaseView * - * @augments BaseView + * @augments Backbone.View * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var HDABaseView = BaseView.extend( LoggableMixin ).extend( +var HDABaseView = Backbone.View.extend( LoggableMixin ).extend( /** @lends HDABaseView.prototype */{ ///** logger used to record this.log messages, commonly set to console */ diff --git a/static/scripts/mvc/dataset/hda-edit.js b/static/scripts/mvc/dataset/hda-edit.js index 7f8c9da62c8..cdf8eb3b6cc 100644 --- a/static/scripts/mvc/dataset/hda-edit.js +++ b/static/scripts/mvc/dataset/hda-edit.js @@ -53,11 +53,12 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( var ajaxPromise = jQuery.ajax( purge_url ); ajaxPromise.success( function( message, status, responseObj ){ hdaView.model.set( 'purged', true ); + hdaView.trigger( 'purged', hdaView ); }); ajaxPromise.error( function( error, status, message ){ //TODO: Exception messages are hidden within error page //!NOTE: that includes the 'Removal of datasets by users is not allowed in this Galaxy instance.' - alert( '(' + error.status + ') ' + _l( 'Unable to purge this dataset' ) + ':\n' + error ); + hdaView.trigger( 'error', _l( "Unable to purge this dataset" ), error, status, message ); }); }); } @@ -152,7 +153,7 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( icon_class : 'delete', on_click : function() { // Delete the dataset on the server and update HDA + view depending on success/failure. - // FIXME: when HDA-delete is implemented in the API, can call set(), then save directly + // FIXME: when HDA-delete is implemented in the API, can call set(), then save directly // on the model. $.ajax({ url: delete_url, @@ -485,7 +486,7 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( // Hide. tagArea.slideUp("fast"); } - return false; + return false; }, /** Find the annotation area and, if initial: load the html (via ajax) for displaying them; otherwise, unhide/hide @@ -504,7 +505,10 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( // Need to fill annotation element. $.ajax({ url: this.urls.annotation.get, - error: function(){ alert( _l( "Annotations failed" ) ); }, + error: function(){ + view.log( "Annotation failed", xhr, status, error ); + view.trigger( 'error', _l( "Annotation failed" ), xhr, status, error ); + }, success: function( htmlFromAjax ){ if( htmlFromAjax === "" ){ htmlFromAjax = "" + _l( "Describe or add notes to dataset" ) + ""; @@ -528,7 +532,7 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( // Hide. annotationArea.slideUp("fast"); } - return false; + return false; }, // ......................................................................... UTILTIY diff --git a/static/scripts/mvc/dataset/hda-model.js b/static/scripts/mvc/dataset/hda-model.js index 83e5bb9f7e3..4f0fce7cf7c 100644 --- a/static/scripts/mvc/dataset/hda-model.js +++ b/static/scripts/mvc/dataset/hda-model.js @@ -6,12 +6,12 @@ * related to a history. * @name HistoryDatasetAssociation * - * @augments BaseModel + * @augments Backbone.Model * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var HistoryDatasetAssociation = BaseModel.extend( LoggableMixin ).extend( +var HistoryDatasetAssociation = Backbone.Model.extend( LoggableMixin ).extend( /** @lends HistoryDatasetAssociation.prototype */{ ///** logger used to record this.log messages, commonly set to console */ diff --git a/static/scripts/mvc/history/history-model.js b/static/scripts/mvc/history/history-model.js index fadb4236663..642e7fdf620 100644 --- a/static/scripts/mvc/history/history-model.js +++ b/static/scripts/mvc/history/history-model.js @@ -6,12 +6,12 @@ * tool use and a collection of the datasets those tools produced. * @name History * - * @augments BaseModel + * @augments Backbone.Model * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var History = BaseModel.extend( LoggableMixin ).extend( +var History = Backbone.Model.extend( LoggableMixin ).extend( /** @lends History.prototype */{ //TODO: bind change events from items and collection to this (itemLengths, states) diff --git a/static/scripts/mvc/history/history-panel.js b/static/scripts/mvc/history/history-panel.js index 86d9c955142..8cb639167c5 100644 --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -54,12 +54,12 @@ TODO: * panel (current right hand panel). * @name HistoryPanel * - * @augments BaseView + * @augments Backbone.View * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var HistoryPanel = BaseView.extend( LoggableMixin ).extend( +var HistoryPanel = Backbone.View.extend( LoggableMixin ).extend( /** @lends HistoryPanel.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -132,9 +132,13 @@ var HistoryPanel = BaseView.extend( LoggableMixin ).extend( this.model.hdas.bind( 'reset', this.addAll, this ); // when a hda model is (un)deleted or (un)hidden, re-render entirely - //TODO??: purged - //TODO??: could be more selective here this.model.hdas.bind( 'change:deleted', this.handleHdaDeletionChange, this ); + // when an hda is purge the disk size changes + this.model.hdas.bind( 'change:purged', function( hda ){ + // hafta get the new nice-size w/o the purged hda + //TODO: any beter way? + this.model.fetch(); + }, this ); // if an a hidden hda is created (gen. by a workflow), moves thru the updater to the ready state, // then: remove it from the collection if the panel is set to NOT show hidden datasets diff --git a/static/scripts/mvc/user/user-model.js b/static/scripts/mvc/user/user-model.js index 6c48cbd687c..1cf25385030 100644 --- a/static/scripts/mvc/user/user-model.js +++ b/static/scripts/mvc/user/user-model.js @@ -1,12 +1,12 @@ /** @class Model for a Galaxy user (including anonymous users). * @name User * - * @augments BaseModel + * @augments Backbone.Model * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var User = BaseModel.extend( LoggableMixin ).extend( +var User = Backbone.Model.extend( LoggableMixin ).extend( /** @lends User.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -25,7 +25,7 @@ var User = BaseModel.extend( LoggableMixin ).extend( username : '(' + _l( "anonymous user" ) + ')', email : "", total_disk_usage : 0, - nice_total_disk_usage : "0 bytes", + nice_total_disk_usage : "", quota_percent : null }, diff --git a/static/scripts/mvc/user/user-quotameter.js b/static/scripts/mvc/user/user-quotameter.js index c3546c505f8..3bb9c107356 100644 --- a/static/scripts/mvc/user/user-quotameter.js +++ b/static/scripts/mvc/user/user-quotameter.js @@ -3,12 +3,12 @@ * or a simple text element displaying the human readable size used. * @name UserQuotaMeter * - * @augments BaseModel + * @augments Backbone.View * @borrows LoggableMixin#logger as #logger * @borrows LoggableMixin#log as #log * @constructs */ -var UserQuotaMeter = BaseView.extend( LoggableMixin ).extend( +var UserQuotaMeter = Backbone.View.extend( LoggableMixin ).extend( /** @lends UserQuotaMeter.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -111,10 +111,12 @@ var UserQuotaMeter = BaseView.extend( LoggableMixin ).extend( // otherwise, render percent of quota (and warning, error) } else { meterHtml = this._render_quota(); + //TODO: add the original text for unregistered quotas + //tooltip = "Your disk quota is %s. You can increase your quota by registering a Galaxy account." } this.$el.html( meterHtml ); - //this.log( this + '.$el:', this.$el ); + this.$el.find( '.quota-meter-text' ).tooltip(); return this; }, diff --git a/static/scripts/packed/galaxy.base.js b/static/scripts/packed/galaxy.base.js index be17f05b7d7..15dcddd97d2 100644 --- a/static/scripts/packed/galaxy.base.js +++ b/static/scripts/packed/galaxy.base.js @@ -1 +1 @@ -(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a