From: lakshya Date: Thu, 29 Aug 2013 23:10:34 +0000 (-0700) Subject: Fix for the Nodes Learnt dashlet error when there are no ports in the topology. X-Git-Tag: releasepom-0.1.0~148 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=808d06a4bf6852f0c5d2dd752d2b7246d2eb3af9 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 --- 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