summaryrefslogtreecommitdiffstats
path: root/js/app
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-01-20 13:41:07 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-01-20 13:41:07 +0100
commit38350e62909f06f93902b09e9963056b1ba470f4 (patch)
treeb498d19c397b2bdb4f84f4be66e964ee33ef00e5 /js/app
parentdb09b78d4e2214164daf4e530d1c535637ece4b4 (diff)
show error messages if auth or network related things fail
Diffstat (limited to 'js/app')
-rw-r--r--js/app/Config.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/js/app/Config.js b/js/app/Config.js
index 415fd9d3b..69d12f9d2 100644
--- a/js/app/Config.js
+++ b/js/app/Config.js
@@ -44,7 +44,38 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
}
};
});
+ $provide.factory('ConnectionErrorInterceptor', function ($q, $timeout) {
+ var timer;
+ return {
+ responseError: function (response) {
+ var messages = {
+ 0: t('news', 'Request failed, network connection ' +
+ 'unavailable!'),
+ 401: t('news', 'Request unauthorized. Are you logged in?'),
+ 403: t('news', 'Request forbidden. Are you an admin?'),
+ 412: t('news', 'Token expired or app not enabled! ' +
+ 'Try to reload the page!'),
+ 500: t('news', 'Internal server error! Please check your ' +
+ 'data/owncloud.log file for additional ' +
+ 'information!')
+ };
+ // status 0 is a network error
+ if (response.status in messages) {
+ if (timer) {
+ $timeout.cancel(timer);
+ }
+ OC.Notification.hide();
+ OC.Notification.showHtml(messages[response.status]);
+ timer = $timeout(function () {
+ OC.Notification.hide();
+ }, 5000);
+ }
+ return $q.reject(response);
+ }
+ };
+ });
$httpProvider.interceptors.push('CSRFInterceptor');
+ $httpProvider.interceptors.push('ConnectionErrorInterceptor');
// routing
var getItemResolve = function (type) {