From 9f85ff0ef23aa56eb43d7e54d3fd9e8804ee93d2 Mon Sep 17 00:00:00 2001 From: ibering Date: Wed, 5 Apr 2023 17:24:52 +0200 Subject: [PATCH 1/2] #ITC-769 Change the size of background images while editing --- .../MapModule/src/Model/Table/MapsTable.php | 16 +++++++++++-- .../MapModule/templates/Mapeditors/edit.php | 8 +++++-- plugins/MapModule/webroot/css/MapModule.css | 10 ++++++++ .../controllers/MapeditorsEditController.js | 24 ++++++++++++++++++- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/plugins/MapModule/src/Model/Table/MapsTable.php b/plugins/MapModule/src/Model/Table/MapsTable.php index 6b0e601596..37f56f6742 100644 --- a/plugins/MapModule/src/Model/Table/MapsTable.php +++ b/plugins/MapModule/src/Model/Table/MapsTable.php @@ -2299,6 +2299,12 @@ public function getDefaultMapeditorSettings() { 'helplines' => [ 'enabled' => true, 'size' => 15 + ], + 'background' => [ + 'position_x' => null, + 'position_y' => null, + 'width' => null, + 'height' => null ] ] ]; @@ -2309,9 +2315,15 @@ public function getDefaultMapeditorSettings() { * @return array|mixed */ public function getMapeditorSettings($config) { + $defaults = $this->getDefaultMapeditorSettings(); if (empty($config)) { - return $this->getDefaultMapeditorSettings(); + return $defaults; } - return json_decode($config, true); + $config = json_decode($config, true); + + return Hash::merge( + $defaults, + $config + ); } } diff --git a/plugins/MapModule/templates/Mapeditors/edit.php b/plugins/MapModule/templates/Mapeditors/edit.php index ec0740449d..d94b71af94 100644 --- a/plugins/MapModule/templates/Mapeditors/edit.php +++ b/plugins/MapModule/templates/Mapeditors/edit.php @@ -136,8 +136,12 @@ class="btn btn-default btn-xs mr-1 shadow-0"> id="mainMapContainer">
- +
+ +
+
diff --git a/plugins/MapModule/webroot/css/MapModule.css b/plugins/MapModule/webroot/css/MapModule.css index e4ae645d02..65f9b6525e 100644 --- a/plugins/MapModule/webroot/css/MapModule.css +++ b/plugins/MapModule/webroot/css/MapModule.css @@ -235,3 +235,13 @@ .invalid-image-src { color:#CC0000; } +.resizable-background { + display: inline-block; + overflow: hidden; + line-height: 0; +} + +.resizable-background img { + width: 100%; + height: 100%; +} diff --git a/plugins/MapModule/webroot/js/scripts/controllers/MapeditorsEditController.js b/plugins/MapModule/webroot/js/scripts/controllers/MapeditorsEditController.js index b186008c1f..610fae1963 100644 --- a/plugins/MapModule/webroot/js/scripts/controllers/MapeditorsEditController.js +++ b/plugins/MapModule/webroot/js/scripts/controllers/MapeditorsEditController.js @@ -24,7 +24,13 @@ angular.module('openITCOCKPIT') enabled: true, size: 15 }, - synchronizeGridAndHelplinesSize: true + synchronizeGridAndHelplinesSize: true, + background: { + position_x: null, + position_y: null, + width: null, + height: null + } }; @@ -1561,6 +1567,11 @@ angular.module('openITCOCKPIT') $scope.saveSummaryItem('dragstop'); break; + case 'mapBackground': + $scope.Mapeditor.background.position_x = x; + $scope.Mapeditor.background.position_y = y; + break; + default: console.log('Unknown map object type'); genericError(); @@ -1623,6 +1634,11 @@ angular.module('openITCOCKPIT') $scope.saveSummaryItem('resizestop'); break; + case 'mapBackground': + $scope.Mapeditor.background.width = newWidth; + $scope.Mapeditor.background.height = newHeight; + break; + default: console.log('Unknown map object type'); genericError(); @@ -1637,6 +1653,7 @@ angular.module('openITCOCKPIT') var $this = $(this); var id = $this.data('id'); var type = $this.data('type'); + console.log('test resizable-no-aspect-ratio'); var newWidth = parseInt(ui.size.width); var newHeight = parseInt(ui.size.height); @@ -1659,6 +1676,11 @@ angular.module('openITCOCKPIT') $scope.saveGadget('resizestop'); break; + case 'mapBackground': + $scope.Mapeditor.background.width = newWidth; + $scope.Mapeditor.background.height = newHeight; + break; + default: console.log('Unknown map object type'); genericError(); From cadf2e2c6efc1cc1c17b4661aaa02bcd5a1edb6c Mon Sep 17 00:00:00 2001 From: ibering Date: Thu, 6 Apr 2023 16:16:25 +0200 Subject: [PATCH 2/2] #ITC-769 Change the size of background images - consider custom position and sizing options for background image --- .../src/Controller/MapeditorsController.php | 8 ++++++ .../MapModule/src/Model/Table/MapsTable.php | 4 +-- .../MapModule/templates/Mapeditors/edit.php | 26 +++++++++++++++---- .../templates/Mapeditors/view_directive.php | 12 ++++++--- plugins/MapModule/webroot/css/MapModule.css | 5 ++++ .../controllers/MapeditorsEditController.js | 13 ++++++---- 6 files changed, 53 insertions(+), 15 deletions(-) diff --git a/plugins/MapModule/src/Controller/MapeditorsController.php b/plugins/MapModule/src/Controller/MapeditorsController.php index c4f669d334..a9e9194416 100755 --- a/plugins/MapModule/src/Controller/MapeditorsController.php +++ b/plugins/MapModule/src/Controller/MapeditorsController.php @@ -110,6 +110,10 @@ public function view($id = null) { $MapForAngular = new MapForAngular($map); $map = $MapForAngular->toArray(); + $config = $MapsTable->getMapeditorSettings($map['Map']['json_data']); + $map['Mapeditor'] = [ + 'background' => $config['Mapeditor']['background'] + ]; $acl = [ 'hosts' => [ @@ -2007,6 +2011,10 @@ public function mapDetails($id) { $MapForAngular = new MapForAngular($map); $map = $MapForAngular->toArray(); + $config = $MapsTable->getMapeditorSettings($map['Map']['json_data']); + $map['Mapeditor'] = [ + 'background' => $config['Mapeditor']['background'] + ]; $this->set('map', $map); $this->viewBuilder()->setOption('serialize', ['map']); diff --git a/plugins/MapModule/src/Model/Table/MapsTable.php b/plugins/MapModule/src/Model/Table/MapsTable.php index 37f56f6742..aa7915f3c3 100644 --- a/plugins/MapModule/src/Model/Table/MapsTable.php +++ b/plugins/MapModule/src/Model/Table/MapsTable.php @@ -2301,8 +2301,8 @@ public function getDefaultMapeditorSettings() { 'size' => 15 ], 'background' => [ - 'position_x' => null, - 'position_y' => null, + 'position_x' => 0, + 'position_y' => 0, 'width' => null, 'height' => null ] diff --git a/plugins/MapModule/templates/Mapeditors/edit.php b/plugins/MapModule/templates/Mapeditors/edit.php index d94b71af94..90b93c393f 100644 --- a/plugins/MapModule/templates/Mapeditors/edit.php +++ b/plugins/MapModule/templates/Mapeditors/edit.php @@ -47,10 +47,12 @@

- - {{map.Map.name}} + + {{map.Map.name}}

-
+
+
+
+
+ + : + + +
Acl->hasPermission('index', 'maps', 'mapmodule')): ?> + class="btn btn-default btn-xs ml-5 mr-1 shadow-0"> @@ -136,9 +148,13 @@ class="btn btn-default btn-xs mr-1 shadow-0"> id="mainMapContainer">
-
diff --git a/plugins/MapModule/templates/Mapeditors/view_directive.php b/plugins/MapModule/templates/Mapeditors/view_directive.php index f4788325d1..e2cc450329 100644 --- a/plugins/MapModule/templates/Mapeditors/view_directive.php +++ b/plugins/MapModule/templates/Mapeditors/view_directive.php @@ -22,9 +22,15 @@ // License agreement and license key will be shipped with the order // confirmation. ?> -<?= __('{0} Map background image is not available!!!', '⚠'); ?> - +
+ <?= __('{0} Map background image is not available!!!', '⚠'); ?> +