From: <ral...@us...> - 2014-11-21 16:18:37
|
Author: ralfbecker Date: Fri Nov 21 17:18:29 2014 New Revision: 49544 URL: http://svn.stylite.de/viewvc/egroupware?rev=49544&view=rev Log: * API: report failed Ajax requests to user incl. a hint that server error-log should contain more information Modified: branches/14.1/phpgwapi/js/jsapi/egw_json.js branches/14.1/phpgwapi/js/jsapi/egw_message.js branches/14.1/phpgwapi/lang/egw_de.lang branches/14.1/phpgwapi/lang/egw_en.lang Modified: branches/14.1/phpgwapi/js/jsapi/egw_json.js URL: http://svn.stylite.de/viewvc/egroupware/branches/14.1/phpgwapi/js/jsapi/egw_json.js?rev=49544&r1=49543&r2=49544&view=diff ============================================================================== --- branches/14.1/phpgwapi/js/jsapi/egw_json.js (original) +++ branches/14.1/phpgwapi/js/jsapi/egw_json.js Fri Nov 21 17:18:29 2014 @@ -33,6 +33,14 @@ /** * Internal implementation of the JSON request object. + * + * @param {string} _menuaction + * @param {array} _parameters + * @param {function} _callback + * @param {object} _context + * @param {boolean} _async + * @param {object} _sender + * @param {egw} _egw */ function json_request(_menuaction, _parameters, _callback, _context, _async, _sender, _egw) @@ -69,7 +77,7 @@ /** * Sends the assembled request to the server * @param {boolean} [async=false] Overrides async provided in constructor to give an easy way to make simple async requests - * @param {string} method='POST' allow to eg. use a (cachable) 'GET' request instead of POST + * @param {string} method ='POST' allow to eg. use a (cachable) 'GET' request instead of POST * * @return {jqXHR} jQuery jqXHR request object */ @@ -103,13 +111,18 @@ // Don't error about an abort if(_err !== 'abort') { - this.egw.debug('error', 'Ajax request to', this.url, ' failed:', _err); + this.egw.message.call(this.egw, this.egw.lang('Ajax request failed')+': '+_xmlhttp.statusText+' ('+_xmlhttp.status+ + ")\n\n"+this.egw.lang('Server error log should contain more information about the problem.')+ + "\n"+this.egw.lang('Trying it again will usually not help!')+ + "\n\nURL: "+this.url+"\n"+_xmlhttp.getAllResponseHeaders().match(/^Date:.*$/m)[0]); + + this.egw.debug('error', 'Ajax request to', this.url, ' failed: ', _err, _xmlhttp.status, _xmlhttp.statusText); } } }); return this.request; - } + }; json_request.prototype.handleResponse = function(data) { if (data && typeof data.response != 'undefined') @@ -162,8 +175,10 @@ ); } catch(e) { var msg = e.message ? e.message : e + ''; - var stack = e.stack ? "\n-- Stack trace --\n" + e.stack : "" - this.egw.debug('error', 'Exception "' + msg + '" while handling JSON response from ' + this.url + ' [' + JSON.stringify(this.parameters) + '] type "' + res.type + '", plugin', plugin, 'response', res, stack); + var stack = e.stack ? "\n-- Stack trace --\n" + e.stack : ""; + this.egw.debug('error', 'Exception "' + msg + '" while handling JSON response from ' + + this.url + ' [' + JSON.stringify(this.parameters) + '] type "' + res.type + + '", plugin', plugin, 'response', res, stack); } } } @@ -175,7 +190,7 @@ } } this.request = null; - } + }; var json = { @@ -228,7 +243,7 @@ // Add the entry plugins[_type].push({ 'callback': _callback, - 'context': _context, + 'context': _context }); }, @@ -273,7 +288,7 @@ { req.alertHandler( res.data.message, - res.data.details) + res.data.details); return true; } throw 'Invalid parameters'; @@ -326,7 +341,7 @@ catch (e) { req.egw.debug('error', 'Error while executing script: ', - res.data,e) + res.data,e); } return true; } Modified: branches/14.1/phpgwapi/js/jsapi/egw_message.js URL: http://svn.stylite.de/viewvc/egroupware/branches/14.1/phpgwapi/js/jsapi/egw_message.js?rev=49544&r1=49543&r2=49544&view=diff ============================================================================== --- branches/14.1/phpgwapi/js/jsapi/egw_message.js (original) +++ branches/14.1/phpgwapi/js/jsapi/egw_message.js Fri Nov 21 17:18:29 2014 @@ -129,6 +129,9 @@ .text(matches[2])); msg_div.append(jQuery(_wnd.document.createElement('span')).text(parts[1])); } + // center the message + msg_div.css('right', ((jQuery(_wnd).innerWidth()-msg_div.width())/2)+'px'); + if (_type == 'success') // clear message again after some time, if no error { message_timer = _wnd.setTimeout(function() { Modified: branches/14.1/phpgwapi/lang/egw_de.lang URL: http://svn.stylite.de/viewvc/egroupware/branches/14.1/phpgwapi/lang/egw_de.lang?rev=49544&r1=49543&r2=49544&view=diff ============================================================================== --- branches/14.1/phpgwapi/lang/egw_de.lang (original) +++ branches/14.1/phpgwapi/lang/egw_de.lang Fri Nov 21 17:18:29 2014 @@ -55,6 +55,7 @@ admin common de Admin administration common de Administration afghanistan common de AFGHANISTAN +ajax request failed common de Ajax Anfrage fehlgeschlagen albania common de ALBANIEN algeria common de ALGERIEN all common de alle @@ -724,6 +725,7 @@ server %1 has been added common de Server %1 wurde zugefügt server answered. processing response... common de Server antwortet. Bearbeite Antwort... server contacted. waiting for response... common de Server kontaktiert. Warte auf Antwort... +server error log should contain more information about the problem. common de Das Fehlerprotokoll des Servers sollte mehr Informationen über das Problem enthalten. server is unwilling to perform. common de Server ist zur Ausführung nicht bereit. server name common de Server Name session has been killed common de Session wurde beendet @@ -826,6 +828,7 @@ total common de Gesamt transparant bg for the icons? common de Transparenter Hintergrund für Symbole trinidad and tobago common de TRINIDAD AND TOBAGO +trying it again will usually not help! common de Es nochmal zu versuchen hilft im Allgemeinen nicht! tuesday common de Dienstag tunisia common de TUNISIEN turkey common de TÃRKEI Modified: branches/14.1/phpgwapi/lang/egw_en.lang URL: http://svn.stylite.de/viewvc/egroupware/branches/14.1/phpgwapi/lang/egw_en.lang?rev=49544&r1=49543&r2=49544&view=diff ============================================================================== --- branches/14.1/phpgwapi/lang/egw_en.lang (original) +++ branches/14.1/phpgwapi/lang/egw_en.lang Fri Nov 21 17:18:29 2014 @@ -55,6 +55,7 @@ admin common en Admin administration common en Administration afghanistan common en AFGHANISTAN +ajax request failed common en Ajax request failed albania common en ALBANIA algeria common en ALGERIA all common en All @@ -724,6 +725,7 @@ server %1 has been added common en Server %1 has been added. server answered. processing response... common en Server answered. Processing response... server contacted. waiting for response... common en Server contacted. Waiting for response... +server error log should contain more information about the problem. common en Server error log should contain more information about the problem. server is unwilling to perform. common en Server is unwilling to perform. server name common en Server name session has been killed common en Session has been killed. @@ -826,6 +828,7 @@ total common en Total transparant bg for the icons? common en Transparant bg for the icons trinidad and tobago common en TRINIDAD AND TOBAGO +trying it again will usually not help! common en Trying it again will usually not help! tuesday common en Tuesday tunisia common en TUNISIA turkey common en TURKEY |