GUI Topo -- Badges - Enhanced uitopo archetype to also use badges.
Change-Id: I80cd4783a4154a2ccce6054175022b97ef7bc6c1
diff --git a/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java b/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
index e0d7d23..22a7bba 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
@@ -16,6 +16,8 @@
package org.onosproject.ui;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.HostId;
import org.onosproject.ui.topo.PropertyPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -106,7 +108,7 @@
*
* @param pp property panel model of summary data
*/
- public void modifyDeviceDetails(PropertyPanel pp) {
+ public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
}
/**
@@ -116,6 +118,6 @@
*
* @param pp property panel model of summary data
*/
- public void modifyHostDetails(PropertyPanel pp) {
+ public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
}
}
diff --git a/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java b/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
index 7c35cc5..65e3489 100644
--- a/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
+++ b/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
@@ -33,7 +33,10 @@
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiConnection;
import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.topo.DeviceHighlight;
import org.onosproject.ui.topo.Highlights;
+import org.onosproject.ui.topo.NodeBadge;
+import org.onosproject.ui.topo.NodeBadge.Status;
import org.onosproject.ui.topo.TopoJson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -224,11 +227,26 @@
if (elementOfNote != null && elementOfNote instanceof Device) {
DeviceId devId = (DeviceId) elementOfNote.id();
Set<Link> links = linkService.getDeviceEgressLinks(devId);
- sendHighlights(fromLinks(links, devId));
+ Highlights highlights = fromLinks(links, devId);
+ addDeviceBadge(highlights, devId, links.size());
+ sendHighlights(highlights);
}
// Note: could also process Host, if available
}
+ private void addDeviceBadge(Highlights h, DeviceId devId, int n) {
+ DeviceHighlight dh = new DeviceHighlight(devId.toString());
+ dh.setBadge(createBadge(n));
+ h.add(dh);
+ }
+
+ private NodeBadge createBadge(int n) {
+ Status status = n > 3 ? Status.ERROR : Status.WARN;
+ String noun = n > 3 ? "(critical)" : "(problematic)";
+ String msg = "Egress links: " + n + " " + noun;
+ return NodeBadge.number(status, n, msg);
+ }
+
private Highlights fromLinks(Set<Link> links, DeviceId devId) {
DemoLinkMap linkMap = new DemoLinkMap();
if (links != null) {
diff --git a/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java b/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java
index 9899982..48e75a5 100644
--- a/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java
+++ b/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java
@@ -18,13 +18,20 @@
*/
package ${package};
+import org.onosproject.net.DeviceId;
import org.onosproject.ui.UiTopoOverlay;
import org.onosproject.ui.topo.ButtonId;
import org.onosproject.ui.topo.PropertyPanel;
import org.onosproject.ui.topo.TopoConstants.CoreButtons;
import org.onosproject.ui.topo.TopoConstants.Glyphs;
-import static org.onosproject.ui.topo.TopoConstants.Properties.*;
+import static org.onosproject.ui.topo.TopoConstants.Properties.FLOWS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.LATITUDE;
+import static org.onosproject.ui.topo.TopoConstants.Properties.LONGITUDE;
+import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION;
/**
* Our topology overlay.
@@ -61,7 +68,7 @@
}
@Override
- public void modifyDeviceDetails(PropertyPanel pp) {
+ public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
pp.title(MY_DEVICE_TITLE);
pp.removeProps(LATITUDE, LONGITUDE);
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
index 8acdc2c..292a5f9 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
@@ -33,6 +33,7 @@
import org.onosproject.mastership.MastershipListener;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
@@ -344,11 +345,13 @@
PropertyPanel pp = null;
if (type.equals(DEVICE)) {
- pp = deviceDetails(deviceId(id), sid);
- overlayCache.currentOverlay().modifyDeviceDetails(pp);
+ DeviceId did = deviceId(id);
+ pp = deviceDetails(did, sid);
+ overlayCache.currentOverlay().modifyDeviceDetails(pp, did);
} else if (type.equals(HOST)) {
- pp = hostDetails(hostId(id), sid);
- overlayCache.currentOverlay().modifyHostDetails(pp);
+ HostId hid = hostId(id);
+ pp = hostDetails(hid, sid);
+ overlayCache.currentOverlay().modifyHostDetails(pp, hid);
}
sendMessage(envelope(SHOW_DETAILS, sid, json(pp)));
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficOverlay.java b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficOverlay.java
index ea8ca3e..f4b5598 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficOverlay.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficOverlay.java
@@ -17,6 +17,7 @@
package org.onosproject.ui.impl;
+import org.onosproject.net.DeviceId;
import org.onosproject.ui.UiTopoOverlay;
import org.onosproject.ui.topo.ButtonId;
import org.onosproject.ui.topo.PropertyPanel;
@@ -55,7 +56,7 @@
}
@Override
- public void modifyDeviceDetails(PropertyPanel pp) {
+ public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
pp.addButton(SHOW_DEVICE_FLOWS)
.addButton(SHOW_RELATED_TRAFFIC);
}