From 9660ca8abc25f6385347ea2cd14c0bcc5c378f07 Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Wed, 1 Mar 2017 20:47:21 +0100 Subject: [PATCH 1/3] Adjusted API error handlling --- .../datastore/datastore-indexes-auto.xml | 12 ++------ IntelliQ/backend/datastore/local_db.bin | Bin 3714400 -> 3714400 bytes .../backend/src/main/webapp/static/js/api.js | 28 ++++++++++-------- .../src/main/webapp/static/js/manage_queue.js | 4 +-- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/IntelliQ/backend/datastore/datastore-indexes-auto.xml b/IntelliQ/backend/datastore/datastore-indexes-auto.xml index ad84c27..1079f30 100644 --- a/IntelliQ/backend/datastore/datastore-indexes-auto.xml +++ b/IntelliQ/backend/datastore/datastore-indexes-auto.xml @@ -1,12 +1,4 @@ - + - + - - - - - - - - diff --git a/IntelliQ/backend/datastore/local_db.bin b/IntelliQ/backend/datastore/local_db.bin index 95aa73ed61882c792285539f1f8aac405b9296fe..42167c8e02d0b181a1e5d4c5e0d88d530b9a7e7f 100644 GIT binary patch delta 337 zcmXxcxlRIM7=>Z}`Pp4SL1b|QTo45Wx9=*v1QX0uc3MqkV?j?dfe<@PFeIYQv@}-S zfw3UOLJKUdeSug!IXR~|!}pOIqIac?+seJEYNnbnpy7rGUijcg071-Q9t&7R2w^N? z84*OWf*4j2M*>Ntu!ePPU=v$NBZDlqv4dUgA%}hBaezY))sZ^g}VG6LOg)QNN5xYv7NHjLH zoqfH4Sxr2ECSHIqjm0M?=PXVXey9k&b7fr~-?-}5Rlh7~*cd?^2_%uiDAE|iI3|$6 zB&LwXG-fah2XmN54tW%?fJH1}87nBFgfdpKhILf1flX{-8#}0?hB_M9#U7g2#{mv; z60KmQ;FOTUGG)$varRoFJ diff --git a/IntelliQ/backend/src/main/webapp/static/js/api.js b/IntelliQ/backend/src/main/webapp/static/js/api.js index 25605a6..108b2ea 100644 --- a/IntelliQ/backend/src/main/webapp/static/js/api.js +++ b/IntelliQ/backend/src/main/webapp/static/js/api.js @@ -240,10 +240,10 @@ var intelliqApi = function(){ api.lastRequestTimestamp = (new Date()).getTime(); //xhr.setRequestHeader("X-Mashape-Authorization", api.apiKey); }, - success : function(data) { + success : function(data, status, xhr) { request.data = data; // check if the API returned a valid response - if (data.statusCode != null && data.statusCode == 200) { + if (data.statusCode && data.statusCode == 200) { // looks good if (request.onSuccessCallback != null) { request.onSuccessCallback(data); @@ -251,27 +251,31 @@ var intelliqApi = function(){ resolve(data); } else { // something went wrong, try to extract error message - if (data.statusMessage != null) { - this.error(data.statusMessage); + if (data.statusMessage) { + this.error(xhr, status, data.statusMessage); } else { - this.error("Request didn't return a valid response: " + data); + this.error(xhr, status, "Request didn't return a valid response:\n" + JSON.stringify(data)); } } }, - error : function(error) { + error : function(xhr, status, error) { + console.log(xhr); + console.log(status); + console.log(error); + request.error = error; + log(error) - if (typeof error == 'string') { - log(error); - request.data = "{ \"error\": \"" + error + "\" }"; + if (xhr.responseText) { + request.data = JSON.parse(xhr.responseText); } else { - log(error.responseText); - request.data = error.responseJSON; + request.data = { "error": error }; } - + if (request.onErrorCallback != null) { request.onErrorCallback(error); } + reject(error); }, complete : function (){ diff --git a/IntelliQ/backend/src/main/webapp/static/js/manage_queue.js b/IntelliQ/backend/src/main/webapp/static/js/manage_queue.js index 37988f4..6b928a1 100644 --- a/IntelliQ/backend/src/main/webapp/static/js/manage_queue.js +++ b/IntelliQ/backend/src/main/webapp/static/js/manage_queue.js @@ -58,7 +58,7 @@ function requestQueue() { reject("Queue not found"); } }).catch(function(error){ - reject("Unable to get queue: " + error); + reject("Unable to get queue: " + JSON.stringify(error)); console.log(error); }); }); @@ -78,7 +78,7 @@ function requestQueueItems() { queueItems = intelliqApi.sortQueueItems(queueItems).byTicketNumber(); resolve(queueItems); }).catch(function(error){ - reject("Unable to get queue items: " + error); + reject("Unable to get queue items: " + JSON.stringify(error)); console.log(error); }); }); From bb35be464b0f8e85eec2884c368955af71c21a28 Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Thu, 2 Mar 2017 09:00:30 +0100 Subject: [PATCH 2/3] Adjusted authentication error handling --- .../main/webapp/static/js/authenticator.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/IntelliQ/backend/src/main/webapp/static/js/authenticator.js b/IntelliQ/backend/src/main/webapp/static/js/authenticator.js index d6f31ac..d36d26a 100644 --- a/IntelliQ/backend/src/main/webapp/static/js/authenticator.js +++ b/IntelliQ/backend/src/main/webapp/static/js/authenticator.js @@ -70,16 +70,22 @@ var authenticator = function(){ } var onGoogleSignInInitializationFailed = function(error) { - log("Google authentication initialization failed: " + error); + log("Google authentication initialization failed: " + JSON.stringify(error)); authenticator.googleAuthenticationInitializing = false; authenticator.googleAuthenticationInitialized = false; + if (error.error) { + if (error.error === "popup_closed_by_user") { + reject("Sign in canceled by user"); + return; + } + } reject(error); } googleAuth.then(onGoogleSignInInitialized, onGoogleSignInInitializationFailed); } - if (gapi.auth2 == null) { + if (!gapi.auth2) { log("Requesting Google auth2 API"); authenticator.googleAuthenticationInitializing = true; gapi.load('auth2', onAuthApiAvailable); @@ -106,8 +112,8 @@ var authenticator = function(){ log("Google sign in failed: " + error); reject(error); }); - } catch (ex) { - log("Google sign in invoking failed: " + ex); + } catch (error) { + log("Google sign in invoking failed: " + error); reject(error); } }).catch(function(error) { @@ -130,8 +136,8 @@ var authenticator = function(){ log("Google sign out failed: " + error); reject(error); }); - } catch (ex) { - log("Google sign out invoking failed: " + ex); + } catch (error) { + log("Google sign out invoking failed: " + error); reject(error); } }).catch(function(error) { @@ -154,8 +160,8 @@ var authenticator = function(){ log("Google disconnection failed: " + error); reject(error); }); - } catch (ex) { - log("Google disconnection invoking failed: " + ex); + } catch (error) { + log("Google disconnection invoking failed: " + error); reject(error); } }).catch(function(error) { @@ -182,7 +188,7 @@ var authenticator = function(){ authenticator.getGoogleSignInStatus = function() { try { return gapi.auth2.getAuthInstance().isSignedIn.get(); - } catch (ex) { + } catch (error) { log("Unable to get Google sign in status") return false; } @@ -203,7 +209,7 @@ var authenticator = function(){ authenticator.getGoogleUser = function() { try { return gapi.auth2.getAuthInstance().currentUser.get(); - } catch (ex) { + } catch (error) { log("Unable to get Google user") return null; } From a9a10b84812d1c47967fafef70a34df094345b98 Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Thu, 2 Mar 2017 22:28:06 +0100 Subject: [PATCH 3/3] Adjusted error handling, renamed tracking script --- .../datastore/datastore-indexes-auto.xml | 24 ++++++++++++++++-- IntelliQ/backend/datastore/local_db.bin | Bin 3714400 -> 3715289 bytes .../static/js/{analyze.js => tracking.js} | 0 .../src/main/webapp/static/js/webapp.js | 5 +++- .../website/includes/en/common_footer.jsp | 2 +- .../website/includes/en/webapp_footer.jsp | 2 +- 6 files changed, 28 insertions(+), 5 deletions(-) rename IntelliQ/backend/src/main/webapp/static/js/{analyze.js => tracking.js} (100%) diff --git a/IntelliQ/backend/datastore/datastore-indexes-auto.xml b/IntelliQ/backend/datastore/datastore-indexes-auto.xml index 1079f30..0915ccc 100644 --- a/IntelliQ/backend/datastore/datastore-indexes-auto.xml +++ b/IntelliQ/backend/datastore/datastore-indexes-auto.xml @@ -1,4 +1,24 @@ - + - + + + + + + + + + + + + + + + + + + + + + diff --git a/IntelliQ/backend/datastore/local_db.bin b/IntelliQ/backend/datastore/local_db.bin index 42167c8e02d0b181a1e5d4c5e0d88d530b9a7e7f..fb539cc4b6203349b96c5c7d63e5616372e91167 100644 GIT binary patch delta 563 zcmYk#y)Q#i9LDjUbBn&v*1KLUO6d!&qOIQ_Ah8%QnWZ5#kr*U3U@%x!ZXJU~f~#U+ zkh_Y-VCqQXr46|W2D8c2^bU9Uk+cNiD<3zQmH++A_Vx#JoaDuG&O?g?!>vA(=loMJY=` z@uASPboa+`d4kpRlAr|D8+SiQ#Cg)zm29|YwD(^ zZf@QiL#`W5VQ%W?=HHL;Jti{+3Oo76x@FtqvRK%HC?8TpyC@JbwphJHwap{ik|gz) niMt{NH2IizJl5A@Qc``tK(HuuR&+#EKMR3AvP>5X47#GZRk~}_h!OMVqrVU zBy$p7h#ip#HrFg9Ho{oh5(yd`3kw^z{?+-C-{$*&kE{DUxx3DjUm2{ZV-ebLTWS=FKg9nL(%8Pwg@dnt)qB8&h diff --git a/IntelliQ/backend/src/main/webapp/static/js/analyze.js b/IntelliQ/backend/src/main/webapp/static/js/tracking.js similarity index 100% rename from IntelliQ/backend/src/main/webapp/static/js/analyze.js rename to IntelliQ/backend/src/main/webapp/static/js/tracking.js diff --git a/IntelliQ/backend/src/main/webapp/static/js/webapp.js b/IntelliQ/backend/src/main/webapp/static/js/webapp.js index 6f0b248..01c2385 100644 --- a/IntelliQ/backend/src/main/webapp/static/js/webapp.js +++ b/IntelliQ/backend/src/main/webapp/static/js/webapp.js @@ -224,7 +224,10 @@ function requestNearbyQueues() { }); }).catch(function(error){ console.log(error); - ui.showErrorMessage(getString("locationUnavailable") + ": " + JSON.stringify(error)); + if (typeof error !== "string") { + error = "\n" + JSON.stringify(error) + } + ui.showErrorMessage(getString("locationUnavailable") + ": " + error); }); } diff --git a/IntelliQ/backend/src/main/webapp/website/includes/en/common_footer.jsp b/IntelliQ/backend/src/main/webapp/website/includes/en/common_footer.jsp index d81a32b..1d5cdc8 100644 --- a/IntelliQ/backend/src/main/webapp/website/includes/en/common_footer.jsp +++ b/IntelliQ/backend/src/main/webapp/website/includes/en/common_footer.jsp @@ -82,7 +82,7 @@ - + diff --git a/IntelliQ/backend/src/main/webapp/website/includes/en/webapp_footer.jsp b/IntelliQ/backend/src/main/webapp/website/includes/en/webapp_footer.jsp index f5a92a1..79079a5 100644 --- a/IntelliQ/backend/src/main/webapp/website/includes/en/webapp_footer.jsp +++ b/IntelliQ/backend/src/main/webapp/website/includes/en/webapp_footer.jsp @@ -44,7 +44,7 @@ - +