dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38644
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19680: GIS web message.
------------------------------------------------------------
revno: 19680
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-07-19 23:43:56 +0200
message:
GIS web message.
added:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/error_m.png
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/warning.png
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css
--
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
=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/error_m.png'
Binary files dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/error_m.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/error_m.png 2015-07-19 21:43:56 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/warning.png'
Binary files dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/warning.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/images/warning.png 2015-07-19 21:43:56 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-07-15 21:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-07-19 21:43:56 +0000
@@ -3025,7 +3025,7 @@
method: 'GET',
failure: function(r) {
gis.olmap.mask.hide();
- alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ gis.alert(r);
},
success: function(r) {
var sharing = Ext.decode(r.responseText),
@@ -4271,9 +4271,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;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-07-15 22:48:48 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-07-19 21:43:56 +0000
@@ -1113,12 +1113,13 @@
failure = function(r) {
gis.olmap.mask.hide();
- if (Ext.Array.contains([403], r.status)) {
- alert(GIS.i18n.you_do_not_have_access_to_all_items_in_this_favorite);
- }
- else {
- alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
- }
+ r = Ext.decode(r.responseText);
+
+ if (Ext.Array.contains([403], parseInt(r.httpStatusCode))) {
+ r.message = GIS.i18n.you_do_not_have_access_to_all_items_in_this_favorite || r.message;
+ }
+
+ gis.alert(r);
};
if (isPlugin) {
@@ -1134,6 +1135,9 @@
url: url,
success: function(r) {
success(Ext.decode(r.responseText));
+ },
+ failure: function(r) {
+ failure(r);
}
});
}
@@ -1408,7 +1412,7 @@
url: gis.init.contextPath + '/api/analytics/events/query/' + view.program.id + '.json' + paramString,
disableCaching: false,
failure: function(r) {
- alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ gis.alert(r);
},
success: function(r) {
success(Ext.decode(r.responseText));
@@ -2389,7 +2393,7 @@
url: gis.init.contextPath + '/api/analytics.json' + paramString,
disableCaching: false,
failure: function(r) {
- alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ gis.alert(r);
},
success: function(r) {
success(Ext.decode(r.responseText));
@@ -2670,6 +2674,9 @@
layers = [],
gis = {};
+ // tmp
+ gis.alert = function() {};
+
// conf
(function() {
conf.finals = {
@@ -3251,6 +3258,64 @@
return dataDimensions;
};
+ util.message = {};
+
+ util.message.alert = function(obj) {
+ var config = {},
+ type,
+ window;
+
+ if (!obj || (Ext.isObject(obj) && !obj.message && !obj.responseText)) {
+ return;
+ }
+
+ // 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 = 'gis-window-title-messagebox ' + type;
+
+ // html
+ 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: 12px; background: #fff; max-width: 600px; max-height: ' + gis.viewport.centerRegion.getHeight() / 2 + 'px';
+
+ // destroy handler
+ config.modal = true;
+ config.destroyOnBlur = true;
+
+ // listeners
+ config.listeners = {
+ show: function(w) {
+ w.setPosition(w.getPosition()[0], w.getPosition()[1] / 2);
+
+ if (!w.hasDestroyOnBlurHandler) {
+ gis.util.gui.window.addDestroyOnBlurHandler(w);
+ }
+ }
+ };
+
+ window = Ext.create('Ext.window.Window', config);
+
+ window.show();
+ };
}());
gis.init = init;
@@ -3628,6 +3693,8 @@
};
}());
+ gis.alert = util.message.alert;
+
gis.api = api;
gis.store = store;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css 2015-03-10 11:49:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css 2015-07-19 21:43:56 +0000
@@ -924,6 +924,16 @@
background: url('../images/measure_14.png') no-repeat;
}
+.gis-window-title-messagebox {
+ padding-left: 16px;
+ background-position-y: 1px;
+}
+.gis-window-title-messagebox.error {
+ background-image: url('../images/error_m.png');
+}
+.gis-window-title-messagebox.warning {
+ background-image: url('../images/warning.png');
+}
/*----------------------------------------------------------------------------
* GIS Grid