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

Bas Couwenberg gitlab at salsa.debian.org
Wed Jul 29 15:41:10 BST 2020



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


Commits:
c3259c19 by Bas Couwenberg at 2020-07-29T16:32:34+02:00
New upstream version 1.9.21
- - - - -


12 changed files:

- ChangeLog
- docs/en_US/map_config_format_description.html
- docs/en_US/worldmap.html
- share/frontend/nagvis-js/js/ElementBox.js
- share/frontend/nagvis-js/js/ElementLine.js
- share/frontend/nagvis-js/js/NagVisObject.js
- share/frontend/nagvis-js/js/frontendMessage.js
- share/frontend/nagvis-js/js/nagvis.js
- share/server/core/classes/GlobalMapCfg.php
- share/server/core/defines/global.php
- share/server/core/mapcfg/default.php
- share/server/core/sources/worldmap.php


Changes:

=====================================
ChangeLog
=====================================
@@ -1,3 +1,14 @@
+1.9.21
+Frontend:
+  * FIX: Additional fix for weathermap lines byte/bit handling for Checkmk
+         interface checks (issue #256)
+  * FIX: Fix random error "NotFoundError: Node.removeChild"
+  * FIX: Fix relative coordinate handling (issue #250)
+  * 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)
+
 1.9.20
 Core:
   * Drop some PHP < 5.2 compatibility code for json encoding / decoding


=====================================
docs/en_US/map_config_format_description.html
=====================================
@@ -1825,11 +1825,17 @@
     <p>When lines have one part (e.g. <i>---></i>) there must be two coords set.
         When using lines with two (e.g. <i>---><---</i>) parts it is possible to set two coordinates for
     direct lines or three coordinates to reposition the middle of the line to a custom place.</p>
-
+    <h3>Relative coordinates</h3>
         <p>Since NagVis 1.6 it is possible to position objects depending on other objects. A relationship between
         two objects is defined from the "childs" view. This means the configuration needs to be done in
         the object which belongs to another object.<br />
         To define a relationship the coordinate is not given as integer anymore. Instead of the px offset the <i>object_id</i> of the parent object is used to define a relative position.</p>
+        Examples:
+        <ul>
+            <li><code>41790e%+30</code> = coordinate of object 41790e plus 30 pixels</li>
+            <li><code>41790e%-199</code> = coordinate of object 41790e minus 199 pixels</li>
+            <li><code>41790e%+0</code> = coordinate same as of object 41790e</li>
+        </ul>
         <p>We adapt the examples above and give the start of the line a relative position to the host object:</p>
     <pre>define host {
  object_id=41790e
@@ -1844,8 +1850,8 @@ define service {
  service_description=Interface eth0
  view_type=line
  line_type=10
- x=41790e,200
- y=41790e,200
+ x=41790e%+0,200
+ y=41790e%+0,200
 }</pre>
     <p>With the configuration above the beginning of the line is attached to the host object and moved every time
   the host object is moved.</p>


=====================================
docs/en_US/worldmap.html
=====================================
@@ -62,7 +62,8 @@
         coordinates to use as initial center for the worldmaps viewport.</p>
 
         <p>The <code>worldmap_zoom=6</code> specifies the initial zoom level to be used when rendering the worldmap.
-        NagVis allows zoom levels from 2 to 18.</p>
+        NagVis allows zoom levels from 2 (world) to 20 (building, detail).</p>
+
 
         <p>The <code>worldmap_tiles_saturate=33</code> dims the colors of default OpenStreetMap so that red motorways or
         large green forests don't interfere with actual map objects. Possible values are 0 (no colors, grayscale) through 100 (full colors).</p>
@@ -77,5 +78,22 @@
 
         <p>You can also create a new worldmap from an existing one by zoom and pan to create the viewport you like
         to use for your new worldmap, then choose <i>Edit Map > Viewport > Save as new Map</i>.
+
+        <h2>Objects on worldmap and zoom</h2>
+        The map object (host, line, textbox, ...) may be configured to only show at certain zoom levels. Related object attributes are:
+        <table style="width:100%">
+            <tr>
+                <th>Parameter</th><th>Default</th><th>Description</th>
+            </tr>
+            <tr>
+                <td>min_zoom</td><td>2</td><td>Only show the object at specified zoom level or higher (more detailed view)</td>
+            </tr>
+            <tr>
+                <td>max_zoom</td><td>20</td><td>Only show the object at specified zoom levels or lower (wider view)</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>
+            </tr>
+        </table>
     </body>
 </html>


=====================================
share/frontend/nagvis-js/js/ElementBox.js
=====================================
@@ -23,12 +23,22 @@
 
 var ElementBox = Element.extend({
     render: function() {
+        let scale = 1;
+        if (g_map && usesSource('worldmap') && this.obj.conf.scale_to_max_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)
+            }
+        }
+
         this.dom_obj = renderNagVisTextbox(
             this.obj.conf.object_id+'-label',
             this.obj.conf.background_color, this.obj.conf.border_color,
             0, 0, // coords are set by this.place()
             this.obj.conf.z, this.obj.conf.w,
-            this.obj.conf.h, this.obj.getText(), this.obj.conf.style
+            this.obj.conf.h, this.obj.getText(), this.obj.conf.style,
+            scale
         );
         this.obj.trigger_obj = this.dom_obj;
         this.place();


=====================================
share/frontend/nagvis-js/js/ElementLine.js
=====================================
@@ -819,12 +819,10 @@ var ElementLine = Element.extend({
         var line_label_in = 'in';
         var line_label_out = 'out';
 
-        // Check_MK if/if64 checks support switching between bytes/bits. The detection
-        // can be made by some curios hack. The most hackish hack I've ever seen. From hell.
-        // Well, let's deal with it.
+        // Check_MK if/if64 checks support switching between bytes/bits.
         var display_bits = false;
-        output = output.match("In: [0-9](.*)Out: [0-9]")[1] || "";
-        if(output.includes("bit/s")){
+
+        if (output.match('In: [0-9].*bit/s.*Out: [0-9]+')) {
             display_bits=true;
         }
 


=====================================
share/frontend/nagvis-js/js/NagVisObject.js
=====================================
@@ -131,7 +131,7 @@ var NagVisObject = Base.extend({
 
         // The line labels need a) the line added to DOM and b) the label added
         // to the dom before being able to calculate the correct coordinates
-        // needed in place().   
+        // needed in place().
         if (this.conf.type == 'line' || this.conf.view_type == 'line')
             for (var i = 0; i < this.elements.length; i++)
                 this.elements[i].place();
@@ -334,32 +334,25 @@ var NagVisObject = Base.extend({
             addZoom = true;
 
         var coord = 0;
+
         if(!isRelativeCoord(val)) {
             coord = parseInt(val);
         } else {
-            // This must be an object id. Is there an offset given?
-            if(val.search('%') !== -1) {
-                var parts     = val.split('%');
-                var objectId  = parts[0];
-                var offset    = parts[1];
-                var refObj    = getMapObjByDomObjId(objectId);
-                if (refObj) {
-                    coord = parseFloat(refObj.parseCoord(refObj.conf[dir], dir, false));
-                    if (addZoom)
-                        coord = addZoomFactor(coord, true);
-
-                    if (addZoom)
-                        coord += addZoomFactor(parseFloat(offset), false);
-                    else
-                        coord += parseFloat(offset);
-
-                    return coord;
-                }
-            } else {
-                // Only an object id. Get the coordinate and return it
-                var refObj = getMapObjByDomObjId(val);
-                if(refObj)
-                    coord = parseInt(refObj.parseCoord(refObj.conf[dir], dir, false));
+            var parts     = val.split('%');
+            var objectId  = parts[0];
+            var offset    = parts[1];
+            var refObj    = getMapObjByDomObjId(objectId);
+            if (refObj) {
+                coord = parseFloat(refObj.parseCoord(refObj.conf[dir], dir, false));
+                if (addZoom)
+                    coord = addZoomFactor(coord, true);
+
+                if (addZoom)
+                    coord += addZoomFactor(parseFloat(offset), false);
+                else
+                    coord += parseFloat(offset);
+
+                return coord;
             }
         }
 


=====================================
share/frontend/nagvis-js/js/frontendMessage.js
=====================================
@@ -29,7 +29,7 @@ function frontendMessagePresent(key) {
 
 function frontendMessageRemove(key) {
     if(frontendMessagePresent(key)) {
-        document.body.removeChild(frontendMessages[key]);
+        popupWindowClose();
         delete frontendMessages[key];
     }
 }


=====================================
share/frontend/nagvis-js/js/nagvis.js
=====================================
@@ -951,7 +951,7 @@ function hideStatusMessage() {
  * @return  Object  Returns the div object of the textbox
  * @author  Lars Michelsen <lm at larsmichelsen.com>
  */
-function renderNagVisTextbox(id, bgColor, borderColor, x, y, z, w, h, text, customStyle) {
+function renderNagVisTextbox(id, bgColor, borderColor, x, y, z, w, h, text, customStyle, scale) {
     var oLabelDiv = document.createElement('div');
     oLabelDiv.setAttribute('id', id);
     oLabelDiv.className = 'box';
@@ -969,6 +969,9 @@ function renderNagVisTextbox(id, bgColor, borderColor, x, y, z, w, h, text, cust
 
     oLabelDiv.style.zIndex = parseInt(z) + 1;
 
+    if (scale)
+        oLabelDiv.style.transform = `scale(${scale})`;
+
     /**
      * IE workaround: The transparent for the color is not enough. The border
      * has really to be hidden.
@@ -1151,8 +1154,7 @@ function pxToInt(v) {
 // san francisco and zooming to new your will lead to a negative 5 digit
 // negative coord).
 function isRelativeCoord(v) {
-    return isset(v) && ((!isInt(v) && !isFloat(v))
-                        || (v.length === 6 && v.charAt(0) != "-" && v.indexOf(".") == -1));
+    return typeof(v) === 'string' && v.includes('%')
 }
 
 // Helper function to determine the number of entries in an object


=====================================
share/server/core/classes/GlobalMapCfg.php
=====================================
@@ -1547,6 +1547,9 @@ class GlobalMapCfg {
                 $val = implode(',', $val);
 
             $val = str_replace( "\n", '<br/>', $val );
+            $val = str_replace( "\r", '', $val );
+            $val = str_replace( "\t", ' ', $val );
+            $val = preg_replace( '/[\x00-\x1f]/', '', $val );
 
             $newLine = $key.'='.$val."\n";
 


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


=====================================
share/server/core/mapcfg/default.php
=====================================
@@ -861,6 +861,12 @@ $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' => '',
@@ -1427,6 +1433,9 @@ $mapConfigVarMap['textbox'] = Array(
         'type' => null,
         'use' => null,
     ),
+    'worldmap' => array(
+        'scale_to_max_zoom' => null,
+    )
 );
 
 $mapConfigVarMap['shape'] = Array(


=====================================
share/server/core/sources/worldmap.php
=====================================
@@ -173,7 +173,7 @@ function line_parameters($ax, $ay, $bx, $by) {
 
     if ($s == -0) $s = 0;
 
-    return [$r, $s, $t];
+    return array($r, $s, $t);
 }
 function worldmap_get_objects_by_bounds($sw_lng, $sw_lat, $ne_lng, $ne_lat) {
     global $DB;



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

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagvis/-/commit/c3259c1981743dffe2803d994bba305449640028
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/20200729/db196695/attachment-0001.html>


More information about the pkg-nagios-changes mailing list