From 808d06a4bf6852f0c5d2dd752d2b7246d2eb3af9 Mon Sep 17 00:00:00 2001 From: lakshya Date: Thu, 29 Aug 2013 16:10:34 -0700 Subject: [PATCH] Fix for the Nodes Learnt dashlet error when there are no ports in the topology. This fixes the issue of the dashlet not loading by introducing a null check. Change-Id: I2c00166409706e95024a913d7e2d85d4f8d4fc3e Signed-off-by: lakshya --- .../web/devices/src/main/resources/js/page.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index 37016860a7..a138eb909e 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -321,9 +321,14 @@ one.f.switchmanager.nodesLearnt = { ' privilege=' + data.privilege + '>' + nodeNameEntry + ''; var ports = item.ports; + var portsMatch = ports.match(/<\/span>/g); + var portsLength = 0; + if (portsMatch != null) { + portsLength = portsMatch.length; + } item.ports = '' + ports.match(/<\/span>/g).length+''; + + '>' + portsLength +''; }); }, delay: 0 @@ -364,9 +369,14 @@ one.f.switchmanager.nodesLearnt = { formatter: function(items) { $.each(items, function (index, item) { var ports = item.ports; + var portsMatch = ports.match(/<\/span>/g); + var portsLength = 0; + if (portsMatch != null) { + portsLength = portsMatch.length; + } item.ports = '' + ports.match(/<\/span>/g).length+''; + + '>' + portsLength +''; }); }, delay: 0 -- 2.36.6