From d93645fb46e61c347003c4f1bee61071a986d9bb Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 27 Jan 2018 23:27:30 +0100 Subject: [PATCH] Fixed: Show error if System->Logs fails to load due to ad blocker. --- src/UI/Shared/ErrorModel.js | 10 ++++++++++ src/UI/Shared/ErrorView.js | 10 ++++++++++ src/UI/Shared/ErrorViewTemplate.hbs | 6 ++++++ src/UI/System/Logs/Table/LogsTableLayout.js | 9 +++++++++ 4 files changed, 35 insertions(+) create mode 100644 src/UI/Shared/ErrorModel.js create mode 100644 src/UI/Shared/ErrorView.js create mode 100644 src/UI/Shared/ErrorViewTemplate.hbs diff --git a/src/UI/Shared/ErrorModel.js b/src/UI/Shared/ErrorModel.js new file mode 100644 index 000000000..b8ccf4fea --- /dev/null +++ b/src/UI/Shared/ErrorModel.js @@ -0,0 +1,10 @@ +var _ = require('underscore'); +var Backbone = require('backbone'); + +module.exports = Backbone.Model.extend({ + defaults : { + 'type' : 'danger', + 'title' : '', + 'message' : '' + } +}); \ No newline at end of file diff --git a/src/UI/Shared/ErrorView.js b/src/UI/Shared/ErrorView.js new file mode 100644 index 000000000..de52d19d3 --- /dev/null +++ b/src/UI/Shared/ErrorView.js @@ -0,0 +1,10 @@ +var Marionette = require('marionette'); +var ErrorModel = require('./ErrorModel'); + +module.exports = Marionette.ItemView.extend({ + template : 'Shared/ErrorViewTemplate', + + initialize: function(data) { + this.model = new ErrorModel(data); + } +}); \ No newline at end of file diff --git a/src/UI/Shared/ErrorViewTemplate.hbs b/src/UI/Shared/ErrorViewTemplate.hbs new file mode 100644 index 000000000..fb69f67fa --- /dev/null +++ b/src/UI/Shared/ErrorViewTemplate.hbs @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/src/UI/System/Logs/Table/LogsTableLayout.js b/src/UI/System/Logs/Table/LogsTableLayout.js index f7d9430b6..e320ca7fa 100644 --- a/src/UI/System/Logs/Table/LogsTableLayout.js +++ b/src/UI/System/Logs/Table/LogsTableLayout.js @@ -8,6 +8,7 @@ var GridPager = require('../../../Shared/Grid/Pager'); var LogCollection = require('../LogsCollection'); var ToolbarLayout = require('../../../Shared/Toolbar/ToolbarLayout'); var LoadingView = require('../../../Shared/LoadingView'); +var ErrorView = require('../../../Shared/ErrorView'); require('../../../jQuery/jquery.spin'); module.exports = Marionette.Layout.extend({ @@ -57,6 +58,7 @@ module.exports = Marionette.Layout.extend({ this.collection = new LogCollection(); this.listenTo(this.collection, 'sync', this._showTable); + this.listenTo(this.collection, 'error', this._showTableError); this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete); }, @@ -68,6 +70,13 @@ module.exports = Marionette.Layout.extend({ this._showToolbar(); }, + _showTableError : function() { + this.grid.show(new ErrorView({ + title: "Oh snap!", + message: "Failed to load logs, your ad blocker might be blocking the api calls." + })); + }, + _showTable : function() { this.grid.show(new Backgrid.Grid({ row : LogRow,