Mahesh Raju-Huawei
Committed by Gerrit Code Review

[ONOS-4159] PCE Web GUI implementation:src and dst glymphs optimization

Change-Id: I6fb0cfb15a8a88590c69dccdf61ff02537769890
(cherry picked from commit 34ffe4b6)
...@@ -109,8 +109,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -109,8 +109,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
109 private Set<Link> allPathLinks; 109 private Set<Link> allPathLinks;
110 private int highlightDelay; 110 private int highlightDelay;
111 private ElementId src, dst; 111 private ElementId src, dst;
112 - private String srcType, dstType; 112 + private List<Path> paths = new LinkedList<>();
113 - private List<Path> paths;
114 private int pathIndex; 113 private int pathIndex;
115 114
116 private final Logger log = LoggerFactory.getLogger(getClass()); 115 private final Logger log = LoggerFactory.getLogger(getClass());
...@@ -137,8 +136,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -137,8 +136,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
137 protected Collection<RequestHandler> createRequestHandlers() { 136 protected Collection<RequestHandler> createRequestHandlers() {
138 return ImmutableSet.of( 137 return ImmutableSet.of(
139 new ClearHandler(), 138 new ClearHandler(),
140 - new SetSrcHandler(),
141 - new SetDstHandler(),
142 new SetPathHandler(), 139 new SetPathHandler(),
143 new UpdatePathQueryHandler(), 140 new UpdatePathQueryHandler(),
144 new UpdatePathHandler(), 141 new UpdatePathHandler(),
...@@ -173,51 +170,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -173,51 +170,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
173 } 170 }
174 171
175 /** 172 /**
176 - * Handles the 'set source' event received from the client.
177 - */
178 - private final class SetSrcHandler extends RequestHandler {
179 -
180 - public SetSrcHandler() {
181 - super(PCEWEB_SET_SRC);
182 - }
183 -
184 - @Override
185 - public void process(long sid, ObjectNode payload) {
186 - String id = string(payload, ID);
187 - src = elementId(id);
188 - srcType = string(payload, TYPE);
189 - if (src.equals(dst)) {
190 - dst = null;
191 - }
192 - sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(),
193 - srcType, src.toString(), SRC)));
194 - }
195 - }
196 -
197 - /**
198 - * Handles the 'set destination' event received from the client.
199 - */
200 - private final class SetDstHandler extends RequestHandler {
201 -
202 - public SetDstHandler() {
203 - super(PCEWEB_SET_DST);
204 - }
205 -
206 - @Override
207 - public void process(long sid, ObjectNode payload) {
208 - String id = string(payload, ID);
209 - dst = elementId(id);
210 - dstType = string(payload, TYPE);
211 - if (src.equals(dst)) {
212 - src = null;
213 - }
214 - sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(),
215 - dstType, dst.toString(), DST)));
216 -
217 - }
218 - }
219 -
220 - /**
221 * Handles the 'path calculation' event received from the client. 173 * Handles the 'path calculation' event received from the client.
222 */ 174 */
223 private final class SetPathHandler extends RequestHandler { 175 private final class SetPathHandler extends RequestHandler {
...@@ -228,6 +180,14 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -228,6 +180,14 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
228 180
229 @Override 181 @Override
230 public void process(long sid, ObjectNode payload) { 182 public void process(long sid, ObjectNode payload) {
183 + String srcId = string(payload, SRCID);
184 + src = elementId(srcId);
185 + String dstId = string(payload, DSTID);
186 + dst = elementId(dstId);
187 + if (src.equals(dst)) {
188 + src = null;
189 + }
190 +
231 String bandWidth = string(payload, BANDWIDTH); 191 String bandWidth = string(payload, BANDWIDTH);
232 String bandWidthType = string(payload, BANDWIDTHTYPE); 192 String bandWidthType = string(payload, BANDWIDTHTYPE);
233 String costType = string(payload, COSTTYPE); 193 String costType = string(payload, COSTTYPE);
...@@ -555,7 +515,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -555,7 +515,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
555 /** 515 /**
556 * Handles the highlights of selected path. 516 * Handles the highlights of selected path.
557 */ 517 */
558 - private void hilightAndSendPaths() { 518 + private void hilightAndSendPaths(Highlights highlights) {
559 PceWebLinkMap linkMap = new PceWebLinkMap(); 519 PceWebLinkMap linkMap = new PceWebLinkMap();
560 allPathLinks.forEach(linkMap::add); 520 allPathLinks.forEach(linkMap::add);
561 Set<Link> selectedPathLinks; 521 Set<Link> selectedPathLinks;
...@@ -563,7 +523,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -563,7 +523,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
563 selectedPathLinks = paths.isEmpty() ? 523 selectedPathLinks = paths.isEmpty() ?
564 ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links()); 524 ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links());
565 525
566 - Highlights highlights = new Highlights();
567 if (highlightDelay > 0) { 526 if (highlightDelay > 0) {
568 highlights.delay(highlightDelay); 527 highlights.delay(highlightDelay);
569 } 528 }
...@@ -571,12 +530,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -571,12 +530,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
571 plink.computeHilight(selectedPathLinks, allPathLinks); 530 plink.computeHilight(selectedPathLinks, allPathLinks);
572 highlights.add(plink.highlight(null)); 531 highlights.add(plink.highlight(null));
573 } 532 }
574 - if (src != null) {
575 - highlights = addBadge(highlights, srcType, src.toString(), SRC);
576 - }
577 - if (dst != null) {
578 - highlights = addBadge(highlights, dstType, dst.toString(), DST);
579 - }
580 sendMessage(TopoJson.highlightsMessage(highlights)); 533 sendMessage(TopoJson.highlightsMessage(highlights));
581 } 534 }
582 535
...@@ -584,17 +537,13 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -584,17 +537,13 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
584 * Handles the addition of badge and highlights. 537 * Handles the addition of badge and highlights.
585 * 538 *
586 * @param highlights highlights 539 * @param highlights highlights
587 - * @param type device type
588 * @param elemId device to be add badge 540 * @param elemId device to be add badge
589 * @param src device to be add badge 541 * @param src device to be add badge
590 * @return 542 * @return
591 */ 543 */
592 - private Highlights addBadge(Highlights highlights, String type, 544 + private Highlights addBadge(Highlights highlights,
593 String elemId, String src) { 545 String elemId, String src) {
594 - if (ROUTER.equals(type)) { 546 + highlights = addDeviceBadge(highlights, elemId, src);
595 - highlights = addDeviceBadge(highlights, elemId, src);
596 - }
597 -
598 return highlights; 547 return highlights;
599 } 548 }
600 549
...@@ -603,7 +552,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -603,7 +552,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
603 * 552 *
604 * @param h highlights 553 * @param h highlights
605 * @param elemId device to be add badge 554 * @param elemId device to be add badge
606 - * @param type device type 555 + * @param type device badge value
607 * @return highlights 556 * @return highlights
608 */ 557 */
609 private Highlights addDeviceBadge(Highlights h, String elemId, String type) { 558 private Highlights addDeviceBadge(Highlights h, String elemId, String type) {
...@@ -616,7 +565,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -616,7 +565,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
616 /** 565 /**
617 * Handles the node badge add and highlights. 566 * Handles the node badge add and highlights.
618 * 567 *
619 - * @param type device type 568 + * @param type device badge value
620 * @return badge of given node 569 * @return badge of given node
621 */ 570 */
622 private NodeBadge createBadge(String type) { 571 private NodeBadge createBadge(String type) {
...@@ -656,21 +605,35 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -656,21 +605,35 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
656 private void findTunnelAndHighlights() { 605 private void findTunnelAndHighlights() {
657 Collection<Tunnel> tunnelSet = null; 606 Collection<Tunnel> tunnelSet = null;
658 tunnelSet = tunnelService.queryTunnel(MPLS); 607 tunnelSet = tunnelService.queryTunnel(MPLS);
608 + if (tunnelSet.size() == 0) {
609 + log.warn("Tunnel does not exist");
610 + return;
611 + }
612 +
613 + paths.removeAll(paths);
614 + Highlights highlights = new Highlights();
659 for (Tunnel tunnel : tunnelSet) { 615 for (Tunnel tunnel : tunnelSet) {
660 if (tunnel.path() == null) { 616 if (tunnel.path() == null) {
661 log.error("path does not exist"); 617 log.error("path does not exist");
662 return; 618 return;
663 } 619 }
620 + Link firstLink = tunnel.path().links().get(0);
621 + if (firstLink != null) {
622 + if (firstLink.src() != null) {
623 + highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC);
624 + }
625 + }
626 + Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1);
627 + if (lastLink != null) {
628 + if (lastLink.dst() != null) {
629 + highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST);
630 + }
631 + }
664 paths.add(tunnel.path()); 632 paths.add(tunnel.path());
665 } 633 }
666 634
667 - if (tunnelSet.size() == 0) {
668 - log.warn("Tunnel does not exist");
669 - return;
670 - }
671 -
672 ImmutableSet.Builder<Link> builder = ImmutableSet.builder(); 635 ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
673 allPathLinks = buildPaths(builder).build(); 636 allPathLinks = buildPaths(builder).build();
674 - hilightAndSendPaths(); 637 + hilightAndSendPaths(highlights);
675 } 638 }
676 } 639 }
......
...@@ -28,9 +28,7 @@ import org.onosproject.net.Device; ...@@ -28,9 +28,7 @@ import org.onosproject.net.Device;
28 import org.onosproject.net.DeviceId; 28 import org.onosproject.net.DeviceId;
29 import org.onosproject.net.Link; 29 import org.onosproject.net.Link;
30 import org.onosproject.ui.UiTopoOverlay; 30 import org.onosproject.ui.UiTopoOverlay;
31 -import org.onosproject.ui.topo.ButtonId;
32 import org.onosproject.ui.topo.PropertyPanel; 31 import org.onosproject.ui.topo.PropertyPanel;
33 -import org.onosproject.net.HostId;
34 import org.onosproject.net.device.DeviceService; 32 import org.onosproject.net.device.DeviceService;
35 import org.onosproject.net.link.LinkEvent; 33 import org.onosproject.net.link.LinkEvent;
36 import org.onosproject.net.resource.ContinuousResource; 34 import org.onosproject.net.resource.ContinuousResource;
...@@ -56,8 +54,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -56,8 +54,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
56 public static final String ASBR_BIT = "externalBit"; 54 public static final String ASBR_BIT = "externalBit";
57 public static final String TE_METRIC = "teCost"; 55 public static final String TE_METRIC = "teCost";
58 56
59 - private static final ButtonId SRC_BUTTON = new ButtonId("src");
60 - private static final ButtonId DST_BUTTON = new ButtonId("dst");
61 /** 57 /**
62 * Initialize the overlay ID. 58 * Initialize the overlay ID.
63 */ 59 */
...@@ -80,8 +76,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -80,8 +76,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
80 76
81 pp.removeAllProps(); 77 pp.removeAllProps();
82 78
83 - pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
84 -
85 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW) 79 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
86 .removeButtons(CoreButtons.SHOW_GROUP_VIEW) 80 .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
87 .removeButtons(CoreButtons.SHOW_METER_VIEW); 81 .removeButtons(CoreButtons.SHOW_METER_VIEW);
...@@ -156,9 +150,4 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -156,9 +150,4 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
156 150
157 return map; 151 return map;
158 } 152 }
159 -
160 - @Override
161 - public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
162 - pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
163 - }
164 } 153 }
......
1 -/* css for sample app topology overlay */
...\ No newline at end of file ...\ No newline at end of file
1 +/* css for PCE web app topology overlay */
2 +.radioButtonSpace {
3 + margin-left:20px;
4 +}
......
...@@ -75,11 +75,21 @@ ...@@ -75,11 +75,21 @@
75 p = form.append('p'); 75 p = form.append('p');
76 76
77 function addAttribute(name, id, nameField, type) { 77 function addAttribute(name, id, nameField, type) {
78 - p.append('input').attr({ 78 + if (type == 'radio') {
79 - type: type, 79 + p.append('input').attr({
80 - name: name, 80 + type: type,
81 - id: id 81 + name: name,
82 - }); 82 + id: id,
83 + class: 'radioButtonSpace'
84 + });
85 + } else {
86 + p.append('input').attr({
87 + type: type,
88 + name: name,
89 + id: id
90 + });
91 + }
92 +
83 93
84 p.append('span').text(nameField); 94 p.append('span').text(nameField);
85 p.append('br'); 95 p.append('br');
...@@ -135,11 +145,21 @@ ...@@ -135,11 +145,21 @@
135 p = form.append('p'); 145 p = form.append('p');
136 146
137 function addAttribute(name, id, nameField, type) { 147 function addAttribute(name, id, nameField, type) {
138 - p.append('input').attr({ 148 + if (type == 'radio') {
139 - type: type, 149 + p.append('input').attr({
140 - name: name, 150 + type: type,
141 - id: id 151 + name: name,
142 - }); 152 + id: id,
153 + class: 'radioButtonSpace'
154 + });
155 + }
156 + else {
157 + p.append('input').attr({
158 + type: type,
159 + name: name,
160 + id: id
161 + });
162 + }
143 163
144 p.append('span').text(nameField); 164 p.append('span').text(nameField);
145 p.append('br'); 165 p.append('br');
...@@ -278,7 +298,7 @@ ...@@ -278,7 +298,7 @@
278 } 298 }
279 299
280 //setup path 300 //setup path
281 - function setMode() { 301 + function setMode(node) {
282 302
283 function dOk() { 303 function dOk() {
284 var bandWidth = isChecked('band-width-box'), 304 var bandWidth = isChecked('band-width-box'),
...@@ -320,6 +340,8 @@ ...@@ -320,6 +340,8 @@
320 } 340 }
321 341
322 wss.sendEvent(setPathmsg, { 342 wss.sendEvent(setPathmsg, {
343 + srid: node[0],
344 + dsid: node[1],
323 bw: bandValue, 345 bw: bandValue,
324 bwtype: bandType, 346 bwtype: bandType,
325 ctype: costTypeVal, 347 ctype: costTypeVal,
......
...@@ -47,71 +47,19 @@ ...@@ -47,71 +47,19 @@
47 // They can be referenced (from this overlay) as '*src' 47 // They can be referenced (from this overlay) as '*src'
48 // That is, the '*' prefix stands in for 'PCE-web-overlay-' 48 // That is, the '*' prefix stands in for 'PCE-web-overlay-'
49 glyphs: { 49 glyphs: {
50 - src: { 50 + jp: {
51 - vb: '0 0 110 110',
52 - d: 'M28.7,59.3 M14.9,53 M8.7,39 M32.4,92.5H25l-0.2-3.6' +
53 - 'c-0.5-9-5.4-23.9-12.9-33.5c-5.2-6.6-7-12.8-7-16.3c0-13.3,10.7-24,23.8-24c13.1,0,23.8,10.8,23.8,24c0,3.5-1.8,9.7-7,16.3' +
54 - 'C38,65,33.1,80,32.6,88.9L32.4,92.5z M27.9,89.5h1.7l0-0.7c0.5-9.4,5.7-25.2,13.5-35.2c4.7-6,6.4-11.4,6.4-14.5' +
55 - 'c0-11.6-9.3-21-20.8-21C17.3,18,7.9,27.5,7.9,39c0,3,1.7,8.4,6.4,14.5c7.9,10.1,13.1,25.8,13.5,35.2L27.9,89.5z M28.7,83.2' +
56 - 'M28.6,29.8c-4.7,0-8.5,3.8-8.5,8.5c0,4.7,3.8,8.5,8.5,8.5s8.5-3.8,8.5-8.5C37.1,33.6,33.3,29.8,28.6,29.8z M89.6,47 M89.6,29.5' +
57 - 'c-0.1,3.1-0.1,12.8,0,17c0.1,4.2,14.1-5.5,13.9-8.5C103.4,35.1,89.6,25.6,89.6,29.5z M51,38.1L89.5,38 M89.5,39.5l0-3L51,36.5l0,3' +
58 - 'L89.5,39.5z'
59 - },
60 - dst: {
61 - vb: '0 0 110 110',
62 - d: 'M80.3,59.8 M85.8,92.5h-7.2L78.4,89c-0.4-8.8-5.2-23.6-12.3-33' +
63 - 'c-4.9-6.5-6.7-12.5-6.7-16c0-13,10.2-23.7,22.7-23.7c12.5,0,22.7,10.6,22.7,23.7c0,3.5-1.8,9.5-6.7,16C91.2,65.4,86.4,80.1,86,89' +
64 - 'L85.8,92.5z M81.4,89.5H83l0-0.7c0.5-9.3,5.4-24.8,12.9-34.7c4.5-5.9,6.1-11.2,6.1-14.2c0-11.4-8.9-20.7-19.8-20.7' +
65 - 'c-10.9,0-19.8,9.3-19.8,20.7c0,3,1.6,8.3,6.1,14.2C76,64,80.9,79.5,81.4,88.8L81.4,89.5z M82.1,30.8c-4.5,0-8.1,3.7-8.1,8.4' +
66 - 's3.6,8.4,8.1,8.4c4.5,0,8.1-3.7,8.1-8.4S86.6,30.8,82.1,30.8z M47.2,47.5 M45.2,30.8c-0.1,3.1-0.1,12.6,0,16.7' +
67 - 'c0.1,4.1,13.4-5.4,13.3-8.4C58.4,36.2,45.2,26.9,45.2,30.8z M45.2,39.1L6.7,39.2 M45.2,40.6l0-3L6.7,37.7l0,3L45.2,40.6z'
68 - },
69 - jp: {
70 vb: '0 0 110 110', 51 vb: '0 0 110 110',
71 d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' + 52 d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' +
72 'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z' 53 'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z'
73 }, 54 },
74 }, 55 },
75 56
76 - // detail panel button definitions 57 + // Key bindings for PCE web overlay buttons
77 - buttons: {
78 - src: {
79 - gid: '*src',
80 - tt: 'Set source node',
81 - cb: function (data) {
82 - $log.debug('Set src action invoked with data:', data);
83 - pps.setSrc(selection);
84 - }
85 - },
86 - dst: {
87 - gid: '*dst',
88 - tt: 'Set destination node',
89 - cb: function (data) {
90 - $log.debug('Set dst action invoked with data:', data);
91 - pps.setDst(selection);
92 - }
93 - }
94 - },
95 - // Key bindings for PCE web overlay buttons
96 // NOTE: fully qual. button ID is derived from overlay-id and key-name 58 // NOTE: fully qual. button ID is derived from overlay-id and key-name
97 keyBindings: { 59 keyBindings: {
98 - openBracket: {
99 - cb: function () {
100 - pps.setSrc(selection);
101 - },
102 - tt: 'Set source node',
103 - gid: '*src'
104 - },
105 - closeBracket: {
106 - cb: function () {
107 - pps.setDst(selection);
108 - },
109 - tt: 'Set destination node',
110 - gid: '*dst'
111 - },
112 1: { 60 1: {
113 cb: function () { 61 cb: function () {
114 - pps.setMode(); 62 + pps.setMode(selection);
115 }, 63 },
116 tt: 'Setup path', 64 tt: 'Setup path',
117 gid: 'plus' 65 gid: 'plus'
...@@ -137,16 +85,9 @@ ...@@ -137,16 +85,9 @@
137 tt: 'Show Tunnels', 85 tt: 'Show Tunnels',
138 gid: 'checkMark' 86 gid: 'checkMark'
139 }, 87 },
140 - 0: {
141 - cb: function () {
142 - pps.clear();
143 - },
144 - tt: 'Clear source and destination',
145 - gid: 'xMark'
146 - },
147 88
148 _keyOrder: [ 89 _keyOrder: [
149 - 'openBracket', 'closeBracket', '1', '2', '3', '4', '0' 90 + '1', '2', '3', '4'
150 ] 91 ]
151 }, 92 },
152 hooks: { 93 hooks: {
......