dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39677
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20098: ER plugin updated.
------------------------------------------------------------
revno: 20098
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-09-11 22:35:00 +0200
message:
ER plugin updated.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/plugin.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/eventreport.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-reports/plugin.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/plugin.html 2015-09-11 18:29:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/plugin.html 2015-09-11 20:35:00 +0000
@@ -21,8 +21,7 @@
DHIS.getEventReport({
url: url,
el: 'table1',
- uid: 'Eb7MEQK3AVq',
- completedOnly: true
+ uid: 'Eb7MEQK3AVq'
});
});
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-09-11 18:29:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-09-11 20:35:00 +0000
@@ -6704,13 +6704,13 @@
};
// core
- extendCore = function(ns) {
- var conf = ns.core.conf,
- api = ns.core.api,
- support = ns.core.support,
- service = ns.core.service,
- web = ns.core.web,
- init = ns.core.init;
+ extendCore = function(core) {
+ var init = core.init,
+ conf = core.conf,
+ api = core.api,
+ support = core.support,
+ service = core.service,
+ web = core.web;
// init
(function() {
@@ -8299,14 +8299,19 @@
fn = function() {
if (++callbacks === requests.length) {
- NS.instances.push(ns);
-
- ns.core.init = init;
- NS.getCore(ns);
- extendCore(ns);
+ ns.core = NS.getCore(init);
+ ns.alert = ns.core.webAlert;
+ extendCore(ns.core);
dimConf = ns.core.conf.finals.dimension;
ns.app.viewport = createViewport();
+
+ ns.core.app.getViewportWidth = function() { return ns.app.viewport.getWidth(); };
+ ns.core.app.getViewportHeight = function() { return ns.app.viewport.getHeight(); };
+ ns.core.app.getCenterRegionWidth = function() { return ns.app.viewport.centerRegion.getWidth(); };
+ ns.core.app.getCenterRegionHeight = function() { return ns.app.viewport.centerRegion.getHeight(); };
+
+ NS.instances.push(ns);
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-09-11 18:29:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-09-11 20:35:00 +0000
@@ -17,17 +17,26 @@
NS.isSessionStorage = ('sessionStorage' in window && window['sessionStorage'] !== null);
// core
- NS.getCore = function(ns) {
- var init = ns.core.init,
- conf = {},
+ NS.getCore = function(init, appConfig) {
+ var conf = {},
api = {},
support = {},
service = {},
web = {},
+ app = {},
+ webAlert,
dimConf;
- // tmp
- ns.alert = function() {};
+ appConfig = appConfig || {};
+
+ // alert
+ webAlert = function() {};
+
+ // app
+ app.getViewportWidth = function() {};
+ app.getViewportHeight = function() {};
+ app.getCenterRegionWidth = function() {};
+ app.getCenterRegionHeight = function() {};
// conf
(function() {
@@ -3578,14 +3587,17 @@
}());
// alert
- ns.alert = web.message.alert;
-
- ns.core.conf = conf;
- ns.core.api = api;
- ns.core.support = support;
- ns.core.service = service;
- ns.core.web = web;
-
- return ns;
+ webAlert = web.message.alert;
+
+ return {
+ init: init,
+ conf: conf,
+ api: api,
+ support: support,
+ service: service,
+ web: web,
+ app: app,
+ webAlert: webAlert
+ };
};
});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/eventreport.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/eventreport.js 2015-09-11 18:29:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/eventreport.js 2015-09-11 20:35:00 +0000
@@ -48,17 +48,26 @@
ER.isSessionStorage = ('sessionStorage' in window && window['sessionStorage'] !== null);
// core
- ER.getCore = function(ns) {
- var init = ns.core.init,
- conf = {},
+ ER.getCore = function(init, appConfig) {
+ var conf = {},
api = {},
support = {},
service = {},
web = {},
+ app = {},
+ webAlert,
dimConf;
- // tmp
- ns.alert = function() {};
+ appConfig = appConfig || {};
+
+ // alert
+ webAlert = function() {};
+
+ // app
+ app.getViewportWidth = function() {};
+ app.getViewportHeight = function() {};
+ app.getCenterRegionWidth = function() {};
+ app.getCenterRegionHeight = function() {};
// conf
(function() {
@@ -698,7 +707,7 @@
if (!(Ext.isArray(config.rows) && config.rows.length > 0)) {
//alert('No values found');
- //return; // for ER, not for PT
+ //return; // for ER, not for ER
}
if (config.rows.length > 0 && config.headers.length !== config.rows[0].length) {
@@ -1048,6 +1057,17 @@
} : null;
};
+ // connection
+ support.connection = {};
+
+ support.connection.ajax = function(requestConfig, authConfig) {
+ if (authConfig.crossDomain && Ext.isString(authConfig.username) && Ext.isString(authConfig.password)) {
+ requestConfig.headers = Ext.isObject(authConfig.headers) ? authConfig.headers : {};
+ requestConfig.headers['Authorization'] = 'Basic ' + btoa(authConfig.username + ':' + authConfig.password);
+ }
+
+ Ext.Ajax.request(requestConfig);
+ };
}());
// service
@@ -3609,15 +3629,18 @@
}());
// alert
- ns.alert = web.message.alert;
-
- ns.core.conf = conf;
- ns.core.api = api;
- ns.core.support = support;
- ns.core.service = service;
- ns.core.web = web;
-
- return ns;
+ webAlert = web.message.alert;
+
+ return {
+ init: init,
+ conf: conf,
+ api: api,
+ support: support,
+ service: service,
+ web: web,
+ app: app,
+ webAlert: webAlert
+ };
};
// PLUGIN
@@ -3639,7 +3662,8 @@
var isInit = false,
requests = [],
callbackCount = 0,
- type = config.plugin && config.crossDomain ? 'jsonp' : 'json',
+ type = 'json',
+ ajax,
fn;
init.contextPath = config.url;
@@ -3656,6 +3680,17 @@
}
};
+ ajax = function(requestConfig, authConfig) {
+ authConfig = authConfig || config;
+
+ if (authConfig.crossDomain && Ext.isString(authConfig.username) && Ext.isString(authConfig.password)) {
+ requestConfig.headers = Ext.isObject(authConfig.headers) ? authConfig.headers : {};
+ requestConfig.headers['Authorization'] = 'Basic ' + btoa(authConfig.username + ':' + authConfig.password);
+ }
+
+ Ext.Ajax.request(requestConfig);
+ };
+
// dhis2
requests.push({
url: init.contextPath + '/api/systemSettings.' + type + '?key=keyCalendar&key=keyDateFormat',
@@ -3737,12 +3772,7 @@
url += '&filter=id:eq:' + ids[i];
}
- if (type === 'jsonp') {
- Ext.data.JsonP.request(optionSetConfig);
- }
- else {
- Ext.Ajax.request(optionSetConfig);
- }
+ ajax(optionSetConfig);
}
};
@@ -3765,12 +3795,7 @@
};
// option sets
- if (type === 'jsonp') {
- Ext.data.JsonP.request(optionSetVersionConfig);
- }
- else {
- Ext.Ajax.request(optionSetVersionConfig);
- }
+ ajax(optionSetVersionConfig);
};
// init
@@ -3795,12 +3820,7 @@
}
};
- if (type === 'jsonp') {
- Ext.data.JsonP.request(userAccountConfig);
- }
- else {
- Ext.Ajax.request(userAccountConfig);
- }
+ ajax(userAccountConfig);
}
});
@@ -3858,12 +3878,7 @@
//init.legendSets = [];
for (var i = 0; i < requests.length; i++) {
- if (type === 'jsonp') {
- Ext.data.JsonP.request(requests[i]);
- }
- else {
- Ext.Ajax.request(requests[i]);
- }
+ ajax(requests[i]);
}
};
@@ -3944,15 +3959,14 @@
return true;
};
- extendInstance = function(ns) {
+ extendInstance = function(ns, appConfig) {
var init = ns.core.init,
+ api = ns.core.api,
conf = ns.core.conf,
- api = ns.core.api,
support = ns.core.support,
service = ns.core.service,
web = ns.core.web,
- dimConf = conf.finals.dimension,
- type = ns.plugin && ns.crossDomain ? 'jsonp' : 'json',
+ type = 'json',
headerMap = {
json: 'application/json',
jsonp: 'application/javascript'
@@ -3961,11 +3975,22 @@
'Content-Type': headerMap[type],
'Accepts': headerMap[type]
},
- el = Ext.get(config.el);
+ el = Ext.get(init.el),
+ dimConf = conf.finals.dimension;
- // init
init.el = config.el;
+ // ns
+ ns.plugin = appConfig.plugin;
+ ns.dashboard = appConfig.dashboard;
+ ns.crossDomain = appConfig.crossDomain;
+ ns.skipMask = appConfig.skipMask;
+ ns.skipFade = appConfig.skipFade;
+ ns.el = appConfig.el;
+ ns.username = appConfig.username;
+ ns.password = appConfig.password;
+ ns.ajax = support.connection.ajax;
+
// message
web.message = web.message || {};
@@ -4392,17 +4417,6 @@
// re-create table
web.report.createReport(layout, null, response, false);
};
-
- // instance
- ns.plugin = init.plugin;
- ns.dashboard = init.dashboard;
- ns.crossDomain = init.crossDomain;
- ns.skipMask = init.skipMask;
- ns.skipFade = init.skipFade;
-
- ns.alert = web.message.alert;
-
- init.el = config.el;
};
createViewport = function() {
@@ -4412,31 +4426,36 @@
};
initialize = function() {
- var el = Ext.get(config.el);
+ var el = Ext.get(config.el),
+ appConfig;
if (!validateConfig(config)) {
return;
}
+ appConfig = {
+ plugin: true,
+ dashboard: Ext.isBoolean(config.dashboard) ? config.dashboard : false,
+ crossDomain: Ext.isBoolean(config.crossDomain) ? config.crossDomain : true,
+ skipMask: Ext.isBoolean(config.skipMask) ? config.skipMask : false,
+ skipFade: Ext.isBoolean(config.skipFade) ? config.skipFade : false,
+ el: Ext.isString(config.el) ? config.el : null,
+ username: Ext.isString(config.username) ? config.username : null,
+ password: Ext.isString(config.password) ? config.password : null
+ };
+
// css
applyCss(config);
- // config
- init.plugin = true;
- init.dashboard = Ext.isBoolean(config.dashboard) ? config.dashboard : false;
- init.crossDomain = Ext.isBoolean(config.crossDomain) ? config.crossDomain : true;
- init.skipMask = Ext.isBoolean(config.skipMask) ? config.skipMask : false;
- init.skipFade = Ext.isBoolean(config.skipFade) ? config.skipFade : false;
-
- // init
- ER.instances.push(ns);
- ns.core.init = init;
- ER.getCore(ns);
- extendInstance(ns);
+ // core
+ ns.core = ER.getCore(init, appConfig);
+ extendInstance(ns, appConfig);
ns.app.viewport = createViewport();
ns.app.centerRegion = ns.app.viewport.centerRegion;
+ ER.instances.push(ns);
+
if (el) {
el.setViewportWidth = function(width) {
ns.app.centerRegion.setWidth(width);