commit/galaxy-central: carlfeberhard: UI: remove unused LazyDataLoader module
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/27bc860232d7/ Changeset: 27bc860232d7 User: carlfeberhard Date: 2015-02-09 22:47:30+00:00 Summary: UI: remove unused LazyDataLoader module Affected #: 3 files diff -r e3179a43319070d78d02a55e394fa765a3549a84 -r 27bc860232d7e531133f0413d6200fe5c171695d client/galaxy/scripts/utils/LazyDataLoader.js --- a/client/galaxy/scripts/utils/LazyDataLoader.js +++ /dev/null @@ -1,228 +0,0 @@ -//============================================================================== -/* -TODO: - ?? superclass dataloader, subclass lazydataloader?? - -*/ -//============================================================================== -/** - * Object to progressively load JSON data from a REST url, delaying some time between loading chunks - * - * Will load size amount of data every delay ms, starting at start and ending at total. - * - * NOTE: Data from ajax loading is aggregated in a list, with one element for each ajax response. - * It's up to the calling code to combine the results in a meaningful, correct way. - * - * example: - * var loader = new scatterplot.LazyDataLoader({ - * //logger : console, - * url : ( apiDatasetsURL + '/' + hda.id + '?data_type=raw_data' - * + '&columns=[10,14]' ), - * total : hda.metadata_data_lines, - * size : 500, - * - * initialize : function( config ){ - * // ... do some stuff - * }, - * - * buildUrl : function( start, size ){ - * // change the formation of start, size in query string - * return loader.url + '&' + jQuery.param({ - * start_val: start, - * max_vals: size - * }); - * }, - * }); - * - * // you can use events - * $( loader ).bind( 'error', function( event, xhr, status, error ){ - * alert( loader + ' ERROR:' + status + '\n' + error ); - * // bail out... - * }); - * $( loader ).bind( 'loaded.new', function( event, response ){ - * console.info( 'new data available:', event, response ); - * // ... do stuff with new data - * }); - * $( loader ).bind( 'complete', function( event, allDataArray, total ){ - * console.info( 'final load complete:', event, allDataArray, total ); - * // ... do stuff with all data - * }); - * - * // ...or use a callback called when all data is loaded - * loader.load( function( dataArray ){ console.debug( 'FINISHED!', x, y, z ); } ); - */ -function LazyDataLoader( config ){ - // for now assume: - // get, async, and params sent via url query string - // we want json - // we know the size of the data on the server beforehand - var loader = this, - // events to trigger when new or all data has been loaded - // new batches of data (including last). Will be sent: the ajax response data, start value, and size - LOADED_NEW_EVENT = 'loaded.new', - // all data has been loaded: the final loader's data array and the total - LOADED_ALL_EVENT = 'complete'; - // error from ajax - ERROR_EVENT = 'error'; - - jQuery.extend( loader, LoggableMixin ); - jQuery.extend( loader, { - - //NOTE: the next two need to be sent in config (required) - // total size of data on server - total : undefined, - // url of service to get the data - url : undefined, - - // holds the interval id for the current load delay - currentIntervalId : undefined, - - // each load call will add an element to this array - // it's the responsibility of the code using this to combine them properly - data : [], - // ms btwn recursive loads - delay : 4000, - // starting line, element, whatever - start : 0, - // size to fetch per load - size : 4000, - - // loader init func: extends loader with config and calls config.init if there - //@param {object} config : object containing variables to override (or additional) - initialize : function( config ){ - jQuery.extend( loader, config ); - - // call the custom initialize function if any - // only dangerous if the user tries LazyDataLoader.prototype.init - if( config.hasOwnProperty( 'initialize' ) ){ - config.initialize.call( loader, config ); - } - this.log( this + ' initialized:', loader ); - }, - - // returns query string formatted start and size (for the next fetch) appended to the loader.url - //OVERRIDE: to change how params are passed, param names, etc. - //@param {int} start : the line/row/datum indicating where in the dataset the next load begins - //@param {int} size : the number of lines/rows/data to get on the next load - buildUrl : function( start, size ){ - // currently VERY SPECIFIC to using data_providers.py start_val, max_vals params - return this.url + '&' + jQuery.param({ - start_val: start, - max_vals: size - }); - }, - - //OVERRIDE: to handle ajax errors differently - ajaxErrorFn : function( xhr, status, error ){ - console.error( 'ERROR fetching data:', error ); - }, - - // converters passed to the jQuery ajax call for data type parsing - //OVERRIDE: to provide custom parsing - converters : { - '* text' : window.String, - 'text html' : true, - 'text xml' : jQuery.parseXML, - 'text json' : jQuery.parseJSON - }, - - // interface to begin load (and first recursive call) - //@param {Function} callback : function to execute when all data is loaded. callback is passed loader.data - load : function( callback ){ - this.log( this + '.load' ); - - // ensure necessary stuff - if( !loader.url ){ throw( loader + ' requires a url' ); } - - if( this.total === null ){ - this.log( '\t total is null (will load all)' ); - } else { - this.log( '\t total:', this.total ); - } - //if( !loader.total ){ throw( loader + ' requires a total (total size of the data)' ); } - - //FIRST RECURSION: start - var startingSize = loader.size; - if( ( loader.total !== null ) && ( loader.total < loader.size ) ){ - startingSize = loader.total; - } - loader.log( loader + '\t beginning recursion' ); - loadHelper( loader.start, startingSize ); - - //FIRST, SUBSEQUENT RECURSION function - function loadHelper( start, size ){ - loader.log( loader + '.loadHelper, start:', start, 'size:', size ); - var url = loader.buildUrl( start, size ); - loader.log( '\t url:', url ); - - jQuery.ajax({ - url : loader.buildUrl( start, size ), - converters : loader.converters, - dataType : 'json', - - error : function( xhr, status, error ){ - loader.log( '\t ajax error, status:', status, 'error:', error ); - if( loader.currentIntervalId ){ - clearInterval( loader.currentIntervalId ); - } - $( loader ).trigger( ERROR_EVENT, [ status, error ] ); - loader.ajaxErrorFn( xhr, status, error ); - }, - - success : function( response ){ - loader.log( '\t ajax success, response:', response, 'next:', next, 'remainder:', remainder ); - - if( response !== null ){ - // store the response as is in a new element - //TODO:?? store start, size as well? - loader.data.push( response ); - - //TODO: these might not be the best way to split this up - // fire the first load event (if this is the first batch) AND partial - $( loader ).trigger( LOADED_NEW_EVENT, [ response, start, size ] ); - - //RECURSION: - var next = start + size, - remainder = loader.size; - - if( loader.total !== null ){ - remainder = Math.min( loader.total - next, loader.size ); - } - loader.log( '\t next recursion, start:', next, 'size:', remainder ); - - // if we haven't gotten everything yet, so set up for next recursive call and set the timer - if( loader.total === null || remainder > 0 ){ - loader.currentIntervalId = setTimeout( - function(){ loadHelper( next, remainder ); }, - loader.delay - ); - loader.log( '\t currentIntervalId:', loader.currentIntervalId ); - - // otherwise (base-case), don't do anything - } else { - loadFinished(); - } - - } else { //response === null --> base-case, server sez nuthin left - loadFinished(); - } - } - }); - } - - //HANDLE BASE-CASE, LAST RECURSION - function loadFinished(){ - loader.log( loader + '.loadHelper, has finished:', loader.data ); - $( loader ).trigger( LOADED_ALL_EVENT, [ loader.data, loader.total ] ); - if( callback ){ callback( loader.data ); } - } - }, - - toString : function(){ return 'LazyDataLoader'; } - }); - - loader.initialize( config ); - return loader; -} - -//============================================================================== diff -r e3179a43319070d78d02a55e394fa765a3549a84 -r 27bc860232d7e531133f0413d6200fe5c171695d static/scripts/packed/utils/LazyDataLoader.js --- a/static/scripts/packed/utils/LazyDataLoader.js +++ /dev/null @@ -1,1 +0,0 @@ -function LazyDataLoader(c){var a=this,d="loaded.new",b="complete";ERROR_EVENT="error";jQuery.extend(a,LoggableMixin);jQuery.extend(a,{total:undefined,url:undefined,currentIntervalId:undefined,data:[],delay:4000,start:0,size:4000,initialize:function(e){jQuery.extend(a,e);if(e.hasOwnProperty("initialize")){e.initialize.call(a,e)}this.log(this+" initialized:",a)},buildUrl:function(f,e){return this.url+"&"+jQuery.param({start_val:f,max_vals:e})},ajaxErrorFn:function(g,e,f){console.error("ERROR fetching data:",f)},converters:{"* text":window.String,"text html":true,"text xml":jQuery.parseXML,"text json":jQuery.parseJSON},load:function(h){this.log(this+".load");if(!a.url){throw (a+" requires a url")}if(this.total===null){this.log("\t total is null (will load all)")}else{this.log("\t total:",this.total)}var g=a.size;if((a.total!==null)&&(a.total<a.size)){g=a.total}a.log(a+"\t beginning recursion");f(a.start,g);function f(k,j){a.log(a+".loadHelper, start:",k,"size:",j);var i=a.buildUrl(k,j);a.log("\t url:",i);jQuery.ajax({url:a.buildUrl(k,j),converters:a.converters,dataType:"json",error:function(n,l,m){a.log("\t ajax error, status:",l,"error:",m);if(a.currentIntervalId){clearInterval(a.currentIntervalId)}$(a).trigger(ERROR_EVENT,[l,m]);a.ajaxErrorFn(n,l,m)},success:function(l){a.log("\t ajax success, response:",l,"next:",m,"remainder:",n);if(l!==null){a.data.push(l);$(a).trigger(d,[l,k,j]);var m=k+j,n=a.size;if(a.total!==null){n=Math.min(a.total-m,a.size)}a.log("\t next recursion, start:",m,"size:",n);if(a.total===null||n>0){a.currentIntervalId=setTimeout(function(){f(m,n)},a.delay);a.log("\t currentIntervalId:",a.currentIntervalId)}else{e()}}else{e()}}})}function e(){a.log(a+".loadHelper, has finished:",a.data);$(a).trigger(b,[a.data,a.total]);if(h){h(a.data)}}},toString:function(){return"LazyDataLoader"}});a.initialize(c);return a}; \ No newline at end of file diff -r e3179a43319070d78d02a55e394fa765a3549a84 -r 27bc860232d7e531133f0413d6200fe5c171695d static/scripts/utils/LazyDataLoader.js --- a/static/scripts/utils/LazyDataLoader.js +++ /dev/null @@ -1,228 +0,0 @@ -//============================================================================== -/* -TODO: - ?? superclass dataloader, subclass lazydataloader?? - -*/ -//============================================================================== -/** - * Object to progressively load JSON data from a REST url, delaying some time between loading chunks - * - * Will load size amount of data every delay ms, starting at start and ending at total. - * - * NOTE: Data from ajax loading is aggregated in a list, with one element for each ajax response. - * It's up to the calling code to combine the results in a meaningful, correct way. - * - * example: - * var loader = new scatterplot.LazyDataLoader({ - * //logger : console, - * url : ( apiDatasetsURL + '/' + hda.id + '?data_type=raw_data' - * + '&columns=[10,14]' ), - * total : hda.metadata_data_lines, - * size : 500, - * - * initialize : function( config ){ - * // ... do some stuff - * }, - * - * buildUrl : function( start, size ){ - * // change the formation of start, size in query string - * return loader.url + '&' + jQuery.param({ - * start_val: start, - * max_vals: size - * }); - * }, - * }); - * - * // you can use events - * $( loader ).bind( 'error', function( event, xhr, status, error ){ - * alert( loader + ' ERROR:' + status + '\n' + error ); - * // bail out... - * }); - * $( loader ).bind( 'loaded.new', function( event, response ){ - * console.info( 'new data available:', event, response ); - * // ... do stuff with new data - * }); - * $( loader ).bind( 'complete', function( event, allDataArray, total ){ - * console.info( 'final load complete:', event, allDataArray, total ); - * // ... do stuff with all data - * }); - * - * // ...or use a callback called when all data is loaded - * loader.load( function( dataArray ){ console.debug( 'FINISHED!', x, y, z ); } ); - */ -function LazyDataLoader( config ){ - // for now assume: - // get, async, and params sent via url query string - // we want json - // we know the size of the data on the server beforehand - var loader = this, - // events to trigger when new or all data has been loaded - // new batches of data (including last). Will be sent: the ajax response data, start value, and size - LOADED_NEW_EVENT = 'loaded.new', - // all data has been loaded: the final loader's data array and the total - LOADED_ALL_EVENT = 'complete'; - // error from ajax - ERROR_EVENT = 'error'; - - jQuery.extend( loader, LoggableMixin ); - jQuery.extend( loader, { - - //NOTE: the next two need to be sent in config (required) - // total size of data on server - total : undefined, - // url of service to get the data - url : undefined, - - // holds the interval id for the current load delay - currentIntervalId : undefined, - - // each load call will add an element to this array - // it's the responsibility of the code using this to combine them properly - data : [], - // ms btwn recursive loads - delay : 4000, - // starting line, element, whatever - start : 0, - // size to fetch per load - size : 4000, - - // loader init func: extends loader with config and calls config.init if there - //@param {object} config : object containing variables to override (or additional) - initialize : function( config ){ - jQuery.extend( loader, config ); - - // call the custom initialize function if any - // only dangerous if the user tries LazyDataLoader.prototype.init - if( config.hasOwnProperty( 'initialize' ) ){ - config.initialize.call( loader, config ); - } - this.log( this + ' initialized:', loader ); - }, - - // returns query string formatted start and size (for the next fetch) appended to the loader.url - //OVERRIDE: to change how params are passed, param names, etc. - //@param {int} start : the line/row/datum indicating where in the dataset the next load begins - //@param {int} size : the number of lines/rows/data to get on the next load - buildUrl : function( start, size ){ - // currently VERY SPECIFIC to using data_providers.py start_val, max_vals params - return this.url + '&' + jQuery.param({ - start_val: start, - max_vals: size - }); - }, - - //OVERRIDE: to handle ajax errors differently - ajaxErrorFn : function( xhr, status, error ){ - console.error( 'ERROR fetching data:', error ); - }, - - // converters passed to the jQuery ajax call for data type parsing - //OVERRIDE: to provide custom parsing - converters : { - '* text' : window.String, - 'text html' : true, - 'text xml' : jQuery.parseXML, - 'text json' : jQuery.parseJSON - }, - - // interface to begin load (and first recursive call) - //@param {Function} callback : function to execute when all data is loaded. callback is passed loader.data - load : function( callback ){ - this.log( this + '.load' ); - - // ensure necessary stuff - if( !loader.url ){ throw( loader + ' requires a url' ); } - - if( this.total === null ){ - this.log( '\t total is null (will load all)' ); - } else { - this.log( '\t total:', this.total ); - } - //if( !loader.total ){ throw( loader + ' requires a total (total size of the data)' ); } - - //FIRST RECURSION: start - var startingSize = loader.size; - if( ( loader.total !== null ) && ( loader.total < loader.size ) ){ - startingSize = loader.total; - } - loader.log( loader + '\t beginning recursion' ); - loadHelper( loader.start, startingSize ); - - //FIRST, SUBSEQUENT RECURSION function - function loadHelper( start, size ){ - loader.log( loader + '.loadHelper, start:', start, 'size:', size ); - var url = loader.buildUrl( start, size ); - loader.log( '\t url:', url ); - - jQuery.ajax({ - url : loader.buildUrl( start, size ), - converters : loader.converters, - dataType : 'json', - - error : function( xhr, status, error ){ - loader.log( '\t ajax error, status:', status, 'error:', error ); - if( loader.currentIntervalId ){ - clearInterval( loader.currentIntervalId ); - } - $( loader ).trigger( ERROR_EVENT, [ status, error ] ); - loader.ajaxErrorFn( xhr, status, error ); - }, - - success : function( response ){ - loader.log( '\t ajax success, response:', response, 'next:', next, 'remainder:', remainder ); - - if( response !== null ){ - // store the response as is in a new element - //TODO:?? store start, size as well? - loader.data.push( response ); - - //TODO: these might not be the best way to split this up - // fire the first load event (if this is the first batch) AND partial - $( loader ).trigger( LOADED_NEW_EVENT, [ response, start, size ] ); - - //RECURSION: - var next = start + size, - remainder = loader.size; - - if( loader.total !== null ){ - remainder = Math.min( loader.total - next, loader.size ); - } - loader.log( '\t next recursion, start:', next, 'size:', remainder ); - - // if we haven't gotten everything yet, so set up for next recursive call and set the timer - if( loader.total === null || remainder > 0 ){ - loader.currentIntervalId = setTimeout( - function(){ loadHelper( next, remainder ); }, - loader.delay - ); - loader.log( '\t currentIntervalId:', loader.currentIntervalId ); - - // otherwise (base-case), don't do anything - } else { - loadFinished(); - } - - } else { //response === null --> base-case, server sez nuthin left - loadFinished(); - } - } - }); - } - - //HANDLE BASE-CASE, LAST RECURSION - function loadFinished(){ - loader.log( loader + '.loadHelper, has finished:', loader.data ); - $( loader ).trigger( LOADED_ALL_EVENT, [ loader.data, loader.total ] ); - if( callback ){ callback( loader.data ); } - } - }, - - toString : function(){ return 'LazyDataLoader'; } - }); - - loader.initialize( config ); - return loader; -} - -//============================================================================== 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.
participants (1)
-
commits-noreply@bitbucket.org