Committed by
Gerrit Code Review
GUI Topo -- Badges - Enhanced uitopo archetype to also use badges.
Change-Id: I80cd4783a4154a2ccce6054175022b97ef7bc6c1
Showing
5 changed files
with
41 additions
and
10 deletions
| ... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.ui; | 17 | package org.onosproject.ui; |
| 18 | 18 | ||
| 19 | +import org.onosproject.net.DeviceId; | ||
| 20 | +import org.onosproject.net.HostId; | ||
| 19 | import org.onosproject.ui.topo.PropertyPanel; | 21 | import org.onosproject.ui.topo.PropertyPanel; |
| 20 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
| ... | @@ -106,7 +108,7 @@ public class UiTopoOverlay { | ... | @@ -106,7 +108,7 @@ public class UiTopoOverlay { |
| 106 | * | 108 | * |
| 107 | * @param pp property panel model of summary data | 109 | * @param pp property panel model of summary data |
| 108 | */ | 110 | */ |
| 109 | - public void modifyDeviceDetails(PropertyPanel pp) { | 111 | + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | /** | 114 | /** |
| ... | @@ -116,6 +118,6 @@ public class UiTopoOverlay { | ... | @@ -116,6 +118,6 @@ public class UiTopoOverlay { |
| 116 | * | 118 | * |
| 117 | * @param pp property panel model of summary data | 119 | * @param pp property panel model of summary data |
| 118 | */ | 120 | */ |
| 119 | - public void modifyHostDetails(PropertyPanel pp) { | 121 | + public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
| 120 | } | 122 | } |
| 121 | } | 123 | } | ... | ... |
| ... | @@ -33,7 +33,10 @@ import org.onosproject.net.link.LinkService; | ... | @@ -33,7 +33,10 @@ import org.onosproject.net.link.LinkService; |
| 33 | import org.onosproject.ui.RequestHandler; | 33 | import org.onosproject.ui.RequestHandler; |
| 34 | import org.onosproject.ui.UiConnection; | 34 | import org.onosproject.ui.UiConnection; |
| 35 | import org.onosproject.ui.UiMessageHandler; | 35 | import org.onosproject.ui.UiMessageHandler; |
| 36 | +import org.onosproject.ui.topo.DeviceHighlight; | ||
| 36 | import org.onosproject.ui.topo.Highlights; | 37 | import org.onosproject.ui.topo.Highlights; |
| 38 | +import org.onosproject.ui.topo.NodeBadge; | ||
| 39 | +import org.onosproject.ui.topo.NodeBadge.Status; | ||
| 37 | import org.onosproject.ui.topo.TopoJson; | 40 | import org.onosproject.ui.topo.TopoJson; |
| 38 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
| 39 | import org.slf4j.LoggerFactory; | 42 | import org.slf4j.LoggerFactory; |
| ... | @@ -224,11 +227,26 @@ public class AppUiTopovMessageHandler extends UiMessageHandler { | ... | @@ -224,11 +227,26 @@ public class AppUiTopovMessageHandler extends UiMessageHandler { |
| 224 | if (elementOfNote != null && elementOfNote instanceof Device) { | 227 | if (elementOfNote != null && elementOfNote instanceof Device) { |
| 225 | DeviceId devId = (DeviceId) elementOfNote.id(); | 228 | DeviceId devId = (DeviceId) elementOfNote.id(); |
| 226 | Set<Link> links = linkService.getDeviceEgressLinks(devId); | 229 | Set<Link> links = linkService.getDeviceEgressLinks(devId); |
| 227 | - sendHighlights(fromLinks(links, devId)); | 230 | + Highlights highlights = fromLinks(links, devId); |
| 231 | + addDeviceBadge(highlights, devId, links.size()); | ||
| 232 | + sendHighlights(highlights); | ||
| 228 | } | 233 | } |
| 229 | // Note: could also process Host, if available | 234 | // Note: could also process Host, if available |
| 230 | } | 235 | } |
| 231 | 236 | ||
| 237 | + private void addDeviceBadge(Highlights h, DeviceId devId, int n) { | ||
| 238 | + DeviceHighlight dh = new DeviceHighlight(devId.toString()); | ||
| 239 | + dh.setBadge(createBadge(n)); | ||
| 240 | + h.add(dh); | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + private NodeBadge createBadge(int n) { | ||
| 244 | + Status status = n > 3 ? Status.ERROR : Status.WARN; | ||
| 245 | + String noun = n > 3 ? "(critical)" : "(problematic)"; | ||
| 246 | + String msg = "Egress links: " + n + " " + noun; | ||
| 247 | + return NodeBadge.number(status, n, msg); | ||
| 248 | + } | ||
| 249 | + | ||
| 232 | private Highlights fromLinks(Set<Link> links, DeviceId devId) { | 250 | private Highlights fromLinks(Set<Link> links, DeviceId devId) { |
| 233 | DemoLinkMap linkMap = new DemoLinkMap(); | 251 | DemoLinkMap linkMap = new DemoLinkMap(); |
| 234 | if (links != null) { | 252 | if (links != null) { | ... | ... |
| ... | @@ -18,13 +18,20 @@ | ... | @@ -18,13 +18,20 @@ |
| 18 | */ | 18 | */ |
| 19 | package ${package}; | 19 | package ${package}; |
| 20 | 20 | ||
| 21 | +import org.onosproject.net.DeviceId; | ||
| 21 | import org.onosproject.ui.UiTopoOverlay; | 22 | import org.onosproject.ui.UiTopoOverlay; |
| 22 | import org.onosproject.ui.topo.ButtonId; | 23 | import org.onosproject.ui.topo.ButtonId; |
| 23 | import org.onosproject.ui.topo.PropertyPanel; | 24 | import org.onosproject.ui.topo.PropertyPanel; |
| 24 | import org.onosproject.ui.topo.TopoConstants.CoreButtons; | 25 | import org.onosproject.ui.topo.TopoConstants.CoreButtons; |
| 25 | import org.onosproject.ui.topo.TopoConstants.Glyphs; | 26 | import org.onosproject.ui.topo.TopoConstants.Glyphs; |
| 26 | 27 | ||
| 27 | -import static org.onosproject.ui.topo.TopoConstants.Properties.*; | 28 | +import static org.onosproject.ui.topo.TopoConstants.Properties.FLOWS; |
| 29 | +import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS; | ||
| 30 | +import static org.onosproject.ui.topo.TopoConstants.Properties.LATITUDE; | ||
| 31 | +import static org.onosproject.ui.topo.TopoConstants.Properties.LONGITUDE; | ||
| 32 | +import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS; | ||
| 33 | +import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS; | ||
| 34 | +import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION; | ||
| 28 | 35 | ||
| 29 | /** | 36 | /** |
| 30 | * Our topology overlay. | 37 | * Our topology overlay. |
| ... | @@ -61,7 +68,7 @@ public class AppUiTopovOverlay extends UiTopoOverlay { | ... | @@ -61,7 +68,7 @@ public class AppUiTopovOverlay extends UiTopoOverlay { |
| 61 | } | 68 | } |
| 62 | 69 | ||
| 63 | @Override | 70 | @Override |
| 64 | - public void modifyDeviceDetails(PropertyPanel pp) { | 71 | + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
| 65 | pp.title(MY_DEVICE_TITLE); | 72 | pp.title(MY_DEVICE_TITLE); |
| 66 | pp.removeProps(LATITUDE, LONGITUDE); | 73 | pp.removeProps(LATITUDE, LONGITUDE); |
| 67 | 74 | ... | ... |
| ... | @@ -33,6 +33,7 @@ import org.onosproject.mastership.MastershipEvent; | ... | @@ -33,6 +33,7 @@ import org.onosproject.mastership.MastershipEvent; |
| 33 | import org.onosproject.mastership.MastershipListener; | 33 | import org.onosproject.mastership.MastershipListener; |
| 34 | import org.onosproject.net.ConnectPoint; | 34 | import org.onosproject.net.ConnectPoint; |
| 35 | import org.onosproject.net.Device; | 35 | import org.onosproject.net.Device; |
| 36 | +import org.onosproject.net.DeviceId; | ||
| 36 | import org.onosproject.net.Host; | 37 | import org.onosproject.net.Host; |
| 37 | import org.onosproject.net.HostId; | 38 | import org.onosproject.net.HostId; |
| 38 | import org.onosproject.net.HostLocation; | 39 | import org.onosproject.net.HostLocation; |
| ... | @@ -344,11 +345,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -344,11 +345,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 344 | PropertyPanel pp = null; | 345 | PropertyPanel pp = null; |
| 345 | 346 | ||
| 346 | if (type.equals(DEVICE)) { | 347 | if (type.equals(DEVICE)) { |
| 347 | - pp = deviceDetails(deviceId(id), sid); | 348 | + DeviceId did = deviceId(id); |
| 348 | - overlayCache.currentOverlay().modifyDeviceDetails(pp); | 349 | + pp = deviceDetails(did, sid); |
| 350 | + overlayCache.currentOverlay().modifyDeviceDetails(pp, did); | ||
| 349 | } else if (type.equals(HOST)) { | 351 | } else if (type.equals(HOST)) { |
| 350 | - pp = hostDetails(hostId(id), sid); | 352 | + HostId hid = hostId(id); |
| 351 | - overlayCache.currentOverlay().modifyHostDetails(pp); | 353 | + pp = hostDetails(hid, sid); |
| 354 | + overlayCache.currentOverlay().modifyHostDetails(pp, hid); | ||
| 352 | } | 355 | } |
| 353 | 356 | ||
| 354 | sendMessage(envelope(SHOW_DETAILS, sid, json(pp))); | 357 | sendMessage(envelope(SHOW_DETAILS, sid, json(pp))); | ... | ... |
| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | ||
| 18 | package org.onosproject.ui.impl; | 18 | package org.onosproject.ui.impl; |
| 19 | 19 | ||
| 20 | +import org.onosproject.net.DeviceId; | ||
| 20 | import org.onosproject.ui.UiTopoOverlay; | 21 | import org.onosproject.ui.UiTopoOverlay; |
| 21 | import org.onosproject.ui.topo.ButtonId; | 22 | import org.onosproject.ui.topo.ButtonId; |
| 22 | import org.onosproject.ui.topo.PropertyPanel; | 23 | import org.onosproject.ui.topo.PropertyPanel; |
| ... | @@ -55,7 +56,7 @@ public class TrafficOverlay extends UiTopoOverlay { | ... | @@ -55,7 +56,7 @@ public class TrafficOverlay extends UiTopoOverlay { |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | @Override | 58 | @Override |
| 58 | - public void modifyDeviceDetails(PropertyPanel pp) { | 59 | + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
| 59 | pp.addButton(SHOW_DEVICE_FLOWS) | 60 | pp.addButton(SHOW_DEVICE_FLOWS) |
| 60 | .addButton(SHOW_RELATED_TRAFFIC); | 61 | .addButton(SHOW_RELATED_TRAFFIC); |
| 61 | } | 62 | } | ... | ... |
-
Please register or login to post a comment