=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js 2015-06-18 10:09:53 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js 2015-07-13 12:13:44 +0000 @@ -1239,7 +1239,7 @@ params: Ext.encode(favorite), failure: function(r) { ns.core.web.mask.show(); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { var id = r.getAllResponseHeaders().location.split('/').pop(); @@ -1271,7 +1271,7 @@ method: 'GET', failure: function(r) { ns.core.web.mask.show(); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { chart = Ext.decode(r.responseText); @@ -1284,7 +1284,7 @@ params: Ext.encode(chart), failure: function(r) { ns.core.web.mask.show(); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { if (ns.app.layout && ns.app.layout.id && ns.app.layout.id === id) { @@ -1514,7 +1514,7 @@ method: 'GET', failure: function(r) { ns.app.viewport.mask.hide(); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { var sharing = Ext.decode(r.responseText), @@ -2440,12 +2440,13 @@ failure: function(r) { web.mask.hide(ns.app.centerRegion); - if (Ext.Array.contains([403], r.status)) { - ns.alert(NS.i18n.you_do_not_have_access_to_all_items_in_this_favorite); - } - else { - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); - } + r = Ext.decode(r.responseText); + + if (Ext.Array.contains([403], parseInt(r.httpStatusCode))) { + r.message = NS.i18n.you_do_not_have_access_to_all_items_in_this_favorite || r.message; + } + + ns.alert(r); }, success: function(r) { var layoutConfig = Ext.decode(r.responseText), @@ -2486,14 +2487,16 @@ 'Accepts': 'application/json' }, disableCaching: false, - failure: function(r) { + failure: function(r) { onFailure(); - if (Ext.Array.contains([413, 414], parseInt(r.status))) { + r = Ext.decode(r.responseText); + + if (Ext.Array.contains([413, 414], parseInt(r.httpStatusCode))) { web.analytics.validateUrl(init.contextPath + '/api/analytics.json' + paramString); } - else { - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + else { + ns.alert(r); } }, success: function(r) { === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js 2015-05-13 16:59:59 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js 2015-07-13 12:13:44 +0000 @@ -2277,24 +2277,42 @@ // message web.message = {}; - web.message.alert = function(msg, type) { + web.message.alert = function(obj) { var config = {}, + type, window; - if (!msg) { + if (!obj || (Ext.isObject(obj) && !obj.message && !obj.responseText)) { return; } - type = type || 'error'; - - config.title = type === 'error' ? NS.i18n.error : (type === 'warning' ? NS.i18n.warning : NS.i18n.info); + // if response object + if (Ext.isObject(obj) && obj.responseText && !obj.message) { + obj = Ext.decode(obj.responseText); + } + + // if string + if (Ext.isString(obj)) { + obj = { + status: 'ERROR', + message: obj + }; + } + + // web message + type = (obj.status || 'INFO').toLowerCase(); + + config.title = obj.status; config.iconCls = 'ns-window-title-messagebox ' + type; // html - config.html = msg + (msg.substr(msg.length - 1) === '.' ? '' : '.'); + config.html = ''; + config.html += obj.httpStatusCode ? 'Code: ' + obj.httpStatusCode + '
' : ''; + config.html += obj.httpStatus ? 'Status: ' + obj.httpStatus + '

' : ''; + config.html += obj.message + (obj.message.substr(obj.message.length - 1) === '.' ? '' : '.'); // bodyStyle - config.bodyStyle = 'padding: 10px; background: #fff; max-width: 350px; max-height: ' + ns.app.centerRegion.getHeight() / 2 + 'px'; + config.bodyStyle = 'padding: 12px; background: #fff; max-width: 600px; max-height: ' + ns.app.centerRegion.getHeight() / 2 + 'px'; // destroy handler config.modal = true;