Thomas Vachuska

Consolidated link list into bidirectional links. Re-ordered views. Took-out buil…

…tin views from injected html snippets.

Change-Id: I8de62b50e437ee6f49a9f2ce9ce6f26bb1e0a6a5
......@@ -19,13 +19,18 @@ package org.onosproject.ui.impl;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
import org.onosproject.net.link.LinkService;
import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink;
/**
* Message handler for link view related messages.
......@@ -42,7 +47,7 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler {
@Override
public void process(ObjectNode message) {
ObjectNode payload = payload(message);
String sortCol = string(payload, "sortCol", "src");
String sortCol = string(payload, "sortCol", "one");
String sortDir = string(payload, "sortDir", "asc");
LinkService service = get(LinkService.class);
......@@ -59,36 +64,54 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler {
private TableRow[] generateTableRows(LinkService service) {
List<TableRow> list = new ArrayList<>();
for (Link link : service.getLinks()) {
list.add(new LinkTableRow(link));
}
// First consolidate all uni-directional links into two-directional ones.
Map<LinkKey, BiLink> biLinks = Maps.newHashMap();
service.getLinks().forEach(link -> addLink(biLinks, link));
// Now scan over all bi-links and produce table rows from them.
biLinks.values().forEach(biLink -> list.add(new LinkTableRow(biLink)));
return list.toArray(new TableRow[list.size()]);
}
/**
* TableRow implementation for {@link Link links}.
* TableRow implementation for {@link org.onosproject.net.Link links}.
*/
private static class LinkTableRow extends AbstractTableRow {
private static final String SOURCE = "src";
private static final String DEST = "dst";
private static final String ONE = "one";
private static final String TWO = "two";
private static final String TYPE = "type";
private static final String STATE = "state";
private static final String DIRECTION = "direction";
private static final String DURABLE = "durable";
private static final String[] COL_IDS = {
SOURCE, DEST, TYPE, STATE, DURABLE
ONE, TWO, TYPE, STATE, DIRECTION, DURABLE
};
public LinkTableRow(Link l) {
ConnectPoint src = l.src();
ConnectPoint dst = l.dst();
public LinkTableRow(BiLink link) {
ConnectPoint src = link.one.src();
ConnectPoint dst = link.one.dst();
add(ONE, src.elementId().toString() + "/" + src.port().toString());
add(TWO, dst.elementId().toString() + "/" + dst.port().toString());
add(TYPE, linkType(link).toLowerCase());
add(STATE, linkState(link).toLowerCase());
add(DIRECTION, link.two != null ? "A <-> B" : "A -> B");
add(DURABLE, Boolean.toString(link.one.isDurable()));
}
private String linkState(BiLink link) {
return link.two == null || link.one.state() == link.two.state() ?
link.one.state().toString() :
link.one.state().toString() + "/" + link.two.state().toString();
}
add(SOURCE, src.elementId().toString() + "/" + src.port().toString());
add(DEST, dst.elementId().toString() + "/" + dst.port().toString());
add(TYPE, l.type().toString());
add(STATE, l.state().toString());
add(DURABLE, Boolean.toString(l.isDurable()));
private String linkType(BiLink link) {
return link.two == null || link.one.type() == link.two.type() ?
link.one.type().toString() :
link.one.type().toString() + "/" + link.two.type().toString();
}
@Override
......
......@@ -719,7 +719,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
private BiLink addLink(Map<LinkKey, BiLink> biLinks, Link link) {
static BiLink addLink(Map<LinkKey, BiLink> biLinks, Link link) {
LinkKey key = canonicalLinkKey(link);
BiLink biLink = biLinks.get(key);
if (biLink != null) {
......@@ -816,7 +816,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// Produces canonical link key, i.e. one that will match link and its inverse.
private LinkKey canonicalLinkKey(Link link) {
static LinkKey canonicalLinkKey(Link link) {
String sn = link.src().elementId().toString();
String dn = link.dst().elementId().toString();
return sn.compareTo(dn) < 0 ?
......@@ -824,7 +824,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// Representation of link and its inverse and any traffic data.
private class BiLink {
static class BiLink {
public final LinkKey key;
public final Link one;
public Link two;
......@@ -861,7 +861,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// Auxiliary key/value carrier.
private class Prop {
static class Prop {
public final String key;
public final String value;
......@@ -872,14 +872,14 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// Auxiliary properties separator
private class Separator extends Prop {
static class Separator extends Prop {
protected Separator() {
super("-", "");
}
}
// Auxiliary carrier of data for requesting traffic message.
protected class TrafficClass {
static class TrafficClass {
public final boolean showTraffic;
public final String type;
public final Iterable<Intent> intents;
......
......@@ -58,21 +58,21 @@ public class UiExtensionManager implements UiExtensionService {
private static UiExtension createCoreExtension() {
List<UiView> coreViews = of(new UiView("topo", "Topology View"),
new UiView("device", "Devices"),
new UiView("link", "Links"),
new UiView("host", "Hosts"),
new UiView("app", "Applications"),
new UiView("intent", "Intents"),
new UiView("app", "Applications"),
new UiView("cluster", "Cluster Nodes"),
new UiView("link", "Links"),
new UiView("sample", "Sample"));
UiMessageHandlerFactory messageHandlerFactory =
() -> ImmutableList.of(
new TopologyViewMessageHandler(),
new DeviceViewMessageHandler(),
new LinkViewMessageHandler(),
new HostViewMessageHandler(),
new ApplicationViewMessageHandler(),
new IntentViewMessageHandler(),
new ClusterViewMessageHandler(),
new LinkViewMessageHandler()
new ApplicationViewMessageHandler(),
new ClusterViewMessageHandler()
);
return new UiExtension(coreViews, messageHandlerFactory, "core",
UiExtensionManager.class.getClassLoader());
......
<link rel="stylesheet" href="app/view/sample/sample.css">
<link rel="stylesheet" href="app/view/topo/topo.css">
<link rel="stylesheet" href="app/view/device/device.css">
<link rel="stylesheet" href="app/view/host/host.css">
<link rel="stylesheet" href="app/view/app/app.css">
<link rel="stylesheet" href="app/view/intent/intent.css">
<link rel="stylesheet" href="app/view/cluster/cluster.css">
<link rel="stylesheet" href="app/view/link/link.css">
<!-- Builtin view stylesheets are in the main index.html -->
......
<script src="app/view/topo/topo.js"></script>
<script src="app/view/topo/topoD3.js"></script>
<script src="app/view/topo/topoEvent.js"></script>
<script src="app/view/topo/topoFilter.js"></script>
<script src="app/view/topo/topoForce.js"></script>
<script src="app/view/topo/topoInst.js"></script>
<script src="app/view/topo/topoLink.js"></script>
<script src="app/view/topo/topoModel.js"></script>
<script src="app/view/topo/topoOblique.js"></script>
<script src="app/view/topo/topoPanel.js"></script>
<script src="app/view/topo/topoSelect.js"></script>
<script src="app/view/topo/topoSprite.js"></script>
<script src="app/view/topo/topoTraffic.js"></script>
<script src="app/view/topo/topoToolbar.js"></script>
<script src="app/view/device/device.js"></script>
<script src="app/view/host/host.js"></script>
<script src="app/view/app/app.js"></script>
<script src="app/view/intent/intent.js"></script>
<script src="app/view/cluster/cluster.js"></script>
<script src="app/view/link/link.js"></script>
<script src="app/view/sample/sample.js"></script>
<!-- Builtin view javascript is in the main index.html -->
\ No newline at end of file
......
......@@ -23,27 +23,29 @@
sort-callback="sortCallback(requestParams)">
<thead>
<tr>
<th colId="src" sortable>Source </th>
<th colId="dst" sortable>Destination </th>
<th colId="one" sortable>Port 1 </th>
<th colId="two" sortable>Port 2 </th>
<th colId="type" sortable>Type </th>
<th colId="state" sortable>State </th>
<th colId="direction" sortable>Direction </th>
<th colId="durable" sortable>Durable </th>
</tr>
</thead>
<tbody>
<tr ng-hide="ctrl.tableData.length">
<td class="nodata" colspan="5">
<td class="nodata" colspan="6">
No Links found
</td>
</tr>
<tr ng-repeat="link in ctrl.tableData"
ng-repeat-done>
<td>{{link.src}}</td>
<td>{{link.dst}}</td>
<td>{{link.one}}</td>
<td>{{link.two}}</td>
<td>{{link.type}}</td>
<td>{{link.state}}</td>
<td>{{link.direction}}</td>
<td>{{link.durable}}</td>
</tr>
</tbody>
......
......@@ -94,8 +94,7 @@
<link rel="stylesheet" href="app/fw/widget/tooltip.css">
<link rel="stylesheet" href="app/fw/widget/table.css">
<!-- This is where contributed javascript will get injected -->
<!-- {INJECTED-JAVASCRIPT-START} -->
<!-- Builtin views javascript. -->
<script src="app/view/topo/topo.js"></script>
<script src="app/view/topo/topoD3.js"></script>
<script src="app/view/topo/topoEvent.js"></script>
......@@ -111,25 +110,29 @@
<script src="app/view/topo/topoTraffic.js"></script>
<script src="app/view/topo/topoToolbar.js"></script>
<script src="app/view/device/device.js"></script>
<script src="app/view/link/link.js"></script>
<script src="app/view/host/host.js"></script>
<script src="app/view/app/app.js"></script>
<script src="app/view/intent/intent.js"></script>
<script src="app/view/cluster/cluster.js"></script>
<script src="app/view/link/link.js"></script>
<script src="app/view/app/app.js"></script>
<script src="app/view/sample/sample.js"></script>
<!-- {INJECTED-JAVASCRIPT-END} -->
<!-- This is where contributed javascript will get injected -->
<!-- {INJECTED-JAVASCRIPT-START} -->
<!-- {INJECTED-JAVASCRIPT-END} -->
<!-- This is where contributed stylesheets will get injected -->
<!-- {INJECTED-STYLESHEETS-START} -->
<!-- Builtin views stylesheets. -->
<link rel="stylesheet" href="app/view/topo/topo.css">
<link rel="stylesheet" href="app/view/device/device.css">
<link rel="stylesheet" href="app/view/link/link.css">
<link rel="stylesheet" href="app/view/host/host.css">
<link rel="stylesheet" href="app/view/app/app.css">
<link rel="stylesheet" href="app/view/intent/intent.css">
<link rel="stylesheet" href="app/view/app/app.css">
<link rel="stylesheet" href="app/view/cluster/cluster.css">
<link rel="stylesheet" href="app/view/link/link.css">
<link rel="stylesheet" href="app/view/sample/sample.css">
<!-- This is where contributed stylesheets will get injected -->
<!-- {INJECTED-STYLESHEETS-START} -->
<!-- {INJECTED-STYLESHEETS-END} -->
</head>
......