From 77845c681b58cb570375b11d3d204b19e7b4c271 Mon Sep 17 00:00:00 2001
From: Armand Bahi <armand.bahi@veremes.com>
Date: Tue, 30 Oct 2018 17:31:23 +0100
Subject: [PATCH] Squashed 'src/module_vmap/' changes from 3e46450b..fb263937
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

fb263937 Merge branch 'bug/1-probleme-d-affichage-getfeatureinfo-sur-mobile' into 'master'
fa4aeff7 Redefine css for mobile usage
151aa0d1 Merge branch 'hotfix/cache_liste_sous_objet_metier'
9e8f5beb Merge branch 'hotfix/wms_avec_mp'
a81125aa Merge branch 'feature/impressions_144dpi' into 'master'
a8af3474 Active the resolution parameter
6f2cd262 Merge branch 'next_version' into feature/impressions_144dpi
bec87f0c Merge branch 'master' into 'next_version'
c1211553 Merge branch 'cherry-pick-d395d1d4' into 'next_version'
f11099e6 Problème lors de l'enregistrement de services avec mots de passe
d395d1d4 Problème lors de l'enregistrement de services avec mots de passe
885c6310 Merge branch 'master' into next_version

git-subtree-dir: src/module_vmap
git-subtree-split: fb263937c5d6540c44231d215f803a66510cf664
---
 module/css/mobile.less                    |  11 ++
 module/javascript/app/vmap/tools/print.js | 190 ++++++++++++----------
 module/javascript/vitis/script_module.js  |  27 ++-
 module/template/tools/print.html          |   4 +-
 web_service/ws/PrintMapServices.class.inc |  12 +-
 5 files changed, 144 insertions(+), 100 deletions(-)

diff --git a/module/css/mobile.less b/module/css/mobile.less
index a281bf06..fd900b75 100755
--- a/module/css/mobile.less
+++ b/module/css/mobile.less
@@ -276,3 +276,14 @@ app-map > div {
 #select-bo-select{
     max-width: 23vw;
 }
+
+.basic-tools-dropdown-select-getFeatureInfo-content{
+    display: block;
+    top: 0px !important;
+    height: 100%;
+    padding: 0px !important;
+    margin: 0px !important;
+    right: 0px !important;
+    width: 100% !important;
+    min-width: auto;
+}
diff --git a/module/javascript/app/vmap/tools/print.js b/module/javascript/app/vmap/tools/print.js
index 342c526f..8c779787 100644
--- a/module/javascript/app/vmap/tools/print.js
+++ b/module/javascript/app/vmap/tools/print.js
@@ -558,7 +558,6 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function
     today = dd + '/' + mm + '/' + yyyy;
 
     // Valeurs par défaut
-    var resolutionCoeff = goog.isDefAndNotNull(opt_options.resolutionCoeff) ? opt_options.resolutionCoeff : 1;
     var templateId = opt_options.templateId;
     var printStyleId = opt_options.printStyleId;
 
@@ -573,51 +572,6 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function
     oPrintScope['date'] = goog.isDefAndNotNull(oPrintScope['date']) ? oPrintScope['date'] : today;
     var sScope = JSON.stringify(oPrintScope);
 
-    // Set mapId/mapJson
-    var sMapId;
-    var sMapJSON;
-    if (goog.isDefAndNotNull(opt_options.mapId)) {
-        sMapId = opt_options.mapId;
-    } else {
-        sMapJSON = oVmap.getMapManager().getJSONLayersTree();
-    }
-
-    // set EWKTFeatures
-    var aFeatures = goog.isDefAndNotNull(opt_options.features) ? opt_options.features : [];
-    var sEWKTFeatures = '';
-    for (var i = 0; i < aFeatures.length; i++) {
-        if (i > 0)
-            sEWKTFeatures += '|';
-        sEWKTFeatures += oVmap.getEWKTFromGeom(aFeatures[i].getGeometry());
-    }
-
-    // set extent
-    var aExtent = goog.isDefAndNotNull(opt_options.extent) ? opt_options.extent : [];
-    var sExtent = '';
-    var aOverviewExtent = [
-        aExtent[0] - (aExtent[2] - aExtent[0]),
-        aExtent[1] - (aExtent[3] - aExtent[1]),
-        aExtent[2] + (aExtent[2] - aExtent[0]),
-        aExtent[3] + (aExtent[3] - aExtent[1])
-    ];
-    var sOverviewExtent = '';
-    for (var i = 0; i < aExtent.length; i++) {
-        if (i > 0) {
-            sExtent += '|';
-            sOverviewExtent += '|';
-        }
-        sExtent += aExtent[i];
-        sOverviewExtent += aOverviewExtent[i];
-    }
-
-    // Features zoom
-    var sFeaturesZoom = 100;
-    if (goog.isDefAndNotNull(opt_options.featuresZoom)) {
-        sFeaturesZoom = opt_options.featuresZoom;
-    } else if (goog.isDefAndNotNull(oVmap['properties']['print']['features_zoom'])) {
-        sFeaturesZoom = oVmap['properties']['print']['features_zoom'];
-    }
-
     // Ouvre la fenêtre d'impression
     var printWindow = window.open("", '_blank', 'height=400,width=600');
 
