Bri Prebilic Cole

GUI -- Updated Intent View to have resources and details listed for each intent.

Change-Id: I2dc0f88970a574d0fe91348fa91bc16b7143a68b
......@@ -19,12 +19,21 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.intent.ConnectivityIntent;
import org.onosproject.net.intent.HostToHostIntent;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.LinkCollectionIntent;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
* Message handler for intent view related messages.
......@@ -73,11 +82,131 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler
private static final String KEY = "key";
private static final String TYPE = "type";
private static final String PRIORITY = "priority";
private static final String RESOURCES = "resources";
private static final String DETAILS = "details";
private static final String[] COL_IDS = {
APP_ID, KEY, TYPE, PRIORITY
APP_ID, KEY, TYPE, PRIORITY, RESOURCES, DETAILS
};
private String formatDetails(Intent intent) {
StringBuilder details = new StringBuilder("");
if (intent instanceof ConnectivityIntent) {
ConnectivityIntent ci = (ConnectivityIntent) intent;
if (!ci.selector().criteria().isEmpty()) {
details.append("selector=")
.append(ci.selector().criteria().toString());
}
if (!ci.treatment().allInstructions().isEmpty()) {
details.append("treatment=")
.append(ci.treatment().allInstructions().toString());
}
if (ci.constraints() != null && !ci.constraints().isEmpty()) {
details.append("constraints=")
.append(ci.constraints().toString());
}
}
if (intent instanceof HostToHostIntent) {
HostToHostIntent pi = (HostToHostIntent) intent;
details.append(" host1=")
.append(pi.one().toString())
.append(", host2=")
.append(pi.two().toString());
} else if (intent instanceof PointToPointIntent) {
PointToPointIntent pi = (PointToPointIntent) intent;
ConnectPoint ingress = pi.ingressPoint();
ConnectPoint egress = pi.egressPoint();
details.append(" ingress=")
.append(ingress.elementId().toString())
.append('/')
.append(ingress.port().toString())
.append(", egress=")
.append(egress.elementId().toString())
.append('/')
.append(egress.port().toString())
.append(' ');
} else if (intent instanceof MultiPointToSinglePointIntent) {
MultiPointToSinglePointIntent pi
= (MultiPointToSinglePointIntent) intent;
Set<ConnectPoint> ingresses = pi.ingressPoints();
ConnectPoint egress = pi.egressPoint();
details.append(" ingress=");
for (ConnectPoint ingress : ingresses) {
details.append(ingress.elementId().toString())
.append('/')
.append(ingress.port().toString())
.append(' ');
}
details.append(", egress=")
.append(egress.elementId().toString())
.append('/')
.append(egress.port().toString())
.append(' ');
} else if (intent instanceof SinglePointToMultiPointIntent) {
SinglePointToMultiPointIntent pi
= (SinglePointToMultiPointIntent) intent;
ConnectPoint ingress = pi.ingressPoint();
Set<ConnectPoint> egresses = pi.egressPoints();
details.append(" ingress=")
.append(ingress.elementId().toString())
.append('/')
.append(ingress.port().toString())
.append(", egress=");
for (ConnectPoint egress : egresses) {
details.append(egress.elementId().toString())
.append('/')
.append(egress.port().toString())
.append(' ');
}
} else if (intent instanceof PathIntent) {
PathIntent pi = (PathIntent) intent;
details.append(" path=")
.append(pi.path().links().toString())
.append(", cost=")
.append(pi.path().cost());
} else if (intent instanceof LinkCollectionIntent) {
LinkCollectionIntent li = (LinkCollectionIntent) intent;
Set<ConnectPoint> egresses = li.egressPoints();
details.append(" links=")
.append(li.links().toString())
.append(", egress=");
for (ConnectPoint egress : egresses) {
details.append(egress.elementId().toString())
.append('/')
.append(egress.port().toString())
.append(' ');
}
}
if (details.toString().equals("")) {
details.append("No details for this intent");
} else {
details.insert(0, "Details: ");
}
return details.toString();
}
private String formatResources(Intent i) {
if (!i.resources().isEmpty()) {
return "Resources: " + i.resources();
}
return "No resources for this intent.";
}
public IntentTableRow(Intent i) {
ApplicationId appid = i.appId();
......@@ -85,6 +214,8 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler
add(KEY, i.key().toString());
add(TYPE, i.getClass().getSimpleName());
add(PRIORITY, Integer.toString(i.priority()));
add(RESOURCES, formatResources(i));
add(DETAILS, formatDetails(i));
}
@Override
......
......@@ -18,5 +18,28 @@
ONOS GUI -- Intent View -- CSS file
*/
#ov-intent td {
}
\ No newline at end of file
.light #ov-intent tr:nth-child(6n + 1),
.light #ov-intent tr:nth-child(6n + 2),
.light #ov-intent tr:nth-child(6n + 3) {
background-color: #eee;
}
.light #ov-intent tr:nth-child(6n + 4),
.light #ov-intent tr:nth-child(6n + 5),
.light #ov-intent tr:nth-child(6n) {
background-color: #ddd;
}
.dark #ov-intent tr:nth-child(6n + 1),
.dark #ov-intent tr:nth-child(6n + 2),
.dark #ov-intent tr:nth-child(6n + 3) {
background-color: #444;
}
.dark #ov-intent tr:nth-child(6n + 4),
.dark #ov-intent tr:nth-child(6n + 5),
.dark #ov-intent tr:nth-child(6n) {
background-color: #333;
}
#ov-intent td.resources,
#ov-intent td.details {
padding-left: 36px;
}
......
......@@ -31,13 +31,18 @@
</thead>
<tbody>
<tr ng-repeat="intent in ctrl.intentData"
ng-repeat-done>
<tr ng-repeat-start="intent in ctrl.intentData">
<td>{{intent.appId}}</td>
<td>{{intent.key}}</td>
<td>{{intent.type}}</td>
<td>{{intent.priority}}</td>
</tr>
<tr>
<td class="resources" colspan="4">{{intent.resources}}</td>
</tr>
<tr ng-repeat-end ng-repeat-done>
<td class="details" colspan="4">{{intent.details}}</td>
</tr>
</tbody>
</table>
......