mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-30 15:52:08 +01:00
[ONOS-4136] Implement Partitions View.
show partition info in table format Change-Id: I5df276ab092715249f97ff118d0012da09789f49
This commit is contained in:
parent
da878fcbf0
commit
c5a99dc2da
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.onosproject.ui.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.onosproject.store.primitives.PartitionAdminService;
|
||||
import org.onosproject.store.service.PartitionInfo;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.CellFormatter;
|
||||
import org.onosproject.ui.table.TableModel;
|
||||
import org.onosproject.ui.table.TableRequestHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Message handler for partition view related messages.
|
||||
*/
|
||||
public class PartitionViewMessageHandler extends UiMessageHandler {
|
||||
private static final String PARTITION_DATA_REQ = "partitionDataRequest";
|
||||
private static final String PARTITION_DATA_RESP = "partitionDataResponse";
|
||||
private static final String PARTITIONS = "partitions";
|
||||
|
||||
private static final String NAME = "name";
|
||||
private static final String TERM = "term";
|
||||
private static final String LEADER = "leader";
|
||||
private static final String MEMBERS = "members";
|
||||
|
||||
private static final String[] COL_IDS = {NAME, TERM, LEADER, MEMBERS};
|
||||
|
||||
@Override
|
||||
protected Collection<RequestHandler> createRequestHandlers() {
|
||||
return ImmutableSet.of(new PartitionDataHandler());
|
||||
}
|
||||
|
||||
private final class PartitionDataHandler extends TableRequestHandler {
|
||||
private static final String NO_ROWS_MESSAGE = "No partitions found";
|
||||
|
||||
private PartitionDataHandler() {
|
||||
super(PARTITION_DATA_REQ, PARTITION_DATA_RESP, PARTITIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getColumnIds() {
|
||||
return COL_IDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String noRowsMessage(ObjectNode payload) {
|
||||
return NO_ROWS_MESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultColumnId() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TableModel createTableModel() {
|
||||
TableModel tm = super.createTableModel();
|
||||
tm.setFormatter(MEMBERS, new MembersFormatter());
|
||||
return tm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateTable(TableModel tm, ObjectNode payload) {
|
||||
PartitionAdminService ps = get(PartitionAdminService.class);
|
||||
for (PartitionInfo partition : ps.partitionInfo()) {
|
||||
populateRow(tm.addRow(), partition);
|
||||
}
|
||||
}
|
||||
|
||||
private void populateRow(TableModel.Row row, PartitionInfo p) {
|
||||
row.cell(NAME, p.name())
|
||||
.cell(TERM, p.term())
|
||||
.cell(LEADER, p.leader())
|
||||
.cell(MEMBERS, p.members());
|
||||
}
|
||||
|
||||
private final class MembersFormatter implements CellFormatter {
|
||||
private static final String COMMA = ", ";
|
||||
|
||||
@Override
|
||||
public String format(Object value) {
|
||||
List<String> members = (List<String>) value;
|
||||
if (members.isEmpty()) {
|
||||
return "(No members for this partition)";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String m : members) {
|
||||
sb.append(m).append(COMMA);
|
||||
}
|
||||
removeTrailingComma(sb);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private StringBuilder removeTrailingComma(StringBuilder sb) {
|
||||
int pos = sb.lastIndexOf(COMMA);
|
||||
sb.delete(pos, sb.length());
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,6 +130,7 @@ public class UiExtensionManager
|
||||
new UiView(PLATFORM, "settings", "Settings", "nav_settings"),
|
||||
new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"),
|
||||
new UiView(PLATFORM, "processor", "Packet Processors", "nav_processors"),
|
||||
new UiView(PLATFORM, "partition", "Partitions", "nav_partitions"),
|
||||
new UiView(NETWORK, "topo", "Topology", "nav_topo"),
|
||||
|
||||
// FIXME: leave commented out for now, while still under development
|
||||
@ -166,7 +167,8 @@ public class UiExtensionManager
|
||||
new SettingsViewMessageHandler(),
|
||||
new ClusterViewMessageHandler(),
|
||||
new ProcessorViewMessageHandler(),
|
||||
new TunnelViewMessageHandler()
|
||||
new TunnelViewMessageHandler(),
|
||||
new PartitionViewMessageHandler()
|
||||
);
|
||||
|
||||
UiTopoOverlayFactory topoOverlayFactory =
|
||||
|
||||
38
web/gui/src/main/webapp/app/view/partition/partition.css
Normal file
38
web/gui/src/main/webapp/app/view/partition/partition.css
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2015-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
ONOS GUI -- Partition View (layout) -- CSS file
|
||||
*/
|
||||
|
||||
#ov-partition h2 {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#ov-partition div.ctrl-btns {
|
||||
}
|
||||
|
||||
#ov-partition td {
|
||||
text-align: center;
|
||||
}
|
||||
#ov-partition td.right {
|
||||
text-align: right;
|
||||
}
|
||||
#ov-partition td.bands {
|
||||
text-align: left;
|
||||
padding-left: 36px;
|
||||
opacity: 0.65;
|
||||
}
|
||||
44
web/gui/src/main/webapp/app/view/partition/partition.html
Normal file
44
web/gui/src/main/webapp/app/view/partition/partition.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!-- Partition partial HTML -->
|
||||
<div id="ov-partition">
|
||||
<div class="tabular-header">
|
||||
<h2>Partitions ({{tableData.length}} total)</h2>
|
||||
<div class="ctrl-btns">
|
||||
<div class="refresh" ng-class="{active: autoRefresh}"
|
||||
icon icon-id="refresh" icon-size="42"
|
||||
tooltip tt-msg="autoRefreshTip"
|
||||
ng-click="toggleRefresh()"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="summary-list" onos-table-resize>
|
||||
<div class="table-header" onos-sortable-header>
|
||||
<table>
|
||||
<tr>
|
||||
<td colId="name" col-width="100px" sortable>Name </td>
|
||||
<td colId="term" col-width="100px" sortable>Term </td>
|
||||
<td colId="leader" col-width="200px" sortable>Leader </td>
|
||||
<td colId="members" >Members </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="table-body">
|
||||
<table onos-flash-changes id-prop="name">
|
||||
<tr ng-if="!tableData.length" class="no-data">
|
||||
<td colspan="4">
|
||||
{{annots.no_rows_msg}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr ng-repeat="partition in tableData track by $index"
|
||||
ng-class="{selected: partition.name === selId}"
|
||||
ng-repeat-complete row-id="{{partition.name}}">
|
||||
<td>{{partition.name}}</td>
|
||||
<td>{{partition.term}}</td>
|
||||
<td>{{partition.leader}}</td>
|
||||
<td>{{partition.members}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
36
web/gui/src/main/webapp/app/view/partition/partition.js
Normal file
36
web/gui/src/main/webapp/app/view/partition/partition.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2015-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
ONOS GUI -- Partition View Module
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ovPartition', [])
|
||||
.controller('OvPartitionCtrl',
|
||||
['$log', '$scope', '$sce', 'FnService', 'TableBuilderService',
|
||||
|
||||
function ($log, $scope, $sce, fs, tbs) {
|
||||
tbs.buildTable({
|
||||
scope: $scope,
|
||||
tag: 'partition'
|
||||
});
|
||||
|
||||
$log.log('OvPartitionCtrl has been created');
|
||||
}]);
|
||||
}());
|
||||
@ -197,6 +197,7 @@
|
||||
<script src="app/view/port/port.js"></script>
|
||||
<script src="app/view/group/group.js"></script>
|
||||
<script src="app/view/meter/meter.js"></script>
|
||||
<script src="app/view/partition/partition.js"></script>
|
||||
<script src="app/view/link/link.js"></script>
|
||||
<script src="app/view/host/host.js"></script>
|
||||
<script src="app/view/intent/intent.js"></script>
|
||||
@ -223,6 +224,7 @@
|
||||
<link rel="stylesheet" href="app/view/group/group-theme.css">
|
||||
<link rel="stylesheet" href="app/view/meter/meter.css">
|
||||
<link rel="stylesheet" href="app/view/meter/meter-theme.css">
|
||||
<link rel="stylesheet" href="app/view/partition/partition.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/intent/intent.css">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user