=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2015-06-19 14:50:47 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2015-07-13 12:08:59 +0000 @@ -1130,7 +1130,7 @@ params: Ext.encode(favorite), failure: function(r) { ns.core.web.mask.hide(ns.app.centerRegion); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { var id = r.getAllResponseHeaders().location.split('/').pop(); @@ -1162,7 +1162,7 @@ method: 'GET', failure: function(r) { ns.core.web.mask.hide(ns.app.centerRegion); - ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText); + ns.alert(r); }, success: function(r) { reportTable = Ext.decode(r.responseText); @@ -1175,7 +1175,7 @@ params: Ext.encode(reportTable), failure: function(r) { ns.core.web.mask.hide(ns.app.centerRegion); - 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) { @@ -1405,7 +1405,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), @@ -1961,7 +1961,7 @@ listeners: { show: function(w) { Ext.Ajax.request({ - url: ns.core.init.contextPath + '/api/system/info.json', + url: ns.core.init.contextPath + '/api/system/infso.json', success: function(r) { var info = Ext.decode(r.responseText), divStyle = 'padding:3px', @@ -1981,9 +1981,7 @@ w.update(html); }, failure: function(r) { - html += r.status + '\n' + r.statusText + '\n' + r.responseText; - - w.update(html); + w.update(r.status + '\n' + r.statusText + '\n' + r.responseText); }, callback: function() { document.body.oncontextmenu = true; @@ -2523,12 +2521,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), @@ -2572,14 +2571,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); + ns.alert(r); } }, success: function(r) { === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js 2015-06-19 14:50:47 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js 2015-07-13 12:08:59 +0000 @@ -2026,24 +2026,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;