From 170c6e94ea4f49f3b27a75beea40b653d919e2c8 Mon Sep 17 00:00:00 2001 From: Alexandre Rossi Date: Tue, 11 Aug 2015 10:16:53 +0200 Subject: [PATCH] better handling of load list errors This patch replaces the loading wheel that stays in case of load list error by an appropriate error message that can be clicked to reload the list. Also, periodic polling of the server will reload the list if the error message is displayed. --- public/css/style.css | 8 ++++++-- public/js/selfoss-base.js | 29 ++++++++++++++++++----------- public/js/selfoss-events-entries.js | 2 ++ public/lang/en.ini | 1 + templates/home.phtml | 2 ++ 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 62a417d15c..adfd2bfd20 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -637,7 +637,7 @@ input { } - .stream-more, .mark-these-read { + .stream-more, .mark-these-read, .stream-error { margin-top:20px; margin-bottom:10px; height:35px; @@ -658,7 +658,11 @@ input { .stream-more.loading span { display:none; } - + + .stream-error { + display:none; + } + #fullscreen-entry { display:none; } diff --git a/public/js/selfoss-base.js b/public/js/selfoss-base.js index c5a68a4158..e213fecce5 100644 --- a/public/js/selfoss-base.js +++ b/public/js/selfoss-base.js @@ -162,6 +162,7 @@ var selfoss = { return; } + $('.stream-error').css('display', 'block').hide(); $('#content').addClass('loading').html(""); selfoss.activeAjaxReq = $.ajax({ @@ -187,19 +188,23 @@ var selfoss = { } if(selfoss.filter.sourcesNav) selfoss.refreshSources(data.sources); - - // clean up - $('#content').removeClass('loading'); - selfoss.activeAjaxReq = null; }, error: function(jqXHR, textStatus, errorThrown) { - if (textStatus == "abort") - return; - else if (textStatus == "parsererror") + if (textStatus == "parsererror") location.reload(); - else if (errorThrown) - selfoss.showError('Load list error: '+ - textStatus+' '+errorThrown); + else { + if (textStatus == "abort") + return; + else if (errorThrown) + selfoss.showError('Load list error: '+ + textStatus+' '+errorThrown); + $('.stream-error').show(); + } + }, + complete: function(jqXHR, textStatus) { + // clean up + $('#content').removeClass('loading'); + selfoss.activeAjaxReq = null; } }); }, @@ -222,7 +227,9 @@ var selfoss = { url: stats_url, type: 'GET', success: function(data) { - if( data.unread>0 && $('.stream-empty').is(':visible') ) { + if( data.unread>0 && + ($('.stream-empty').is(':visible') || + $('.stream-error').is(':visible')) ) { selfoss.reloadList(); } else { selfoss.refreshStats(data.all, data.unread, data.starred); diff --git a/public/js/selfoss-events-entries.js b/public/js/selfoss-events-entries.js index 0a87c11912..aaaa678215 100644 --- a/public/js/selfoss-events-entries.js +++ b/public/js/selfoss-events-entries.js @@ -126,6 +126,8 @@ selfoss.events.entries = function(e) { $('.mark-these-read').unbind('click').click(selfoss.markVisibleRead); + $('.stream-error').unbind('click').click(selfoss.reloadList); + // more $('.stream-more').unbind('click').click(function () { var streamMore = $(this); diff --git a/public/lang/en.ini b/public/lang/en.ini index 80baf5853f..471b704a73 100644 --- a/public/lang/en.ini +++ b/public/lang/en.ini @@ -47,3 +47,4 @@ lang_login_username=username lang_login_password=password lang_no_title=no title lang_error=an error occured +lang_streamerror=No items loaded, reload? diff --git a/templates/home.phtml b/templates/home.phtml index 7b8a7b5ce9..2e8a874470 100644 --- a/templates/home.phtml +++ b/templates/home.phtml @@ -150,6 +150,8 @@ content; ?> +
+