GUI -- Base Link View added -- WIP.
Change-Id: Iad0bb3d4a796b420d0fcb071812d320c35941b6b
Showing
9 changed files
with
219 additions
and
1 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.ui.impl; | ||
18 | + | ||
19 | +import com.fasterxml.jackson.databind.node.ArrayNode; | ||
20 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
21 | +import com.google.common.collect.ImmutableSet; | ||
22 | +import org.onosproject.net.ConnectPoint; | ||
23 | +import org.onosproject.net.Link; | ||
24 | +import org.onosproject.net.link.LinkService; | ||
25 | + | ||
26 | +import java.util.ArrayList; | ||
27 | +import java.util.Arrays; | ||
28 | +import java.util.List; | ||
29 | + | ||
30 | +/** | ||
31 | + * Message handler for link view related messages. | ||
32 | + */ | ||
33 | +public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { | ||
34 | + | ||
35 | + /** | ||
36 | + * Creates a new message handler for the link messages. | ||
37 | + */ | ||
38 | + protected LinkViewMessageHandler() { | ||
39 | + super(ImmutableSet.of("linkDataRequest")); | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public void process(ObjectNode message) { | ||
44 | + ObjectNode payload = payload(message); | ||
45 | + String sortCol = string(payload, "sortCol", "src"); | ||
46 | + String sortDir = string(payload, "sortDir", "asc"); | ||
47 | + | ||
48 | + LinkService service = get(LinkService.class); | ||
49 | + TableRow[] rows = generateTableRows(service); | ||
50 | + RowComparator rc = | ||
51 | + new RowComparator(sortCol, RowComparator.direction(sortDir)); | ||
52 | + Arrays.sort(rows, rc); | ||
53 | + ArrayNode links = generateArrayNode(rows); | ||
54 | + ObjectNode rootNode = mapper.createObjectNode(); | ||
55 | + rootNode.set("links", links); | ||
56 | + | ||
57 | + connection().sendMessage("linkDataResponse", 0, rootNode); | ||
58 | + } | ||
59 | + | ||
60 | + private TableRow[] generateTableRows(LinkService service) { | ||
61 | + List<TableRow> list = new ArrayList<>(); | ||
62 | + for (Link link : service.getLinks()) { | ||
63 | + list.add(new LinkTableRow(link)); | ||
64 | + } | ||
65 | + return list.toArray(new TableRow[list.size()]); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * TableRow implementation for {@link Link links}. | ||
70 | + */ | ||
71 | + private static class LinkTableRow extends AbstractTableRow { | ||
72 | + | ||
73 | + private static final String SOURCE = "src"; | ||
74 | + private static final String DEST = "dst"; | ||
75 | + private static final String TYPE = "type"; | ||
76 | + private static final String STATE = "state"; | ||
77 | + private static final String DURABLE = "durable"; | ||
78 | + | ||
79 | + private static final String[] COL_IDS = { | ||
80 | + SOURCE, DEST, TYPE, STATE, DURABLE | ||
81 | + }; | ||
82 | + | ||
83 | + public LinkTableRow(Link l) { | ||
84 | + ConnectPoint src = l.src(); | ||
85 | + ConnectPoint dst = l.dst(); | ||
86 | + | ||
87 | + add(SOURCE, src.elementId().toString() + "/" + src.port().toString()); | ||
88 | + add(DEST, dst.elementId().toString() + "/" + dst.port().toString()); | ||
89 | + add(TYPE, l.type().toString()); | ||
90 | + add(STATE, l.state().toString()); | ||
91 | + add(DURABLE, Boolean.toString(l.isDurable())); | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + protected String[] columnIds() { | ||
96 | + return COL_IDS; | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | +} |
... | @@ -62,6 +62,7 @@ public class UiExtensionManager implements UiExtensionService { | ... | @@ -62,6 +62,7 @@ public class UiExtensionManager implements UiExtensionService { |
62 | new UiView("app", "Applications"), | 62 | new UiView("app", "Applications"), |
63 | new UiView("intent", "Intents"), | 63 | new UiView("intent", "Intents"), |
64 | new UiView("cluster", "Cluster Nodes"), | 64 | new UiView("cluster", "Cluster Nodes"), |
65 | + new UiView("link", "Links"), | ||
65 | new UiView("sample", "Sample")); | 66 | new UiView("sample", "Sample")); |
66 | UiMessageHandlerFactory messageHandlerFactory = | 67 | UiMessageHandlerFactory messageHandlerFactory = |
67 | () -> ImmutableList.of( | 68 | () -> ImmutableList.of( |
... | @@ -70,7 +71,8 @@ public class UiExtensionManager implements UiExtensionService { | ... | @@ -70,7 +71,8 @@ public class UiExtensionManager implements UiExtensionService { |
70 | new HostViewMessageHandler(), | 71 | new HostViewMessageHandler(), |
71 | new ApplicationViewMessageHandler(), | 72 | new ApplicationViewMessageHandler(), |
72 | new IntentViewMessageHandler(), | 73 | new IntentViewMessageHandler(), |
73 | - new ClusterViewMessageHandler() | 74 | + new ClusterViewMessageHandler(), |
75 | + new LinkViewMessageHandler() | ||
74 | ); | 76 | ); |
75 | return new UiExtension(coreViews, messageHandlerFactory, "core", | 77 | return new UiExtension(coreViews, messageHandlerFactory, "core", |
76 | UiExtensionManager.class.getClassLoader()); | 78 | UiExtensionManager.class.getClassLoader()); | ... | ... |
... | @@ -5,3 +5,4 @@ | ... | @@ -5,3 +5,4 @@ |
5 | <link rel="stylesheet" href="app/view/app/app.css"> | 5 | <link rel="stylesheet" href="app/view/app/app.css"> |
6 | <link rel="stylesheet" href="app/view/intent/intent.css"> | 6 | <link rel="stylesheet" href="app/view/intent/intent.css"> |
7 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> | 7 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> |
8 | +<link rel="stylesheet" href="app/view/link/link.css"> | ... | ... |
... | @@ -17,4 +17,5 @@ | ... | @@ -17,4 +17,5 @@ |
17 | <script src="app/view/app/app.js"></script> | 17 | <script src="app/view/app/app.js"></script> |
18 | <script src="app/view/intent/intent.js"></script> | 18 | <script src="app/view/intent/intent.js"></script> |
19 | <script src="app/view/cluster/cluster.js"></script> | 19 | <script src="app/view/cluster/cluster.js"></script> |
20 | +<script src="app/view/link/link.js"></script> | ||
20 | <script src="app/view/sample/sample.js"></script> | 21 | <script src="app/view/sample/sample.js"></script> | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + ONOS GUI -- Link View -- CSS file | ||
19 | + */ | ||
20 | + | ||
21 | +#ov-link td { | ||
22 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +<!-- | ||
2 | + ~ Copyright 2015 Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | + --> | ||
16 | + | ||
17 | +<!-- Link partial HTML --> | ||
18 | +<div id="ov-link"> | ||
19 | + <h2>Links ({{ctrl.tableData.length}} total)</h2> | ||
20 | + <table class="summary-list" | ||
21 | + onos-fixed-header | ||
22 | + onos-sortable-header | ||
23 | + sort-callback="sortCallback(requestParams)"> | ||
24 | + <thead> | ||
25 | + <tr> | ||
26 | + <th colId="src" sortable>Source </th> | ||
27 | + <th colId="dst" sortable>Destination </th> | ||
28 | + <th colId="type" sortable>Type </th> | ||
29 | + <th colId="state" sortable>State </th> | ||
30 | + <th colId="durable" sortable>Durable </th> | ||
31 | + </tr> | ||
32 | + </thead> | ||
33 | + | ||
34 | + <tbody> | ||
35 | + <tr ng-hide="ctrl.tableData.length"> | ||
36 | + <td class="nodata" colspan="5"> | ||
37 | + No Links found | ||
38 | + </td> | ||
39 | + </tr> | ||
40 | + | ||
41 | + <tr ng-repeat="link in ctrl.tableData" | ||
42 | + ng-repeat-done> | ||
43 | + <td>{{link.src}}</td> | ||
44 | + <td>{{link.dst}}</td> | ||
45 | + <td>{{link.type}}</td> | ||
46 | + <td>{{link.state}}</td> | ||
47 | + <td>{{link.durable}}</td> | ||
48 | + </tr> | ||
49 | + </tbody> | ||
50 | + </table> | ||
51 | + | ||
52 | +</div> |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + ONOS GUI -- Host View Module | ||
19 | + */ | ||
20 | + | ||
21 | +(function () { | ||
22 | + 'use strict'; | ||
23 | + | ||
24 | + angular.module('ovLink', []) | ||
25 | + .controller('OvLinkCtrl', | ||
26 | + ['$log', '$scope', 'TableBuilderService', | ||
27 | + | ||
28 | + function ($log, $scope, tbs) { | ||
29 | + tbs.buildTable({ | ||
30 | + self: this, | ||
31 | + scope: $scope, | ||
32 | + tag: 'link' | ||
33 | + }); | ||
34 | + | ||
35 | + $log.log('OvLinkCtrl has been created'); | ||
36 | + }]); | ||
37 | +}()); |
... | @@ -115,6 +115,7 @@ | ... | @@ -115,6 +115,7 @@ |
115 | <script src="app/view/app/app.js"></script> | 115 | <script src="app/view/app/app.js"></script> |
116 | <script src="app/view/intent/intent.js"></script> | 116 | <script src="app/view/intent/intent.js"></script> |
117 | <script src="app/view/cluster/cluster.js"></script> | 117 | <script src="app/view/cluster/cluster.js"></script> |
118 | + <script src="app/view/link/link.js"></script> | ||
118 | <script src="app/view/sample/sample.js"></script> | 119 | <script src="app/view/sample/sample.js"></script> |
119 | <!-- {INJECTED-JAVASCRIPT-END} --> | 120 | <!-- {INJECTED-JAVASCRIPT-END} --> |
120 | 121 | ||
... | @@ -127,6 +128,7 @@ | ... | @@ -127,6 +128,7 @@ |
127 | <link rel="stylesheet" href="app/view/app/app.css"> | 128 | <link rel="stylesheet" href="app/view/app/app.css"> |
128 | <link rel="stylesheet" href="app/view/intent/intent.css"> | 129 | <link rel="stylesheet" href="app/view/intent/intent.css"> |
129 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> | 130 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> |
131 | + <link rel="stylesheet" href="app/view/link/link.css"> | ||
130 | <link rel="stylesheet" href="app/view/sample/sample.css"> | 132 | <link rel="stylesheet" href="app/view/sample/sample.css"> |
131 | <!-- {INJECTED-STYLESHEETS-END} --> | 133 | <!-- {INJECTED-STYLESHEETS-END} --> |
132 | 134 | ... | ... |
-
Please register or login to post a comment