Simon Hunt

ONOS-2186 - GUI Topo Overlay - (WIP)

- Default behaviour is to "unsubdue" each node and link present in the Highlights message.
- Now added ability to tag nodes/links for remaining subdued when rendered
(this needed for BYON application).

Change-Id: I351ee0d135bf3ef8f46102f461a45ee48fe9a5cc
...@@ -26,6 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -26,6 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
26 public abstract class AbstractHighlight { 26 public abstract class AbstractHighlight {
27 private final TopoElementType type; 27 private final TopoElementType type;
28 private final String elementId; 28 private final String elementId;
29 + private boolean keepSubdued = false;
29 30
30 /** 31 /**
31 * Constructs the highlight. 32 * Constructs the highlight.
...@@ -39,6 +40,13 @@ public abstract class AbstractHighlight { ...@@ -39,6 +40,13 @@ public abstract class AbstractHighlight {
39 } 40 }
40 41
41 /** 42 /**
43 + * Sets a flag to tell the renderer to keep this element subdued.
44 + */
45 + public void keepSubdued() {
46 + keepSubdued = true;
47 + }
48 +
49 + /**
42 * Returns the element type. 50 * Returns the element type.
43 * 51 *
44 * @return element type 52 * @return element type
...@@ -55,4 +63,13 @@ public abstract class AbstractHighlight { ...@@ -55,4 +63,13 @@ public abstract class AbstractHighlight {
55 public String elementId() { 63 public String elementId() {
56 return elementId; 64 return elementId;
57 } 65 }
66 +
67 + /**
68 + * Returns the subdued flag.
69 + *
70 + * @return subdued flag
71 + */
72 + public boolean subdued() {
73 + return keepSubdued;
74 + }
58 } 75 }
......
...@@ -90,20 +90,32 @@ public final class TopoJson { ...@@ -90,20 +90,32 @@ public final class TopoJson {
90 } 90 }
91 91
92 private static ObjectNode json(DeviceHighlight dh) { 92 private static ObjectNode json(DeviceHighlight dh) {
93 - return objectNode() 93 + ObjectNode n = objectNode()
94 .put(ID, dh.elementId()); 94 .put(ID, dh.elementId());
95 + if (dh.subdued()) {
96 + n.put(SUBDUE, true);
97 + }
98 + return n;
95 } 99 }
96 100
97 private static ObjectNode json(HostHighlight hh) { 101 private static ObjectNode json(HostHighlight hh) {
98 - return objectNode() 102 + ObjectNode n = objectNode()
99 .put(ID, hh.elementId()); 103 .put(ID, hh.elementId());
104 + if (hh.subdued()) {
105 + n.put(SUBDUE, true);
106 + }
107 + return n;
100 } 108 }
101 109
102 private static ObjectNode json(LinkHighlight lh) { 110 private static ObjectNode json(LinkHighlight lh) {
103 - return objectNode() 111 + ObjectNode n = objectNode()
104 .put(ID, lh.elementId()) 112 .put(ID, lh.elementId())
105 .put(LABEL, lh.label()) 113 .put(LABEL, lh.label())
106 .put(CSS, lh.cssClasses()); 114 .put(CSS, lh.cssClasses());
115 + if (lh.subdued()) {
116 + n.put(SUBDUE, true);
117 + }
118 + return n;
107 } 119 }
108 120
109 /** 121 /**
......
...@@ -326,7 +326,9 @@ ...@@ -326,7 +326,9 @@
326 data.hosts.forEach(function (host) { 326 data.hosts.forEach(function (host) {
327 var hdata = api.findNodeById(host.id); 327 var hdata = api.findNodeById(host.id);
328 if (hdata && !hdata.el.empty()) { 328 if (hdata && !hdata.el.empty()) {
329 - api.unsupNode(hdata.id, less); 329 + if (!host.subdue) {
330 + api.unsupNode(hdata.id, less);
331 + }
330 // TODO: further highlighting? 332 // TODO: further highlighting?
331 } 333 }
332 }); 334 });
...@@ -334,7 +336,9 @@ ...@@ -334,7 +336,9 @@
334 data.devices.forEach(function (device) { 336 data.devices.forEach(function (device) {
335 var ddata = api.findNodeById(device.id); 337 var ddata = api.findNodeById(device.id);
336 if (ddata && !ddata.el.empty()) { 338 if (ddata && !ddata.el.empty()) {
337 - api.unsupNode(ddata.id, less); 339 + if (!device.subdue) {
340 + api.unsupNode(ddata.id, less);
341 + }
338 // TODO: further highlighting? 342 // TODO: further highlighting?
339 } 343 }
340 }); 344 });
...@@ -345,10 +349,13 @@ ...@@ -345,10 +349,13 @@
345 units, portcls, magnitude; 349 units, portcls, magnitude;
346 350
347 if (ldata && !ldata.el.empty()) { 351 if (ldata && !ldata.el.empty()) {
348 - api.unsupLink(ldata.key, less); 352 + if (!link.subdue) {
353 + api.unsupLink(ldata.key, less);
354 + }
349 ldata.el.classed(link.css, true); 355 ldata.el.classed(link.css, true);
350 ldata.label = lab; 356 ldata.label = lab;
351 357
358 + // TODO: this needs to be pulled out into traffic overlay
352 // inject additional styling for port-based traffic 359 // inject additional styling for port-based traffic
353 if (fs.endsWith(lab, 'bps')) { 360 if (fs.endsWith(lab, 'bps')) {
354 units = lab.substring(lab.length-4); 361 units = lab.substring(lab.length-4);
......