dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25424
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12616: (GIS, PT, DV) Plugin fixes.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 12616 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-10-13 23:09:41 +0200
message:
(GIS, PT, DV) Plugin fixes.
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js 2013-10-13 13:09:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js 2013-10-13 21:03:02 +0000
@@ -2606,6 +2606,10 @@
};
DV.plugin.getChart = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
configs.push(config);
if (!isInitialized) {
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js 2013-10-11 11:44:58 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js 2013-10-13 21:03:02 +0000
@@ -1,7 +1,7 @@
Ext.onReady( function() {
// CUSTOM
-
+
/*----------------------------------------------------------------------------
* EXTJS UX custom
*--------------------------------------------------------------------------*/
@@ -391,7 +391,7 @@
// GIS CORE
-
+
// ext config
Ext.Ajax.method = 'GET';
@@ -2734,7 +2734,7 @@
// MAPFISH (mapfish.js)
-
+
(function() {
window.mapfish = {
@@ -2815,7 +2815,7 @@
// MAPFISH COLOR (color.js)
-
+
/**
* An abstract representation of color.
*/
@@ -2858,11 +2858,11 @@
color.greenLevel == this.greenLevel &&
color.blueLevel == this.blueLevel;
},
-
+
getColorRgb: function() {
return this;
},
-
+
getRgbArray: function() {
return [
this.redLevel,
@@ -2870,10 +2870,10 @@
this.blueLevel
];
},
-
+
/**
* Method: hex2rgbArray
- * Converts a Hex color string to an Rbg array
+ * Converts a Hex color string to an Rbg array
*
* Parameters:
* rgbHexString - {String} Hex color string (format: #rrggbb)
@@ -2891,13 +2891,13 @@
if (rgbArray[i] < 0 || rgbArray[i] > 255 ) {
OpenLayers.Console.error("Invalid rgb hex color string: rgbHexString");
}
- }
+ }
return rgbArray;
},
-
+
/**
* APIMethod: setFromHex
- * Sets the color from a color hex string
+ * Sets the color from a color hex string
*
* Parameters:
* rgbHexString - {String} Hex color string (format: #rrggbb)
@@ -2908,7 +2908,7 @@
this.greenLevel = rgbArray[1];
this.blueLevel = rgbArray[2];
},
-
+
/**
* APIMethod: setFromRgb
* Sets the color from a color rgb string
@@ -2920,7 +2920,7 @@
this.greenLevel = color.g;
this.blueLevel = color.b;
},
-
+
/**
* APIMethod: toHexString
* Converts the rgb color to hex string
@@ -2932,7 +2932,7 @@
var b = this.toHex(this.blueLevel);
return '#' + r + g + b;
},
-
+
/**
* Method: toHex
* Converts a color level to its hexadecimal value
@@ -2955,7 +2955,7 @@
// return hexadecimal equivalent
return hexCharacters.charAt(i) + hexCharacters.charAt(j);
},
-
+
CLASS_NAME: "mapfish.ColorRgb"
});
@@ -2982,13 +2982,13 @@
}
for (var i = 0; i < nbColors; i++) {
var rgbTriplet = [];
- rgbTriplet[0] = colorAVal[0] +
+ rgbTriplet[0] = colorAVal[0] +
i * (colorBVal[0] - colorAVal[0]) / (nbColors - 1);
- rgbTriplet[1] = colorAVal[1] +
+ rgbTriplet[1] = colorAVal[1] +
i * (colorBVal[1] - colorAVal[1]) / (nbColors - 1);
- rgbTriplet[2] = colorAVal[2] +
+ rgbTriplet[2] = colorAVal[2] +
i * (colorBVal[2] - colorAVal[2]) / (nbColors - 1);
- resultColors[i] = new mapfish.ColorRgb(parseInt(rgbTriplet[0]),
+ resultColors[i] = new mapfish.ColorRgb(parseInt(rgbTriplet[0]),
parseInt(rgbTriplet[1]), parseInt(rgbTriplet[2]));
}
return resultColors;
@@ -3163,7 +3163,7 @@
// MAPFISH GEOSTAT (geostat.js)
-
+
/**
* @requires OpenLayers/Layer/Vector.js
* @requires OpenLayers/Popup/AnchoredBubble.js
@@ -3442,7 +3442,7 @@
// MAPFISH ALL (all.js)
-
+
/**
* @requires core/GeoStat.js
*/
@@ -3757,7 +3757,7 @@
CLASS_NAME: "mapfish.GeoStat.Facility"
});
- mapfish.GeoStat.createThematic = function(name) {
+ mapfish.GeoStat.createThematic = function(name) {
mapfish.GeoStat[name] = OpenLayers.Class(mapfish.GeoStat, {
colors: [new mapfish.ColorRgb(120, 120, 0), new mapfish.ColorRgb(255, 0, 0)],
@@ -3871,7 +3871,7 @@
createColorInterpolation: function() {
var numColors = this.classification.bins.length;
-
+
if (!this.view.legendSet) {
this.colorInterpolation = mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0], this.colors[1], numColors);
}
@@ -3952,7 +3952,7 @@
var element = document.createElement("div"),
child,
legendNames;
-
+
// data
child = document.createElement("div");
child.style.height = "14px";
@@ -3964,7 +3964,7 @@
child = document.createElement("div");
child.style.clear = "left";
element.appendChild(child);
-
+
// period
child = document.createElement("div");
child.style.height = "14px";
@@ -3976,13 +3976,13 @@
child = document.createElement("div");
child.style.clear = "left";
element.appendChild(child);
-
+
// separator
child = document.createElement("div");
child.style.width = "1px";
child.style.height = "5px";
element.appendChild(child);
-
+
// legends
if (this.view.legendSet) {
for (var i = 0; i < this.classification.bins.length; i++) {
@@ -4023,7 +4023,7 @@
element.appendChild(child);
}
}
-
+
this.layer.legendPanel.update(element.outerHTML);
},
@@ -4037,18 +4037,136 @@
mapfish.GeoStat.createThematic('Thematic4');
-
// GIS PLUGIN (plugin.js)
+ var init = {},
+ configs = [],
+ isInitialized = false,
+ getInit,
+ applyCss,
+ execute;
+
+ GIS.i18n = {
+ facility_layer_legend: 'Facility layer legend',
+ thematic_layer_1_legend: 'Thematic layer 1 legend',
+ thematic_layer_2_legend: 'Thematic layer 2 legend',
+ thematic_layer_3_legend: 'Thematic layer 3 legend',
+ thematic_layer_4_legend: 'Thematic layer 4 legend',
+ measure_distance: 'Measure distance'
+ };
GIS.plugin = {};
- GIS.plugin.getMap = function(config) {
+ getInit = function(config) {
+ var requests = [],
+ callbacks = 0,
+ fn;
+
+ init.user = {};
+
+ fn = function() {
+ applyCss();
+
+ if (++callbacks === requests.length) {
+ for (var i = 0; i < configs.length; i++) {
+ execute(configs[i]);
+ }
+ }
+ };
+
+ requests.push({
+ url: config.url + '/api/system/info.jsonp',
+ success: function(r) {
+ init.contextPath = r.contextPath;
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false',
+ success: function(r) {
+ var ou = r.organisationUnits[0];
+ init.user.ou = ou.id;
+ init.user.ouc = Ext.Array.pluck(ou.children, 'id');
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false',
+ success: function(r) {
+ init.legendSets = r.mapLegendSets;
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/dimensions.jsonp?links=false&paging=false',
+ success: function(r) {
+ init.dimensions = r.dimensions;
+ fn();
+ }
+ });
+
+ for (var i = 0; i < requests.length; i++) {
+ Ext.data.JsonP.request(requests[i]);
+ }
+ };
+
+ applyCss = function() {
+ var css = '.gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n';
+ css += '.x-panel-body { font-size: 11px; } \n';
+ css += '.x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n';
+ css += '.gis-container-default .x-window-body { padding: 5px; background: #fff; } \n';
+ css += '.olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n';
+ css += '.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';
+ css += '.olControlPanel.zoomIn { right: 72px; } \n';
+ css += '.olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n';
+ css += '.olControlPanel.zoomOut { right: 48px; } \n';
+ css += '.olControlPanel.zoomVisible { right: 24px; } \n';
+ css += '.olControlPermalink { display: none !important; } \n';
+ css += '.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';
+ css += '.olControlMousePosition * { font-size: 10px !important; } \n';
+ css += '.text-mouseposition-lonlat { color: #555; } \n';
+ css += '.olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n';
+ css += '#google-logo { background: url("' + init.contextPath + '/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';
+ css += '.olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n';
+ css += '.olControlScaleLineBottom { display: none; } \n';
+ css += '.olControlScaleLineTop { font-weight: bold; } \n';
+ css += '.x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n';
+ css += '.x-mask-msg div { background-position: 11px center; } \n';
+ css += '.x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n';
+ css += '.gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n';
+ css += '.gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n';
+ css += '.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';
+ css += '.x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n';
+ css += '.x-menu-item-active .x-menu-item-link { border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n';
+ css += '.x-menu-item-link { padding: 4px 5px 4px 26px; } \n';
+ css += '.x-menu-item-text { color: #111; } \n';
+ css += '.disabled { opacity: 0.4; cursor: default !important; } \n';
+ css += '.el-opacity-1 { opacity: 1 !important; } \n';
+ css += '.el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n';
+ css += '.el-fontsize-10 { font-size: 10px !important; } \n';
+ css += '.gis-grid-row-icon-disabled * { cursor: default !important; } \n';
+ css += '.gis-toolbar-btn-menu { margin-top: 4px; } \n';
+ css += '.gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n';
+ css += '.gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n';
+ css += '.gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n';
+ css += '.gis-menu-item-first.x-menu-item-active .x-menu-item-link { border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n';
+ css += '.gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n';
+ css += '.gis-menu-item-icon-drill { \n background: url("' + init.contextPath + '/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';
+ css += '.gis-menu-item-icon-float { background: url("' + init.contextPath + '/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';
+ css += '.x-color-picker a { padding: 0; } \n';
+ css += '.x-color-picker em span { width: 14px; height: 14px; } \n';
+
+ Ext.util.CSS.createStyleSheet(css);
+ };
+
+ execute = function(config) {
var validateConfig,
- onRender,
+ createViewport,
afterRender,
- createViewport,
- gis,
- initialize;
+ initialize,
+ gis;
validateConfig = function() {
if (!Ext.isString(config.url)) {
@@ -4075,66 +4193,6 @@
return true;
};
- applyCss = function(contextPath) {
- var css = '.gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n';
- css += '.x-panel-body { font-size: 11px; } \n';
- css += '.x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n';
- css += '.gis-container-default .x-window-body { padding: 5px; background: #fff; } \n';
- css += '.olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n';
- css += '.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';
- css += '.olControlPanel.zoomIn { right: 72px; } \n';
- css += '.olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n';
- css += '.olControlPanel.zoomOut { right: 48px; } \n';
- css += '.olControlPanel.zoomVisible { right: 24px; } \n';
- css += '.olControlPermalink { display: none !important; } \n';
- css += '.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';
- css += '.olControlMousePosition * { font-size: 10px !important; } \n';
- css += '.text-mouseposition-lonlat { color: #555; } \n';
- css += '.olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n';
- css += '#google-logo { background: url("' + contextPath + '/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';
- css += '.olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n';
- css += '.olControlScaleLineBottom { display: none; } \n';
- css += '.olControlScaleLineTop { font-weight: bold; } \n';
- css += '.x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n';
- css += '.x-mask-msg div { background-position: 11px center; } \n';
- css += '.x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n';
- css += '.gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n';
- css += '.gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n';
- css += '.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';
- css += '.x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n';
- css += '.x-menu-item-active .x-menu-item-link { border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n';
- css += '.x-menu-item-link { padding: 4px 5px 4px 26px; } \n';
- css += '.x-menu-item-text { color: #111; } \n';
- css += '.disabled { opacity: 0.4; cursor: default !important; } \n';
- css += '.el-opacity-1 { opacity: 1 !important; } \n';
- css += '.el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n';
- css += '.el-fontsize-10 { font-size: 10px !important; } \n';
- css += '.gis-grid-row-icon-disabled * { cursor: default !important; } \n';
- css += '.gis-toolbar-btn-menu { margin-top: 4px; } \n';
- css += '.gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n';
- css += '.gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n';
- css += '.gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n';
- css += '.gis-menu-item-first.x-menu-item-active .x-menu-item-link { border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n';
- css += '.gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n';
- css += '.gis-menu-item-icon-drill { \n background: url("' + contextPath + '/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';
- css += '.gis-menu-item-icon-float { background: url("' + contextPath + '/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';
- css += '.x-color-picker a { padding: 0; } \n';
- css += '.x-color-picker em span { width: 14px; height: 14px; } \n';
-
- Ext.util.CSS.createStyleSheet(css);
- };
-
- afterRender = function(vp) {
- var len = Ext.query('.zoomInButton').length;
-
- for (var i = 0; i < len; i++) {
- Ext.query('.zoomInButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomin_24.png" />';
- Ext.query('.zoomOutButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomout_24.png" />';
- Ext.query('.zoomVisibleButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomvisible_24.png" />';
- Ext.query('.measureButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/measure_24.png" />';
- }
- };
-
createViewport = function() {
var viewport,
eastRegion,
@@ -4242,49 +4300,56 @@
return viewport;
};
+ afterRender = function(vp) {
+ var len = Ext.query('.zoomInButton').length;
+
+ for (var i = 0; i < len; i++) {
+ Ext.query('.zoomInButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomin_24.png" />';
+ Ext.query('.zoomOutButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomout_24.png" />';
+ Ext.query('.zoomVisibleButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomvisible_24.png" />';
+ Ext.query('.measureButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/measure_24.png" />';
+ }
+ };
+
initialize = function() {
if (!validateConfig()) {
return;
}
- Ext.data.JsonP.request({
- url: config.url + '/dhis-web-mapping/initialize.action',
- success: function(r) {
- var init = r;
-
- GIS.i18n = init.i18n;
-
- gis = GIS.core.getInstance(init);
- gis.el = config.el;
-
- applyCss(gis.init.contextPath);
-
- GIS.core.createSelectHandlers(gis, gis.layer.boundary);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic1);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic2);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic3);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic4);
- GIS.core.createSelectHandlers(gis, gis.layer.facility);
-
- gis.map = config;
-
- gis.viewport = createViewport();
-
- gis.olmap.mask = Ext.create('Ext.LoadMask', gis.viewport.centerRegion.getEl(), {
- msg: 'Loading'
- });
-
- GIS.core.MapLoader(gis).load();
- }
+ gis = GIS.core.getInstance(init);
+ gis.el = config.el;
+
+ GIS.core.createSelectHandlers(gis, gis.layer.boundary);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic1);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic2);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic3);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic4);
+ GIS.core.createSelectHandlers(gis, gis.layer.facility);
+
+ gis.map = config;
+
+ gis.viewport = createViewport();
+
+ gis.olmap.mask = Ext.create('Ext.LoadMask', gis.viewport.centerRegion.getEl(), {
+ msg: 'Loading'
});
+
+ GIS.core.MapLoader(gis).load();
}();
};
- GIS.getMap = GIS.plugin.getMap;
-
- DHIS = Ext.isObject(DHIS) ? DHIS : {};
-
- DHIS.getMap = GIS.plugin.getMap;
+ GIS.plugin.getMap = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
+ configs.push(config);
+
+ if (!isInitialized) {
+ isInitialized = true;
+ getInit(config);
+ }
+ };
})();
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js 2013-10-13 13:09:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js 2013-10-13 21:03:02 +0000
@@ -2921,6 +2921,10 @@
};
PT.plugin.getTable = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
configs.push(config);
if (!isInitialized) {
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html 2013-10-10 11:15:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html 2013-10-13 21:03:02 +0000
@@ -14,18 +14,17 @@
<style>h1 {font-size: 20px; padding: 30px 0 20px;}</style>
<script>
- var base = "http://localhost:8080/";
-
Ext.onReady(function() {
+ var url = "http://localhost:8080";
GIS.plugin.getMap({
- url: base,
+ url: url,
el: "map1",
id: "ytkZY3ChM6J"
});
GIS.plugin.getMap({
- url: base,
+ url: url,
el: "map2",
mapViews: [{
columns: [{dimension: 'in', items: [{id: 'Uvn6LCg7dVU'}]}], // data
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2013-10-11 11:44:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2013-10-13 21:03:02 +0000
@@ -1,14 +1,133 @@
Ext.onReady( function() {
+ var init = {},
+ configs = [],
+ isInitialized = false,
+ getInit,
+ applyCss,
+ execute;
+
+ GIS.i18n = {
+ facility_layer_legend: 'Facility layer legend',
+ thematic_layer_1_legend: 'Thematic layer 1 legend',
+ thematic_layer_2_legend: 'Thematic layer 2 legend',
+ thematic_layer_3_legend: 'Thematic layer 3 legend',
+ thematic_layer_4_legend: 'Thematic layer 4 legend',
+ measure_distance: 'Measure distance'
+ };
GIS.plugin = {};
- GIS.plugin.getMap = function(config) {
+ getInit = function(config) {
+ var requests = [],
+ callbacks = 0,
+ fn;
+
+ init.user = {};
+
+ fn = function() {
+ applyCss();
+
+ if (++callbacks === requests.length) {
+ for (var i = 0; i < configs.length; i++) {
+ execute(configs[i]);
+ }
+ }
+ };
+
+ requests.push({
+ url: config.url + '/api/system/info.jsonp',
+ success: function(r) {
+ init.contextPath = r.contextPath;
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false',
+ success: function(r) {
+ var ou = r.organisationUnits[0];
+ init.user.ou = ou.id;
+ init.user.ouc = Ext.Array.pluck(ou.children, 'id');
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false',
+ success: function(r) {
+ init.legendSets = r.mapLegendSets;
+ fn();
+ }
+ });
+
+ requests.push({
+ url: config.url + '/api/dimensions.jsonp?links=false&paging=false',
+ success: function(r) {
+ init.dimensions = r.dimensions;
+ fn();
+ }
+ });
+
+ for (var i = 0; i < requests.length; i++) {
+ Ext.data.JsonP.request(requests[i]);
+ }
+ };
+
+ applyCss = function() {
+ var css = '.gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n';
+ css += '.x-panel-body { font-size: 11px; } \n';
+ css += '.x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n';
+ css += '.gis-container-default .x-window-body { padding: 5px; background: #fff; } \n';
+ css += '.olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n';
+ css += '.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';
+ css += '.olControlPanel.zoomIn { right: 72px; } \n';
+ css += '.olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n';
+ css += '.olControlPanel.zoomOut { right: 48px; } \n';
+ css += '.olControlPanel.zoomVisible { right: 24px; } \n';
+ css += '.olControlPermalink { display: none !important; } \n';
+ css += '.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';
+ css += '.olControlMousePosition * { font-size: 10px !important; } \n';
+ css += '.text-mouseposition-lonlat { color: #555; } \n';
+ css += '.olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n';
+ css += '#google-logo { background: url("' + init.contextPath + '/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';
+ css += '.olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n';
+ css += '.olControlScaleLineBottom { display: none; } \n';
+ css += '.olControlScaleLineTop { font-weight: bold; } \n';
+ css += '.x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n';
+ css += '.x-mask-msg div { background-position: 11px center; } \n';
+ css += '.x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n';
+ css += '.gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n';
+ css += '.gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n';
+ css += '.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';
+ css += '.x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n';
+ css += '.x-menu-item-active .x-menu-item-link { border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n';
+ css += '.x-menu-item-link { padding: 4px 5px 4px 26px; } \n';
+ css += '.x-menu-item-text { color: #111; } \n';
+ css += '.disabled { opacity: 0.4; cursor: default !important; } \n';
+ css += '.el-opacity-1 { opacity: 1 !important; } \n';
+ css += '.el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n';
+ css += '.el-fontsize-10 { font-size: 10px !important; } \n';
+ css += '.gis-grid-row-icon-disabled * { cursor: default !important; } \n';
+ css += '.gis-toolbar-btn-menu { margin-top: 4px; } \n';
+ css += '.gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n';
+ css += '.gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n';
+ css += '.gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n';
+ css += '.gis-menu-item-first.x-menu-item-active .x-menu-item-link { border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n';
+ css += '.gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n';
+ css += '.gis-menu-item-icon-drill { \n background: url("' + init.contextPath + '/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';
+ css += '.gis-menu-item-icon-float { background: url("' + init.contextPath + '/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';
+ css += '.x-color-picker a { padding: 0; } \n';
+ css += '.x-color-picker em span { width: 14px; height: 14px; } \n';
+
+ Ext.util.CSS.createStyleSheet(css);
+ };
+
+ execute = function(config) {
var validateConfig,
- onRender,
+ createViewport,
afterRender,
- createViewport,
- gis,
- initialize;
+ initialize,
+ gis;
validateConfig = function() {
if (!Ext.isString(config.url)) {
@@ -35,66 +154,6 @@
return true;
};
- applyCss = function(contextPath) {
- var css = '.gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n';
- css += '.x-panel-body { font-size: 11px; } \n';
- css += '.x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n';
- css += '.gis-container-default .x-window-body { padding: 5px; background: #fff; } \n';
- css += '.olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n';
- css += '.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';
- css += '.olControlPanel.zoomIn { right: 72px; } \n';
- css += '.olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n';
- css += '.olControlPanel.zoomOut { right: 48px; } \n';
- css += '.olControlPanel.zoomVisible { right: 24px; } \n';
- css += '.olControlPermalink { display: none !important; } \n';
- css += '.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';
- css += '.olControlMousePosition * { font-size: 10px !important; } \n';
- css += '.text-mouseposition-lonlat { color: #555; } \n';
- css += '.olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n';
- css += '#google-logo { background: url("' + contextPath + '/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';
- css += '.olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n';
- css += '.olControlScaleLineBottom { display: none; } \n';
- css += '.olControlScaleLineTop { font-weight: bold; } \n';
- css += '.x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n';
- css += '.x-mask-msg div { background-position: 11px center; } \n';
- css += '.x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n';
- css += '.gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n';
- css += '.gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n';
- css += '.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';
- css += '.x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n';
- css += '.x-menu-item-active .x-menu-item-link { border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n';
- css += '.x-menu-item-link { padding: 4px 5px 4px 26px; } \n';
- css += '.x-menu-item-text { color: #111; } \n';
- css += '.disabled { opacity: 0.4; cursor: default !important; } \n';
- css += '.el-opacity-1 { opacity: 1 !important; } \n';
- css += '.el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n';
- css += '.el-fontsize-10 { font-size: 10px !important; } \n';
- css += '.gis-grid-row-icon-disabled * { cursor: default !important; } \n';
- css += '.gis-toolbar-btn-menu { margin-top: 4px; } \n';
- css += '.gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n';
- css += '.gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n';
- css += '.gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n';
- css += '.gis-menu-item-first.x-menu-item-active .x-menu-item-link { border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n';
- css += '.gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n';
- css += '.gis-menu-item-icon-drill { \n background: url("' + contextPath + '/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';
- css += '.gis-menu-item-icon-float { background: url("' + contextPath + '/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';
- css += '.x-color-picker a { padding: 0; } \n';
- css += '.x-color-picker em span { width: 14px; height: 14px; } \n';
-
- Ext.util.CSS.createStyleSheet(css);
- };
-
- afterRender = function(vp) {
- var len = Ext.query('.zoomInButton').length;
-
- for (var i = 0; i < len; i++) {
- Ext.query('.zoomInButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomin_24.png" />';
- Ext.query('.zoomOutButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomout_24.png" />';
- Ext.query('.zoomVisibleButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomvisible_24.png" />';
- Ext.query('.measureButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/measure_24.png" />';
- }
- };
-
createViewport = function() {
var viewport,
eastRegion,
@@ -202,47 +261,54 @@
return viewport;
};
+ afterRender = function(vp) {
+ var len = Ext.query('.zoomInButton').length;
+
+ for (var i = 0; i < len; i++) {
+ Ext.query('.zoomInButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomin_24.png" />';
+ Ext.query('.zoomOutButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomout_24.png" />';
+ Ext.query('.zoomVisibleButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/zoomvisible_24.png" />';
+ Ext.query('.measureButton')[i].innerHTML = '<img src="' + gis.init.contextPath + '/dhis-web-mapping/app/images/measure_24.png" />';
+ }
+ };
+
initialize = function() {
if (!validateConfig()) {
return;
}
- Ext.data.JsonP.request({
- url: config.url + '/dhis-web-mapping/initialize.action',
- success: function(r) {
- var init = r;
-
- GIS.i18n = init.i18n;
-
- gis = GIS.core.getInstance(init);
- gis.el = config.el;
-
- applyCss(gis.init.contextPath);
-
- GIS.core.createSelectHandlers(gis, gis.layer.boundary);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic1);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic2);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic3);
- GIS.core.createSelectHandlers(gis, gis.layer.thematic4);
- GIS.core.createSelectHandlers(gis, gis.layer.facility);
-
- gis.map = config;
-
- gis.viewport = createViewport();
-
- gis.olmap.mask = Ext.create('Ext.LoadMask', gis.viewport.centerRegion.getEl(), {
- msg: 'Loading'
- });
-
- GIS.core.MapLoader(gis).load();
- }
+ gis = GIS.core.getInstance(init);
+ gis.el = config.el;
+
+ GIS.core.createSelectHandlers(gis, gis.layer.boundary);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic1);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic2);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic3);
+ GIS.core.createSelectHandlers(gis, gis.layer.thematic4);
+ GIS.core.createSelectHandlers(gis, gis.layer.facility);
+
+ gis.map = config;
+
+ gis.viewport = createViewport();
+
+ gis.olmap.mask = Ext.create('Ext.LoadMask', gis.viewport.centerRegion.getEl(), {
+ msg: 'Loading'
});
+
+ GIS.core.MapLoader(gis).load();
}();
};
- GIS.getMap = GIS.plugin.getMap;
-
- DHIS = Ext.isObject(DHIS) ? DHIS : {};
-
- DHIS.getMap = GIS.plugin.getMap;
+ GIS.plugin.getMap = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
+ configs.push(config);
+
+ if (!isInitialized) {
+ isInitialized = true;
+ getInit(config);
+ }
+ };
});
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js 2013-10-13 13:09:02 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js 2013-10-13 21:03:02 +0000
@@ -57,7 +57,7 @@
};
requests.push({
- url: config.url + '/api/system/info',
+ url: config.url + '/api/system/info.jsonp',
success: function(r) {
init.contextPath = r.contextPath;
fn();
@@ -181,6 +181,10 @@
};
PT.plugin.getTable = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
configs.push(config);
if (!isInitialized) {
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js 2013-10-13 13:09:02 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js 2013-10-13 21:03:02 +0000
@@ -44,7 +44,7 @@
};
requests.push({
- url: config.url + '/api/system/info',
+ url: config.url + '/api/system/info.jsonp',
success: function(r) {
init.contextPath = r.contextPath;
fn();
@@ -166,6 +166,10 @@
};
DV.plugin.getChart = function(config) {
+ if (Ext.isString(config.url) && config.url.split('').pop() === '/') {
+ config.url = config.url.substr(0, config.url.length - 1);
+ }
+
configs.push(config);
if (!isInitialized) {