From 77179da3f70ec38c849be4e1c0736e124743e810 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Wed, 24 Apr 2013 13:35:27 +0000 Subject: QPID-4773: Add functionality to display information about http errors which might occur when communicating with the broker git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1471409 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/resources/index.html | 16 +++++++++ .../src/main/java/resources/js/qpid/common/util.js | 41 ++++++++++++++++++++++ .../java/resources/js/qpid/management/treeView.js | 3 +- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html index 2117ef361d..4b97c464ec 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html @@ -85,6 +85,22 @@
+ +
+
+
+
An error occurred when communicating with the broker.
+
+
Please try to reload.
+
+ +
+
+
+ +
+
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 77ae1ccf47..2c2096d390 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -309,8 +309,49 @@ define(["dojo/_base/xhr", var maxHeight = Math.max(Math.floor(viewport.h * 0.6), 100); dialogContentArea.style.overflow= "auto"; dialogContentArea.style.height = Math.min(aproximateHeight, maxHeight ) + "px"; + setAttributesDialog.on("hide", function(e){setAttributesDialog.destroy();}); setAttributesDialog.show(); }; + util.xhrErrorHandler = function(error) + { + if (error) + { + if (error.hasOwnProperty("status")) + { + if (error.status == 401) + { + dojo.byId("statusMessage").innerHTML = "401 - Authentication required."; + } + else if (error.status == 403) + { + dojo.byId("statusMessage").innerHTML = "403 - Access denied."; + } + else + { + dojo.byId("statusMessage").innerHTML = "HTTP status code: " + error.status; + } + } + else + { + dojo.byId("statusMessage").innerHTML = ""; + } + if (error.hasOwnProperty("message")) + { + dojo.byId("errorDetailsMessage").innerHTML = error.message; + dojo.byId("errorDetails").style.display = "block"; + } + else + { + dojo.byId("errorDetails").style.display = "none"; + } + var dialog = dijit.byId("errorDialog"); + if (!dialog.open) + { + dialog.show(); + } + } + }; + return util; }); \ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js index 7bb52b938f..05df5e24b7 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js @@ -42,7 +42,6 @@ define(["dojo/_base/xhr", this.onDelete = function (object) { // fired when an object is deleted }; - } @@ -297,7 +296,7 @@ define(["dojo/_base/xhr", else { thisObj.buildModel(data); } - }); + }, util.xhrErrorHandler); }; -- cgit v1.2.1