mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-28 06:41:19 +01:00
[onos-6337] Adding first set of changes ( server side with client side stub )
[onos-6337] Patchset-2 with changes addressing review comments [onos-6337] Patchset-3 with changes addressing review comments Change-Id: I37011ad7b8d2fbb01082736b1d787331aaad0a42
This commit is contained in:
parent
4e59382ecd
commit
d25440b45d
@ -29,6 +29,7 @@ import org.onosproject.ui.table.TableRequestHandler;
|
|||||||
import org.onosproject.ui.table.cell.NumberFormatter;
|
import org.onosproject.ui.table.cell.NumberFormatter;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +40,8 @@ public class PortViewMessageHandler extends UiMessageHandler {
|
|||||||
private static final String PORT_DATA_REQ = "portDataRequest";
|
private static final String PORT_DATA_REQ = "portDataRequest";
|
||||||
private static final String PORT_DATA_RESP = "portDataResponse";
|
private static final String PORT_DATA_RESP = "portDataResponse";
|
||||||
private static final String PORTS = "ports";
|
private static final String PORTS = "ports";
|
||||||
|
private static final String DELTA = "showDelta";
|
||||||
|
private static final String NZ = "nzFilter";
|
||||||
|
|
||||||
private static final String ID = "id";
|
private static final String ID = "id";
|
||||||
private static final String PKT_RX = "pkt_rx";
|
private static final String PKT_RX = "pkt_rx";
|
||||||
@ -93,10 +96,18 @@ public class PortViewMessageHandler extends UiMessageHandler {
|
|||||||
@Override
|
@Override
|
||||||
protected void populateTable(TableModel tm, ObjectNode payload) {
|
protected void populateTable(TableModel tm, ObjectNode payload) {
|
||||||
String uri = string(payload, "devId");
|
String uri = string(payload, "devId");
|
||||||
|
boolean nz = bool(payload, NZ);
|
||||||
|
boolean delta = bool(payload, DELTA);
|
||||||
if (!Strings.isNullOrEmpty(uri)) {
|
if (!Strings.isNullOrEmpty(uri)) {
|
||||||
DeviceId deviceId = DeviceId.deviceId(uri);
|
DeviceId deviceId = DeviceId.deviceId(uri);
|
||||||
DeviceService ds = get(DeviceService.class);
|
DeviceService ds = get(DeviceService.class);
|
||||||
for (PortStatistics stat : ds.getPortStatistics(deviceId)) {
|
List<PortStatistics> stats = delta ?
|
||||||
|
ds.getPortDeltaStatistics(deviceId) :
|
||||||
|
ds.getPortStatistics(deviceId);
|
||||||
|
for (PortStatistics stat : stats) {
|
||||||
|
if (nz && stat.isZero()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
populateRow(tm.addRow(), stat);
|
populateRow(tm.addRow(), stat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,6 +152,10 @@
|
|||||||
|
|
||||||
requestTableData();
|
requestTableData();
|
||||||
startRefresh();
|
startRefresh();
|
||||||
|
|
||||||
|
return {
|
||||||
|
forceRefesh : requestTableData
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('onosWidget')
|
angular.module('onosWidget')
|
||||||
|
|||||||
@ -28,10 +28,20 @@
|
|||||||
#ov-port td {
|
#ov-port td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ov-port td.right {
|
#ov-port td.right {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ov-port td.delta {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ov-port td.delta:before {
|
||||||
|
content: "+";
|
||||||
|
}
|
||||||
|
|
||||||
#ov-port tr.no-data td {
|
#ov-port tr.no-data td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,18 @@
|
|||||||
|
|
||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<div class="refresh" ng-class="{active: isNZ()}"
|
||||||
|
icon icon-size="42" icon-id="plus"
|
||||||
|
tooltip tt-msg="toggleNZTip"
|
||||||
|
ng-click="toggleNZ()"></div>
|
||||||
|
|
||||||
|
<div class="refresh" ng-class="{active: isDelta()}"
|
||||||
|
icon icon-size="42" icon-id="triangleUp"
|
||||||
|
tooltip tt-msg="toggleDeltaTip"
|
||||||
|
ng-click="toggleDelta()"></div>
|
||||||
|
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
<div class="active"
|
<div class="active"
|
||||||
icon icon-id="deviceTable" icon-size="42"
|
icon icon-id="deviceTable" icon-size="42"
|
||||||
tooltip tt-msg="deviceTip"
|
tooltip tt-msg="deviceTip"
|
||||||
@ -82,13 +94,13 @@
|
|||||||
<tr ng-repeat="port in tableData | filter:queryFilter track by $index"
|
<tr ng-repeat="port in tableData | filter:queryFilter track by $index"
|
||||||
ng-repeat-complete row-id="{{port.id}}">
|
ng-repeat-complete row-id="{{port.id}}">
|
||||||
<td>{{port.id}}</td>
|
<td>{{port.id}}</td>
|
||||||
<td class="right">{{port.pkt_rx}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.pkt_rx}}</td>
|
||||||
<td class="right">{{port.pkt_tx}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.pkt_tx}}</td>
|
||||||
<td class="right">{{port.bytes_rx}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.bytes_rx}}</td>
|
||||||
<td class="right">{{port.bytes_tx}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.bytes_tx}}</td>
|
||||||
<td class="right">{{port.pkt_rx_drp}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.pkt_rx_drp}}</td>
|
||||||
<td class="right">{{port.pkt_tx_drp}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.pkt_tx_drp}}</td>
|
||||||
<td class="right">{{port.duration}}</td>
|
<td ng-class="(isDelta() ? 'delta' : 'right')">{{port.duration}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -22,33 +22,79 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// injected references
|
// injected references
|
||||||
var $log, $scope, $location, fs, tbs, ns;
|
var $log, $scope, $location, fs, tbs, wss, ns, ps;
|
||||||
|
|
||||||
|
var nz = 'nzFilter',
|
||||||
|
del = 'showDelta';
|
||||||
|
|
||||||
// internal state
|
// internal state
|
||||||
var nzFilter = true,
|
var nzFilter = true,
|
||||||
showDelta = false;
|
showDelta = false;
|
||||||
|
|
||||||
// TODO: (1) init nzFilter and showDelta from user preferences service
|
var defaultPortPrefsState = {
|
||||||
// TODO: (2) track nzFilter and showDelta state from toggle buttons
|
nzFilter : 1,
|
||||||
// (also setting new state in user preference service)
|
showDelta : 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefsState = {};
|
||||||
|
|
||||||
|
function updatePrefsState(what, b) {
|
||||||
|
prefsState[what] = b ? 1 : 0;
|
||||||
|
ps.setPrefs('port_prefs', prefsState);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleNZState(b) {
|
||||||
|
if (b === undefined) {
|
||||||
|
nzFilter = !nzFilter;
|
||||||
|
} else {
|
||||||
|
nzFilter = b;
|
||||||
|
}
|
||||||
|
updatePrefsState(nz, nzFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDeltaState(b) {
|
||||||
|
if (b === undefined) {
|
||||||
|
showDelta = !showDelta;
|
||||||
|
} else {
|
||||||
|
showDelta = b;
|
||||||
|
}
|
||||||
|
updatePrefsState(del, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreConfigFromPrefs() {
|
||||||
|
prefsState = ps.asNumbers(
|
||||||
|
ps.getPrefs('port_prefs', defaultPortPrefsState)
|
||||||
|
);
|
||||||
|
|
||||||
|
$log.debug('Port - Prefs State:', prefsState);
|
||||||
|
toggleDeltaState(prefsState.showDelta);
|
||||||
|
toggleNZState(prefsState.nzFilter);
|
||||||
|
}
|
||||||
|
|
||||||
angular.module('ovPort', [])
|
angular.module('ovPort', [])
|
||||||
.controller('OvPortCtrl',
|
.controller('OvPortCtrl',
|
||||||
['$log', '$scope', '$location',
|
['$log', '$scope', '$location',
|
||||||
'FnService', 'TableBuilderService', 'NavService',
|
'FnService', 'TableBuilderService', 'WebSocketService', 'NavService',
|
||||||
|
'PrefsService',
|
||||||
|
|
||||||
function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _ns_) {
|
function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _wss_, _ns_, _ps_) {
|
||||||
var params;
|
var params;
|
||||||
|
var tableApi;
|
||||||
$log = _$log_;
|
$log = _$log_;
|
||||||
$scope = _$scope_;
|
$scope = _$scope_;
|
||||||
$location = _$location_;
|
$location = _$location_;
|
||||||
fs = _fs_;
|
fs = _fs_;
|
||||||
tbs = _tbs_;
|
tbs = _tbs_;
|
||||||
|
wss = _wss_;
|
||||||
ns = _ns_;
|
ns = _ns_;
|
||||||
|
ps = _ps_;
|
||||||
|
|
||||||
$scope.deviceTip = 'Show device table';
|
$scope.deviceTip = 'Show device table';
|
||||||
$scope.flowTip = 'Show flow view for this device';
|
$scope.flowTip = 'Show flow view for this device';
|
||||||
$scope.groupTip = 'Show group view for this device';
|
$scope.groupTip = 'Show group view for this device';
|
||||||
$scope.meterTip = 'Show meter view for selected device';
|
$scope.meterTip = 'Show meter view for selected device';
|
||||||
|
$scope.toggleDeltaTip = 'Toggle port delta statistics';
|
||||||
|
$scope.toggleNZTip = 'Toggle non zero port statistics';
|
||||||
|
|
||||||
params = $location.search();
|
params = $location.search();
|
||||||
if (params.hasOwnProperty('devId')) {
|
if (params.hasOwnProperty('devId')) {
|
||||||
@ -60,18 +106,45 @@
|
|||||||
showDelta: showDelta
|
showDelta: showDelta
|
||||||
};
|
};
|
||||||
|
|
||||||
tbs.buildTable({
|
tableApi = tbs.buildTable({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
tag: 'port',
|
tag: 'port',
|
||||||
query: params
|
query: params
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function filterToggleState() {
|
||||||
|
return {
|
||||||
|
nzFilter: nzFilter,
|
||||||
|
showDelta: showDelta
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
$scope.nav = function (path) {
|
$scope.nav = function (path) {
|
||||||
if ($scope.devId) {
|
if ($scope.devId) {
|
||||||
ns.navTo(path, { devId: $scope.devId });
|
ns.navTo(path, { devId: $scope.devId });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.toggleNZ = function () {
|
||||||
|
toggleNZState();
|
||||||
|
$scope.payloadParams = filterToggleState();
|
||||||
|
tableApi.forceRefesh();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleDelta = function () {
|
||||||
|
toggleDeltaState();
|
||||||
|
$scope.payloadParams = filterToggleState();
|
||||||
|
tableApi.forceRefesh();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.isDelta = function() {
|
||||||
|
return showDelta;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.isNZ = function() {
|
||||||
|
return nzFilter;
|
||||||
|
};
|
||||||
|
|
||||||
Object.defineProperty($scope, "queryFilter", {
|
Object.defineProperty($scope, "queryFilter", {
|
||||||
get: function() {
|
get: function() {
|
||||||
var out = {};
|
var out = {};
|
||||||
@ -80,6 +153,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
restoreConfigFromPrefs();
|
||||||
$log.log('OvPortCtrl has been created');
|
$log.log('OvPortCtrl has been created');
|
||||||
}]);
|
}]);
|
||||||
}());
|
}());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user