Author:   Lars Michelsen <[email protected]>
Date:     Mon May 30 23:20:45 2011 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Mon May 30 23:20:45 2011 +0200

Applied several weathermap fixes

* Bugfix: Fixed parsing of label_type=14 lines (Thanks to Laurent Lebatard)
* Bugfix: Label positioning in case of weathermap lines (Thanks to Laurent 
Lebatard)

---

 ChangeLog                                          |    2 +
 TODO                                               |    3 +
 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   15 +++++--
 share/frontend/nagvis-js/js/lines.js               |   43 ++++++++++----------
 4 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2272f7b..7765a74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@ Core
 
 Frontend
   * Bugfix: Added missing controls to services which are displayed as gadgets
+  * Bugfix: Fixed parsing of label_type=14 lines (Thanks to Laurent Lebatard)
+  * Bugfix: Label positioning in case of weathermap lines (Thanks to Laurent 
Lebatard)
 
 1.6b1
 
diff --git a/TODO b/TODO
index d3540db..80517c6 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,9 @@
 This is a small file for storing quick thoughts about new features and needed 
changes:
 ===============================================================================
 
+Bugs:
+  - Labels können nicht verschoben werden
+
 - Backends:
  - Zusätzlich beliebige Variablen vom Backend holen lassen
    Pro Objekt "Custom Vars" für Context- und Hover-Menus einbauen. Diese 
