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;
public abstract class AbstractHighlight {
private final TopoElementType type;
private final String elementId;
private boolean keepSubdued = false;
/**
* Constructs the highlight.
......@@ -39,6 +40,13 @@ public abstract class AbstractHighlight {
}
/**
* Sets a flag to tell the renderer to keep this element subdued.
*/
public void keepSubdued() {
keepSubdued = true;
}
/**
* Returns the element type.
*
* @return element type
......@@ -55,4 +63,13 @@ public abstract class AbstractHighlight {
public String elementId() {
return elementId;
}
/**
* Returns the subdued flag.
*
* @return subdued flag
*/
public boolean subdued() {
return keepSubdued;
}
}
......
......@@ -90,20 +90,32 @@ public final class TopoJson {
}
private static ObjectNode json(DeviceHighlight dh) {
return objectNode()
ObjectNode n = objectNode()
.put(ID, dh.elementId());
if (dh.subdued()) {
n.put(SUBDUE, true);
}
return n;
}
private static ObjectNode json(HostHighlight hh) {
return objectNode()
ObjectNode n = objectNode()
.put(ID, hh.elementId());
if (hh.subdued()) {
n.put(SUBDUE, true);
}
return n;
}
private static ObjectNode json(LinkHighlight lh) {
return objectNode()
ObjectNode n = objectNode()
.put(ID, lh.elementId())
.put(LABEL, lh.label())
.put(CSS, lh.cssClasses());
if (lh.subdued()) {
n.put(SUBDUE, true);
}
return n;
}
/**
......
......@@ -326,7 +326,9 @@
data.hosts.forEach(function (host) {
var hdata = api.findNodeById(host.id);
if (hdata && !hdata.el.empty()) {
api.unsupNode(hdata.id, less);
if (!host.subdue) {
api.unsupNode(hdata.id, less);
}
// TODO: further highlighting?
}
});
......@@ -334,7 +336,9 @@
data.devices.forEach(function (device) {
var ddata = api.findNodeById(device.id);
if (ddata && !ddata.el.empty()) {
api.unsupNode(ddata.id, less);
if (!device.subdue) {
api.unsupNode(ddata.id, less);
}
// TODO: further highlighting?
}
});
......@@ -345,10 +349,13 @@
units, portcls, magnitude;
if (ldata && !ldata.el.empty()) {
api.unsupLink(ldata.key, less);
if (!link.subdue) {
api.unsupLink(ldata.key, less);
}
ldata.el.classed(link.css, true);
ldata.label = lab;
// TODO: this needs to be pulled out into traffic overlay
// inject additional styling for port-based traffic
if (fs.endsWith(lab, 'bps')) {
units = lab.substring(lab.length-4);
......