@@ -664,46 +618,17 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function
             template.innerHTML = response['data']['data'][0]['definition'];
 
             var mapImageSize = this_.getTemplateTargetSize(template, '#map_image');
-            var overviezSize = this_.getTemplateTargetSize(template, '#map_overview');
-
-            if (goog.isDefAndNotNull(mapImageSize)) {
-                var oMapDef = {
-                    'map_id': sMapId,
-                    'map_json': sMapJSON,
-                    'image_size': (mapImageSize[0] * resolutionCoeff) + '|' + (mapImageSize[1] * resolutionCoeff),
-                    'resolution_coeff': resolutionCoeff,
-                    'extent': sExtent,
-                    'features': sEWKTFeatures,
-                    'features_zoom': sFeaturesZoom
-                };
-            }
-
-            if (goog.isDefAndNotNull(overviezSize)) {
-                var oOverviewDef = {
-                    'map_id': sMapId,
-                    'map_json': sMapJSON,
-                    'image_size': (overviezSize[0] * resolutionCoeff) + '|' + (overviezSize[1] * resolutionCoeff),
-                    'resolution_coeff': resolutionCoeff,
-                    'extent': sOverviewExtent,
-                    'features': sEWKTFeatures,
-                    'features_zoom': 400
-                };
-            }
-
-            var oMapsJson = [];
-            if (goog.isDefAndNotNull(oMapDef)) {
-                oMapsJson.push({
-                    'target': '#map_image',
-                    'map_definition': oMapDef
-                });
-            }
-            if (goog.isDefAndNotNull(oOverviewDef)) {
-                oMapsJson.push({
-                    'target': '#map_overview',
-                    'map_definition': oOverviewDef
-                });
-            }
-            var mapsJson = JSON.stringify(oMapsJson);
+            var overviewSize = this_.getTemplateTargetSize(template, '#map_overview');
+
+            var mapsJson = this_.getMapsJsonDef({
+                mapId: opt_options.mapId,
+                resolutionCoeff: opt_options.resolutionCoeff,
+                extent: opt_options.extent,
+                features: opt_options.features,
+                featuresZoom: opt_options.featuresZoom,
+                mapImageSize: mapImageSize,
+                overviewSize: overviewSize
+            })
 
             // Récupère les infos de l'utilisateur
             this_.getUserInfos_().then(function (oUserInfos) {
@@ -773,6 +698,99 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function
     return 1;
 };
 
+nsVmap.nsToolsManager.Print.prototype.printController.prototype.getMapsJsonDef = function (opt_options) {
+    oVmap.log('nsVmap.nsToolsManager.Print.prototype.printController.prototype.getMapsJsonDef');
+
+    // Resolution
+    var resolutionCoeff = goog.isDefAndNotNull(opt_options.resolutionCoeff) ? opt_options.resolutionCoeff : 1;
+
+    // mapId/mapJson
+    var sMapId;
+    var sMapJSON;
+    if (goog.isDefAndNotNull(opt_options.mapId)) {
+        sMapId = opt_options.mapId;
+    } else {
+        sMapJSON = oVmap.getMapManager().getJSONLayersTree();
+    }
+
+    // Extent
+    var aExtent = goog.isDefAndNotNull(opt_options.extent) ? opt_options.extent : [];
+    var sExtent = '';
+    var aOverviewExtent = [
+        aExtent[0] - (aExtent[2] - aExtent[0]),
+        aExtent[1] - (aExtent[3] - aExtent[1]),
+        aExtent[2] + (aExtent[2] - aExtent[0]),
+        aExtent[3] + (aExtent[3] - aExtent[1])
+    ];
+    var sOverviewExtent = '';
+    for (var i = 0; i < aExtent.length; i++) {
+        if (i > 0) {
+            sExtent += '|';
+            sOverviewExtent += '|';
+        }
+        sExtent += aExtent[i];
+        sOverviewExtent += aOverviewExtent[i];
+    }
+
+    // Features
+    var aFeatures = goog.isDefAndNotNull(opt_options.features) ? opt_options.features : [];
+    var sEWKTFeatures = '';
+    for (var i = 0; i < aFeatures.length; i++) {
+        if (i > 0)
+            sEWKTFeatures += '|';
+        sEWKTFeatures += oVmap.getEWKTFromGeom(aFeatures[i].getGeometry());
+    }
+
+    var sFeaturesZoom = 100;
+    if (goog.isDefAndNotNull(opt_options.featuresZoom)) {
+        sFeaturesZoom = opt_options.featuresZoom;
+    } else if (goog.isDefAndNotNull(oVmap['properties']['print']['features_zoom'])) {
+        sFeaturesZoom = oVmap['properties']['print']['features_zoom'];
+    }
+
+    if (goog.isDefAndNotNull(opt_options.mapImageSize)) {
+        var oMapDef = {
+            'map_id': sMapId,
+            'map_json': sMapJSON,
+            'image_size': (opt_options.mapImageSize[0] * resolutionCoeff) + '|' + (opt_options.mapImageSize[1] * resolutionCoeff),
+            'resolution_coeff': resolutionCoeff,
+            'extent': sExtent,
+            'features': sEWKTFeatures,
+            'features_zoom': sFeaturesZoom
+        };
+    }
+
+    if (goog.isDefAndNotNull(opt_options.overviewSize)) {
+        var oOverviewDef = {
+            'map_id': sMapId,
+            'map_json': sMapJSON,
+            'image_size': (opt_options.overviewSize[0] * resolutionCoeff) + '|' + (opt_options.overviewSize[1] * resolutionCoeff),
+            'resolution_coeff': resolutionCoeff,
+            'extent': sOverviewExtent,
+            'features': sEWKTFeatures,
+            'features_zoom': 400
+        };
+    }
+
+    var oMapsJson = [];
+    if (goog.isDefAndNotNull(oMapDef)) {
+        oMapsJson.push({
+            'target': '#map_image',
+            'map_definition': oMapDef
+        });
+    }
+    if (goog.isDefAndNotNull(oOverviewDef)) {
+        oMapsJson.push({
+            'target': '#map_overview',
+            'map_definition': oOverviewDef
+        });
+    }
+
+    var mapsJson = JSON.stringify(oMapsJson);
+
+    return mapsJson;
+}
+
 /**
  * Get the size of a target in a template
  * @param {string} template
diff --git a/module/javascript/vitis/script_module.js b/module/javascript/vitis/script_module.js
index f14e1f32..00d7bea3 100644
--- a/module/javascript/vitis/script_module.js
+++ b/module/javascript/vitis/script_module.js
@@ -915,7 +915,9 @@ vitisApp.on('appMainDrtvLoaded', function () {
         }
 
         this['getCapabilities'](serviceUrl, {
-            'version': serviceVersion
+            'version': serviceVersion,
+            'service_login': envSrvc["oFormValues"][envSrvc['sFormDefinitionName']]['service_login'],
+            'service_password': envSrvc["oFormValues"][envSrvc['sFormDefinitionName']]['service_password']
         }).then(function (oResult) {
             if (goog.isDefAndNotNull(oResult)) {
                 if (goog.isDefAndNotNull(oResult['json'])) {
@@ -1098,6 +1100,12 @@ vitisApp.on('appMainDrtvLoaded', function () {
                 if (goog.isDefAndNotNull(scope['oServices'][sServiceId]['service_type_version'])) {
                     envSrvc["oFormValues"][envSrvc['sFormDefinitionName']]["service_type_version"] = scope['oServices'][sServiceId]['service_type_version'];
                 }
+                if (goog.isDefAndNotNull(scope['oServices'][sServiceId]['service_login'])) {
+                    envSrvc["oFormValues"][envSrvc['sFormDefinitionName']]["service_login"] = scope['oServices'][sServiceId]['service_login'];
+                }
+                if (goog.isDefAndNotNull(scope['oServices'][sServiceId]['service_password'])) {
+                    envSrvc["oFormValues"][envSrvc['sFormDefinitionName']]["service_password"] = scope['oServices'][sServiceId]['service_password'];
+                }
             }
         } else {
             sServiceType = envSrvc['oFormValues'][envSrvc['sFormDefinitionName']]['service_type_id'];
@@ -2497,11 +2505,15 @@ vitisApp.on('appMainDrtvLoaded', function () {
 
         $translate(["BTN_ADD_LAYERS_VMAP_MAP_LAYER"]).then(function (oTranslations) {
             var sServiceUrl = envSrvc["oFormValues"][sParentFormDefinitionName]["service_url"];
+            var sServiceLogin = envSrvc["oFormValues"][sParentFormDefinitionName]["service_login"];
+            var sServicePassword = envSrvc["oFormValues"][sParentFormDefinitionName]["service_password"];
             var sVersion = envSrvc["oFormValues"][sParentFormDefinitionName]["service_type_version"];
             sServiceUrl = sServiceUrl.replace("[token]", sha256(sessionSrvc["token"]));
             sServiceUrl = sServiceUrl.replace("[ms_cgi_url]", propertiesSrvc["ms_cgi_url"]);
             this_['showLayerModalWindow']({
                 'service_url': sServiceUrl,
+                'service_login': sServiceLogin,
+                'service_password': sServicePassword,
                 'service_version': sVersion,
                 'buttons': [{
                         "label": oTranslations["BTN_ADD_LAYERS_VMAP_MAP_LAYER"],
@@ -2874,7 +2886,9 @@ vitisApp.on('appMainDrtvLoaded', function () {
         } else if (goog.isDefAndNotNull(sServiceUrl)) {
             // Calques du service wms.
             scope.$root['getCapabilities'](sServiceUrl, {
-                'version': opt_options['service_version']
+                'version': opt_options['service_version'],
+                'service_login': opt_options['service_login'],
+                'service_password': opt_options['service_password']
             }).then(function (oGetCapabilities) {
                 oCapabilities = oGetCapabilities;
                 if (goog.isDefAndNotNull(oCapabilities)) {
@@ -2906,6 +2920,9 @@ vitisApp.on('appMainDrtvLoaded', function () {
             "showErrorMessage": true,
             "version": "1.3.0"
         };
+        var oHeaders = {
+            "charset": "charset=utf-8"
+        };
         if (typeof (oOptions) == "undefined")
             oOptions = oDefaultOptions;
         else {
@@ -2918,6 +2935,11 @@ vitisApp.on('appMainDrtvLoaded', function () {
         if (!goog.isDefAndNotNull(oOptions['showErrorMessage'])) {
             oOptions['showErrorMessage'] = true;
         }
+        if (goog.isDefAndNotNull(oOptions['service_login']) && goog.isDefAndNotNull(oOptions['service_password'])) {
+            if (oOptions['service_login'].length > 0 && oOptions['service_password'].length > 0) {
+                oHeaders['Authorization'] = "Basic " + btoa(oOptions['service_login'] + ":" + oOptions['service_password']);
+            }
+        }
         // Création de l'url vers le service.
         if (sServiceUrl.indexOf("?") === -1)
             sServiceUrl += "?";
@@ -2941,6 +2963,7 @@ vitisApp.on('appMainDrtvLoaded', function () {
                 "method": "GET",
                 "url": propertiesSrvc['proxy_url'],
                 "params": {"url": sServiceUrl},
+                'headers': oHeaders,
                 "scope": scope,
                 "responseType": "text",
                 "success": function (response) {
diff --git a/module/template/tools/print.html b/module/template/tools/print.html
index 92421e58..0a1fd62b 100644
--- a/module/template/tools/print.html
+++ b/module/template/tools/print.html
@@ -45,8 +45,8 @@
             <option value="100">1:100</option>
         </select>
 
-        <div class="hidden print-form-label">Résolution</div>
-        <select id="select-print-resolution" class="hidden form-control minus" ng-model="ctrl.dpi">
+        <div class="print-form-label">Résolution</div>
+        <select id="select-print-resolution" class="form-control minus" ng-model="ctrl.dpi">
             <option value="1">72 dpi</option>
             <option value="2" ng-show="ctrl.resolution <= 4">144 dpi</option>
             <option value="4" ng-show="ctrl.resolution <= 2">288 dpi</option>
diff --git a/web_service/ws/PrintMapServices.class.inc b/web_service/ws/PrintMapServices.class.inc
index 34623aa9..8c656d82 100755
--- a/web_service/ws/PrintMapServices.class.inc
+++ b/web_service/ws/PrintMapServices.class.inc
@@ -15,7 +15,7 @@ require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vmlib/BdDataAccess.i
  *  \brief This file contains the PrintMapServices php class
  *
  * This class defines the rest api for printmapservices
- * 
+ *
  */
 class PrintMapServices extends PrintServices {
     /**
@@ -241,14 +241,6 @@ class PrintMapServices extends PrintServices {
             }
         }
 
-        // Change la taille de l'image en fonction de la résolution
-        if (isset($this->aValues['resolution_coeff'])) {
-            $aImageSize = explode('|', $sImageSize);
-            $aImageSize[0] = $aImageSize[0] * $this->aValues['resolution_coeff'];
-            $aImageSize[1] = $aImageSize[1] * $this->aValues['resolution_coeff'];
-            $sImageSize = implode('|', $aImageSize);
-        }
-
         // Écrit les paramètres gros dans des fichiers
         if (is_dir($this->aProperties['vas_home'])) {
             if (!is_dir($this->aProperties['vas_home'] . '/public')) {
@@ -343,4 +335,4 @@ class PrintMapServices extends PrintServices {
 
 }
 
-?>
\ No newline at end of file
+?>
-- 
GitLab