diff options
Diffstat (limited to 'web/nms.gathering.org')
-rwxr-xr-x | web/nms.gathering.org/api/public/switches | 3 | ||||
-rw-r--r-- | web/nms.gathering.org/index.html | 7 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 27 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-map.js | 38 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms.js | 5 |
5 files changed, 68 insertions, 12 deletions
diff --git a/web/nms.gathering.org/api/public/switches b/web/nms.gathering.org/api/public/switches index 3aa8af8..72c77be 100755 --- a/web/nms.gathering.org/api/public/switches +++ b/web/nms.gathering.org/api/public/switches @@ -12,7 +12,7 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v4_netsize,mgmt_v6_gw,mgmt_v6_netsize,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype from switches where placement is not null'); +my $q2 = $nms::web::dbh->prepare('select switch,sysname,distro_name,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v4_netsize,mgmt_v6_gw,mgmt_v6_netsize,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype from switches where placement is not null'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { @@ -23,6 +23,7 @@ while (my $ref = $q2->fetchrow_hashref()) { $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'y'} = $y2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'width'} = $x1 - $x2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'height'} = $y1 - $y2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'distro_name'} = $ref->{'distro_name'}; } my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, (select sysname from switches where switch = switch2) as sysname2 from linknets'); diff --git a/web/nms.gathering.org/index.html b/web/nms.gathering.org/index.html index 081c206..2862c69 100644 --- a/web/nms.gathering.org/index.html +++ b/web/nms.gathering.org/index.html @@ -71,6 +71,7 @@ <li class="divider"> </li> <li class="dropdown-header">View</li> <li><a href="#" onclick="toggleNightMode()">Toggle Night Mode</a></li> + <li><a href="#" onclick="toggleConnect()">Toggle linknets</a></li> <li class="divider"> </li> <li class="dropdown-header">Move switches</li> <li><a href="#" onclick="nmsMap.moveSet(true);">Enable switch moving</a></li> @@ -169,6 +170,10 @@ <td>View Disco map</td> </tr> <tr> + <td>c</td> + <td>Toggle linknet connections</td> + </tr> + <tr> <td>h</td> <td>Step 1 hour back in time</td> </tr> @@ -236,7 +241,7 @@ </div> <canvas id="bgCanvas" width="1920" height="1032" style="position: absolute; z-index: 1;"> </canvas> - <canvas id="linkCanvas" width="1920" height="1032" style="position: absolute; z-index: 10;"> </canvas> + <canvas id="linkCanvas" width="1920" height="1032" style="position: absolute; z-index: 10; display: none;"> </canvas> <canvas id="blurCanvas" width="1920" height="1032" style="position: absolute; z-index: 20;"> </canvas> <canvas id="switchCanvas" width="1920" height="1032" style="position: absolute; z-index: 30;"> </canvas> <canvas id="textCanvas" width="1920" height="1032" style="position: absolute; z-index: 40;"> </canvas> diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index a2d4f86..0b90d49 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -436,7 +436,7 @@ nmsInfoBox._makeCommentTable = function(content) { nmsInfoBox._searchSmart = function(id, sw) { try { - if (nmsData.smanagement.switches[sw].distro == id) { + if (nmsData.switches.switches[sw].distro_name == id) { return true; } if (id.match("active")) { @@ -461,15 +461,22 @@ nmsInfoBox._searchSmart = function(id, sw) { } } } - if (nmsData.smanagement.switches[sw].ip.match(id)) { - return true; - } - if (nmsData.smanagement.switches[sw].subnet4.match(id)) { - return true; - } - if (nmsData.smanagement.switches[sw].subnet6.match(id)) { - return true; - } + try { + if (nmsData.smanagement.switches[sw].mgmt_v4_addr.match(id)) { + return true; + } + if (nmsData.smanagement.switches[sw].mgmt_v6_addr.match(id)) { + return true; + } + } catch (e) {} + try { + if (nmsData.smanagement.switches[sw].subnet4.match(id)) { + return true; + } + if (nmsData.smanagement.switches[sw].subnet6.match(id)) { + return true; + } + } catch (e) {} if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) { return true; } diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js index 7cbf274..ada6886 100644 --- a/web/nms.gathering.org/js/nms-map.js +++ b/web/nms.gathering.org/js/nms-map.js @@ -47,6 +47,7 @@ var nmsMap = nmsMap || { }, _color: { }, + _linknets: {} , _highlight: { }, _highlightActive: false, _c: {} @@ -157,6 +158,7 @@ nmsMap._resizeEvent = function() { nmsMap._blurDrawn = false; nmsMap._drawBG(); nmsMap._drawAllSwitches(); + nmsMap._drawAllLinknets(); nmsMap.drawNow(); nmsMap.stats.resizeEvents++; } @@ -330,6 +332,40 @@ nmsMap._drawText = function(ctx, text, box, align) { ctx.restore(); }; +nmsMap._setLinknetColor = function(l, color1, color2) +{ + var oldcolor1; + var oldcolor2; + try { + oldcolor1 = nmsMap._linknets[l].sysname1; + oldcolor2 = nmsMap._linknets[l].sysname2; + if (oldcolor1 == color1 && oldcolor2 == color2) { + return ; + } + } catch (e) {} + nmsMap._linknets[l] = {}; + nmsMap._linknets[l].sysname1 = color1; + nmsMap._linknets[l].sysname2 = color2; + nmsMap._drawLinknet(l) +} + +nmsMap._drawLinknet = function(l) { + try { + var color1 = blue; + var color2 = blue; + try { + color1 = nmsMap._linknets[l].sysname1; + color2 = nmsMap._linknets[l].sysname2; + } catch(e) { } + nmsMap._connectSwitches(nmsData.switches.linknets[l].sysname1, nmsData.switches.linknets[l].sysname2, color1, color2); + } catch(e) { } +} + +nmsMap._drawAllLinknets = function() { + for (var l in nmsData.switches.linknets) { + nmsMap._drawLinknet(l); + } +} nmsMap._drawAllSwitches = function() { if (nmsData.switches == undefined) { this.stats.earlyDrawAll++; @@ -386,10 +422,12 @@ nmsMap._connectBoxes = function(box1, box2,color1, color2) { gradient.addColorStop(0, color1); gradient.addColorStop(1, color2); ctx.strokeStyle = gradient; + ctx.beginPath(); ctx.moveTo(x0,y0); ctx.lineTo(x1,y1); ctx.lineWidth = 5; ctx.stroke(); + ctx.closePath(); ctx.restore(); }; diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index 49cacde..964c73f 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -38,6 +38,7 @@ var nms = { '5':setMapModeFromN, '6':setMapModeFromN, '7':setMapModeFromN, + 'c':toggleConnect, 'h':moveTimeFromKey, 'j':moveTimeFromKey, 'k':moveTimeFromKey, @@ -345,6 +346,10 @@ function toggleLayer(layer) { l.style.display = 'none'; } +function toggleConnect() { + toggleLayer("linkCanvas"); +} + function commentInactive(id) { commentChange(id,"inactive"); |