Author: Max Sikström <[email protected]>
Date: Mon Jun 10 22:50:52 2013 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Mon Jun 10 22:50:52 2013 +0200
Adding a weathermap line (-->BW+%-><-BW+%--) for a service not presenting the
correct performace data, or for a line without a related service, the perfdata
variable in the method drawNagVisLine is set to null.
This results in an error when trying to access perfdata[0].
This patch sets perfdata to an empty array, making array access to the perfdata
available, but perfdata[0] isn't set, which is ok due to tests afterwards.
When perfdata isn't set, make the output nicer than a string "null" too.
Signed-off-by: Max Sikström <[email protected]>
---
share/frontend/nagvis-js/js/lines.js | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/share/frontend/nagvis-js/js/lines.js
b/share/frontend/nagvis-js/js/lines.js
index 29b885f..c4d7d67 100644
--- a/share/frontend/nagvis-js/js/lines.js
+++ b/share/frontend/nagvis-js/js/lines.js
@@ -259,6 +259,11 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z,
width, colorFill, col
var xEnd = x[x.length - 1];
var yEnd = y[y.length - 1];
+ //If no performance data is available, make perfdata defined, so
perfdata[0]
+ //doesn't trigger an error, but is unset
+ if(perfdata == null)
+ perfdata = [];
+
// Handle start/end offsets
//xStart = xStart + newX(xEnd-xStart, yEnd-yStart, 16, 0);
//yStart = yStart + newY(xEnd-xStart, yEnd-yStart, 16, 0);
@@ -266,8 +271,10 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z,
width, colorFill, col
//yEnd = yEnd + newY(xEnd-xStart, yEnd-yStart, -16, 0);
width = parseInt(width, 10);
- var perfdataA = null;
- var perfdataB = null;
+
+ // If not set below, better output something readable than "null"
+ var perfdataA = "N/A";
+ var perfdataB = "N/A";
// Cuts
// Lines meeting point position
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins