X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2F_global%2Findex.js;h=fddb476dcf67650fbf5cbd8f37b1b90e60b7e987;hb=061fca8c6eb1221788dd29c5494d63d6eadacd8f;hp=00410754a244209c8b07bfa3dabb4152825626a2;hpb=b28c5430efefa63d04d87404c99798e82d0427e4;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 00410754..fddb476d 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js @@ -9,7 +9,7 @@ import 'material-design-icons-iconfont/dist/material-design-icons.css'; import 'lato-font/css/lato-font.css'; import './global.scss'; -/* Shortcuts*/ +/* Shortcuts */ import './js/shortcuts/entry'; import './js/shortcuts/main'; @@ -28,8 +28,27 @@ $(document).ready(() => { element: document.querySelector('article'), }); + const authorization = { + permits() { return true; }, + }; + app.registry.registerUtility(authorization, 'authorizationPolicy'); + const x = JSON.parse($('#annotationroutes').html()); - app.include(annotator.storage.http, x); + app.include(annotator.storage.http, $.extend({}, x, { + onError(msg, xhr) { + if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) { + annotator.notification.banner('An error occurred', 'error'); + return; + } + $.each(xhr.responseJSON.children, (k, v) => { + if (v.errors) { + $.each(v.errors, (n, errorText) => { + annotator.notification.banner(errorText, 'error'); + }); + } + }); + }, + })); app.start().then(() => { app.annotations.load({ entry: x.entryId });