Simon Hunt
Committed by Gerrit Code Review

GUI Topo -- Cleaned up NodeBadge, now that we have a clearer idea of what we want to model.

Change-Id: I754a94cbd1fbe2a2c8affccaca88c48c3fa33b92
...@@ -23,18 +23,15 @@ public final class NodeBadge { ...@@ -23,18 +23,15 @@ public final class NodeBadge {
23 23
24 private static final String EMPTY = ""; 24 private static final String EMPTY = "";
25 25
26 - /** Designates the type of badge. */ 26 + /** Designates the badge status. */
27 - public enum Type { 27 + public enum Status {
28 INFO("i"), 28 INFO("i"),
29 WARN("w"), 29 WARN("w"),
30 - ERROR("e"), 30 + ERROR("e");
31 - CHECK_MARK("/"),
32 - X_MARK("X"),
33 - NUMBER("n");
34 31
35 private String code; 32 private String code;
36 33
37 - Type(String code) { 34 + Status(String code) {
38 this.code = code; 35 this.code = code;
39 } 36 }
40 37
...@@ -43,33 +40,60 @@ public final class NodeBadge { ...@@ -43,33 +40,60 @@ public final class NodeBadge {
43 return "{" + code + "}"; 40 return "{" + code + "}";
44 } 41 }
45 42
46 - /** Returns the type's code in string form. */ 43 + /** Returns the status code in string form. */
47 public String code() { 44 public String code() {
48 return code; 45 return code;
49 } 46 }
50 } 47 }
51 48
52 - private final Type type; 49 + private final Status status;
50 + private final boolean isGlyph;
51 + private final String text;
53 private final String message; 52 private final String message;
54 53
55 // only instantiated through static methods. 54 // only instantiated through static methods.
56 - private NodeBadge(Type type, String message) { 55 + private NodeBadge(Status status, boolean isGlyph, String text, String message) {
57 - this.type = type; 56 + this.status = status == null ? Status.INFO : status;
57 + this.isGlyph = isGlyph;
58 + this.text = text;
58 this.message = message; 59 this.message = message;
59 } 60 }
60 61
61 @Override 62 @Override
62 public String toString() { 63 public String toString() {
63 - return "{Badge " + type + " \"" + message + "\"}"; 64 + return "{Badge " + status +
65 + " (" + text + ")" +
66 + (isGlyph ? "*G " : " ") +
67 + "\"" + message + "\"}";
64 } 68 }
65 69
66 /** 70 /**
67 - * Returns the badge type. 71 + * Returns the badge status.
68 * 72 *
69 - * @return badge type 73 + * @return badge status
70 */ 74 */
71 - public Type type() { 75 + public Status status() {
72 - return type; 76 + return status;
77 + }
78 +
79 + /**
80 + * Returns true if the text for this badge designates a glyph ID.
81 + *
82 + * @return true if badge uses glyph
83 + */
84 + public boolean isGlyph() {
85 + return isGlyph;
86 + }
87 +
88 + /**
89 + * Returns the text for the badge.
90 + * Note that if {@link #isGlyph} is true, the text is a glyph ID, otherwise
91 + * the text is displayed verbatim in the badge.
92 + *
93 + * @return text for badge
94 + */
95 + public String text() {
96 + return text;
73 } 97 }
74 98
75 /** 99 /**
...@@ -86,64 +110,111 @@ public final class NodeBadge { ...@@ -86,64 +110,111 @@ public final class NodeBadge {
86 } 110 }
87 111
88 /** 112 /**
89 - * Returns an informational badge, with associated message. 113 + * Returns an arbitrary text badge, with default status.
90 * 114 *
91 - * @param message the message 115 + * @param txt the text
92 - * @return INFO type node badge 116 + * @return node badge to display text
93 */ 117 */
94 - public static NodeBadge info(String message) { 118 + public static NodeBadge text(String txt) {
95 - return new NodeBadge(Type.INFO, nonNull(message)); 119 + // TODO: consider length constraint on txt (3 chars?)
120 + return new NodeBadge(Status.INFO, false, nonNull(txt), null);
96 } 121 }
97 122
98 /** 123 /**
99 - * Returns a warning badge, with associated message. 124 + * Returns a glyph badge, with default status.
100 * 125 *
101 - * @param message the message 126 + * @param gid the glyph ID
102 - * @return WARN type node badge 127 + * @return node badge to display glyph
103 */ 128 */
104 - public static NodeBadge warn(String message) { 129 + public static NodeBadge glyph(String gid) {
105 - return new NodeBadge(Type.WARN, nonNull(message)); 130 + return new NodeBadge(Status.INFO, true, nonNull(gid), null);
106 } 131 }
107 132
108 /** 133 /**
109 - * Returns an error badge, with associated message. 134 + * Returns a numeric badge, with default status.
110 * 135 *
111 - * @param message the message 136 + * @param n the number
112 - * @return ERROR type node badge 137 + * @return node badge to display a number
113 */ 138 */
114 - public static NodeBadge error(String message) { 139 + public static NodeBadge number(int n) {
115 - return new NodeBadge(Type.ERROR, nonNull(message)); 140 + // TODO: consider constraints, e.g. 1 <= n <= 999
141 + return new NodeBadge(Status.INFO, false, Integer.toString(n), null);
116 } 142 }
117 143
118 /** 144 /**
119 - * Returns a check-mark badge, with associated message. 145 + * Returns an arbitrary text badge, with the given status.
120 * 146 *
121 - * @param message the message 147 + * @param s the status
122 - * @return CHECK_MARK type node badge 148 + * @param txt the text
149 + * @return node badge to display text
123 */ 150 */
124 - public static NodeBadge checkMark(String message) { 151 + public static NodeBadge text(Status s, String txt) {
125 - return new NodeBadge(Type.CHECK_MARK, nonNull(message)); 152 + // TODO: consider length constraint on txt (3 chars?)
153 + return new NodeBadge(s, false, nonNull(txt), null);
126 } 154 }
127 155
128 /** 156 /**
129 - * Returns an X-mark badge, with associated message. 157 + * Returns a glyph badge, with the given status.
130 * 158 *
131 - * @param message the message 159 + * @param s the status
132 - * @return X_MARK type node badge 160 + * @param gid the glyph ID
161 + * @return node badge to display glyph
133 */ 162 */
134 - public static NodeBadge xMark(String message) { 163 + public static NodeBadge glyph(Status s, String gid) {
135 - return new NodeBadge(Type.X_MARK, nonNull(message)); 164 + return new NodeBadge(s, true, nonNull(gid), null);
136 } 165 }
137 166
167 +
138 /** 168 /**
139 - * Returns a numeric badge. 169 + * Returns a numeric badge, with the given status and optional message.
140 * 170 *
171 + * @param s the status
141 * @param n the number 172 * @param n the number
142 - * @return NUMBER type node badge 173 + * @return node badge to display a number
143 */ 174 */
144 - public static NodeBadge number(int n) { 175 + public static NodeBadge number(Status s, int n) {
145 - // TODO: consider constraints, e.g. 1 <= n <= 99 176 + // TODO: consider constraints, e.g. 1 <= n <= 999
146 - return new NodeBadge(Type.NUMBER, Integer.toString(n)); 177 + return new NodeBadge(s, false, Integer.toString(n), null);
178 + }
179 +
180 + /**
181 + * Returns an arbitrary text badge, with the given status and optional
182 + * message.
183 + *
184 + * @param s the status
185 + * @param txt the text
186 + * @param msg the optional message
187 + * @return node badge to display text
188 + */
189 + public static NodeBadge text(Status s, String txt, String msg) {
190 + // TODO: consider length constraint on txt (3 chars?)
191 + return new NodeBadge(s, false, nonNull(txt), msg);
192 + }
193 +
194 + /**
195 + * Returns a glyph badge, with the given status and optional message.
196 + *
197 + * @param s the status
198 + * @param gid the glyph ID
199 + * @param msg the optional message
200 + * @return node badge to display glyph
201 + */
202 + public static NodeBadge glyph(Status s, String gid, String msg) {
203 + return new NodeBadge(s, true, nonNull(gid), msg);
204 + }
205 +
206 +
207 + /**
208 + * Returns a numeric badge, with the given status and optional message.
209 + *
210 + * @param s the status
211 + * @param n the number
212 + * @param msg the optional message
213 + * @return node badge to display a number
214 + */
215 + public static NodeBadge number(Status s, int n, String msg) {
216 + // TODO: consider constraints, e.g. 1 <= n <= 999
217 + return new NodeBadge(s, false, Integer.toString(n), msg);
147 } 218 }
148 219
149 } 220 }
......
...@@ -38,6 +38,9 @@ public final class TopoJson { ...@@ -38,6 +38,9 @@ public final class TopoJson {
38 static final String LABEL = "label"; 38 static final String LABEL = "label";
39 static final String CSS = "css"; 39 static final String CSS = "css";
40 static final String BADGE = "badge"; 40 static final String BADGE = "badge";
41 + static final String STATUS = "status";
42 + static final String TXT = "txt";
43 + static final String GID = "gid";
41 static final String MSG = "msg"; 44 static final String MSG = "msg";
42 45
43 static final String TITLE = "title"; 46 static final String TITLE = "title";
...@@ -99,6 +102,16 @@ public final class TopoJson { ...@@ -99,6 +102,16 @@ public final class TopoJson {
99 return payload; 102 return payload;
100 } 103 }
101 104
105 + private static ObjectNode json(NodeBadge b) {
106 + ObjectNode n = objectNode()
107 + .put(STATUS, b.status().code())
108 + .put(b.isGlyph() ? GID : TXT, b.text());
109 + if (b.message() != null) {
110 + n.put(MSG, b.message());
111 + }
112 + return n;
113 + }
114 +
102 private static ObjectNode json(DeviceHighlight dh) { 115 private static ObjectNode json(DeviceHighlight dh) {
103 ObjectNode n = objectNode() 116 ObjectNode n = objectNode()
104 .put(ID, dh.elementId()); 117 .put(ID, dh.elementId());
...@@ -107,10 +120,7 @@ public final class TopoJson { ...@@ -107,10 +120,7 @@ public final class TopoJson {
107 } 120 }
108 NodeBadge badge = dh.badge(); 121 NodeBadge badge = dh.badge();
109 if (badge != null) { 122 if (badge != null) {
110 - ObjectNode b = objectNode() 123 + n.set(BADGE, json(badge));
111 - .put(TYPE, badge.type().code())
112 - .put(MSG, badge.message());
113 - n.set(BADGE, b);
114 } 124 }
115 return n; 125 return n;
116 } 126 }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 package org.onosproject.ui.topo; 17 package org.onosproject.ui.topo;
18 18
19 import org.junit.Test; 19 import org.junit.Test;
20 +import org.onosproject.ui.topo.NodeBadge.Status;
20 21
21 import static org.junit.Assert.assertEquals; 22 import static org.junit.Assert.assertEquals;
22 23
...@@ -25,92 +26,87 @@ import static org.junit.Assert.assertEquals; ...@@ -25,92 +26,87 @@ import static org.junit.Assert.assertEquals;
25 */ 26 */
26 public class NodeBadgeTest { 27 public class NodeBadgeTest {
27 28
28 - private static final String SOME_MSG = "a msg"; 29 + private static final String MSG = "a msg";
29 - private static final String WR_T = "wrong type"; 30 + private static final String TXT = "text";
31 + private static final String GID = "glyph-id";
32 + private static final int NUM = 42;
33 + private static final String NUM_STR = Integer.toString(NUM);
34 +
35 + private static final String WR_S = "wrong status";
36 + private static final String WR_B = "wrong boolean";
37 + private static final String WR_T = "wrong text";
30 private static final String WR_M = "wrong message"; 38 private static final String WR_M = "wrong message";
31 private static final String WR_SF = "wrong string format"; 39 private static final String WR_SF = "wrong string format";
32 40
33 private NodeBadge badge; 41 private NodeBadge badge;
34 42
35 - private String expStr(String t) { 43 + private void checkFields(NodeBadge b, Status s, boolean g,
36 - return "{Badge {" + t + "} \"" + SOME_MSG + "\"}"; 44 + String txt, String msg) {
45 + assertEquals(WR_S, s, b.status());
46 + assertEquals(WR_B, g, b.isGlyph());
47 + assertEquals(WR_T, txt, b.text());
48 + assertEquals(WR_M, msg, b.message());
37 } 49 }
38 50
39 - private String expNumStr(String n) { 51 + @Test
40 - return "{Badge {n} \"" + n + "\"}"; 52 + public void badgeTypes() {
53 + assertEquals(WR_SF, "i", Status.INFO.code());
54 + assertEquals(WR_SF, "w", Status.WARN.code());
55 + assertEquals(WR_SF, "e", Status.ERROR.code());
56 + assertEquals("unexpected size", 3, Status.values().length);
41 } 57 }
42 58
43 @Test 59 @Test
44 - public void info() { 60 + public void textOnly() {
45 - badge = NodeBadge.info(SOME_MSG); 61 + badge = NodeBadge.text(TXT);
46 - assertEquals(WR_T, NodeBadge.Type.INFO, badge.type()); 62 + checkFields(badge, Status.INFO, false, TXT, null);
47 - assertEquals(WR_M, SOME_MSG, badge.message());
48 - assertEquals(WR_SF, expStr("i"), badge.toString());
49 } 63 }
50 64
51 @Test 65 @Test
52 - public void warn() { 66 + public void glyphOnly() {
53 - badge = NodeBadge.warn(SOME_MSG); 67 + badge = NodeBadge.glyph(GID);
54 - assertEquals(WR_T, NodeBadge.Type.WARN, badge.type()); 68 + checkFields(badge, Status.INFO, true, GID, null);
55 - assertEquals(WR_M, SOME_MSG, badge.message());
56 - assertEquals(WR_SF, expStr("w"), badge.toString());
57 } 69 }
58 70
59 @Test 71 @Test
60 - public void error() { 72 + public void numberOnly() {
61 - badge = NodeBadge.error(SOME_MSG); 73 + badge = NodeBadge.number(NUM);
62 - assertEquals(WR_T, NodeBadge.Type.ERROR, badge.type()); 74 + checkFields(badge, Status.INFO, false, NUM_STR, null);
63 - assertEquals(WR_M, SOME_MSG, badge.message());
64 - assertEquals(WR_SF, expStr("e"), badge.toString());
65 } 75 }
66 76
67 @Test 77 @Test
68 - public void checkMark() { 78 + public void textInfo() {
69 - badge = NodeBadge.checkMark(SOME_MSG); 79 + badge = NodeBadge.text(Status.INFO, TXT);
70 - assertEquals(WR_T, NodeBadge.Type.CHECK_MARK, badge.type()); 80 + checkFields(badge, Status.INFO, false, TXT, null);
71 - assertEquals(WR_M, SOME_MSG, badge.message());
72 - assertEquals(WR_SF, expStr("/"), badge.toString());
73 } 81 }
74 82
75 @Test 83 @Test
76 - public void xMark() { 84 + public void glyphWarn() {
77 - badge = NodeBadge.xMark(SOME_MSG); 85 + badge = NodeBadge.glyph(Status.WARN, GID);
78 - assertEquals(WR_T, NodeBadge.Type.X_MARK, badge.type()); 86 + checkFields(badge, Status.WARN, true, GID, null);
79 - assertEquals(WR_M, SOME_MSG, badge.message());
80 - assertEquals(WR_SF, expStr("X"), badge.toString());
81 } 87 }
82 88
83 @Test 89 @Test
84 - public void number0() { 90 + public void numberError() {
85 - badge = NodeBadge.number(0); 91 + badge = NodeBadge.number(Status.ERROR, NUM);
86 - assertEquals(WR_T, NodeBadge.Type.NUMBER, badge.type()); 92 + checkFields(badge, Status.ERROR, false, NUM_STR, null);
87 - assertEquals(WR_M, "0", badge.message());
88 - assertEquals(WR_SF, expNumStr("0"), badge.toString());
89 } 93 }
90 94
91 @Test 95 @Test
92 - public void number5() { 96 + public void textInfoMsg() {
93 - badge = NodeBadge.number(5); 97 + badge = NodeBadge.text(Status.INFO, TXT, MSG);
94 - assertEquals(WR_T, NodeBadge.Type.NUMBER, badge.type()); 98 + checkFields(badge, Status.INFO, false, TXT, MSG);
95 - assertEquals(WR_M, "5", badge.message());
96 - assertEquals(WR_SF, expNumStr("5"), badge.toString());
97 } 99 }
98 100
99 @Test 101 @Test
100 - public void number99() { 102 + public void glyphWarnMsg() {
101 - badge = NodeBadge.number(99); 103 + badge = NodeBadge.glyph(Status.WARN, GID, MSG);
102 - assertEquals(WR_T, NodeBadge.Type.NUMBER, badge.type()); 104 + checkFields(badge, Status.WARN, true, GID, MSG);
103 - assertEquals(WR_M, "99", badge.message());
104 - assertEquals(WR_SF, expNumStr("99"), badge.toString());
105 } 105 }
106 106
107 @Test 107 @Test
108 - public void badgeTypes() { 108 + public void numberErrorMsg() {
109 - assertEquals(WR_SF, "i", NodeBadge.Type.INFO.code()); 109 + badge = NodeBadge.number(Status.ERROR, NUM, MSG);
110 - assertEquals(WR_SF, "w", NodeBadge.Type.WARN.code()); 110 + checkFields(badge, Status.ERROR, false, NUM_STR, MSG);
111 - assertEquals(WR_SF, "e", NodeBadge.Type.ERROR.code());
112 - assertEquals(WR_SF, "/", NodeBadge.Type.CHECK_MARK.code());
113 - assertEquals(WR_SF, "X", NodeBadge.Type.X_MARK.code());
114 - assertEquals(WR_SF, "n", NodeBadge.Type.NUMBER.code());
115 } 111 }
116 } 112 }
......
...@@ -21,9 +21,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -21,9 +21,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
21 import org.junit.Test; 21 import org.junit.Test;
22 import org.onosproject.ui.JsonUtils; 22 import org.onosproject.ui.JsonUtils;
23 import org.onosproject.ui.topo.Highlights.Amount; 23 import org.onosproject.ui.topo.Highlights.Amount;
24 +import org.onosproject.ui.topo.NodeBadge.Status;
24 25
25 import static org.junit.Assert.assertEquals; 26 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull; 27 import static org.junit.Assert.assertNotNull;
28 +import static org.junit.Assert.assertNull;
27 29
28 /** 30 /**
29 * Unit tests for {@link TopoJson}. 31 * Unit tests for {@link TopoJson}.
...@@ -32,7 +34,8 @@ public class TopoJsonTest { ...@@ -32,7 +34,8 @@ public class TopoJsonTest {
32 34
33 private static final String DEV1 = "device-1"; 35 private static final String DEV1 = "device-1";
34 private static final String DEV2 = "device-2"; 36 private static final String DEV2 = "device-2";
35 - private static final String BADGE_MSG = "Hello there"; 37 + private static final String SOME_MSG = "Hello there";
38 + private static final String GID = "glyph-ID";
36 39
37 private ObjectNode payload; 40 private ObjectNode payload;
38 41
...@@ -78,15 +81,15 @@ public class TopoJsonTest { ...@@ -78,15 +81,15 @@ public class TopoJsonTest {
78 public void badgedDevice() { 81 public void badgedDevice() {
79 Highlights h = new Highlights(); 82 Highlights h = new Highlights();
80 DeviceHighlight dh = new DeviceHighlight(DEV1); 83 DeviceHighlight dh = new DeviceHighlight(DEV1);
81 - dh.setBadge(NodeBadge.info(BADGE_MSG)); 84 + dh.setBadge(NodeBadge.number(7));
82 h.add(dh); 85 h.add(dh);
83 86
84 dh = new DeviceHighlight(DEV2); 87 dh = new DeviceHighlight(DEV2);
85 - dh.setBadge(NodeBadge.number(7)); 88 + dh.setBadge(NodeBadge.glyph(Status.WARN, GID, SOME_MSG));
86 h.add(dh); 89 h.add(dh);
87 90
88 payload = TopoJson.json(h); 91 payload = TopoJson.json(h);
89 - System.out.println(payload); 92 +// System.out.println(payload);
90 93
91 // dig into the payload, and verify the badges are set on the devices 94 // dig into the payload, and verify the badges are set on the devices
92 ArrayNode a = (ArrayNode) payload.get(TopoJson.DEVICES); 95 ArrayNode a = (ArrayNode) payload.get(TopoJson.DEVICES);
...@@ -96,15 +99,19 @@ public class TopoJsonTest { ...@@ -96,15 +99,19 @@ public class TopoJsonTest {
96 99
97 ObjectNode b = (ObjectNode) d.get(TopoJson.BADGE); 100 ObjectNode b = (ObjectNode) d.get(TopoJson.BADGE);
98 assertNotNull("missing badge", b); 101 assertNotNull("missing badge", b);
99 - assertEquals("wrong type code", "i", b.get(TopoJson.TYPE).asText()); 102 + assertEquals("wrong status code", "i", b.get(TopoJson.STATUS).asText());
100 - assertEquals("wrong message", BADGE_MSG, b.get(TopoJson.MSG).asText()); 103 + assertEquals("wrong text", "7", b.get(TopoJson.TXT).asText());
104 + assertNull("glyph?", b.get(TopoJson.GID));
105 + assertNull("msg?", b.get(TopoJson.MSG));
101 106
102 d = (ObjectNode) a.get(1); 107 d = (ObjectNode) a.get(1);
103 assertEquals("wrong device id", DEV2, d.get(TopoJson.ID).asText()); 108 assertEquals("wrong device id", DEV2, d.get(TopoJson.ID).asText());
104 109
105 b = (ObjectNode) d.get(TopoJson.BADGE); 110 b = (ObjectNode) d.get(TopoJson.BADGE);
106 assertNotNull("missing badge", b); 111 assertNotNull("missing badge", b);
107 - assertEquals("wrong type code", "n", b.get(TopoJson.TYPE).asText()); 112 + assertEquals("wrong status code", "w", b.get(TopoJson.STATUS).asText());
108 - assertEquals("wrong message", "7", b.get(TopoJson.MSG).asText()); 113 + assertNull("text?", b.get(TopoJson.TXT));
114 + assertEquals("wrong text", GID, b.get(TopoJson.GID).asText());
115 + assertEquals("wrong message", SOME_MSG, b.get(TopoJson.MSG).asText());
109 } 116 }
110 } 117 }
......
...@@ -218,6 +218,24 @@ ...@@ -218,6 +218,24 @@
218 .attr('transform', sus.translate(dx, dy)); 218 .attr('transform', sus.translate(dx, dy));
219 } 219 }
220 220
221 + function updateDeviceBadge(d) {
222 + // TODO: Fix this WIP
223 + var node = d.el,
224 + bsel;
225 +
226 + if (d.badge) {
227 + bsel = node.append('g')
228 + .classed('badge', true)
229 + .attr('transform', sus.translate(-14, -14));
230 +
231 + bsel.append('circle')
232 + .attr('r', 14);
233 + bsel.append('text')
234 + .attr('transform', sus.translate(-5, 3))
235 + .text('42');
236 + }
237 + }
238 +
221 function updateHostLabel(d) { 239 function updateHostLabel(d) {
222 var label = trimLabel(hostLabel(d)); 240 var label = trimLabel(hostLabel(d));
223 d.el.select('text').text(label); 241 d.el.select('text').text(label);
...@@ -241,6 +259,7 @@ ...@@ -241,6 +259,7 @@
241 var node = d.el; 259 var node = d.el;
242 node.classed('online', d.online); 260 node.classed('online', d.online);
243 updateDeviceLabel(d); 261 updateDeviceLabel(d);
262 + updateDeviceBadge(d);
244 api.posNode(d, true); 263 api.posNode(d, true);
245 } 264 }
246 265
......
...@@ -860,6 +860,16 @@ ...@@ -860,6 +860,16 @@
860 }); 860 });
861 } 861 }
862 862
863 + function clearNodeDeco() {
864 + node.selectAll('g.badge').remove();
865 + }
866 +
867 + function removeNodeBadges() {
868 + network.nodes.forEach(function (d) {
869 + d.badge = null;
870 + });
871 + }
872 +
863 function updateLinkLabelModel() { 873 function updateLinkLabelModel() {
864 // create the backing data for showing labels.. 874 // create the backing data for showing labels..
865 var data = []; 875 var data = [];
...@@ -923,6 +933,8 @@ ...@@ -923,6 +933,8 @@
923 933
924 function mkOverlayApi() { 934 function mkOverlayApi() {
925 return { 935 return {
936 + clearNodeDeco: clearNodeDeco,
937 + removeNodeBadges: removeNodeBadges,
926 clearLinkTrafficStyle: clearLinkTrafficStyle, 938 clearLinkTrafficStyle: clearLinkTrafficStyle,
927 removeLinkLabels: removeLinkLabels, 939 removeLinkLabels: removeLinkLabels,
928 findLinkById: tms.findLinkById, 940 findLinkById: tms.findLinkById,
......
...@@ -294,7 +294,8 @@ ...@@ -294,7 +294,8 @@
294 unsupLink( key, [less] ) 294 unsupLink( key, [less] )
295 */ 295 */
296 296
297 - // TODO: clear node highlighting 297 + api.clearNodeDeco();
298 + api.removeNodeBadges();
298 api.clearLinkTrafficStyle(); 299 api.clearLinkTrafficStyle();
299 api.removeLinkLabels(); 300 api.removeLinkLabels();
300 301
...@@ -319,8 +320,11 @@ ...@@ -319,8 +320,11 @@
319 }); 320 });
320 321
321 data.devices.forEach(function (device) { 322 data.devices.forEach(function (device) {
322 - var ddata = api.findNodeById(device.id); 323 + var ddata = api.findNodeById(device.id),
324 + badgeData = device.badge || null;
325 +
323 if (ddata && !ddata.el.empty()) { 326 if (ddata && !ddata.el.empty()) {
327 + ddata.badge = badgeData;
324 if (!device.subdue) { 328 if (!device.subdue) {
325 api.unsupNode(ddata.id, less); 329 api.unsupNode(ddata.id, less);
326 } 330 }
......
1 { 1 {
2 "event": "showHighlights", 2 "event": "showHighlights",
3 "payload": { 3 "payload": {
4 - "devices": [], 4 + "devices": [
5 + {
6 + "id": "of:0000000000000001",
7 + "badge": {
8 + "status": "e",
9 + "gid": "xMark",
10 + "msg": "x marks the spot"
11 + }
12 + },
13 + {
14 + "id": "of:0000000000000002",
15 + "badge": {
16 + "status": "w",
17 + "txt": "7"
18 + }
19 + }
20 + ],
5 "hosts": [], 21 "hosts": [],
6 "links": [ 22 "links": [
7 { 23 {
......