Module: nagvis
Branch: master
Commit: 43140a22e40fcd333b1cb2969b668f68694bc12e
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=43140a22e40fcd333b1cb2969b668f68694bc12e

Author: Lars Michelsen <[email protected]>
Date:   Sat Jun  5 13:40:57 2010 +0200

Code formating in weatermap line code; Weathermap labels are printed on the 
lines even when the perfdata of the service is not ok

---

 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   15 +--
 share/frontend/nagvis-js/js/lines.js               |  102 +++++++++++---------
 2 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 9318de2..6eadfae 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -488,7 +488,7 @@ var NagVisStatefulObject = NagVisObject.extend({
                var width = this.conf.line_width;
                
                var colorFill = '';
-                var colorFill2 = '';
+    var colorFill2 = '';
                var colorBorder = '#000000';
 
                var setPerfdata = [];
@@ -570,20 +570,15 @@ var NagVisStatefulObject = NagVisObject.extend({
                }
 
                // Get the border color depending on ack/downtime
-               if(this.conf.summary_problem_has_been_acknowledged == 1) {
+               if(this.conf.summary_problem_has_been_acknowledged == 1 || 
this.conf.summary_in_downtime == 1) {
                        colorBorder = '#666666';
-                       
-                       colorFill = lightenColor(colorFill, 100, 100, 100);
-               }
-               
-               if(this.conf.summary_in_downtime == 1) {
-                       colorBorder = '#666666';
-                       
                        colorFill = lightenColor(colorFill, 100, 100, 100);
                }
 
                // Parse the line object
-               drawNagVisLine(this.conf.object_id, this.conf.line_type, x[0], 
y[0], x[1], y[1], this.conf.z, width, colorFill, colorFill2, setPerfdata, 
colorBorder, ((this.conf.url && this.conf.url !== '') || (this.conf.hover_menu 
&& this.conf.hover_menu !== '')));
+               drawNagVisLine(this.conf.object_id, this.conf.line_type, x[0], 
y[0], x[1], y[1],
+                              this.conf.z, width, colorFill, colorFill2, 
setPerfdata, colorBorder,
+                              ((this.conf.url && this.conf.url !== '') || 
(this.conf.hover_menu && this.conf.hover_menu !== '')));
                oMsg = null;
 
        },
diff --git a/share/frontend/nagvis-js/js/lines.js 
b/share/frontend/nagvis-js/js/lines.js
index 969b668..157508a 100644
--- a/share/frontend/nagvis-js/js/lines.js
+++ b/share/frontend/nagvis-js/js/lines.js
@@ -127,18 +127,22 @@ function drawPolygonBasedObject(objectId, lineType, 
xCoord, yCoord, z, w, colorF
        if(bLinkArea && bLinkArea === true) {
                var oLinkContainer = 
document.getElementById(objectId+'-linelinkdiv');
 
+               var labelShift = 10;
+               if(lineType == '13' || lineType == '14') {
+                       labelShift = getLabelShift(perfdataA);
+               }
+
                if(lineType == '13') {
-                       var labelShift = (perfdataA.length / 2) * 9;
                        var label = drawNagVisTextbox(objectId, 'box', 
'#ffffff', '#000000', (middle(xMin, xMax)-labelShift), (middle(yMin, yMax)-10), 
z, 'auto', 'auto', '<b>' + perfdataA + '</b>');
                        oLinkContainer.appendChild(label);
+                       label = null;
                } else if(lineType == '14') {
-                       var labelShift = (perfdataA.length / 2) * 9;
-                       label = drawNagVisTextbox(objectId, 'box', '#ffffff', 
'#000000', (middle(xMin, xMax)-labelShift), (middle(yMin, yMax)-10), z, 'auto', 
'auto', '<b>' + perfdataA + '</b>');
+                       var label = drawNagVisTextbox(objectId, 'box', 
'#ffffff', '#000000', (middle(xMin, xMax)-labelShift), (middle(yMin, yMax)-10), 
z, 'auto', 'auto', '<b>' + perfdataA + '</b>');
                        oLinkContainer.appendChild(label);
-                       labelShift = (perfdataB.length / 2) * 8;
+                       labelShift = getLabelShift(perfdataB);
                        label = drawNagVisTextbox(objectId, 'box', '#ffffff', 
'#000000', (middle(xMin, xMax)-labelShift), (middle(yMin, yMax)+10), z, 'auto', 
'auto', '<b>' + perfdataB + '</b>');
                        oLinkContainer.appendChild(label);
-               
+                       label = null;
                } else {
                        var oImg = document.createElement('img');
                        oImg.setAttribute('id', objectId+'-link');
@@ -158,6 +162,13 @@ function drawPolygonBasedObject(objectId, lineType, 
xCoord, yCoord, z, w, colorF
        }
 }
 
+function getLabelShift(str) {
+       if(str.length > 0)
+               return (str.length / 2) * 9;
+       else
+               return 10
+}
+
 // This function draws an arrow like it is used on NagVis maps
 // It draws following line types: ---> and ---><---
 //function drawArrow(objectId, x1, y1, x2, y2, z, w, colorFill, colorBorder, 
bLinkArea lineType, perfdata) {
@@ -238,26 +249,24 @@ function drawNagVisLine(objectId, type, x1, y1, x2, y2, 
z, width, colorFill, col
                        drawSimpleLine(objectId, type, x1, y1, x2, y2, z, 
width, colorFill, perfdataA, perfdataB, colorBorder, bLinkArea);
                        break;
                case '13':
-                       // -%-><-%- lines
-                       var xMid = middle(x1,x2);
-                       var yMid = middle(y1,y2);
+                       // -%-><-%- lines
+                       var xMid = middle(x1,x2);
+                       var yMid = middle(y1,y2);
                        perfdataA = perfdata[0][1] + perfdata[0][2];
-
-                       drawArrow(objectId, type, x1, y1, xMid, yMid, z, width, 
colorFill, perfdataA, perfdataB, colorBorder, bLinkArea);
+                       drawArrow(objectId, type, x1, y1, xMid, yMid, z, width, 
colorFill, perfdataA, perfdataB, colorBorder, bLinkArea);
                        perfdataA = perfdata[1][1] + perfdata[1][2];
-                       drawArrow(objectId, type, x2, y2, xMid, yMid, z, width, 
colorFill2, perfdataA, perfdataB, colorBorder, bLinkArea);
+                       drawArrow(objectId, type, x2, y2, xMid, yMid, z, width, 
colorFill2, perfdataA, perfdataB, colorBorder, bLinkArea);
                        break;
                case '14':
-                       // -%+BW-><-%+BW- lines
-                       var xMid = middle(x1,x2);
-                       var yMid = middle(y1,y2);
+                       // -%+BW-><-%+BW- lines
+                       var xMid = middle(x1,x2);
+                       var yMid = middle(y1,y2);
                        perfdataA = perfdata[0][1] + perfdata[0][2];
                        perfdataB = perfdata[2][1] + ' ' + perfdata[2][2];
-
-                       drawArrow(objectId, type, x1, y1, xMid, yMid, z, width, 
colorFill, perfdataA, perfdataB, colorBorder, bLinkArea);
+                       drawArrow(objectId, type, x1, y1, xMid, yMid, z, width, 
colorFill, perfdataA, perfdataB, colorBorder, bLinkArea);
                        perfdataA = perfdata[1][1] + perfdata[1][2];
                        perfdataB = perfdata[3][1] + ' ' + perfdata[3][2];
-                       drawArrow(objectId, type, x2, y2, xMid, yMid, z, width, 
colorFill2, perfdataA, perfdataB, colorBorder, bLinkArea);
+                       drawArrow(objectId, type, x2, y2, xMid, yMid, z, width, 
colorFill2, perfdataA, perfdataB, colorBorder, bLinkArea);
                        break;
                default:
                        alert('Error: Unknown line type');
@@ -358,35 +367,34 @@ function splicePerfdata(nagiosPerfdata) {
  *
  */
 function getColorFill(percent) {
-        // set color based on percent level
-
-        var percent;
-        var color = '';
-
-        eventlog("test", "debug", "Percent:" + percent);
-        if(percent >= 0 && percent <= 10) {
-                // purple
-                return '#8c00ff';
-        } else if (percent > 10 && percent <= 25) {
-                // blue
-                return '#2020ff';
-        } else if (percent > 25 && percent <= 40) {
-                // light blue
-                return '#00c0ff';
-        } else if (percent > 40 && percent <= 55) {
-                // green
-                return '#00f000';
-        } else if (percent > 55 && percent <= 70) {
-                // yellow
-                return '#f0f000';
-        } else if (percent > 70 && percent <= 85) {
-                // orange
-                return '#ffc000';
-        } else if (percent > 85 && percent <= 100) {
-                // red
-                return '#ff0000';
-        } else {
-                return '#000000';
-        }
+       // set color based on percent level
+       var percent;
+       var color = '';
+
+       eventlog("test", "debug", "Percent:" + percent);
+       if(percent >= 0 && percent <= 10) {
+               // purple
+               return '#8c00ff';
+       } else if (percent > 10 && percent <= 25) {
+               // blue
+               return '#2020ff';
+       } else if (percent > 25 && percent <= 40) {
+               // light blue
+               return '#00c0ff';
+       } else if (percent > 40 && percent <= 55) {
+               // green
+               return '#00f000';
+       } else if (percent > 55 && percent <= 70) {
+               // yellow
+               return '#f0f000';
+       } else if (percent > 70 && percent <= 85) {
+               // orange
+               return '#ffc000';
+       } else if (percent > 85 && percent <= 100) {
+               // red
+               return '#ff0000';
+       } else {
+               return '#000000';
+       }
 }
 


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to