[pkg-nagios-changes] [Git][nagios-team/pkg-nagvis][upstream] New upstream version 1.9.22

Bas Couwenberg gitlab at salsa.debian.org
Wed Sep 23 05:28:23 BST 2020



Bas Couwenberg pushed to branch upstream at Debian Nagios Maintainer Group / pkg-nagvis


Commits:
72e9f10f by Bas Couwenberg at 2020-09-23T06:20:25+02:00
New upstream version 1.9.22
- - - - -


11 changed files:

- ChangeLog
- docs/en_US/worldmap.html
- share/frontend/nagvis-js/js/ElementBox.js
- share/frontend/nagvis-js/js/ViewWorldmap.js
- share/frontend/nagvis-js/js/edit.js
- share/frontend/nagvis-js/js/nagvis.js
- share/server/core/classes/CorePDOHandler.php
- share/server/core/defines/global.php
- share/server/core/defines/matches.php
- share/server/core/mapcfg/default.php
- share/server/core/sources/worldmap.php


Changes:

=====================================
ChangeLog
=====================================
@@ -1,3 +1,16 @@
+1.9.22
+Core:
+  * FIX: Fix error handling of DB backends when DB opening failed
+    (Undefined property: CorePDOHandler::$dsn) (#267)
+
+Frontend:
+  * Colors with alpha channel are now allowed (format: #RRGGBBAA) (#270)
+  * FIX: Improve validation of file names in several places to prevent input of
+    not printable characters.
+
+Worldmap:
+  * Improve recently introduced textbox scaling according to zoom (pull #263)
+
 1.9.21
 Frontend:
   * FIX: Additional fix for weathermap lines byte/bit handling for Checkmk
@@ -7,7 +20,7 @@ Frontend:
   * FIX: Remove "\r", "\t" and 0x00 - 0x1F from multiline text boxes (issue #258)
 
 Worldmap:
-  * textbox scaling according to zoom (scale_to_max_zoom option) (issue #255)
+  * textbox scaling according to zoom (scale_to_zoom option) (pull #255)
 
 1.9.20
 Core:


=====================================
docs/en_US/worldmap.html
=====================================
@@ -91,8 +91,21 @@
             <tr>
                 <td>max_zoom</td><td>20</td><td>Only show the object at specified zoom levels or lower (wider view)</td>
             </tr>
+        </table>
+
+        <h2>Scalable textboxes on worldmap</h2>
+        Static textboxes can scale according to the view zoom level. In other words, a box shrinks as you zoom out, or grows as you zoom in.
+        <table style="width:100%">
+            <tr>
+                <th>Parameter</th><th>Default</th><th>Description</th>
+            </tr>
+            <tr>
+                <td>scale_to_zoom</td><td>No</td><td>Scale the textbox size down to 50% for every zoom level below <code>normal_size_at_zoom</code>,
+                    or 50% up for every zoom level above.
+                </td>
+            </tr>
             <tr>
-                <td>scale_to_max_zoom</td><td>No</td><td>Scale the object size down to 50% for every zoom level below <code>max_zoom</code>. Only applicable to textboxes.</td>
+                <td>normal_size_at_zoom</td><td>19</td><td>At this zoom level, the <code>scale_to_zoom=yes</code> textboxes are displayed at original 1:1 (100%) size.</td>
             </tr>
         </table>
     </body>


=====================================
share/frontend/nagvis-js/js/ElementBox.js
=====================================
@@ -24,11 +24,14 @@
 var ElementBox = Element.extend({
     render: function() {
         let scale = 1;
-        if (g_map && usesSource('worldmap') && this.obj.conf.scale_to_max_zoom == '1') {
+        if (g_map && usesSource('worldmap') && this.obj.conf.scale_to_zoom == '1') {
             let currentZoom = g_map.getZoom();
-            let maxZoom = Number(this.obj.conf.max_zoom)
-            if (currentZoom < maxZoom) {
-                scale = 1 / Math.pow(2, maxZoom-currentZoom)
+            let one2oneZoom = Number(this.obj.conf.normal_size_at_zoom) || 19
+            if (currentZoom < one2oneZoom) {
+                scale = 1 / Math.pow(2, one2oneZoom-currentZoom)
+            }
+            if (currentZoom > one2oneZoom) {
+                scale = Math.pow(2, currentZoom-one2oneZoom)
             }
         }
 


=====================================
share/frontend/nagvis-js/js/ViewWorldmap.js
=====================================
@@ -263,10 +263,9 @@ L.NagVisMarker = L.Marker.extend({
     // Update the size off the icon to make the object being centered
     _onAdd: function(lEvent) {
         var icon = this.options.icon,
-            obj = icon.options.obj,
             trigger_obj = icon.options.obj.trigger_obj,
-            w = trigger_obj.clientWidth,
-            h = trigger_obj.clientHeight;
+            w = pxToInt(trigger_obj.style.width),
+            h = pxToInt(trigger_obj.style.height);
 
         icon.options.iconSize = [w, h];
         icon._applyOffset();


=====================================
share/frontend/nagvis-js/js/edit.js
=====================================
@@ -125,8 +125,8 @@ function resizeMouseDown(event) {
 
     g_resize_obj.grabx  = event.clientX;
     g_resize_obj.graby  = event.clientY;
-    g_resize_obj.width  = target.offsetWidth;
-    g_resize_obj.height = target.offsetHeight;
+    g_resize_obj.width  = pxToInt(target.style.width);
+    g_resize_obj.height = pxToInt(target.style.height);
     g_resize_obj.left   = pxToInt(target.style.left);
     g_resize_obj.top    = pxToInt(target.style.top);
 
@@ -150,26 +150,19 @@ function resizeMouseUp(event) {
     var objW = rmZoomFactor(parseInt(dom_obj.style.width));
     var objH = rmZoomFactor(parseInt(dom_obj.style.height));
 
-    // Reposition in frontend
-    var obj = getMapObjByDomObjId(objId);
-    obj.conf.x = objX;
-    obj.conf.y = objY;
-    obj.conf.w = objW;
-    obj.conf.h = objH;
-    obj.place();
-
-    if (!isInt(objX) || !isInt(objY) || !isInt(objW) || !isInt(objH)) {
-        alert('ERROR: Invalid coords ('+objX+'/'+objY+'/'+objW+'/'+objH+'). Terminating.');
-        return false;
+    // (worldmap) X and Y are center coordinates, not the top/left corner
+    var objMarginTop = rmZoomFactor(pxToInt(dom_obj.style.marginTop), true);
+    var objMarginLeft = rmZoomFactor(pxToInt(dom_obj.style.marginLeft), true);
+    if (objMarginLeft && objMarginTop) {
+      objX = Math.round(objX + objMarginLeft + objW/2);
+      objY = Math.round(objY + objMarginTop + objH/2);
     }
 
     var parts = g_view.unproject(objX, objY);
-    objX = parts[0];
-    objY = parts[1];
 
     saveObjectAttr(objId, {
-        'x': objX,
-        'y': objY,
+        'x': parts[0],
+        'y': parts[1],
         'w': objW,
         'h': objH
     });
@@ -202,24 +195,59 @@ function resizeMouseMove(event) {
     if (g_resize_obj === null)
         return true;
 
-    var xMin = 8, // The smallest width and height possible
-        yMin = 8;
+    var scale = g_resize_obj.el.dataset.theScale ? g_resize_obj.el.dataset.theScale : 1;
+
+    var minWidth = 8 * scale, // The smallest width and height possible
+        minHeight = 8 * scale;
+
+    let grabOffsetX = event.clientX - g_resize_obj.grabx;
+    let grabOffsetY = event.clientY - g_resize_obj.graby;
 
-    if(g_resize_obj.dir.indexOf("e") != -1)
-        g_resize_obj.el.style.width = Math.max(xMin, g_resize_obj.width + event.clientX - g_resize_obj.grabx) + "px";
+    if(g_resize_obj.dir.indexOf("e") != -1) {
+        grabOffsetX = Math.max(grabOffsetX, -g_resize_obj.width*scale + minWidth);
 
+        let newWidth = g_resize_obj.width + grabOffsetX/scale;
+        let newLeft = g_resize_obj.left + grabOffsetX/2;
+        let newMarginLeft = -newWidth/2;
+
+        g_resize_obj.el.style.width = newWidth + "px";
+        g_resize_obj.el.style.left = newLeft + "px";
+        g_resize_obj.el.style.marginLeft = newMarginLeft + "px";
+    }
     if(g_resize_obj.dir.indexOf("s") != -1) {
-        g_resize_obj.el.style.height = Math.max(yMin, g_resize_obj.height + event.clientY - g_resize_obj.graby) + "px";
+        grabOffsetY = Math.max(grabOffsetY, -g_resize_obj.height*scale + minHeight);
+
+        let newHeight = g_resize_obj.height + grabOffsetY/scale;
+        let newTop = g_resize_obj.top + grabOffsetY/2;
+        let newMarginTop = -newHeight/2;
+
+        g_resize_obj.el.style.height = newHeight + "px";
+        g_resize_obj.el.style.top = newTop + "px";
+        g_resize_obj.el.style.marginTop = newMarginTop + "px";
     }
 
     if(g_resize_obj.dir.indexOf("w") != -1) {
-        g_resize_obj.el.style.left = Math.min(g_resize_obj.left + event.clientX - g_resize_obj.grabx, g_resize_obj.left + g_resize_obj.width - xMin) + "px";
-        g_resize_obj.el.style.width = Math.max(xMin, g_resize_obj.width - event.clientX + g_resize_obj.grabx) + "px";
+        grabOffsetX = Math.min(grabOffsetX, g_resize_obj.width*scale - minWidth);
+
+        let newWidth = g_resize_obj.width - grabOffsetX/scale;
+        let newLeft = g_resize_obj.left + grabOffsetX/2;
+        let newMarginLeft = -newWidth/2;
+
+        g_resize_obj.el.style.width = newWidth + "px";
+        g_resize_obj.el.style.left = newLeft + "px";
+        g_resize_obj.el.style.marginLeft = newMarginLeft + "px";
     }
     if(g_resize_obj.dir.indexOf("n") != -1) {
-        g_resize_obj.el.style.top = Math.min(g_resize_obj.top + event.clientY - g_resize_obj.graby, g_resize_obj.top + g_resize_obj.height - yMin) + "px";
-        g_resize_obj.el.style.height = Math.max(yMin, g_resize_obj.height - event.clientY + g_resize_obj.graby) + "px";
-    }
+        grabOffsetY = Math.min(grabOffsetY, g_resize_obj.height*scale - minHeight);
+
+        let newHeight = g_resize_obj.height - grabOffsetY/scale;
+        let newTop = g_resize_obj.top + grabOffsetY/2;
+        let newMarginTop = -newHeight/2;
+
+        g_resize_obj.el.style.height = newHeight + "px";
+        g_resize_obj.el.style.top = newTop + "px";
+        g_resize_obj.el.style.marginTop = newMarginTop + "px";
+  }
 
     return preventDefaultEvents(event);
 }
@@ -683,7 +711,7 @@ function addClick(e) {
                + '&x=' + addX.join(',')
                + '&y=' + addY.join(',');
 
-    if(addObjType != 'textbox' && addObjType != 'container' 
+    if(addObjType != 'textbox' && addObjType != 'container'
        && addObjType != 'shape' && addViewType != 'icon' && addViewType != '')
         sUrl += '&view_type=' + addViewType;
 


=====================================
share/frontend/nagvis-js/js/nagvis.js
=====================================
@@ -969,8 +969,10 @@ function renderNagVisTextbox(id, bgColor, borderColor, x, y, z, w, h, text, cust
 
     oLabelDiv.style.zIndex = parseInt(z) + 1;
 
-    if (scale)
+    if (scale) {
         oLabelDiv.style.transform = `scale(${scale})`;
+        oLabelDiv.dataset.theScale = scale;
+    }
 
     /**
      * IE workaround: The transparent for the color is not enough. The border


=====================================
share/server/core/classes/CorePDOHandler.php
=====================================
@@ -42,6 +42,7 @@ function _build_dsn_common($params) {
 class CorePDOHandler {
     private $DB = null;
     private $file = null;
+    private $dsn = null;
 
     // needs to be initialized after class declaration because directly
     // initializing it here is a syntax error in PHP 5.3


=====================================
share/server/core/defines/global.php
=====================================
@@ -23,7 +23,7 @@
  *****************************************************************************/
  
 // NagVis Version
-define('CONST_VERSION', '1.9.21');
+define('CONST_VERSION', '1.9.22');
 
 // Set PHP error handling to standard level
 // Different levels for php versions below 5.1 because PHP 5.1 reports


=====================================
share/server/core/defines/matches.php
=====================================
@@ -54,18 +54,18 @@ define('MATCH_BOOLEAN', '/^(?:1|0)$/i');
 define('MATCH_BOOLEAN_EMPTY', '/^(?:1|0)*$/i');
 define('MATCH_LATLONG', '/^-?[0-9]+(.[0-9]+),-?[0-9]+(.[0-9]+)?$/');
 
-define('MATCH_COLOR', '/^(#?[0-9a-f]{3,6}|transparent)$/i');
+define('MATCH_COLOR', '/^(#?[0-9a-f]{3,8}|transparent)$/i');
 define('MATCH_OBJECTTYPE', '/^(?:global|host|service|dyngroup|aggr|hostgroup|servicegroup|map|textbox|shape|line|template|container)$/i');
 define('MATCH_OBJECTID', '/^(?:[a-z0-9]+)$/i');
 define('MATCH_OBJECTID_EMPTY', '/^(?:[a-z0-9]*)$/i');
-define('MATCH_PNGFILE', '/^([^\s]+)\.png$/i');
-define('MATCH_PNG_GIF_JPG_FILE', '/^([^\s]+)\.(png|gif|jpg)$/i');
-define('MATCH_PNG_GIF_JPG_FILE_OR_URL_NONE', '/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s:+[\]()=%?&_.\-#@=\/\\\]+\]|none)$/i');
-define('MATCH_PNG_GIF_JPG_FILE_OR_URL', '/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s:+[\]()=%?&_.\-#@=\/\\\]+\])$/i');
+define('MATCH_PNGFILE', '/^([^\s]+)\.png$/iu');
+define('MATCH_PNG_GIF_JPG_FILE', '/^([^\s]+)\.(png|gif|jpg)$/iu');
+define('MATCH_PNG_GIF_JPG_FILE_OR_URL_NONE', '/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s:+[\]()=%?&_.\-#@=\/\\\]+\]|none)$/iu');
+define('MATCH_PNG_GIF_JPG_FILE_OR_URL', '/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s:+[\]()=%?&_.\-#@=\/\\\]+\])$/iu');
 define('MATCH_ROTATION_STEP_TYPES_EMPTY', '/^(?:map|url)?$/');
 define('MATCH_LANGUAGE_EMPTY', '/^[a-zA-Z0-9\-_]*$/');
 define('MATCH_LANGUAGE_FILE', '/^([^.].*)/');
-define('MATCH_ICONSET', '/^(.+)_ok.(png|gif|jpg)$/');
+define('MATCH_ICONSET', '/^(.+)_ok.(png|gif|jpg)$/u');
 define('MATCH_BACKEND_FILE', '/^GlobalBackend([^MI].+)\.php$/');
 define('MATCH_BACKEND_ID', '/^[0-9a-z._-]*$/iu');
 define('MATCH_DOC_DIR', '/^([a-z]{2}_[A-Z]{2})/');
@@ -98,14 +98,14 @@ define('MATCH_ZOOM_FACTOR', '/^(?:[0-9]+|fill)$/');
 
 define('MATCH_URI_PART', '/^[a-zA-Z0-9_-]*$/');
 
-define('MATCH_CFG_FILE', '/^(.+)\.cfg$/');
-define('MATCH_CSV_FILE', '/^(.+)\.csv$/i');
-define('MATCH_MP3_FILE', '/^(.+)\.mp3$/i');
-define('MATCH_HEADER_TEMPLATE_FILE', '/^(.+)\.header\.html$/i');
-define('MATCH_HOVER_TEMPLATE_FILE', '/^(.+)\.hover\.html$/i');
-define('MATCH_CONTEXT_TEMPLATE_FILE', '/^(.+)\.context\.html$/i');
-define('MATCH_PHP_FILE', '/^(.+\.php)$/i');
-define('MATCH_SOURCE_FILE', '/^(.+)\.php$/i');
+define('MATCH_CFG_FILE', '/^(.+)\.cfg$/u');
+define('MATCH_CSV_FILE', '/^(.+)\.csv$/iu');
+define('MATCH_MP3_FILE', '/^(.+)\.mp3$/iu');
+define('MATCH_HEADER_TEMPLATE_FILE', '/^(.+)\.header\.html$/iu');
+define('MATCH_HOVER_TEMPLATE_FILE', '/^(.+)\.hover\.html$/iu');
+define('MATCH_CONTEXT_TEMPLATE_FILE', '/^(.+)\.context\.html$/iu');
+define('MATCH_PHP_FILE', '/^(.+\.php)$/iu');
+define('MATCH_SOURCE_FILE', '/^(.+)\.php$/iu');
 define('MATCH_INTEGER_PRESIGN', '/^[+-]?[0-9]+$/');
 define('MATCH_INTEGER_PRESIGN_EMPTY', '/^[+-]?[0-9]*$/');
 define('MATCH_LABEL_X', '/^([+-]?[0-9]+|center)$/');


=====================================
share/server/core/mapcfg/default.php
=====================================
@@ -861,12 +861,6 @@ $mapConfigVars = Array(
         'field_type' => 'color',
         'match'      => MATCH_COLOR,
     ),
-    'scale_to_max_zoom' => Array(
-        'must'       => 0,
-        'default'    => 0,
-        'match'      => MATCH_BOOLEAN,
-        'field_type' => 'boolean',
-    ),
     'style' => Array(
         'must' => 0,
         'default' => '',
@@ -1433,9 +1427,7 @@ $mapConfigVarMap['textbox'] = Array(
         'type' => null,
         'use' => null,
     ),
-    'worldmap' => array(
-        'scale_to_max_zoom' => null,
-    )
+    // See also: core/sources/worldmap.php (textbox-specific options)
 );
 
 $mapConfigVarMap['shape'] = Array(


=====================================
share/server/core/sources/worldmap.php
=====================================
@@ -49,6 +49,19 @@ $configVars = array(
         'default'   => 20,
         'match'     => MATCH_WORLDMAP_ZOOM,
     ),
+
+    'scale_to_zoom' => Array(
+        'must'       => 0,
+        'default'    => 0,
+        'match'      => MATCH_BOOLEAN,
+        'field_type' => 'boolean',
+    ),
+    'normal_size_at_zoom' => array(
+        'must'      => false,
+        'default'   => 19,
+        'match'     => MATCH_WORLDMAP_ZOOM,
+    ),
+
 );
 
 // Assign config variables to specific object types
@@ -73,6 +86,12 @@ foreach (getMapObjectTypes() AS $type) {
     );
 }
 
+// Textbox-specific options
+$configVarMap['textbox']['worldmap'] = array_merge($configVarMap['textbox']['worldmap'], array(
+    'scale_to_zoom' => null,
+    'normal_size_at_zoom' => null,
+));
+
 // Global config vars not to show for worldmaps
 $hiddenConfigVars = array(
     'zoom',



View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagvis/-/commit/72e9f10fd7987d979973737742252d9769ed64af

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagvis/-/commit/72e9f10fd7987d979973737742252d9769ed64af
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20200923/5a4ab05b/attachment-0001.html>


More information about the pkg-nagios-changes mailing list