From e71bd6d196e0796fc62b1481d51063f5d0d619f6 Mon Sep 17 00:00:00 2001 From: Akron Date: Tue, 11 Jun 2024 15:47:39 +0200 Subject: [PATCH] Correctly propagate frontend call warnings (fixes #211) Change-Id: Ia571b8e6b0ba0a4edbf0501254ce2bc115f18cf6 --- Changes | 3 +++ dev/js/src/api.js | 14 ++++++++++---- dev/js/src/init.js | 4 ++-- lib/Kalamar.pm | 2 +- package.json | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index ac459ff8b..b67d33eca 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +0.55 2024-06-11 + - Correctly propagate warnings in frontend calls. (diewald) + 0.54 2024-06-10 - Remove deprecated 'matchInfo' API path. (diewald, margaretha) - Improve footer responsiveness. (diewald) diff --git a/dev/js/src/api.js b/dev/js/src/api.js index 80391d842..3b3b82133 100644 --- a/dev/js/src/api.js +++ b/dev/js/src/api.js @@ -169,10 +169,16 @@ define(['util'], function () { return; }; - if (retJSObj !== undefined && retJSObj["errors"] !== undefined) { - retJSObj["errors"].forEach( - e => KorAP.log(e[0], e[1] || "Unknown") - ); + if (retJSObj !== undefined) { + if (retJSObj["errors"] !== undefined) { + retJSObj["errors"].forEach( + e => KorAP.log(e[0], e[1] || "Unknown") + ); + } else if (retJSObj["warnings"] !== undefined) { + retJSObj["warnings"].forEach( + e => KorAP.log(e[0], e[1] || "Unknown", null, 'warn') + ); + } } else if (this.status !== 200) { diff --git a/dev/js/src/init.js b/dev/js/src/init.js index 6243bc7df..6e6b4f111 100644 --- a/dev/js/src/init.js +++ b/dev/js/src/init.js @@ -56,7 +56,7 @@ define([ // Override KorAP.log window.alertify = alertifyClass; - KorAP.log = function (code, msg, src) { + KorAP.log = function (code, msg, src, type) { if (src) { msg += ''+src+''; @@ -66,7 +66,7 @@ define([ alertifyClass.log( (code === 0 ? '' : code + ': ') + msg, - 'error', + (type ? type : 'error'), 10000 ); }; diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm index 31cefb61a..2afe546f3 100644 --- a/lib/Kalamar.pm +++ b/lib/Kalamar.pm @@ -8,7 +8,7 @@ use Mojo::Util qw/url_escape deprecated slugify/; use List::Util qw!none uniq!; # Minor version - may be patched from package.json -our $VERSION = '0.54'; +our $VERSION = '0.55'; # Supported version of Backend API our $API_VERSION = '1.0'; diff --git a/package.json b/package.json index 2a8316513..500c24a68 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "Kalamar", "description": "Mojolicious-based Frontend for KorAP", "license": "BSD-2-Clause", - "version": "0.54.0", + "version": "0.55.0", "pluginVersion": "0.2.2", "engines": { "node": ">=6.0.0"