Committed by
Gerrit Code Review
Prototyping mouse-over behaviour for path/traffic selection; needs re-work.
Change-Id: I27507e8129b790e56192077bfb56028f2ec56d90
Showing
2 changed files
with
44 additions
and
19 deletions
... | @@ -91,7 +91,7 @@ public class TopologyWebSocket | ... | @@ -91,7 +91,7 @@ public class TopologyWebSocket |
91 | private final IntentListener intentListener = new InternalIntentListener(); | 91 | private final IntentListener intentListener = new InternalIntentListener(); |
92 | 92 | ||
93 | // Intents that are being monitored for the GUI | 93 | // Intents that are being monitored for the GUI |
94 | - private static Map<Intent, Long> intentsToMonitor = new ConcurrentHashMap<>(); | 94 | + private Map<Intent, Long> intentsToMonitor = new ConcurrentHashMap<>(); |
95 | 95 | ||
96 | private long lastActive = System.currentTimeMillis(); | 96 | private long lastActive = System.currentTimeMillis(); |
97 | private boolean listenersRemoved = false; | 97 | private boolean listenersRemoved = false; |
... | @@ -118,6 +118,8 @@ public class TopologyWebSocket | ... | @@ -118,6 +118,8 @@ public class TopologyWebSocket |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Indicates if this connection is idle. | 120 | * Indicates if this connection is idle. |
121 | + * | ||
122 | + * @return true if idle or closed | ||
121 | */ | 123 | */ |
122 | synchronized boolean isIdle() { | 124 | synchronized boolean isIdle() { |
123 | boolean idle = (System.currentTimeMillis() - lastActive) > MAX_AGE_MS; | 125 | boolean idle = (System.currentTimeMillis() - lastActive) > MAX_AGE_MS; |
... | @@ -293,6 +295,10 @@ public class TopologyWebSocket | ... | @@ -293,6 +295,10 @@ public class TopologyWebSocket |
293 | // Produces a set of intents that target all selected hosts or connect points. | 295 | // Produces a set of intents that target all selected hosts or connect points. |
294 | private Set<Intent> getIntents(Set<Host> hosts, Set<ConnectPoint> edgePoints) { | 296 | private Set<Intent> getIntents(Set<Host> hosts, Set<ConnectPoint> edgePoints) { |
295 | Set<Intent> intents = new HashSet<>(); | 297 | Set<Intent> intents = new HashSet<>(); |
298 | + if (hosts.isEmpty()) { | ||
299 | + return intents; | ||
300 | + } | ||
301 | + | ||
296 | for (Intent intent : intentService.getIntents()) { | 302 | for (Intent intent : intentService.getIntents()) { |
297 | boolean isRelevant = false; | 303 | boolean isRelevant = false; |
298 | if (intent instanceof HostToHostIntent) { | 304 | if (intent instanceof HostToHostIntent) { |
... | @@ -454,6 +460,7 @@ public class TopologyWebSocket | ... | @@ -454,6 +460,7 @@ public class TopologyWebSocket |
454 | ObjectNode payload = pathMessage(path, "host") | 460 | ObjectNode payload = pathMessage(path, "host") |
455 | .put("intentId", intent.id().toString()); | 461 | .put("intentId", intent.id().toString()); |
456 | sendMessage(envelope("showPath", sid, payload)); | 462 | sendMessage(envelope("showPath", sid, payload)); |
463 | + sendMessage(trafficMessage(intentsToMonitor.keySet(), sid)); | ||
457 | } | 464 | } |
458 | } | 465 | } |
459 | } | 466 | } | ... | ... |
... | @@ -88,7 +88,7 @@ | ... | @@ -88,7 +88,7 @@ |
88 | linkDistance: { | 88 | linkDistance: { |
89 | direct: 100, | 89 | direct: 100, |
90 | optical: 120, | 90 | optical: 120, |
91 | - hostLink: 5 | 91 | + hostLink: 3 |
92 | }, | 92 | }, |
93 | linkStrength: { | 93 | linkStrength: { |
94 | direct: 1.0, | 94 | direct: 1.0, |
... | @@ -98,7 +98,7 @@ | ... | @@ -98,7 +98,7 @@ |
98 | note_for_nodes: 'node.class is used to differentiate', | 98 | note_for_nodes: 'node.class is used to differentiate', |
99 | charge: { | 99 | charge: { |
100 | device: -8000, | 100 | device: -8000, |
101 | - host: -300 | 101 | + host: -5000 |
102 | }, | 102 | }, |
103 | pad: 20, | 103 | pad: 20, |
104 | translate: function() { | 104 | translate: function() { |
... | @@ -497,14 +497,16 @@ | ... | @@ -497,14 +497,16 @@ |
497 | 497 | ||
498 | function showTraffic(data) { | 498 | function showTraffic(data) { |
499 | fnTrace('showTraffic', data.payload.id); | 499 | fnTrace('showTraffic', data.payload.id); |
500 | - data.payload.paths.forEach(function () { | 500 | + var paths = data.payload.paths; |
501 | - var links = data.payload.links, | 501 | + |
502 | - s = [ data.event + "\n" + links.length ]; | 502 | + // Revert any links hilighted previously. |
503 | - links.forEach(function (d, i) { | 503 | + network.links.forEach(function (d) { |
504 | - s.push(d); | 504 | + d.el.classed('showPath', false); |
505 | - }); | 505 | + }); |
506 | - network.view.alert(s.join('\n')); | ||
507 | 506 | ||
507 | + // Now hilight all links in the paths payload. | ||
508 | + paths.forEach(function (d) { | ||
509 | + var links = d.links; | ||
508 | links.forEach(function (d, i) { | 510 | links.forEach(function (d, i) { |
509 | var link = network.lookup[d]; | 511 | var link = network.lookup[d]; |
510 | if (link) { | 512 | if (link) { |
... | @@ -559,10 +561,11 @@ | ... | @@ -559,10 +561,11 @@ |
559 | return true; | 561 | return true; |
560 | } | 562 | } |
561 | 563 | ||
562 | - function requestTraffic() { | 564 | + function requestTraffic(hoverNode) { |
563 | - if (nSel() > 0) { | 565 | + if (nSel() > 0 || hoverNode) { |
566 | + var nodes = hoverNode ? selectOrder.concat(hoverNode.id) : selectOrder; | ||
564 | sendMessage('requestTraffic', { | 567 | sendMessage('requestTraffic', { |
565 | - ids: selectOrder | 568 | + ids: nodes |
566 | }); | 569 | }); |
567 | } else { | 570 | } else { |
568 | userFeedback('Request-Traffic requires one or\n' + | 571 | userFeedback('Request-Traffic requires one or\n' + |
... | @@ -582,11 +585,15 @@ | ... | @@ -582,11 +585,15 @@ |
582 | } | 585 | } |
583 | } | 586 | } |
584 | 587 | ||
585 | - function cancelTraffic() { | 588 | + function cancelTraffic(hoverNode) { |
586 | - // FIXME: from where do we get the intent id(s) to send to the server? | 589 | + if (hoverNode && selectOrder.length) { |
587 | - sendMessage('cancelTraffic', { | 590 | + requestTraffic(); |
588 | - ids: ["need_the_intent_id"] | 591 | + } else { |
589 | - }); | 592 | + // FIXME: from where do we get the intent id(s) to send to the server? |
593 | + sendMessage('cancelTraffic', { | ||
594 | + ids: ["need_the_intent_id"] | ||
595 | + }); | ||
596 | + } | ||
590 | } | 597 | } |
591 | 598 | ||
592 | // request details for the selected element | 599 | // request details for the selected element |
... | @@ -943,7 +950,18 @@ | ... | @@ -943,7 +950,18 @@ |
943 | opacity: 0 | 950 | opacity: 0 |
944 | }) | 951 | }) |
945 | .call(network.drag) | 952 | .call(network.drag) |
946 | - //.on('mouseover', function (d) {}) | 953 | + .on('mouseover', function (d) { |
954 | + console.log(d); | ||
955 | + if (d.class === 'host') { | ||
956 | + requestTraffic(d); | ||
957 | + } | ||
958 | + }) | ||
959 | + .on('mouseout', function (d) { | ||
960 | + console.log(d); | ||
961 | + if (d.class === 'host') { | ||
962 | + cancelTraffic(d); | ||
963 | + } | ||
964 | + }) | ||
947 | //.on('mouseover', function (d) {}) | 965 | //.on('mouseover', function (d) {}) |
948 | .transition() | 966 | .transition() |
949 | .attr('opacity', 1); | 967 | .attr('opacity', 1); | ... | ... |
-
Please register or login to post a comment