[view,backend/dataproxy][s]: handle errors from dataproxy better and notify errors better in view.

This commit is contained in:
Rufus Pollock
2012-02-29 22:01:37 +00:00
parent e6ce2ca533
commit fc979023e6
3 changed files with 51 additions and 31 deletions

View File

@@ -48,6 +48,9 @@ this.recline.Backend = this.recline.Backend || {};
});
var dfd = $.Deferred();
my.wrapInTimeout(jqxhr).done(function(results) {
if (results.error) {
dfd.reject(results.error);
}
dataset.fields.reset(_.map(results.fields, function(fieldId) {
return {id: fieldId};
})

View File

@@ -104,17 +104,30 @@ my.DataExplorer = Backbone.View.extend({
this.router = new Backbone.Router();
this.setupRouting();
this.model.bind('query:start', function(eventName) {
this.model.bind('query:start', function() {
my.notify('Loading data', {loader: true});
});
this.model.bind('query:done', function(eventName) {
this.model.bind('query:done', function() {
my.clearNotifications();
self.el.find('.doc-count').text(self.model.docCount || 'Unknown');
my.notify('Data loaded', {category: 'success'});
});
this.model.bind('query:fail', function(eventName, error) {
this.model.bind('query:fail', function(error) {
my.clearNotifications();
my.notify(error.message, {category: 'error', persist: true});
var msg = '';
if (typeof(error) == 'string') {
msg = error;
} else if (typeof(error) == 'object') {
if (error.title) {
msg = error.title + ': ';
}
if (error.message) {
msg += error.message;
}
} else {
msg = 'There was an error querying the backend';
}
my.notify(msg, {category: 'error', persist: true});
});
// retrieve basic data like fields etc