=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js' --- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-01-03 17:22:29 +0000 +++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-01-03 17:40:45 +0000 @@ -4805,8 +4805,8 @@ text += '\n'; text += '\n\n'; text += '\n\n\n\n'; text += '
\n'; text += '\n'; @@ -5422,88 +5422,86 @@ success: function(r) { var i18nArray = Ext.decode(r.responseText); - // i18n - requests.push({ - url: init.contextPath + '/api/i18n?package=org.hisp.dhis.pivot', - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Accepts': 'application/json' - }, - params: Ext.encode(i18nArray), - success: function(r) { - NS.i18n = Ext.decode(r.responseText); - fn(); - } - }); - - // root nodes - requests.push({ - url: init.contextPath + '/api/organisationUnits.json?level=1&paging=false&links=false&viewClass=detailed', - success: function(r) { - init.rootNodes = Ext.decode(r.responseText).organisationUnits || []; - fn(); - } - }); - - // organisation unit levels - requests.push({ - url: init.contextPath + '/api/organisationUnitLevels.json?paging=false&links=false', - success: function(r) { - init.organisationUnitLevels = Ext.decode(r.responseText).organisationUnitLevels || []; - fn(); - } - }); - - // user orgunits and children - requests.push({ - url: init.contextPath + '/api/organisationUnits.json?userOnly=true&viewClass=detailed&links=false', - success: function(r) { - var organisationUnits = Ext.decode(r.responseText).organisationUnits || []; - - if (organisationUnits.length) { - var ou = organisationUnits[0]; - - init.user = { - ou: ou.id, - ouc: Ext.Array.pluck(ou.children, 'id') - }; - - fn(); - } - } - }); - - // legend sets - requests.push({ - url: init.contextPath + '/api/mapLegendSets.json?viewClass=detailed&links=false&paging=false', - success: function(r) { - init.legendSets = Ext.decode(r.responseText).mapLegendSets || []; - fn(); - } - }); - - // dimensions - requests.push({ - url: init.contextPath + '/api/dimensions.json?links=false&paging=false', - success: function(r) { - init.dimensions = Ext.decode(r.responseText).dimensions || []; - fn(); - } - }); - - // host url - requests.push({ + Ext.Ajax.request({ url: init.contextPath + '/api/system/context.json', success: function(r) { - init.host = Ext.decode(r.responseText).contextPath || ''; - fn(); + init.contextPath = Ext.decode(r.responseText).contextPath || init.contextPath; + + // i18n + requests.push({ + url: init.contextPath + '/api/i18n?package=org.hisp.dhis.pivot', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accepts': 'application/json' + }, + params: Ext.encode(i18nArray), + success: function(r) { + NS.i18n = Ext.decode(r.responseText); + fn(); + } + }); + + // root nodes + requests.push({ + url: init.contextPath + '/api/organisationUnits.json?level=1&paging=false&links=false&viewClass=detailed', + success: function(r) { + init.rootNodes = Ext.decode(r.responseText).organisationUnits || []; + fn(); + } + }); + + // organisation unit levels + requests.push({ + url: init.contextPath + '/api/organisationUnitLevels.json?paging=false&links=false', + success: function(r) { + init.organisationUnitLevels = Ext.decode(r.responseText).organisationUnitLevels || []; + fn(); + } + }); + + // user orgunits and children + requests.push({ + url: init.contextPath + '/api/organisationUnits.json?userOnly=true&viewClass=detailed&links=false', + success: function(r) { + var organisationUnits = Ext.decode(r.responseText).organisationUnits || []; + + if (organisationUnits.length) { + var ou = organisationUnits[0]; + + init.user = { + ou: ou.id, + ouc: Ext.Array.pluck(ou.children, 'id') + }; + } + + fn(); + } + }); + + // legend sets + requests.push({ + url: init.contextPath + '/api/mapLegendSets.json?viewClass=detailed&links=false&paging=false', + success: function(r) { + init.legendSets = Ext.decode(r.responseText).mapLegendSets || []; + fn(); + } + }); + + // dimensions + requests.push({ + url: init.contextPath + '/api/dimensions.json?links=false&paging=false', + success: function(r) { + init.dimensions = Ext.decode(r.responseText).dimensions || []; + fn(); + } + }); + + for (var i = 0; i < requests.length; i++) { + Ext.Ajax.request(requests[i]); + } } }); - - for (var i = 0; i < requests.length; i++) { - Ext.Ajax.request(requests[i]); - } } }); }