Committed by
Gerrit Code Review
[ONOS-2096] Let GUI support tunnel
1. add a TunnelViewMesageHandler to handle message from the client. 2. add a tunnel view to show tunnel information on the GUI Change-Id: I1d9a73c0e4e8ed1a55cdbef09426995989c4e76a
Showing
6 changed files
with
228 additions
and
2 deletions
| 1 | +package org.onosproject.ui.impl; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 4 | +import com.google.common.collect.ImmutableSet; | ||
| 5 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
| 6 | +import org.onosproject.incubator.net.tunnel.TunnelService; | ||
| 7 | +import org.onosproject.ui.RequestHandler; | ||
| 8 | +import org.onosproject.ui.UiMessageHandler; | ||
| 9 | +import org.onosproject.ui.table.TableModel; | ||
| 10 | +import org.onosproject.ui.table.TableRequestHandler; | ||
| 11 | +import org.onosproject.ui.table.cell.EnumFormatter; | ||
| 12 | + | ||
| 13 | +import java.util.Collection; | ||
| 14 | + | ||
| 15 | +public class TunnelViewMessageHandler extends UiMessageHandler { | ||
| 16 | + private static final String TUNNEL_DATA_REQ = "tunnelDataRequest"; | ||
| 17 | + private static final String TUNNEL_DATA_RESP = "tunnelDataResponse"; | ||
| 18 | + private static final String TUNNELS = "tunnels"; | ||
| 19 | + private static final String ID = "id"; | ||
| 20 | + private static final String NAME = "name"; | ||
| 21 | + private static final String ONE = "one"; | ||
| 22 | + private static final String TWO = "two"; | ||
| 23 | + private static final String TYPE = "type"; | ||
| 24 | + private static final String GROUP_ID = "group_id"; | ||
| 25 | + | ||
| 26 | + private static final String BANDWIDTH = "bandwidth"; | ||
| 27 | + private static final String PATH = "path"; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + private static final String[] COL_IDS = { | ||
| 31 | + ID, NAME, ONE, TWO, TYPE, GROUP_ID, | ||
| 32 | + BANDWIDTH, PATH | ||
| 33 | + }; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + protected Collection<RequestHandler> createRequestHandlers() { | ||
| 37 | + return ImmutableSet.of(new TunnelDataRequestHandler()); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + private final class TunnelDataRequestHandler extends TableRequestHandler { | ||
| 41 | + | ||
| 42 | + public TunnelDataRequestHandler() { | ||
| 43 | + super(TUNNEL_DATA_REQ, TUNNEL_DATA_RESP, TUNNELS); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + protected String[] getColumnIds() { | ||
| 48 | + return COL_IDS; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + protected TableModel createTableModel() { | ||
| 53 | + TableModel tm = super.createTableModel(); | ||
| 54 | + //TODO add more formater class so that we can get a more readable table | ||
| 55 | + tm.setFormatter(TYPE, EnumFormatter.INSTANCE); | ||
| 56 | + return tm; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + protected void populateTable(TableModel tm, ObjectNode payload) { | ||
| 61 | + TunnelService ts = get(TunnelService.class); | ||
| 62 | + ts.queryAllTunnels().forEach(tunnel -> { | ||
| 63 | + populateRow(tm.addRow(), tunnel); | ||
| 64 | + }); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + private void populateRow(TableModel.Row row, Tunnel tunnel) { | ||
| 70 | + row.cell(ID, tunnel.tunnelId().id()) | ||
| 71 | + .cell(NAME, tunnel.tunnelName().value()) | ||
| 72 | + .cell(ONE, tunnel.src()) | ||
| 73 | + .cell(TWO, tunnel.dst()) | ||
| 74 | + .cell(TYPE, tunnel.type()) | ||
| 75 | + .cell(GROUP_ID, tunnel.groupId().id()) | ||
| 76 | + .cell(BANDWIDTH, tunnel.annotations().value(BANDWIDTH)) | ||
| 77 | + .cell(PATH, tunnel.path()); | ||
| 78 | + } | ||
| 79 | +} |
| ... | @@ -84,7 +84,9 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { | ... | @@ -84,7 +84,9 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { |
| 84 | new UiViewHidden("group"), | 84 | new UiViewHidden("group"), |
| 85 | new UiView(NETWORK, "link", "Links", "nav_links"), | 85 | new UiView(NETWORK, "link", "Links", "nav_links"), |
| 86 | new UiView(NETWORK, "host", "Hosts", "nav_hosts"), | 86 | new UiView(NETWORK, "host", "Hosts", "nav_hosts"), |
| 87 | - new UiView(NETWORK, "intent", "Intents", "nav_intents") | 87 | + new UiView(NETWORK, "intent", "Intents", "nav_intents"), |
| 88 | + //TODO add a new type of icon for tunnel | ||
| 89 | + new UiView(NETWORK, "tunnel", "Tunnels", "nav_links") | ||
| 88 | ); | 90 | ); |
| 89 | 91 | ||
| 90 | UiMessageHandlerFactory messageHandlerFactory = | 92 | UiMessageHandlerFactory messageHandlerFactory = |
| ... | @@ -99,7 +101,8 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { | ... | @@ -99,7 +101,8 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { |
| 99 | new IntentViewMessageHandler(), | 101 | new IntentViewMessageHandler(), |
| 100 | new ApplicationViewMessageHandler(), | 102 | new ApplicationViewMessageHandler(), |
| 101 | new SettingsViewMessageHandler(), | 103 | new SettingsViewMessageHandler(), |
| 102 | - new ClusterViewMessageHandler() | 104 | + new ClusterViewMessageHandler(), |
| 105 | + new TunnelViewMessageHandler() | ||
| 103 | ); | 106 | ); |
| 104 | 107 | ||
| 105 | UiTopoOverlayFactory topoOverlayFactory = | 108 | UiTopoOverlayFactory topoOverlayFactory = | ... | ... |
| 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-tunnel h2 { | ||
| 22 | + display: inline-block; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +#ov-tunnel div.ctrl-btns { | ||
| 26 | + width: 45px; | ||
| 27 | +} | ||
| ... | \ 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 | +<!-- Tunnel partial HTML --> | ||
| 18 | +<div id="ov-tunnel"> | ||
| 19 | + <div class="tabular-header"> | ||
| 20 | + <h2>Tunnels ({{tableData.length}} total)</h2> | ||
| 21 | + <div class="ctrl-btns"> | ||
| 22 | + <div class="refresh" ng-class="{active: autoRefresh}" | ||
| 23 | + icon icon-size="36" icon-id="refresh" | ||
| 24 | + tooltip tt-msg="autoRefreshTip" | ||
| 25 | + ng-click="toggleRefresh()"></div> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + | ||
| 29 | + <div class="summary-list" onos-table-resize> | ||
| 30 | + <div ng-show="loading" class="loading-wheel" | ||
| 31 | + icon icon-id="loading" icon-size="75"></div> | ||
| 32 | + | ||
| 33 | + <div class="table-header" onos-sortable-header> | ||
| 34 | + <table> | ||
| 35 | + <tr> | ||
| 36 | + <td colId="id" sortable>ID </td> | ||
| 37 | + <td colId="name" sortable>Name</td> | ||
| 38 | + <td colId="one" sortable>Port 1 </td> | ||
| 39 | + <td colId="two" sortable>Port 2 </td> | ||
| 40 | + <td colId="type" sortable>Type </td> | ||
| 41 | + <td colId="group_id" sortable>Group Id</td> | ||
| 42 | + <td colId="bandwidth" sortable>Bandwidth</td> | ||
| 43 | + <td colId="path" sortable>Path</td> | ||
| 44 | + </tr> | ||
| 45 | + </table> | ||
| 46 | + </div> | ||
| 47 | + | ||
| 48 | + <div class="table-body"> | ||
| 49 | + <table onos-flash-changes id-prop="one"> | ||
| 50 | + <tr ng-if="!tableData.length" class="no-data"> | ||
| 51 | + <td colspan="6"> | ||
| 52 | + No tunnels found | ||
| 53 | + </td> | ||
| 54 | + </tr> | ||
| 55 | + | ||
| 56 | + <tr ng-repeat="tunnel in tableData track by $index" | ||
| 57 | + ng-repeat-complete row-id="{{tunnel.id}}"> | ||
| 58 | + <td>{{tunnel.id}}</td> | ||
| 59 | + <td>{{tunnel.name}}</td> | ||
| 60 | + <td>{{tunnel.one}}</td> | ||
| 61 | + <td>{{tunnel.two}}</td> | ||
| 62 | + <td>{{tunnel.type}}</td> | ||
| 63 | + <td>{{tunnel.group_id}}</td> | ||
| 64 | + <td>{{tunnel.path}}</td> | ||
| 65 | + </tr> | ||
| 66 | + </table> | ||
| 67 | + </div> | ||
| 68 | + | ||
| 69 | + </div> | ||
| 70 | + | ||
| 71 | +</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('ovTunnel', []) | ||
| 25 | + .controller('OvTunnelCtrl', | ||
| 26 | + ['$log', '$scope', '$sce', 'FnService', 'TableBuilderService', | ||
| 27 | + | ||
| 28 | + function ($log, $scope, $sce, fs, tbs) { | ||
| 29 | + tbs.buildTable({ | ||
| 30 | + scope: $scope, | ||
| 31 | + tag: 'tunnel' | ||
| 32 | + }); | ||
| 33 | + | ||
| 34 | + $scope.$watch('tableData', function () { | ||
| 35 | + if (!fs.isEmptyObject($scope.tableData)) { | ||
| 36 | + $scope.tableData.forEach(function (tunnel) { | ||
| 37 | + //tunnel.direction = $sce.trustAsHtml(tunnel.direction); | ||
| 38 | + }); | ||
| 39 | + } | ||
| 40 | + }); | ||
| 41 | + | ||
| 42 | + $log.log('OvTunnelCtrl has been created'); | ||
| 43 | + }]); | ||
| 44 | +}()); |
| ... | @@ -121,6 +121,7 @@ | ... | @@ -121,6 +121,7 @@ |
| 121 | <script src="app/view/app/app.js"></script> | 121 | <script src="app/view/app/app.js"></script> |
| 122 | <script src="app/view/settings/settings.js"></script> | 122 | <script src="app/view/settings/settings.js"></script> |
| 123 | <script src="app/view/cluster/cluster.js"></script> | 123 | <script src="app/view/cluster/cluster.js"></script> |
| 124 | + <script src="app/view/tunnel/tunnel.js"></script> | ||
| 124 | 125 | ||
| 125 | <!-- This is where contributed javascript will get injected --> | 126 | <!-- This is where contributed javascript will get injected --> |
| 126 | <!-- {INJECTED-JAVASCRIPT-START} --> | 127 | <!-- {INJECTED-JAVASCRIPT-START} --> |
| ... | @@ -138,6 +139,7 @@ | ... | @@ -138,6 +139,7 @@ |
| 138 | <link rel="stylesheet" href="app/view/app/app.css"> | 139 | <link rel="stylesheet" href="app/view/app/app.css"> |
| 139 | <link rel="stylesheet" href="app/view/settings/settings.css"> | 140 | <link rel="stylesheet" href="app/view/settings/settings.css"> |
| 140 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> | 141 | <link rel="stylesheet" href="app/view/cluster/cluster.css"> |
| 142 | + <link rel="stylesheet" href="app/view/tunnel/tunnel.css"> | ||
| 141 | 143 | ||
| 142 | <!-- This is where contributed stylesheets will get injected --> | 144 | <!-- This is where contributed stylesheets will get injected --> |
| 143 | <!-- {INJECTED-STYLESHEETS-START} --> | 145 | <!-- {INJECTED-STYLESHEETS-START} --> | ... | ... |
-
Please register or login to post a comment