Consolidated link list into bidirectional links. Re-ordered views. Took-out buil…
…tin views from injected html snippets. Change-Id: I8de62b50e437ee6f49a9f2ce9ce6f26bb1e0a6a5
Showing
7 changed files
with
72 additions
and
71 deletions
... | @@ -19,13 +19,18 @@ package org.onosproject.ui.impl; | ... | @@ -19,13 +19,18 @@ package org.onosproject.ui.impl; |
19 | import com.fasterxml.jackson.databind.node.ArrayNode; | 19 | import com.fasterxml.jackson.databind.node.ArrayNode; |
20 | import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
21 | import com.google.common.collect.ImmutableSet; | 21 | import com.google.common.collect.ImmutableSet; |
22 | +import com.google.common.collect.Maps; | ||
22 | import org.onosproject.net.ConnectPoint; | 23 | import org.onosproject.net.ConnectPoint; |
23 | -import org.onosproject.net.Link; | 24 | +import org.onosproject.net.LinkKey; |
24 | import org.onosproject.net.link.LinkService; | 25 | import org.onosproject.net.link.LinkService; |
26 | +import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink; | ||
25 | 27 | ||
26 | import java.util.ArrayList; | 28 | import java.util.ArrayList; |
27 | import java.util.Arrays; | 29 | import java.util.Arrays; |
28 | import java.util.List; | 30 | import java.util.List; |
31 | +import java.util.Map; | ||
32 | + | ||
33 | +import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink; | ||
29 | 34 | ||
30 | /** | 35 | /** |
31 | * Message handler for link view related messages. | 36 | * Message handler for link view related messages. |
... | @@ -42,7 +47,7 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { | ... | @@ -42,7 +47,7 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { |
42 | @Override | 47 | @Override |
43 | public void process(ObjectNode message) { | 48 | public void process(ObjectNode message) { |
44 | ObjectNode payload = payload(message); | 49 | ObjectNode payload = payload(message); |
45 | - String sortCol = string(payload, "sortCol", "src"); | 50 | + String sortCol = string(payload, "sortCol", "one"); |
46 | String sortDir = string(payload, "sortDir", "asc"); | 51 | String sortDir = string(payload, "sortDir", "asc"); |
47 | 52 | ||
48 | LinkService service = get(LinkService.class); | 53 | LinkService service = get(LinkService.class); |
... | @@ -59,36 +64,54 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { | ... | @@ -59,36 +64,54 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { |
59 | 64 | ||
60 | private TableRow[] generateTableRows(LinkService service) { | 65 | private TableRow[] generateTableRows(LinkService service) { |
61 | List<TableRow> list = new ArrayList<>(); | 66 | List<TableRow> list = new ArrayList<>(); |
62 | - for (Link link : service.getLinks()) { | 67 | + |
63 | - list.add(new LinkTableRow(link)); | 68 | + // First consolidate all uni-directional links into two-directional ones. |
64 | - } | 69 | + Map<LinkKey, BiLink> biLinks = Maps.newHashMap(); |
70 | + service.getLinks().forEach(link -> addLink(biLinks, link)); | ||
71 | + | ||
72 | + // Now scan over all bi-links and produce table rows from them. | ||
73 | + biLinks.values().forEach(biLink -> list.add(new LinkTableRow(biLink))); | ||
65 | return list.toArray(new TableRow[list.size()]); | 74 | return list.toArray(new TableRow[list.size()]); |
66 | } | 75 | } |
67 | 76 | ||
68 | /** | 77 | /** |
69 | - * TableRow implementation for {@link Link links}. | 78 | + * TableRow implementation for {@link org.onosproject.net.Link links}. |
70 | */ | 79 | */ |
71 | private static class LinkTableRow extends AbstractTableRow { | 80 | private static class LinkTableRow extends AbstractTableRow { |
72 | 81 | ||
73 | - private static final String SOURCE = "src"; | 82 | + private static final String ONE = "one"; |
74 | - private static final String DEST = "dst"; | 83 | + private static final String TWO = "two"; |
75 | private static final String TYPE = "type"; | 84 | private static final String TYPE = "type"; |
76 | private static final String STATE = "state"; | 85 | private static final String STATE = "state"; |
86 | + private static final String DIRECTION = "direction"; | ||
77 | private static final String DURABLE = "durable"; | 87 | private static final String DURABLE = "durable"; |
78 | 88 | ||
79 | private static final String[] COL_IDS = { | 89 | private static final String[] COL_IDS = { |
80 | - SOURCE, DEST, TYPE, STATE, DURABLE | 90 | + ONE, TWO, TYPE, STATE, DIRECTION, DURABLE |
81 | }; | 91 | }; |
82 | 92 | ||
83 | - public LinkTableRow(Link l) { | 93 | + public LinkTableRow(BiLink link) { |
84 | - ConnectPoint src = l.src(); | 94 | + ConnectPoint src = link.one.src(); |
85 | - ConnectPoint dst = l.dst(); | 95 | + ConnectPoint dst = link.one.dst(); |
96 | + | ||
97 | + add(ONE, src.elementId().toString() + "/" + src.port().toString()); | ||
98 | + add(TWO, dst.elementId().toString() + "/" + dst.port().toString()); | ||
99 | + add(TYPE, linkType(link).toLowerCase()); | ||
100 | + add(STATE, linkState(link).toLowerCase()); | ||
101 | + add(DIRECTION, link.two != null ? "A <-> B" : "A -> B"); | ||
102 | + add(DURABLE, Boolean.toString(link.one.isDurable())); | ||
103 | + } | ||
104 | + | ||
105 | + private String linkState(BiLink link) { | ||
106 | + return link.two == null || link.one.state() == link.two.state() ? | ||
107 | + link.one.state().toString() : | ||
108 | + link.one.state().toString() + "/" + link.two.state().toString(); | ||
109 | + } | ||
86 | 110 | ||
87 | - add(SOURCE, src.elementId().toString() + "/" + src.port().toString()); | 111 | + private String linkType(BiLink link) { |
88 | - add(DEST, dst.elementId().toString() + "/" + dst.port().toString()); | 112 | + return link.two == null || link.one.type() == link.two.type() ? |
89 | - add(TYPE, l.type().toString()); | 113 | + link.one.type().toString() : |
90 | - add(STATE, l.state().toString()); | 114 | + link.one.type().toString() + "/" + link.two.type().toString(); |
91 | - add(DURABLE, Boolean.toString(l.isDurable())); | ||
92 | } | 115 | } |
93 | 116 | ||
94 | @Override | 117 | @Override | ... | ... |
... | @@ -719,7 +719,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { | ... | @@ -719,7 +719,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
722 | - private BiLink addLink(Map<LinkKey, BiLink> biLinks, Link link) { | 722 | + static BiLink addLink(Map<LinkKey, BiLink> biLinks, Link link) { |
723 | LinkKey key = canonicalLinkKey(link); | 723 | LinkKey key = canonicalLinkKey(link); |
724 | BiLink biLink = biLinks.get(key); | 724 | BiLink biLink = biLinks.get(key); |
725 | if (biLink != null) { | 725 | if (biLink != null) { |
... | @@ -816,7 +816,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { | ... | @@ -816,7 +816,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
816 | } | 816 | } |
817 | 817 | ||
818 | // Produces canonical link key, i.e. one that will match link and its inverse. | 818 | // Produces canonical link key, i.e. one that will match link and its inverse. |
819 | - private LinkKey canonicalLinkKey(Link link) { | 819 | + static LinkKey canonicalLinkKey(Link link) { |
820 | String sn = link.src().elementId().toString(); | 820 | String sn = link.src().elementId().toString(); |
821 | String dn = link.dst().elementId().toString(); | 821 | String dn = link.dst().elementId().toString(); |
822 | return sn.compareTo(dn) < 0 ? | 822 | return sn.compareTo(dn) < 0 ? |
... | @@ -824,7 +824,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { | ... | @@ -824,7 +824,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
824 | } | 824 | } |
825 | 825 | ||
826 | // Representation of link and its inverse and any traffic data. | 826 | // Representation of link and its inverse and any traffic data. |
827 | - private class BiLink { | 827 | + static class BiLink { |
828 | public final LinkKey key; | 828 | public final LinkKey key; |
829 | public final Link one; | 829 | public final Link one; |
830 | public Link two; | 830 | public Link two; |
... | @@ -861,7 +861,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { | ... | @@ -861,7 +861,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
861 | } | 861 | } |
862 | 862 | ||
863 | // Auxiliary key/value carrier. | 863 | // Auxiliary key/value carrier. |
864 | - private class Prop { | 864 | + static class Prop { |
865 | public final String key; | 865 | public final String key; |
866 | public final String value; | 866 | public final String value; |
867 | 867 | ||
... | @@ -872,14 +872,14 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { | ... | @@ -872,14 +872,14 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
872 | } | 872 | } |
873 | 873 | ||
874 | // Auxiliary properties separator | 874 | // Auxiliary properties separator |
875 | - private class Separator extends Prop { | 875 | + static class Separator extends Prop { |
876 | protected Separator() { | 876 | protected Separator() { |
877 | super("-", ""); | 877 | super("-", ""); |
878 | } | 878 | } |
879 | } | 879 | } |
880 | 880 | ||
881 | // Auxiliary carrier of data for requesting traffic message. | 881 | // Auxiliary carrier of data for requesting traffic message. |
882 | - protected class TrafficClass { | 882 | + static class TrafficClass { |
883 | public final boolean showTraffic; | 883 | public final boolean showTraffic; |
884 | public final String type; | 884 | public final String type; |
885 | public final Iterable<Intent> intents; | 885 | public final Iterable<Intent> intents; | ... | ... |
... | @@ -58,21 +58,21 @@ public class UiExtensionManager implements UiExtensionService { | ... | @@ -58,21 +58,21 @@ public class UiExtensionManager implements UiExtensionService { |
58 | private static UiExtension createCoreExtension() { | 58 | private static UiExtension createCoreExtension() { |
59 | List<UiView> coreViews = of(new UiView("topo", "Topology View"), | 59 | List<UiView> coreViews = of(new UiView("topo", "Topology View"), |
60 | new UiView("device", "Devices"), | 60 | new UiView("device", "Devices"), |
61 | + new UiView("link", "Links"), | ||
61 | new UiView("host", "Hosts"), | 62 | new UiView("host", "Hosts"), |
62 | - new UiView("app", "Applications"), | ||
63 | new UiView("intent", "Intents"), | 63 | new UiView("intent", "Intents"), |
64 | + new UiView("app", "Applications"), | ||
64 | new UiView("cluster", "Cluster Nodes"), | 65 | new UiView("cluster", "Cluster Nodes"), |
65 | - new UiView("link", "Links"), | ||
66 | new UiView("sample", "Sample")); | 66 | new UiView("sample", "Sample")); |
67 | UiMessageHandlerFactory messageHandlerFactory = | 67 | UiMessageHandlerFactory messageHandlerFactory = |
68 | () -> ImmutableList.of( | 68 | () -> ImmutableList.of( |
69 | new TopologyViewMessageHandler(), | 69 | new TopologyViewMessageHandler(), |
70 | new DeviceViewMessageHandler(), | 70 | new DeviceViewMessageHandler(), |
71 | + new LinkViewMessageHandler(), | ||
71 | new HostViewMessageHandler(), | 72 | new HostViewMessageHandler(), |
72 | - new ApplicationViewMessageHandler(), | ||
73 | new IntentViewMessageHandler(), | 73 | new IntentViewMessageHandler(), |
74 | - new ClusterViewMessageHandler(), | 74 | + new ApplicationViewMessageHandler(), |
75 | - new LinkViewMessageHandler() | 75 | + new ClusterViewMessageHandler() |
76 | ); | 76 | ); |
77 | return new UiExtension(coreViews, messageHandlerFactory, "core", | 77 | return new UiExtension(coreViews, messageHandlerFactory, "core", |
78 | UiExtensionManager.class.getClassLoader()); | 78 | UiExtensionManager.class.getClassLoader()); | ... | ... |
1 | -<link rel="stylesheet" href="app/view/sample/sample.css"> | 1 | +<!-- Builtin view stylesheets are in the main index.html --> |
2 | -<link rel="stylesheet" href="app/view/topo/topo.css"> | ||
3 | -<link rel="stylesheet" href="app/view/device/device.css"> | ||
4 | -<link rel="stylesheet" href="app/view/host/host.css"> | ||
5 | -<link rel="stylesheet" href="app/view/app/app.css"> | ||
6 | -<link rel="stylesheet" href="app/view/intent/intent.css"> | ||
7 | -<link rel="stylesheet" href="app/view/cluster/cluster.css"> | ||
8 | -<link rel="stylesheet" href="app/view/link/link.css"> | ... | ... |
1 | -<script src="app/view/topo/topo.js"></script> | 1 | +<!-- Builtin view javascript is in the main index.html --> |
2 | -<script src="app/view/topo/topoD3.js"></script> | ||
3 | -<script src="app/view/topo/topoEvent.js"></script> | ||
4 | -<script src="app/view/topo/topoFilter.js"></script> | ||
5 | -<script src="app/view/topo/topoForce.js"></script> | ||
6 | -<script src="app/view/topo/topoInst.js"></script> | ||
7 | -<script src="app/view/topo/topoLink.js"></script> | ||
8 | -<script src="app/view/topo/topoModel.js"></script> | ||
9 | -<script src="app/view/topo/topoOblique.js"></script> | ||
10 | -<script src="app/view/topo/topoPanel.js"></script> | ||
11 | -<script src="app/view/topo/topoSelect.js"></script> | ||
12 | -<script src="app/view/topo/topoSprite.js"></script> | ||
13 | -<script src="app/view/topo/topoTraffic.js"></script> | ||
14 | -<script src="app/view/topo/topoToolbar.js"></script> | ||
15 | -<script src="app/view/device/device.js"></script> | ||
16 | -<script src="app/view/host/host.js"></script> | ||
17 | -<script src="app/view/app/app.js"></script> | ||
18 | -<script src="app/view/intent/intent.js"></script> | ||
19 | -<script src="app/view/cluster/cluster.js"></script> | ||
20 | -<script src="app/view/link/link.js"></script> | ||
21 | -<script src="app/view/sample/sample.js"></script> | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -23,27 +23,29 @@ | ... | @@ -23,27 +23,29 @@ |
23 | sort-callback="sortCallback(requestParams)"> | 23 | sort-callback="sortCallback(requestParams)"> |
24 | <thead> | 24 | <thead> |
25 | <tr> | 25 | <tr> |
26 | - <th colId="src" sortable>Source </th> | 26 | + <th colId="one" sortable>Port 1 </th> |
27 | - <th colId="dst" sortable>Destination </th> | 27 | + <th colId="two" sortable>Port 2 </th> |
28 | <th colId="type" sortable>Type </th> | 28 | <th colId="type" sortable>Type </th> |
29 | <th colId="state" sortable>State </th> | 29 | <th colId="state" sortable>State </th> |
30 | + <th colId="direction" sortable>Direction </th> | ||
30 | <th colId="durable" sortable>Durable </th> | 31 | <th colId="durable" sortable>Durable </th> |
31 | </tr> | 32 | </tr> |
32 | </thead> | 33 | </thead> |
33 | 34 | ||
34 | <tbody> | 35 | <tbody> |
35 | <tr ng-hide="ctrl.tableData.length"> | 36 | <tr ng-hide="ctrl.tableData.length"> |
36 | - <td class="nodata" colspan="5"> | 37 | + <td class="nodata" colspan="6"> |
37 | No Links found | 38 | No Links found |
38 | </td> | 39 | </td> |
39 | </tr> | 40 | </tr> |
40 | 41 | ||
41 | <tr ng-repeat="link in ctrl.tableData" | 42 | <tr ng-repeat="link in ctrl.tableData" |
42 | ng-repeat-done> | 43 | ng-repeat-done> |
43 | - <td>{{link.src}}</td> | 44 | + <td>{{link.one}}</td> |
44 | - <td>{{link.dst}}</td> | 45 | + <td>{{link.two}}</td> |
45 | <td>{{link.type}}</td> | 46 | <td>{{link.type}}</td> |
46 | <td>{{link.state}}</td> | 47 | <td>{{link.state}}</td> |
48 | + <td>{{link.direction}}</td> | ||
47 | <td>{{link.durable}}</td> | 49 | <td>{{link.durable}}</td> |
48 | </tr> | 50 | </tr> |
49 | </tbody> | 51 | </tbody> | ... | ... |
... | @@ -94,8 +94,7 @@ | ... | @@ -94,8 +94,7 @@ |
94 | <link rel="stylesheet" href="app/fw/widget/tooltip.css"> | 94 | <link rel="stylesheet" href="app/fw/widget/tooltip.css"> |
95 | <link rel="stylesheet" href="app/fw/widget/table.css"> | 95 | <link rel="stylesheet" href="app/fw/widget/table.css"> |
96 | 96 | ||
97 | - <!-- This is where contributed javascript will get injected --> | 97 | + <!-- Builtin views javascript. --> |
98 | - <!-- {INJECTED-JAVASCRIPT-START} --> | ||
99 | <script src="app/view/topo/topo.js"></script> | 98 | <script src="app/view/topo/topo.js"></script> |
100 | <script src="app/view/topo/topoD3.js"></script> | 99 | <script src="app/view/topo/topoD3.js"></script> |
101 | <script src="app/view/topo/topoEvent.js"></script> | 100 | <script src="app/view/topo/topoEvent.js"></script> |
... | @@ -111,25 +110,29 @@ | ... | @@ -111,25 +110,29 @@ |
111 | <script src="app/view/topo/topoTraffic.js"></script> | 110 | <script src="app/view/topo/topoTraffic.js"></script> |
112 | <script src="app/view/topo/topoToolbar.js"></script> | 111 | <script src="app/view/topo/topoToolbar.js"></script> |
113 | <script src="app/view/device/device.js"></script> | 112 | <script src="app/view/device/device.js"></script> |
113 | + <script src="app/view/link/link.js"></script> | ||
114 | <script src="app/view/host/host.js"></script> | 114 | <script src="app/view/host/host.js"></script> |
115 | - <script src="app/view/app/app.js"></script> | ||
116 | <script src="app/view/intent/intent.js"></script> | 115 | <script src="app/view/intent/intent.js"></script> |
117 | <script src="app/view/cluster/cluster.js"></script> | 116 | <script src="app/view/cluster/cluster.js"></script> |
118 | - <script src="app/view/link/link.js"></script> | 117 | + <script src="app/view/app/app.js"></script> |
119 | <script src="app/view/sample/sample.js"></script> | 118 | <script src="app/view/sample/sample.js"></script> |
120 | - <!-- {INJECTED-JAVASCRIPT-END} --> | ||
121 | 119 | ||
120 | + <!-- This is where contributed javascript will get injected --> | ||
121 | + <!-- {INJECTED-JAVASCRIPT-START} --> | ||
122 | + <!-- {INJECTED-JAVASCRIPT-END} --> | ||
122 | 123 | ||
123 | - <!-- This is where contributed stylesheets will get injected --> | 124 | + <!-- Builtin views stylesheets. --> |
124 | - <!-- {INJECTED-STYLESHEETS-START} --> | ||
125 | <link rel="stylesheet" href="app/view/topo/topo.css"> | 125 | <link rel="stylesheet" href="app/view/topo/topo.css"> |
126 | <link rel="stylesheet" href="app/view/device/device.css"> | 126 | <link rel="stylesheet" href="app/view/device/device.css"> |
127 | + <link rel="stylesheet" href="app/view/link/link.css"> | ||
127 | <link rel="stylesheet" href="app/view/host/host.css"> | 128 | <link rel="stylesheet" href="app/view/host/host.css"> |
128 | - <link rel="stylesheet" href="app/view/app/app.css"> | ||
129 | <link rel="stylesheet" href="app/view/intent/intent.css"> | 129 | <link rel="stylesheet" href="app/view/intent/intent.css"> |
130 | + <link rel="stylesheet" href="app/view/app/app.css"> | ||
130 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> | 131 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> |
131 | - <link rel="stylesheet" href="app/view/link/link.css"> | ||
132 | <link rel="stylesheet" href="app/view/sample/sample.css"> | 132 | <link rel="stylesheet" href="app/view/sample/sample.css"> |
133 | + | ||
134 | + <!-- This is where contributed stylesheets will get injected --> | ||
135 | + <!-- {INJECTED-STYLESHEETS-START} --> | ||
133 | <!-- {INJECTED-STYLESHEETS-END} --> | 136 | <!-- {INJECTED-STYLESHEETS-END} --> |
134 | 137 | ||
135 | </head> | 138 | </head> | ... | ... |
-
Please register or login to post a comment