Thomas Vachuska
Committed by Gerrit Code Review

GUI -- Added Settings view

Change-Id: Icdabb361bff3ccc3e4d12cb889dd77e62c1519e0
/*
* Copyright 2015 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.cfg.ComponentConfigService;
import org.onosproject.cfg.ConfigProperty;
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiMessageHandler;
import org.onosproject.ui.table.TableModel;
import org.onosproject.ui.table.TableRequestHandler;
import java.util.Collection;
/**
* Message handler for component configuration view related messages.
*/
public class SettingsViewMessageHandler extends UiMessageHandler {
private static final String DATA_REQUEST = "settingDataRequest";
private static final String DATA_RESPONSE = "settingDataResponse";
private static final String SETTINGS = "settings";
private static final String COMPONENT = "component";
private static final String ID = "id";
private static final String TYPE = "type";
private static final String VALUE = "value";
private static final String DEFAULT = "defValue";
private static final String DESC = "desc";
private static final String[] COL_IDS = {
COMPONENT, ID, TYPE, VALUE, DEFAULT, DESC
};
@Override
protected Collection<RequestHandler> createRequestHandlers() {
return ImmutableSet.of(new SettingsRequest());
}
// handler for host table requests
private final class SettingsRequest extends TableRequestHandler {
private SettingsRequest() {
super(DATA_REQUEST, DATA_RESPONSE, SETTINGS);
}
@Override
protected String[] getColumnIds() {
return COL_IDS;
}
@Override
protected String defaultColumnId() {
return COMPONENT;
}
@Override
protected TableModel createTableModel() {
TableModel tm = super.createTableModel();
return tm;
}
@Override
protected void populateTable(TableModel tm, ObjectNode payload) {
ComponentConfigService ccs = get(ComponentConfigService.class);
for (String component : ccs.getComponentNames()) {
for (ConfigProperty prop : ccs.getProperties(component)) {
populateRow(tm.addRow(), component, prop);
}
}
}
private void populateRow(TableModel.Row row, String component, ConfigProperty prop) {
row.cell(COMPONENT, component)
.cell(ID, prop.name())
.cell(TYPE, prop.type().toString().toLowerCase())
.cell(VALUE, prop.value())
.cell(DEFAULT, prop.defaultValue())
.cell(DESC, prop.description());
}
}
}
......@@ -71,6 +71,7 @@ public class UiExtensionManager
private UiExtension createCoreExtension() {
List<UiView> coreViews = of(
new UiView(PLATFORM, "app", "Applications", "nav_apps"),
new UiView(PLATFORM, "settings", "Settings", "nav_settings"),
new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"),
new UiView(NETWORK, "topo", "Topology", "nav_topo"),
new UiView(NETWORK, "device", "Devices", "nav_devs"),
......@@ -94,6 +95,7 @@ public class UiExtensionManager
new GroupViewMessageHandler(),
new IntentViewMessageHandler(),
new ApplicationViewMessageHandler(),
new SettingsViewMessageHandler(),
new ClusterViewMessageHandler()
);
......
......@@ -53,6 +53,7 @@
hostIcon_bgpSpeaker: 'bgpSpeaker',
nav_apps: 'bird',
nav_settings: 'chain',
nav_cluster: 'node',
nav_topo: 'topo',
nav_devs: 'switch',
......
/*
* Copyright 2015 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 -- Settings View -- CSS file
*/
#ov-settings h2 {
display: inline-block;
}
#ov-settings div.ctrl-btns {
width: 45px;
}
<!-- settings partial HTML -->
<div id="ov-settings">
<div class="tabular-header">
<h2>Component Settings ({{tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="refresh"
ng-click="refresh()"></div>
</div>
</div>
<div class="summary-list" onos-fixed-header>
<div class="table-header"
onos-sortable-header sort-callback="sortCallback(requestParams)">
<table>
<tr>
<td colId="component" sortable col-width="400px">Component </td>
<td colId="id" sortable>Property </td>
<td colId="type" sortable col-width="70px">Type </td>
<td colId="value" sortable>Value </td>
<td colId="defValue" sortable>Default </td>
<td colId="desc" col-width="520px">Description </td>
</tr>
</table>
</div>
<div class="table-body">
<table>
<tr ng-hide="tableData.length" class="no-data ignore-width">
<td colspan="6">
No Settings found
</td>
</tr>
<tr ng-repeat="prop in tableData"
ng-repeat-done>
<td>{{prop.component}}</td>
<td>{{prop.id}}</td>
<td>{{prop.type}}</td>
<td>{{prop.value}}</td>
<td>{{prop.defValue}}</td>
<td>{{prop.desc}}</td>
</tr>
</table>
</div>
</div>
</div>
/*
* Copyright 2015 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 -- Component Settings View Module
*/
(function () {
'use strict';
angular.module('ovSettings', [])
.controller('OvSettingsCtrl',
['$log', '$scope', 'TableBuilderService',
function ($log, $scope, tbs) {
tbs.buildTable({
scope: $scope,
tag: 'setting'
});
$log.log('OvSettingsCtrl has been created');
}]);
}());
......@@ -116,8 +116,9 @@
<script src="app/view/link/link.js"></script>
<script src="app/view/host/host.js"></script>
<script src="app/view/intent/intent.js"></script>
<script src="app/view/cluster/cluster.js"></script>
<script src="app/view/app/app.js"></script>
<script src="app/view/settings/settings.js"></script>
<script src="app/view/cluster/cluster.js"></script>
<!-- This is where contributed javascript will get injected -->
<!-- {INJECTED-JAVASCRIPT-START} -->
......@@ -133,6 +134,7 @@
<link rel="stylesheet" href="app/view/host/host.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/settings/settings.css">
<link rel="stylesheet" href="app/view/cluster/cluster.css">
<!-- This is where contributed stylesheets will get injected -->
......