Skip to content

Commit

Permalink
Add error message if charts fails to retrieve plugin resources from i…
Browse files Browse the repository at this point in the history
…ts repository
  • Loading branch information
guerler committed Aug 30, 2016
1 parent 59852d0 commit af45adb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
30 changes: 19 additions & 11 deletions config/plugins/visualizations/charts/static/app.js
@@ -1,26 +1,34 @@
/**
* Main application class.
*/
define( [ 'mvc/ui/ui-modal', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', 'utils/utils', 'plugin/components/storage', 'plugin/components/model', 'utils/deferred', 'plugin/views/viewer', 'plugin/views/editor', 'remote/build/types' ],
function( Modal, Portlet, Ui, Utils, Storage, Chart, Deferred, Viewer, Editor, Types ) {
define( [ 'mvc/ui/ui-modal', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', 'utils/utils', 'plugin/components/storage', 'plugin/components/model', 'utils/deferred', 'plugin/views/viewer', 'plugin/views/editor' ],
function( Modal, Portlet, Ui, Utils, Storage, Chart, Deferred, Viewer, Editor ) {
return Backbone.View.extend({
initialize: function( options ) {
var self = this;
Utils.get({
url : Galaxy.root + 'api/datasets/' + options.config.dataset_id,
cache : true,
success : function( dataset ) {
self.dataset = dataset;
self._build( options );
}
require( [ 'remote/build/types', 'remote/build/keywords' ], function( Types, Keywords ) {
self.types = Types;
self.keywords = Keywords;
Utils.get({
url : Galaxy.root + 'api/datasets/' + options.config.dataset_id,
cache : true,
success : function( dataset ) {
self.dataset = dataset;
self._build( options );
}
});
}, function( err ) {
self.$el.append( $( '<div/>' ).addClass( 'errormessagelarge' )
.append( $( '<p/>' ).text( 'Unable to access the Charts plugin repository:' ) )
.append( $( '<pre/>' ).text( 'charts_plugin_url = ' + remote_root + 'package.json' ) )
.append( $( '<p/>' ).html( 'Please verify that your internet connection works properly and that the above base url is correct. Contact your admin if this error persists.' ) ) );
});
},

_build: function( options ) {
this.options = options;
this.types = Types;
this.chart = new Chart();
this.modal = parent.Galaxy && parent.Galaxy.modal || new Modal.View();
this.chart = new Chart();
this.storage = new Storage( this.chart, this.types, options );
this.deferred = new Deferred();
this.viewer = new Viewer( this );
Expand Down
4 changes: 2 additions & 2 deletions config/plugins/visualizations/charts/static/views/types.js
@@ -1,5 +1,5 @@
/** This class renders the chart type selection grid. */
define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'remote/build/keywords' ], function( Utils, Ui, Tabs, Keywords ) {
define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs' ], function( Utils, Ui, Tabs ) {
return Backbone.View.extend({
events : {
'click .item' : '_onclick',
Expand Down Expand Up @@ -30,7 +30,7 @@ define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'remote/build/keywo
}
});
this.tabs.delAll();
_.each( Keywords, function( d, i ) {
_.each( this.app.keywords, function( d, i ) {
var keyword = d.value;
var categories = self.index[ keyword ];
if ( _.size( categories ) > 0 ) {
Expand Down
Expand Up @@ -89,8 +89,11 @@ define( [ 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', 'utils/utils' ], function( Port
var n_panels = chart.settings.get( 'use_panels' ) === 'true' ? chart.groups.length : 1;
this._createContainer( chart.definition.tag, n_panels );
chart.state( 'wait', 'Please wait...' );
require( [ 'remote/build/' + chart.get( 'type' ) ], function( ChartView ) {
require( [ 'remote/builds/' + chart.get( 'type' ) ], function( ChartView ) {
new ChartView( { process: process, chart: chart, dataset: self.app.dataset, targets: self.targets } );
}, function( err ) {
chart.state( 'failed', 'This visualization could not be found in the remote repository. Please contact the Galaxy Team if this error persists.' );
process.resolve();
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion config/plugins/visualizations/charts/templates/charts.mako
@@ -1,7 +1,7 @@
<%
root = h.url_for( "/" )
app_root = root + "plugins/visualizations/charts/static/"
remote_root = "https://raw.githubusercontent.com/guerler/galaxy-charts/master/"
remote_root = app.config.get( "charts_plugins_url", "https://raw.githubusercontent.com/guerler/galaxy-charts/master/" )
%>

<!DOCTYPE HTML>
Expand Down

0 comments on commit af45adb

Please sign in to comment.