FIX: Show error if dashboard can't load

This commit is contained in:
Robin Ward 2018-03-29 14:12:29 -04:00
parent e4a5b0c39a
commit ec6bbe2af0
1 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@ export default Ember.Controller.extend({
versionCheck: null, versionCheck: null,
dashboardFetchedAt: null, dashboardFetchedAt: null,
showVersionChecks: setting('version_checks'), showVersionChecks: setting('version_checks'),
exceptionController: Ember.inject.controller('exception'),
@computed('problems.length') @computed('problems.length')
foundProblems(problemsLength) { foundProblems(problemsLength) {
@ -39,10 +40,10 @@ export default Ember.Controller.extend({
fetchDashboard() { fetchDashboard() {
if (!this.get('dashboardFetchedAt') || moment().subtract(30, 'minutes').toDate() > this.get('dashboardFetchedAt')) { if (!this.get('dashboardFetchedAt') || moment().subtract(30, 'minutes').toDate() > this.get('dashboardFetchedAt')) {
this.set('dashboardFetchedAt', new Date());
this.set('loading', true); this.set('loading', true);
const versionChecks = this.siteSettings.version_checks; const versionChecks = this.siteSettings.version_checks;
AdminDashboard.find().then(d => { AdminDashboard.find().then(d => {
this.set('dashboardFetchedAt', new Date());
if (versionChecks) { if (versionChecks) {
this.set('versionCheck', VersionCheck.create(d.version_check)); this.set('versionCheck', VersionCheck.create(d.version_check));
} }
@ -56,6 +57,10 @@ export default Ember.Controller.extend({
} }
ATTRIBUTES.forEach(a => this.set(a, d[a])); ATTRIBUTES.forEach(a => this.set(a, d[a]));
}).catch(e => {
this.get('exceptionController').set('thrown', e.jqXHR);
this.replaceRoute('exception');
}).finally(() => {
this.set('loading', false); this.set('loading', false);
}); });
} }