1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/03f935bb636e/ Changeset: 03f935bb636e User: guerler Date: 2014-03-06 22:02:55 Summary: Charts: Add job cleanup procedure, handle multiple job requests Affected #: 5 files diff -r 7f4aa510ab2c3a60b2171d20051af4b1257acc5c -r 03f935bb636e0f4fa63782ce5d6a551ac508144a config/plugins/visualizations/charts/static/charts/histogram.js --- a/config/plugins/visualizations/charts/static/charts/histogram.js +++ b/config/plugins/visualizations/charts/static/charts/histogram.js @@ -29,6 +29,7 @@ // send request var self = this; this.app.datasets.request(request_dictionary, function(data) { + chart.set('state', 'ok'); nv.addGraph(function() { self.d3_chart = nv.models.multiBarChart(); @@ -39,8 +40,6 @@ .call(self.d3_chart); nv.utils.windowResize(self.d3_chart.update); - - chart.set('state', 'ok'); }); }); } diff -r 7f4aa510ab2c3a60b2171d20051af4b1257acc5c -r 03f935bb636e0f4fa63782ce5d6a551ac508144a config/plugins/visualizations/charts/static/library/jobs.js --- a/config/plugins/visualizations/charts/static/library/jobs.js +++ b/config/plugins/visualizations/charts/static/library/jobs.js @@ -28,24 +28,29 @@ // configure tool data = { 'tool_id' : 'rkit', - 'history_id' : chart.history_id, + 'history_id' : chart.get('history_id'), 'inputs' : { - 'input' : chart.dataset_hid, + 'input' : chart.get('dataset_hid'), 'module' : chart_type, 'options' : request_string } } + // cleanup previous dataset file + var previous = chart.get('dataset_id_job'); + if (previous) { + Utils.request('PUT', config.root + 'api/histories/' + chart.get('history_id') + '/contents/' + previous, { deleted: true }); + } + // set chart state chart.state('submit', 'Sending job request...'); - + // post job Utils.request('POST', config.root + 'api/tools', data, // success handler function(response) { if (!response.outputs || response.outputs.length == 0) { chart.state('failed', 'Job submission failed. No response.'); - self.app.log('handle::load()', 'Job submission failed.'); } else { // update galaxy history if (Galaxy && Galaxy.currHistoryPanel) { @@ -65,7 +70,7 @@ self._loop(job.id, function(job) { switch (job.state) { case 'ok': - chart.state('ok', 'Job completed successfully...'); + chart.state('success', 'Job completed successfully...'); callback(job); return true; case 'error': @@ -80,8 +85,7 @@ }, // error handler function(response) { - chart.state('failed', 'Job submission failed.'); - self.app.log('handle::load()', 'Job submission failed.'); + chart.state('failed', 'Job submission failed. Please make sure that \'R-kit\' is installed.'); } ); }, diff -r 7f4aa510ab2c3a60b2171d20051af4b1257acc5c -r 03f935bb636e0f4fa63782ce5d6a551ac508144a config/plugins/visualizations/charts/static/models/chart.js --- a/config/plugins/visualizations/charts/static/models/chart.js +++ b/config/plugins/visualizations/charts/static/models/chart.js @@ -11,7 +11,7 @@ title : '', type : '', date : null, - state : '', + state : 'ok', state_info : '' }, @@ -44,6 +44,10 @@ state: function(value, info) { this.set('state_info', info); this.set('state', value); + }, + + ready: function() { + return (this.get('state') == 'ok') || (this.get('state') == 'failed'); } }); diff -r 7f4aa510ab2c3a60b2171d20051af4b1257acc5c -r 03f935bb636e0f4fa63782ce5d6a551ac508144a config/plugins/visualizations/charts/static/views/chart.js --- a/config/plugins/visualizations/charts/static/views/chart.js +++ b/config/plugins/visualizations/charts/static/views/chart.js @@ -286,7 +286,7 @@ } // trigger redraw - current.set('state', 'redraw'); + current.trigger('redraw', current); } }); diff -r 7f4aa510ab2c3a60b2171d20051af4b1257acc5c -r 03f935bb636e0f4fa63782ce5d6a551ac508144a config/plugins/visualizations/charts/static/views/viewport.js --- a/config/plugins/visualizations/charts/static/views/viewport.js +++ b/config/plugins/visualizations/charts/static/views/viewport.js @@ -48,10 +48,18 @@ self._removeChart(chart.id); }); - // replace - this.app.charts.on('change', function(chart) { - if (chart.get('state') == 'redraw') { + // redraw + this.app.charts.on('redraw', function(chart) { + // redraw if chart is not currently processed + if (chart.ready()) { self._refreshChart(chart); + } else { + // redraw once current drawing process has finished + chart.on('change:state', function() { + if (chart.ready()) { + self._refreshChart(chart); + } + }); } }); }, @@ -111,6 +119,12 @@ // link this var self = this; + // check + if (!chart.ready()) { + self.app.log('viewport:_refreshChart()', 'Invalid attempt to refresh chart before completion.'); + return; + } + // backup chart details var chart_id = chart.id; @@ -138,6 +152,9 @@ // show chart from list this.showChart(chart_id); + // clear all previous handlers (including redraw listeners) + chart.off('change:state'); + // link status handler chart.on('change:state', function() { // get info element @@ -185,10 +202,10 @@ var mode = chart_settings.mode; if (mode == 'execute') { self.app.jobs.submit(chart, self._defaultRequestString(chart), function() { - view.plot(chart, self._defaultRequestDictionary(chart)) + view.plot(chart, self._defaultRequestDictionary(chart)); }); } else { - view.plot(chart, self._defaultRequestDictionary(chart)) + view.plot(chart, self._defaultRequestDictionary(chart)); } }); }, 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.