partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 92f92a401dbb4c638da7c65a5580de6e9480dc9a
parent 5ce43bde2787b80ede56ea051576a662dfa6f69a
Author: Felicitus <felicitus@felicitus.org>
Date:   Mon, 22 Jun 2015 19:35:42 +0200

Refactored exception window for ExtJS5

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Data/RestProxy.js | 35+++++++++++------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Dialogs/ExceptionWindow.js | 46++++++++++++++++++++--------------------------
2 files changed, 31 insertions(+), 50 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/RestProxy.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/RestProxy.js @@ -3,7 +3,7 @@ Ext.define("PartKeepr.data.RestProxy", { alias: 'proxy.PartKeeprREST', reader: { - type: 'hydra', + type: 'hydra' }, writer: { type: 'jsonwithassociations' @@ -17,38 +17,25 @@ Ext.define("PartKeepr.data.RestProxy", { this.callParent(arguments); }, listeners: { - exception: function (proxy, response, operation) { + exception: function (reader, response, operation, eOpts) { + var request = operation.getRequest(); + + var requestParams = { + method: response.request.options.method, + request: response.request.options.jsonData, + response: response.responseText + }; try { var data = Ext.decode(response.responseText); - var requestData = {}; - requestData.method = operation.request.method; - requestData.headers = operation.request.headers; - requestData.jsonData = operation.request.jsonData; - - request = { - request: Ext.encode(requestData), - response: response.responseText - }; - - PartKeepr.ExceptionWindow.showException(data.exception, request); + PartKeepr.ExceptionWindow.showException(data.exception, response); } catch (ex) { var exception = { message: i18n("Critical Error"), detail: i18n("The server returned a response which we were not able to interpret.") }; - - requestData.method = operation.request.method; - requestData.headers = operation.request.headers; - requestData.jsonData = operation.request.jsonData; - - request = { - request: Ext.encode(requestData), - response: response.responseText - }; - - PartKeepr.ExceptionWindow.showException(exception, request); + PartKeepr.ExceptionWindow.showException(exception, response); } } }, diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Dialogs/ExceptionWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Dialogs/ExceptionWindow.js @@ -141,13 +141,9 @@ Ext.define('PartKeepr.ExceptionWindow', { * @param exception The exception data * @param requestData The request data. May be empty. */ - _showException: function (exception, requestData) { + _showException: function (exception, response) { var separator = "=================================="; - if (!requestData) { - requestData = {}; - } - this.setIcon(Ext.MessageBox.ERROR); this.messageDiv.update(exception.message); @@ -182,25 +178,23 @@ Ext.define('PartKeepr.ExceptionWindow', { } else { this.backtraceDetails.setValue("No backtrace available"); } - - if (requestData.request) { - fullDetails += "\n\n"+i18n("Request")+"\n"+separator+"\n"; - fullDetails += requestData.request; - - this.requestDetails.setValue(nl2br(requestData.request)); - } else { - this.requestDetails.setValue("No server request information available"); - } - - if (requestData.response) { - fullDetails += "\n\n"+i18n("Response")+"\n"+separator+"\n"; - fullDetails += requestData.response; + + var requestData = response.request.options.method + " " + response.request.options.url; + + if (response.request.jsonData) { + requestData += "\n\n"+response.request.jsonData; + } + + fullDetails += "\n\n"+i18n("Request")+"\n"+separator+"\n"; + fullDetails += requestData; + + this.requestDetails.setValue(nl2br(requestData)); + + fullDetails += "\n\n"+i18n("Response")+"\n"+separator+"\n"; + fullDetails += response.responseText; - this.responseDetails.setValue(nl2br(requestData.response)); - } else { - this.responseDetails.setValue("No server response information available"); - } - + this.responseDetails.setValue(nl2br(response.responseText)); + fullDetails += "\n\n"+i18n("Server Configuration")+"\n"+separator+"\n"; for (var j in window.parameters) { @@ -234,14 +228,14 @@ Ext.define('PartKeepr.ExceptionWindow', { * Any members specified are strings. Any other data type is not supported. * * @param exception The exception object - * @param requestData The request data + * @param response The response object */ - showException: function (exception, requestData) { + showException: function (exception, response) { if (!PartKeepr.ExceptionWindow.activeInstance) { PartKeepr.ExceptionWindow.activeInstance = new PartKeepr.ExceptionWindow(); } - PartKeepr.ExceptionWindow.activeInstance._showException(exception, requestData); + PartKeepr.ExceptionWindow.activeInstance._showException(exception, response); } }