Committed by
Gerrit Code Review
[ONOS-4159] PCE Web GUI implementation: Tunnel highlight and defect fixes
Change-Id: I385c00d4654e746133f0d9757511e3a8821fad7a
Showing
3 changed files
with
359 additions
and
82 deletions
... | @@ -36,8 +36,11 @@ import org.onosproject.ui.UiConnection; | ... | @@ -36,8 +36,11 @@ import org.onosproject.ui.UiConnection; |
36 | import org.onosproject.ui.UiMessageHandler; | 36 | import org.onosproject.ui.UiMessageHandler; |
37 | import org.onosproject.ui.topo.DeviceHighlight; | 37 | import org.onosproject.ui.topo.DeviceHighlight; |
38 | import org.onosproject.ui.topo.Highlights; | 38 | import org.onosproject.ui.topo.Highlights; |
39 | +import org.onosproject.ui.topo.LinkHighlight; | ||
40 | +import org.onosproject.ui.topo.Mod; | ||
39 | import org.onosproject.ui.topo.NodeBadge; | 41 | import org.onosproject.ui.topo.NodeBadge; |
40 | import org.onosproject.ui.topo.TopoJson; | 42 | import org.onosproject.ui.topo.TopoJson; |
43 | +import org.onosproject.ui.topo.TopoUtils; | ||
41 | import org.onosproject.net.device.DeviceService; | 44 | import org.onosproject.net.device.DeviceService; |
42 | import org.onosproject.net.intent.Constraint; | 45 | import org.onosproject.net.intent.Constraint; |
43 | import org.onosproject.pce.pceservice.LspType; | 46 | import org.onosproject.pce.pceservice.LspType; |
... | @@ -53,6 +56,7 @@ import org.onosproject.incubator.net.tunnel.TunnelEvent; | ... | @@ -53,6 +56,7 @@ import org.onosproject.incubator.net.tunnel.TunnelEvent; |
53 | import org.onosproject.incubator.net.tunnel.TunnelId; | 56 | import org.onosproject.incubator.net.tunnel.TunnelId; |
54 | import org.onosproject.incubator.net.tunnel.TunnelListener; | 57 | import org.onosproject.incubator.net.tunnel.TunnelListener; |
55 | import org.onosproject.incubator.net.tunnel.TunnelService; | 58 | import org.onosproject.incubator.net.tunnel.TunnelService; |
59 | +import static org.onosproject.ui.topo.LinkHighlight.Flavor.*; | ||
56 | import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | 60 | import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; |
57 | 61 | ||
58 | import com.fasterxml.jackson.databind.node.ArrayNode; | 62 | import com.fasterxml.jackson.databind.node.ArrayNode; |
... | @@ -68,8 +72,6 @@ import java.util.Set; | ... | @@ -68,8 +72,6 @@ import java.util.Set; |
68 | public class PceWebTopovMessageHandler extends UiMessageHandler { | 72 | public class PceWebTopovMessageHandler extends UiMessageHandler { |
69 | 73 | ||
70 | private static final String PCEWEB_CLEAR = "pceTopovClear"; | 74 | private static final String PCEWEB_CLEAR = "pceTopovClear"; |
71 | - private static final String PCEWEB_SET_SRC = "pceTopovSetSrc"; | ||
72 | - private static final String PCEWEB_SET_DST = "pceTopovSetDst"; | ||
73 | private static final String PCEWEB_SET_PATH = "pceTopovSetMode"; | 75 | private static final String PCEWEB_SET_PATH = "pceTopovSetMode"; |
74 | private static final String PCEWEB_UPDATE_PATH_QUERY = "pceTopovUpdateQuery"; | 76 | private static final String PCEWEB_UPDATE_PATH_QUERY = "pceTopovUpdateQuery"; |
75 | private static final String PCEWEB_UPDATE_PATH = "pceTopovUpdate"; | 77 | private static final String PCEWEB_UPDATE_PATH = "pceTopovUpdate"; |
... | @@ -78,11 +80,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -78,11 +80,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
78 | private static final String PCEWEB_QUERY_TUNNELS = "pceTopovTunnelDisplay"; | 80 | private static final String PCEWEB_QUERY_TUNNELS = "pceTopovTunnelDisplay"; |
79 | private static final String PCEWEB_SHOW_TUNNEL = "pceTopovShowTunnels"; | 81 | private static final String PCEWEB_SHOW_TUNNEL = "pceTopovShowTunnels"; |
80 | private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem"; | 82 | private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem"; |
81 | - private static final String ID = "id"; | 83 | + private static final String PCEWEB_TUNNEL_UPDATE_INFO = "updatePathmsgInfo"; |
82 | - private static final String TYPE = "type"; | 84 | + private static final String PCEWEB_TUNNEL_UPDATE_INFO_REPLY = "pceTopovShowTunnelsUpdate"; |
83 | - private static final String ROUTER = "router"; | 85 | + private static final String DST = "DST"; |
84 | - private static final String DST = "Egress"; | 86 | + private static final String SRC = "SRC"; |
85 | - private static final String SRC = "Ingress"; | ||
86 | private static final String BANDWIDTH = "bw"; | 87 | private static final String BANDWIDTH = "bw"; |
87 | private static final String BANDWIDTHTYPE = "bwtype"; | 88 | private static final String BANDWIDTHTYPE = "bwtype"; |
88 | private static final String COSTTYPE = "ctype"; | 89 | private static final String COSTTYPE = "ctype"; |
... | @@ -94,6 +95,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -94,6 +95,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
94 | private static final String COST_TYPE_IGP = "igp"; | 95 | private static final String COST_TYPE_IGP = "igp"; |
95 | private static final String COST_TYPE_TE = "te"; | 96 | private static final String COST_TYPE_TE = "te"; |
96 | private static final String BANDWIDTH_TYPE_KBPS = "kbps"; | 97 | private static final String BANDWIDTH_TYPE_KBPS = "kbps"; |
98 | + private static final String BANDWIDTH_TYPE_MBPS = "kbps"; | ||
97 | private static final String BUFFER_ARRAY = "a"; | 99 | private static final String BUFFER_ARRAY = "a"; |
98 | private static final String BANDWIDTH_BPS = "BPS"; | 100 | private static final String BANDWIDTH_BPS = "BPS"; |
99 | private static final String LSP_TYPE_CR = "cr"; | 101 | private static final String LSP_TYPE_CR = "cr"; |
... | @@ -105,9 +107,11 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -105,9 +107,11 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
105 | private static final int DELAY_MS = 1100; | 107 | private static final int DELAY_MS = 1100; |
106 | private static final double BANDWIDTH_KBPS = 1_000; | 108 | private static final double BANDWIDTH_KBPS = 1_000; |
107 | private static final double BANDWIDTH_MBPS = 1_000_000; | 109 | private static final double BANDWIDTH_MBPS = 1_000_000; |
108 | - | 110 | + private static String[] linkColor = {"pCol1", "pCol2", "pCol3", "pCol4", "pCol5", |
111 | + "pCol6", "pCol7", "pCol8", "pCol9", "pCol10", | ||
112 | + "pCol11", "pCol12", "pCol13", "pCol14", "pCol15"}; | ||
113 | + private static final int LINK_COLOR_MAX = 15; | ||
109 | private Set<Link> allPathLinks; | 114 | private Set<Link> allPathLinks; |
110 | - private int highlightDelay; | ||
111 | private ElementId src, dst; | 115 | private ElementId src, dst; |
112 | private List<Path> paths = new LinkedList<>(); | 116 | private List<Path> paths = new LinkedList<>(); |
113 | private int pathIndex; | 117 | private int pathIndex; |
... | @@ -141,6 +145,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -141,6 +145,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
141 | new UpdatePathHandler(), | 145 | new UpdatePathHandler(), |
142 | new RemovePathQueryHandler(), | 146 | new RemovePathQueryHandler(), |
143 | new RemovePathHandler(), | 147 | new RemovePathHandler(), |
148 | + new UpdatePathInfoHandler(), | ||
144 | new ShowTunnelHandler()); | 149 | new ShowTunnelHandler()); |
145 | } | 150 | } |
146 | 151 | ||
... | @@ -276,6 +281,50 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -276,6 +281,50 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
276 | } | 281 | } |
277 | 282 | ||
278 | /** | 283 | /** |
284 | + * Handles the 'update path' event received from the client. | ||
285 | + */ | ||
286 | + private final class UpdatePathInfoHandler extends RequestHandler { | ||
287 | + | ||
288 | + public UpdatePathInfoHandler() { | ||
289 | + super(PCEWEB_TUNNEL_UPDATE_INFO); | ||
290 | + } | ||
291 | + | ||
292 | + @Override | ||
293 | + public void process(long sid, ObjectNode payload) { | ||
294 | + String tunnelIdStr = string(payload, TUNNEL_ID); | ||
295 | + | ||
296 | + if (tunnelIdStr == null) { | ||
297 | + log.error("PCE update path is failed."); | ||
298 | + } | ||
299 | + | ||
300 | + if (tunnelIdStr.equals(STRING_NULL)) { | ||
301 | + log.error("PCE update path is failed."); | ||
302 | + return; | ||
303 | + } | ||
304 | + | ||
305 | + if (pceService == null) { | ||
306 | + log.error("PCE service is not active"); | ||
307 | + return; | ||
308 | + } | ||
309 | + | ||
310 | + TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr); | ||
311 | + Tunnel tunnel = tunnelService.queryTunnel(tunnelId); | ||
312 | + ObjectNode result = objectNode(); | ||
313 | + ArrayNode arrayNode = arrayNode(); | ||
314 | + | ||
315 | + arrayNode.add("Tunnel"); | ||
316 | + arrayNode.add(tunnelIdStr); | ||
317 | + arrayNode.add("BandWidth"); | ||
318 | + arrayNode.add(tunnel.annotations().value("bandwidth")); | ||
319 | + arrayNode.add("CostType"); | ||
320 | + arrayNode.add(tunnel.annotations().value("costType")); | ||
321 | + | ||
322 | + result.putArray(BUFFER_ARRAY).addAll(arrayNode); | ||
323 | + sendMessage(PCEWEB_TUNNEL_UPDATE_INFO_REPLY, sid, result); | ||
324 | + } | ||
325 | + } | ||
326 | + | ||
327 | + /** | ||
279 | * Handles the 'remove path query' event received from the client. | 328 | * Handles the 'remove path query' event received from the client. |
280 | */ | 329 | */ |
281 | private final class RemovePathQueryHandler extends RequestHandler { | 330 | private final class RemovePathQueryHandler extends RequestHandler { |
... | @@ -484,7 +533,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -484,7 +533,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
484 | } | 533 | } |
485 | if (bandWidthType.equals(BANDWIDTH_TYPE_KBPS)) { | 534 | if (bandWidthType.equals(BANDWIDTH_TYPE_KBPS)) { |
486 | bwValue = bwValue * BANDWIDTH_KBPS; | 535 | bwValue = bwValue * BANDWIDTH_KBPS; |
487 | - } else { | 536 | + } else if (bandWidthType.equals(BANDWIDTH_TYPE_MBPS)) { |
488 | bwValue = bwValue * BANDWIDTH_MBPS; | 537 | bwValue = bwValue * BANDWIDTH_MBPS; |
489 | } | 538 | } |
490 | 539 | ||
... | @@ -516,20 +565,20 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -516,20 +565,20 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
516 | * Handles the highlights of selected path. | 565 | * Handles the highlights of selected path. |
517 | */ | 566 | */ |
518 | private void hilightAndSendPaths(Highlights highlights) { | 567 | private void hilightAndSendPaths(Highlights highlights) { |
519 | - PceWebLinkMap linkMap = new PceWebLinkMap(); | 568 | + LinkHighlight lh; |
520 | - allPathLinks.forEach(linkMap::add); | 569 | + int linkclr = 0; |
521 | - Set<Link> selectedPathLinks; | 570 | + for (Path path : paths) { |
522 | - | 571 | + for (Link link : path.links()) { |
523 | - selectedPathLinks = paths.isEmpty() ? | 572 | + lh = new LinkHighlight(TopoUtils.compactLinkString(link), PRIMARY_HIGHLIGHT) |
524 | - ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links()); | 573 | + .addMod(new Mod(linkColor[linkclr])); |
525 | - | 574 | + highlights.add(lh); |
526 | - if (highlightDelay > 0) { | 575 | + } |
527 | - highlights.delay(highlightDelay); | 576 | + linkclr = linkclr + 1; |
528 | - } | 577 | + if (linkclr == LINK_COLOR_MAX) { |
529 | - for (PceWebLink plink : linkMap.biLinks()) { | 578 | + linkclr = 0; |
530 | - plink.computeHilight(selectedPathLinks, allPathLinks); | 579 | + } |
531 | - highlights.add(plink.highlight(null)); | ||
532 | } | 580 | } |
581 | + | ||
533 | sendMessage(TopoJson.highlightsMessage(highlights)); | 582 | sendMessage(TopoJson.highlightsMessage(highlights)); |
534 | } | 583 | } |
535 | 584 | ||
... | @@ -578,9 +627,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -578,9 +627,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
578 | private class InternalTopologyListener implements TopologyListener { | 627 | private class InternalTopologyListener implements TopologyListener { |
579 | @Override | 628 | @Override |
580 | public void event(TopologyEvent event) { | 629 | public void event(TopologyEvent event) { |
581 | - highlightDelay = DELAY_MS; | ||
582 | findTunnelAndHighlights(); | 630 | findTunnelAndHighlights(); |
583 | - highlightDelay = 0; | ||
584 | } | 631 | } |
585 | } | 632 | } |
586 | 633 | ||
... | @@ -592,9 +639,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -592,9 +639,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
592 | public void event(TunnelEvent event) { | 639 | public void event(TunnelEvent event) { |
593 | Tunnel tunnel = event.subject(); | 640 | Tunnel tunnel = event.subject(); |
594 | if (tunnel.type() == MPLS) { | 641 | if (tunnel.type() == MPLS) { |
595 | - highlightDelay = DELAY_MS; | ||
596 | findTunnelAndHighlights(); | 642 | findTunnelAndHighlights(); |
597 | - highlightDelay = 0; | ||
598 | } | 643 | } |
599 | } | 644 | } |
600 | } | 645 | } |
... | @@ -604,17 +649,19 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -604,17 +649,19 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
604 | */ | 649 | */ |
605 | private void findTunnelAndHighlights() { | 650 | private void findTunnelAndHighlights() { |
606 | Collection<Tunnel> tunnelSet = null; | 651 | Collection<Tunnel> tunnelSet = null; |
652 | + Highlights highlights = new Highlights(); | ||
653 | + paths.removeAll(paths); | ||
607 | tunnelSet = tunnelService.queryTunnel(MPLS); | 654 | tunnelSet = tunnelService.queryTunnel(MPLS); |
608 | if (tunnelSet.size() == 0) { | 655 | if (tunnelSet.size() == 0) { |
609 | log.warn("Tunnel does not exist"); | 656 | log.warn("Tunnel does not exist"); |
657 | + sendMessage(TopoJson.highlightsMessage(highlights)); | ||
610 | return; | 658 | return; |
611 | } | 659 | } |
612 | 660 | ||
613 | - paths.removeAll(paths); | ||
614 | - Highlights highlights = new Highlights(); | ||
615 | for (Tunnel tunnel : tunnelSet) { | 661 | for (Tunnel tunnel : tunnelSet) { |
616 | if (tunnel.path() == null) { | 662 | if (tunnel.path() == null) { |
617 | log.error("path does not exist"); | 663 | log.error("path does not exist"); |
664 | + sendMessage(TopoJson.highlightsMessage(highlights)); | ||
618 | return; | 665 | return; |
619 | } | 666 | } |
620 | Link firstLink = tunnel.path().links().get(0); | 667 | Link firstLink = tunnel.path().links().get(0); | ... | ... |
... | @@ -2,3 +2,153 @@ | ... | @@ -2,3 +2,153 @@ |
2 | .radioButtonSpace { | 2 | .radioButtonSpace { |
3 | margin-left:20px; | 3 | margin-left:20px; |
4 | } | 4 | } |
5 | +/* color:1 */ | ||
6 | +#ov-topo svg .link.primary.pCol1 { | ||
7 | + stroke-width: 6px; | ||
8 | +} | ||
9 | +.light #ov-topo svg .link.primary.pCol1 { | ||
10 | + stroke: #FF00CE; | ||
11 | +} | ||
12 | +.dark #ov-topo svg .link.primary.pCol1 { | ||
13 | + stroke: #FF00CE; | ||
14 | +} | ||
15 | +/* color:2 */ | ||
16 | +#ov-topo svg .link.primary.pCol2 { | ||
17 | + stroke-width: 6px; | ||
18 | +} | ||
19 | +.light #ov-topo svg .link.primary.pCol2 { | ||
20 | + stroke: #ff4000; | ||
21 | +} | ||
22 | +.dark #ov-topo svg .link.primary.pCol2 { | ||
23 | + stroke: #ff4000; | ||
24 | +} | ||
25 | +/* color:3 */ | ||
26 | +#ov-topo svg .link.primary.pCol3 { | ||
27 | + stroke-width: 6px; | ||
28 | +} | ||
29 | +.light #ov-topo svg .link.primary.pCol3 { | ||
30 | + stroke: #ffb400; | ||
31 | +} | ||
32 | +.dark #ov-topo svg .link.primary.pCol3 { | ||
33 | + stroke: #ffb400; | ||
34 | +} | ||
35 | +/* color:4 */ | ||
36 | +#ov-topo svg .link.primary.pCol4 { | ||
37 | + stroke-width: 6px; | ||
38 | +} | ||
39 | +.light #ov-topo svg .link.primary.pCol4 { | ||
40 | + stroke: #89ff00; | ||
41 | +} | ||
42 | +.dark #ov-topo svg .link.primary.pCol4 { | ||
43 | + stroke: #89ff00; | ||
44 | +} | ||
45 | +/* color:5 */ | ||
46 | +#ov-topo svg .link.primary.pCol5 { | ||
47 | + stroke-width: 6px; | ||
48 | +} | ||
49 | +.light #ov-topo svg .link.primary.pCol5 { | ||
50 | + stroke: #00FF2B; | ||
51 | +} | ||
52 | +.dark #ov-topo svg .link.primary.pCol5 { | ||
53 | + stroke: #00FF2B; | ||
54 | +} | ||
55 | +/* color:6 */ | ||
56 | +#ov-topo svg .link.primary.pCol6 { | ||
57 | + stroke-width: 6px; | ||
58 | +} | ||
59 | +.light #ov-topo svg .link.primary.pCol6 { | ||
60 | + stroke: #00ffec; | ||
61 | +} | ||
62 | +.dark #ov-topo svg .link.primary.pCol6 { | ||
63 | + stroke: #00ffec; | ||
64 | +} | ||
65 | +/* color:7 */ | ||
66 | +#ov-topo svg .link.primary.pCol7 { | ||
67 | + stroke-width: 6px; | ||
68 | +} | ||
69 | +.light #ov-topo svg .link.primary.pCol7 { | ||
70 | + stroke: #00abff; | ||
71 | +} | ||
72 | +.dark #ov-topo svg .link.primary.pCol7 { | ||
73 | + stroke: #00abff; | ||
74 | +} | ||
75 | +/* color:8 */ | ||
76 | +#ov-topo svg .link.primary.pCol8 { | ||
77 | + stroke-width: 6px; | ||
78 | +} | ||
79 | +.light #ov-topo svg .link.primary.pCol8 { | ||
80 | + stroke: #005eff; | ||
81 | +} | ||
82 | +.dark #ov-topo svg .link.primary.pCol8 { | ||
83 | + stroke: #005eff; | ||
84 | +} | ||
85 | +/* color:9 */ | ||
86 | +#ov-topo svg .link.primary.pCol9 { | ||
87 | + stroke-width: 6px; | ||
88 | +} | ||
89 | +.light #ov-topo svg .link.primary.pCol9 { | ||
90 | + stroke: #0011ff; | ||
91 | +} | ||
92 | +.dark #ov-topo svg .link.primary.pCol9 { | ||
93 | + stroke: #0011ff; | ||
94 | +} | ||
95 | +/* color:10 */ | ||
96 | +#ov-topo svg .link.primary.pCol10 { | ||
97 | + stroke-width: 6px; | ||
98 | +} | ||
99 | +.light #ov-topo svg .link.primary.pCol10 { | ||
100 | + stroke: #7c00ff; | ||
101 | +} | ||
102 | +.dark #ov-topo svg .link.primary.pCol10 { | ||
103 | + stroke: #7c00ff; | ||
104 | +} | ||
105 | +/* color:11 */ | ||
106 | +#ov-topo svg .link.primary.pCol11 { | ||
107 | + stroke-width: 6px; | ||
108 | +} | ||
109 | +.light #ov-topo svg .link.primary.pCol11 { | ||
110 | + stroke: #ffe700; | ||
111 | +} | ||
112 | +.dark #ov-topo svg .link.primary.pCol11 { | ||
113 | + stroke: #ffe700; | ||
114 | +} | ||
115 | +/* color:12 */ | ||
116 | +#ov-topo svg .link.primary.pCol12 { | ||
117 | + stroke-width: 6px; | ||
118 | +} | ||
119 | +.light #ov-topo svg .link.primary.pCol12 { | ||
120 | + stroke: #00ffec; | ||
121 | +} | ||
122 | +.dark #ov-topo svg .link.primary.pCol12 { | ||
123 | + stroke: #00ffec; | ||
124 | +} | ||
125 | +/* color:13 */ | ||
126 | +#ov-topo svg .link.primary.pCol13 { | ||
127 | + stroke-width: 6px; | ||
128 | +} | ||
129 | +.light #ov-topo svg .link.primary.pCol13 { | ||
130 | + stroke: #c900ff; | ||
131 | +} | ||
132 | +.dark #ov-topo svg .link.primary.pCol13 { | ||
133 | + stroke: #c900ff; | ||
134 | +} | ||
135 | +/* color:14 */ | ||
136 | +#ov-topo svg .link.primary.pCol14 { | ||
137 | + stroke-width: 6px; | ||
138 | +} | ||
139 | +.light #ov-topo svg .link.primary.pCol14 { | ||
140 | + stroke: #ff00e7; | ||
141 | +} | ||
142 | +.dark #ov-topo svg .link.primary.pCol14 { | ||
143 | + stroke: #ff00e7; | ||
144 | +} | ||
145 | +/* color:15 */ | ||
146 | +#ov-topo svg .link.primary.pCol15 { | ||
147 | + stroke-width: 6px; | ||
148 | +} | ||
149 | +.light #ov-topo svg .link.primary.pCol15 { | ||
150 | + stroke: #3c00ff; | ||
151 | +} | ||
152 | +.dark #ov-topo svg .link.primary.pCol15 { | ||
153 | + stroke: #3c00ff; | ||
154 | +} | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | 21 | ||
22 | // injected refs | 22 | // injected refs |
23 | var $log, fs, flash, wss, tps, ns, tds, ds; | 23 | var $log, fs, flash, wss, tps, ns, tds, ds; |
24 | - var tunnelNameData, tunnelNameDataRemove; | 24 | + var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd; |
25 | // constants | 25 | // constants |
26 | var srcMessage = 'pceTopovSetSrc', | 26 | var srcMessage = 'pceTopovSetSrc', |
27 | dstMessage = 'pceTopovSetDst', | 27 | dstMessage = 'pceTopovSetDst', |
... | @@ -30,14 +30,17 @@ | ... | @@ -30,14 +30,17 @@ |
30 | updatePathmsgQuery = 'pceTopovUpdateQuery', | 30 | updatePathmsgQuery = 'pceTopovUpdateQuery', |
31 | remPathmsgQuery = 'pceTopovRemQuery', | 31 | remPathmsgQuery = 'pceTopovRemQuery', |
32 | updatePathmsg = 'pceTopovUpdate', | 32 | updatePathmsg = 'pceTopovUpdate', |
33 | + updatePathmsgInfo = 'updatePathmsgInfo', | ||
33 | remPathmsg = 'pceTopovRem', | 34 | remPathmsg = 'pceTopovRem', |
34 | showTunnelInfoMsg = 'pceTopovShowTunnels', | 35 | showTunnelInfoMsg = 'pceTopovShowTunnels', |
35 | queryDisplayTunnelMsg = 'pceTopovTunnelDisplay', | 36 | queryDisplayTunnelMsg = 'pceTopovTunnelDisplay', |
36 | - showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem'; | 37 | + showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem', |
38 | + showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate'; | ||
37 | // internal state | 39 | // internal state |
38 | var currentMode = null; | 40 | var currentMode = null; |
39 | var handlerMap = {}, | 41 | var handlerMap = {}, |
40 | - handlerMapRem = {}; | 42 | + handlerMapRem = {}, |
43 | + handlerMapShowUpdate = {}; | ||
41 | // === --------------------------- | 44 | // === --------------------------- |
42 | // === Helper functions | 45 | // === Helper functions |
43 | 46 | ||
... | @@ -89,8 +92,6 @@ | ... | @@ -89,8 +92,6 @@ |
89 | id: id | 92 | id: id |
90 | }); | 93 | }); |
91 | } | 94 | } |
92 | - | ||
93 | - | ||
94 | p.append('span').text(nameField); | 95 | p.append('span').text(nameField); |
95 | p.append('br'); | 96 | p.append('br'); |
96 | } | 97 | } |
... | @@ -100,6 +101,7 @@ | ... | @@ -100,6 +101,7 @@ |
100 | addAttribute('band-width-value-name', 'band-width-value', null, 'number'); | 101 | addAttribute('band-width-value-name', 'band-width-value', null, 'number'); |
101 | addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio'); | 102 | addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio'); |
102 | addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio'); | 103 | addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio'); |
104 | + addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio'); | ||
103 | //Add the cost type related inputs. | 105 | //Add the cost type related inputs. |
104 | addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox'); | 106 | addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox'); |
105 | addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio'); | 107 | addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio'); |
... | @@ -139,10 +141,11 @@ | ... | @@ -139,10 +141,11 @@ |
139 | return content; | 141 | return content; |
140 | } | 142 | } |
141 | 143 | ||
142 | - function createUserTextUpdatePathEvent() { | 144 | + function createUserTextUpdatePathEvent(data) { |
143 | var content = ds.createDiv(), | 145 | var content = ds.createDiv(), |
144 | form = content.append('form'), | 146 | form = content.append('form'), |
145 | p = form.append('p'); | 147 | p = form.append('p'); |
148 | + var constType; | ||
146 | 149 | ||
147 | function addAttribute(name, id, nameField, type) { | 150 | function addAttribute(name, id, nameField, type) { |
148 | if (type == 'radio') { | 151 | if (type == 'radio') { |
... | @@ -165,15 +168,79 @@ | ... | @@ -165,15 +168,79 @@ |
165 | p.append('br'); | 168 | p.append('br'); |
166 | } | 169 | } |
167 | 170 | ||
168 | - //Add the bandwidth related inputs. | 171 | + data.a.forEach( function (val, idx) { |
169 | - addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); | 172 | + if (val == 'Tunnel') { |
170 | - addAttribute('band-width-value-name', 'update-band-width-value', null, 'number'); | 173 | + constType = 'TUNNEL'; |
171 | - addAttribute('pce-band-type', 'update-band-kpbs-val', 'kbps', 'radio'); | 174 | + return; |
172 | - addAttribute('pce-band-type', 'update-band-mpbs-val', 'mbps', 'radio'); | 175 | + } |
173 | - //Add the cost type related inputs. | 176 | + |
174 | - addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); | 177 | + if (val == 'BandWidth') { |
175 | - addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio'); | 178 | + constType = 'BW'; |
176 | - addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio'); | 179 | + return; |
180 | + } | ||
181 | + | ||
182 | + if (val == 'CostType') { | ||
183 | + constType = 'CT'; | ||
184 | + return; | ||
185 | + } | ||
186 | + | ||
187 | + if (constType == 'TUNNEL') { | ||
188 | + p.append('span').text('Tunnel Id: '); | ||
189 | + p.append('span').text(val); | ||
190 | + p.append('br'); | ||
191 | + tunnelIdUpd = val; | ||
192 | + } | ||
193 | + | ||
194 | + if (constType == 'BW') { | ||
195 | + addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); | ||
196 | + p.append('input').attr({ | ||
197 | + id: 'update-band-width-value', | ||
198 | + type: 'number', | ||
199 | + name: 'band-width-value-name', | ||
200 | + value: val | ||
201 | + }); | ||
202 | + p.append('br'); | ||
203 | + p.append('input').attr({ | ||
204 | + id: 'update-band-bps-val', | ||
205 | + type: 'radio', | ||
206 | + name: 'pce-band-type', | ||
207 | + checked: 'checked', | ||
208 | + class: 'radioButtonSpace' | ||
209 | + }); | ||
210 | + p.append('span').text('bps'); | ||
211 | + p.append('br'); | ||
212 | + addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio'); | ||
213 | + addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio'); | ||
214 | + } | ||
215 | + | ||
216 | + if (constType == 'CT') { | ||
217 | + addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); | ||
218 | + if (val == 'COST') { | ||
219 | + p.append('input').attr({ | ||
220 | + id: 'update-pce-cost-type-igp', | ||
221 | + type: 'radio', | ||
222 | + name: 'pce-cost-type-value', | ||
223 | + checked: 'checked', | ||
224 | + class: 'radioButtonSpace' | ||
225 | + }); | ||
226 | + p.append('span').text('IGP'); | ||
227 | + p.append('br'); | ||
228 | + addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio'); | ||
229 | + | ||
230 | + } else { | ||
231 | + addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio'); | ||
232 | + p.append('input').attr({ | ||
233 | + id: 'update-pce-cost-type-te', | ||
234 | + type: 'radio', | ||
235 | + name: 'pce-cost-type-value', | ||
236 | + checked: 'checked', | ||
237 | + class: 'radioButtonSpace' | ||
238 | + }); | ||
239 | + p.append('span').text('TE'); | ||
240 | + p.append('br'); | ||
241 | + } | ||
242 | + } | ||
243 | + } ); | ||
177 | 244 | ||
178 | return content; | 245 | return content; |
179 | } | 246 | } |
... | @@ -222,66 +289,65 @@ | ... | @@ -222,66 +289,65 @@ |
222 | tdString = val; | 289 | tdString = val; |
223 | } | 290 | } |
224 | } ); | 291 | } ); |
292 | + //send event to server for getting the tunnel information. | ||
293 | + if (tdString != null) { | ||
294 | + handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle; | ||
295 | + wss.bindHandlers(handlerMapShowUpdate); | ||
225 | 296 | ||
226 | - constraintsUpdateDialog(tdString); | 297 | + wss.sendEvent(updatePathmsgInfo, { |
298 | + tunnelid: tdString | ||
299 | + }); | ||
300 | + } | ||
301 | + //constraintsUpdateDialog(tdString); | ||
227 | $log.debug('Dialog OK button clicked'); | 302 | $log.debug('Dialog OK button clicked'); |
228 | } | 303 | } |
229 | 304 | ||
230 | tds.openDialog() | 305 | tds.openDialog() |
231 | .setTitle('Available LSPs with selected device') | 306 | .setTitle('Available LSPs with selected device') |
232 | .addContent(createUserTextUpdate(data)) | 307 | .addContent(createUserTextUpdate(data)) |
233 | - .addOkChained(dOkUpdate, 'OK') | 308 | + .addOk(dOkUpdate, 'OK') |
234 | .addCancel(dClose, 'Close') | 309 | .addCancel(dClose, 'Close') |
235 | .bindKeys(); | 310 | .bindKeys(); |
236 | } | 311 | } |
237 | 312 | ||
238 | - function constraintsUpdateDialog(tunnelId) { | 313 | + function dOkUpdateEvent() { |
239 | - | 314 | + $log.debug('Select constraints for update path Dialog OK button pressed'); |
240 | - // invoked when the OK button is pressed on this dialog | ||
241 | - function dOkUpdateEvent() { | ||
242 | - $log.debug('Select constraints for update path Dialog OK button pressed'); | ||
243 | 315 | ||
244 | - var bandWidth = isChecked('update-band-width-box'), | 316 | + var bandWidth = isChecked('update-band-width-box'), |
245 | - bandValue = null, | 317 | + bandValue = null, |
246 | - bandType = null; | 318 | + bandType = null; |
247 | 319 | ||
248 | - if (bandWidth) { | 320 | + if (bandWidth) { |
249 | - bandValue = d3.select('#update-band-width-value'); | 321 | + bandValue = getCheckedValue('update-band-width-value'); |
250 | 322 | ||
251 | - if (isChecked('update-band-kpbs-val')) { | 323 | + if (isChecked('update-band-kbps-val')) { |
252 | bandType = 'kbps'; | 324 | bandType = 'kbps'; |
253 | - } else if (isChecked('update-band-mpbs-val')) { | 325 | + } else if (isChecked('update-band-mbps-val')) { |
254 | bandType = 'mbps'; | 326 | bandType = 'mbps'; |
255 | - } | 327 | + } else if (isChecked('update-band-bps-val')) { |
328 | + bandType = 'bps'; | ||
256 | } | 329 | } |
330 | + } | ||
257 | 331 | ||
258 | - var costType = isChecked('update-pce-cost-type'), | 332 | + var costType = isChecked('update-pce-cost-type'), |
259 | - costTypeVal = null; | 333 | + costTypeVal = null; |
260 | 334 | ||
261 | - if (costType) { | 335 | + if (costType) { |
262 | - if (isChecked('update-pce-cost-type-igp')) { | 336 | + if (isChecked('update-pce-cost-type-igp')) { |
263 | - costTypeVal = 'igp'; | 337 | + costTypeVal = 'igp'; |
264 | - } else if (isChecked('update-pce-cost-type-te')) { | 338 | + } else if (isChecked('update-pce-cost-type-te')) { |
265 | - costTypeVal = 'te'; | 339 | + costTypeVal = 'te'; |
266 | - } | ||
267 | } | 340 | } |
268 | - | ||
269 | - wss.sendEvent(updatePathmsg, { | ||
270 | - bw: bandValue, | ||
271 | - ctype: costTypeVal, | ||
272 | - tunnelname: tunnelId | ||
273 | - }); | ||
274 | - | ||
275 | - flash.flash('update path message'); | ||
276 | - | ||
277 | } | 341 | } |
278 | 342 | ||
279 | - tds.openDialog() | 343 | + wss.sendEvent(updatePathmsg, { |
280 | - .setTitle('Select constraints for update path') | 344 | + bw: bandValue, |
281 | - .addContent(createUserTextUpdatePathEvent()) | 345 | + bwtype: bandType, |
282 | - .addCancel() | 346 | + ctype: costTypeVal, |
283 | - .addOk(dOkUpdateEvent, 'OK') // NOTE: NOT the "chained" version! | 347 | + tunnelname: tunnelIdUpd |
284 | - .bindKeys(); | 348 | + }); |
349 | + | ||
350 | + flash.flash('update path message'); | ||
285 | 351 | ||
286 | } | 352 | } |
287 | 353 | ||
... | @@ -297,6 +363,18 @@ | ... | @@ -297,6 +363,18 @@ |
297 | .bindKeys(); | 363 | .bindKeys(); |
298 | } | 364 | } |
299 | 365 | ||
366 | + function showTunnelInfoUpdateMsgHandle(data) { | ||
367 | + | ||
368 | + wss.unbindHandlers(handlerMapShowUpdate); | ||
369 | + tunnelDataUpdateInfo = data; | ||
370 | + tds.openDialog() | ||
371 | + .setTitle('Constrainst selection for update') | ||
372 | + .addContent(createUserTextUpdatePathEvent(data)) | ||
373 | + .addOk(dOkUpdateEvent, 'OK') | ||
374 | + .addCancel(dClose, 'Close') | ||
375 | + .bindKeys(); | ||
376 | + } | ||
377 | + | ||
300 | //setup path | 378 | //setup path |
301 | function setMode(node) { | 379 | function setMode(node) { |
302 | 380 | ||
... | @@ -312,6 +390,8 @@ | ... | @@ -312,6 +390,8 @@ |
312 | bandType = 'kbps'; | 390 | bandType = 'kbps'; |
313 | } else if (isChecked('band-mpbs-val')) { | 391 | } else if (isChecked('band-mpbs-val')) { |
314 | bandType = 'mbps'; | 392 | bandType = 'mbps'; |
393 | + } else if (isChecked('band-bps-val')) { | ||
394 | + bandType = 'bps'; | ||
315 | } | 395 | } |
316 | } | 396 | } |
317 | 397 | ... | ... |
-
Please register or login to post a comment