werden dann pro Objekt
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index b570638..70c1efa 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -881,19 +881,26 @@ var NagVisStatefulObject = NagVisObject.extend({
 
         // If there is a presign it should be relative to the objects x/y
         if(this.conf.label_x && 
this.conf.label_x.toString().match(/^(?:\+|\-)/))
-            x = this.parseCoord(this.conf.x, 'x') + 
parseFloat(this.conf.label_x);
+            x = this.parseCoord(this.parseLabelCoord(this.conf.x), 'x') + 
parseFloat(this.conf.label_x);
         if(this.conf.label_y && 
this.conf.label_y.toString().match(/^(?:\+|\-)/))
-            y = this.parseCoord(this.conf.y, 'y') + 
parseFloat(this.conf.label_y);
+            y = this.parseCoord(this.parseLabelCoord(this.conf.y), 'y') + 
parseFloat(this.conf.label_y);
 
         // If no x/y coords set, fallback to object x/y
         if(!this.conf.label_x || this.conf.label_x === '' || this.conf.label_x 
=== '0')
-            x = this.parseCoord(this.conf.x, 'x');
+            x = this.parseCoord(this.parseLabelCoord(this.conf.x), 'x');
         if(!this.conf.label_y || this.conf.label_y === '' || this.conf.label_y 
=== '0')
-            y = this.parseCoord(this.conf.y, 'y');
+            y = this.parseCoord(this.parseLabelCoord(this.conf.y), 'y');
 
         return [ x, y ];
     },
 
+    parseLabelCoord: function (val) {
+        var k = val.indexOf(",");
+        if (k > 0)
+           return val.substring(0, k);
+        return val;
+    },
+
     /**
      * Parses the HTML-Code of a label
      *
diff --git a/share/frontend/nagvis-js/js/lines.js 
b/share/frontend/nagvis-js/js/lines.js
index ccec75b..68f3c72 100644
--- a/share/frontend/nagvis-js/js/lines.js
+++ b/share/frontend/nagvis-js/js/lines.js
@@ -141,11 +141,11 @@ function drawLabel(objectId, num, lineType, lx, ly, z, 
perfdataA, perfdataB) {
         if(oLinkContainer)
             oLinkContainer.appendChild(drawNagVisTextbox(objectId+'-link'+num, 
'box', '#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' 
+ perfdataA + '</b>'));
     } else if(lineType == '14') {
-        var label = drawNagVisTextbox(objectId+'-link'+num, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' + perfdataA + 
'</b>');
+        var label = drawNagVisTextbox(objectId+'-link'+num, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly-20), z, 'auto', 'auto', '<b>' + perfdataA + 
'</b>');
         if(oLinkContainer)
             oLinkContainer.appendChild(label);
         labelShift = getLabelShift(perfdataB);
-        label = drawNagVisTextbox(objectId+'-link'+num, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly+10), z, 'auto', 'auto', '<b>' + perfdataB + 
'</b>');
+        label = drawNagVisTextbox(objectId+'-link'+(num+1), 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly+10), z, 'auto', 'auto', '<b>' + perfdataB + 
'</b>');
         if(oLinkContainer)
             oLinkContainer.appendChild(label);
         label = null;
@@ -259,7 +259,7 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, 
width, colorFill, col
 
     // Cuts
     // Lines meeting point position
-  // First line label position
+    // First line label position
     // Second line label position
     var cut = cuts[0];
     var cutIn = cuts[1];
@@ -277,24 +277,24 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, 
z, width, colorFill, col
             }
 
             drawArrow(objectId, 1, xStart, yStart, xMid, yMid, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
+            drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
             drawArrow(objectId, 2, xEnd, yEnd, xMid, yMid, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 2, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
-            break;
+            drawLinkOrLabel(objectId, 2, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
+        break;
         case '11':
             // ---> lines
             var xMid = middle(xStart, xEnd, cut);
             var yMid = middle(yStart, yEnd, cut);
             drawArrow(objectId, 1, xStart, yStart, xEnd, yEnd, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
-            break;
+            drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
+        break;
         case '12':
             // --- lines
             var xMid = middle(xStart, xEnd, cut);
             var yMid = middle(yStart, yEnd, cut);
-            drawSimpleLine(objectId, xStart, yStart, xEnd, yEnd, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
-            break;
+            drawSimpleLine(objectId, 1, xStart, yStart, xEnd, yEnd, z, width, 
colorFill, colorBorder);
+            drawLinkOrLabel(objectId, 1, lineType, xMid, yMid, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow);
+        break;
         case '13':
             // -%-><-%- lines
             if(x.length == 2) {
@@ -308,18 +308,18 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, 
z, width, colorFill, col
             if(isset(perfdata[0]) && isset(perfdata[0][1]) && 
isset(perfdata[0][2]))
                 perfdataA = perfdata[0][1] + perfdata[0][2];
             drawArrow(objectId, 1, xStart, yStart, xMid, yMid, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, cutIn), 
middle(yStart, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
+            drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, 
cutIn), middle(yStart, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, 
bLabelShow);
 
             if(isset(perfdata[1]) && isset(perfdata[1][1]) && 
isset(perfdata[1][2]))
                 perfdataA = perfdata[1][1] + perfdata[1][2];
             drawArrow(objectId, 2, xEnd, yEnd, xMid, yMid, z, width, 
colorFill2, colorBorder);
-      drawLinkOrLabel(objectId, 2, lineType, middle(xEnd, xMid, cutOut), 
middle(yEnd, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
-            break;
+            drawLinkOrLabel(objectId, 2, lineType, middle(xEnd, xMid, cutOut), 
middle(yEnd, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
+        break;
         case '14':
             // -%+BW-><-%+BW- lines
             if(x.length == 2) {
-                var xMid = middle(xStart, x2, cut);
-                var yMid = middle(y1, y2, cut);
+                var xMid = middle(xStart, xEnd, cut);
+                var yMid = middle(yStart, yEnd, cut);
             } else {
                 var xMid = x[1];
                 var yMid = y[1];
@@ -331,15 +331,16 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, 
z, width, colorFill, col
             if(isset(perfdata[2]) && isset(perfdata[2][1]) && 
isset(perfdata[2][2]))
                 perfdataB = perfdata[2][1] + perfdata[2][2];
             drawArrow(objectId, 1, xStart, yStart, xMid, yMid, z, width, 
colorFill, colorBorder);
-      drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, cutOut), 
middle(yStart, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
+            drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, 
cutOut), middle(yStart, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, 
bLabelShow);
 
             if(isset(perfdata[1]) && isset(perfdata[1][1]) && 
isset(perfdata[1][2]))
                 perfdataA = perfdata[1][1] + perfdata[1][2];
             if(isset(perfdata[3]) && isset(perfdata[3][1]) && 
isset(perfdata[3][2]))
                 perfdataB = perfdata[3][1] + perfdata[3][2];
-            drawArrow(objectId, 2, xEnd, yEnd, xMid, yMid, z, width, 
colorFill2, colorBorder);
-            drawLinkOrLabel(objectId, 2, lineType, middle(xEnd, xMid, cutIn), 
middle(yEnd, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
-            break;
+           // Needs to be num = 3 because drawLinkOrLabel() call above 
consumes two ids
+            drawArrow(objectId, 3, xEnd, yEnd, xMid, yMid, z, width, 
colorFill2, colorBorder);
+            drawLinkOrLabel(objectId, 3, lineType, middle(xEnd, xMid, cutIn), 
middle(yEnd, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
+        break;
         default:
             // Unknown
             alert('Error: Unknown line type');
@@ -422,4 +423,4 @@ function splicePerfdata(nagiosPerfdata) {
             return setMatches;
         }
     }
-}
\ No newline at end of file
+}


------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to