Simon Hunt

GUI -- TopoView - Port numbers now appear when hovering over a link.

- (but they are centered on the node -- still need to move them away from the node).

Change-Id: I491851ef2f4d31b85db0dbc2b3145218a4913844
...@@ -484,6 +484,8 @@ ...@@ -484,6 +484,8 @@
484 stroke: #7352CD; 484 stroke: #7352CD;
485 } 485 }
486 486
487 +/* Link Labels */
488 +
487 #ov-topo svg .linkLabel rect { 489 #ov-topo svg .linkLabel rect {
488 stroke: none; 490 stroke: none;
489 } 491 }
...@@ -506,6 +508,32 @@ ...@@ -506,6 +508,32 @@
506 fill: #eee; 508 fill: #eee;
507 } 509 }
508 510
511 +/* Port Labels */
512 +
513 +#ov-topo svg .portLabel rect {
514 + stroke: none;
515 +}
516 +.light #ov-topo svg .portLabel rect {
517 + fill: #eee;
518 +}
519 +.dark #ov-topo svg .portLabel rect {
520 + fill: #555;
521 +}
522 +
523 +#ov-topo svg .portLabel text {
524 + text-anchor: middle;
525 + stroke-width: 0.1;
526 + font-size: 9pt;
527 +}
528 +.light #ov-topo svg .portLabel text {
529 + fill: #444;
530 +}
531 +.dark #ov-topo svg .portLabel text {
532 + fill: #eee;
533 +}
534 +
535 +
536 +
509 537
510 /* radio buttons injected into masthead */ 538 /* radio buttons injected into masthead */
511 539
......
...@@ -413,6 +413,27 @@ ...@@ -413,6 +413,27 @@
413 return sus.translate(xMid, yMid); 413 return sus.translate(xMid, yMid);
414 } 414 }
415 415
416 + function applyPortLabels(data, portLabelG) {
417 + var entering = portLabelG.selectAll('.portLabel')
418 + .data(data).enter().append('g')
419 + .classed('portLabel', true)
420 + .attr('id', function (d) { return d.id; });
421 +
422 + entering.each(function (d) {
423 + var el = d3.select(this),
424 + rect = el.append('rect'),
425 + text = el.append('text').text(d.num);
426 +
427 + rect.attr(rectAroundText(el));
428 + text.attr('dy', linkLabelOffset);
429 + el.attr('transform', transformPort(d));
430 + });
431 + }
432 +
433 + function transformPort(d) {
434 + // TODO: offset along the link, away from the node
435 + return sus.translate(d.baseX, d.baseY);
436 + }
416 437
417 // ========================== 438 // ==========================
418 // Module definition 439 // Module definition
...@@ -459,8 +480,8 @@ ...@@ -459,8 +480,8 @@
459 480
460 linkEntering: linkEntering, 481 linkEntering: linkEntering,
461 applyLinkLabels: applyLinkLabels, 482 applyLinkLabels: applyLinkLabels,
462 - 483 + transformLabel: transformLabel,
463 - transformLabel: transformLabel 484 + applyPortLabels: applyPortLabels
464 }; 485 };
465 }]); 486 }]);
466 }()); 487 }());
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
60 dim; // the dimensions of the force layout [w,h] 60 dim; // the dimensions of the force layout [w,h]
61 61
62 // SVG elements; 62 // SVG elements;
63 - var linkG, linkLabelG, nodeG; 63 + var linkG, linkLabelG, portLabelG, nodeG;
64 64
65 // D3 selections; 65 // D3 selections;
66 var link, linkLabel, node; 66 var link, linkLabel, node;
...@@ -741,6 +741,7 @@ ...@@ -741,6 +741,7 @@
741 forceG: forceG, 741 forceG: forceG,
742 zoomer: uplink.zoomer(), 742 zoomer: uplink.zoomer(),
743 network: network, 743 network: network,
744 + portLabelG: function () { return portLabelG; },
744 showHosts: function () { return showHosts; } 745 showHosts: function () { return showHosts; }
745 }; 746 };
746 } 747 }
...@@ -792,13 +793,14 @@ ...@@ -792,13 +793,14 @@
792 tts.initTraffic(mkTrafficApi(uplink)); 793 tts.initTraffic(mkTrafficApi(uplink));
793 tos.initOblique(mkObliqueApi(uplink, fltr)); 794 tos.initOblique(mkObliqueApi(uplink, fltr));
794 fltr.initFilter(mkFilterApi(uplink), d3.select('#mast-right')); 795 fltr.initFilter(mkFilterApi(uplink), d3.select('#mast-right'));
795 - tls.initLink(mkLinkApi(svg, forceG, uplink)); 796 + tls.initLink(mkLinkApi(svg, forceG, uplink), td3);
796 797
797 settings = angular.extend({}, defaultSettings, opts); 798 settings = angular.extend({}, defaultSettings, opts);
798 799
799 linkG = forceG.append('g').attr('id', 'topo-links'); 800 linkG = forceG.append('g').attr('id', 'topo-links');
800 linkLabelG = forceG.append('g').attr('id', 'topo-linkLabels'); 801 linkLabelG = forceG.append('g').attr('id', 'topo-linkLabels');
801 nodeG = forceG.append('g').attr('id', 'topo-nodes'); 802 nodeG = forceG.append('g').attr('id', 'topo-nodes');
803 + portLabelG = forceG.append('g').attr('id', 'topo-portLabels');
802 804
803 link = linkG.selectAll('.link'); 805 link = linkG.selectAll('.link');
804 linkLabel = linkLabelG.selectAll('.linkLabel'); 806 linkLabel = linkLabelG.selectAll('.linkLabel');
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
26 var $log, fs, sus, ts; 26 var $log, fs, sus, ts;
27 27
28 var api, 28 var api,
29 + td3,
29 network, 30 network,
30 enhancedLink = null; // the link which the mouse is hovering over 31 enhancedLink = null; // the link which the mouse is hovering over
31 32
...@@ -190,14 +191,31 @@ ...@@ -190,14 +191,31 @@
190 191
191 function unenhance(d) { 192 function unenhance(d) {
192 d.el.classed('enhanced', false); 193 d.el.classed('enhanced', false);
194 + api.portLabelG().selectAll('.portLabel').remove();
193 } 195 }
194 196
195 function enhance(d) { 197 function enhance(d) {
196 d.el.classed('enhanced', true); 198 d.el.classed('enhanced', true);
197 $log.debug('[' + (d.srcPort || 'H') + '] ---> [' + d.tgtPort + ']', d.key); 199 $log.debug('[' + (d.srcPort || 'H') + '] ---> [' + d.tgtPort + ']', d.key);
198 - }
199 200
201 + // define port label data objects
202 + var data = [
203 + {
204 + id: 'topo-port-src',
205 + num: d.srcPort,
206 + baseX: d.source.x,
207 + baseY: d.source.y
208 + },
209 + {
210 + id: 'topo-port-tgt',
211 + num: d.tgtPort,
212 + baseX: d.target.x,
213 + baseY: d.target.y
214 + }
215 + ];
200 216
217 + td3.applyPortLabels(data, api.portLabelG());
218 + }
201 219
202 220
203 // ========================== 221 // ==========================
...@@ -213,8 +231,9 @@ ...@@ -213,8 +231,9 @@
213 sus = _sus_; 231 sus = _sus_;
214 ts = _ts_; 232 ts = _ts_;
215 233
216 - function initLink(_api_) { 234 + function initLink(_api_, _td3_) {
217 api = _api_; 235 api = _api_;
236 + td3 = _td3_;
218 svg = api.svg; 237 svg = api.svg;
219 network = api.network; 238 network = api.network;
220 setupMouse(api.forceG, api.zoomer); 239 setupMouse(api.forceG, api.zoomer);
......