dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38529
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19635: EV web message.
------------------------------------------------------------
revno: 19635
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-07-13 14:28:37 +0200
message:
EV web message.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js 2015-05-27 13:54:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js 2015-07-13 12:28:37 +0000
@@ -2739,7 +2739,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();
@@ -2770,7 +2770,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) {
eventChart = Ext.decode(r.responseText);
@@ -2783,7 +2783,7 @@
params: Ext.encode(eventChart),
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 === id) {
@@ -3018,7 +3018,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),
@@ -6848,12 +6848,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),
@@ -6886,7 +6887,7 @@
web.mask.hide(ns.app.centerRegion);
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
ns.app.dateCreate = new Date();
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js 2015-05-21 15:34:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js 2015-07-13 12:28:37 +0000
@@ -2865,24 +2865,42 @@
// message
web.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 + '<br>' : '';
+ config.html += obj.httpStatus ? 'Status: ' + obj.httpStatus + '<br><br>' : '';
+ 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;
@@ -3029,7 +3047,10 @@
msg += '\n\n' + 'Hint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.';
- ns.alert(msg, 'warning');
+ ns.alert({
+ status: 'INFO',
+ message: msg
+ });
};
// report