ONOS-6258: UiTopo2Overlay et al.
- Added Topo2TrafficMessageHandler
- Wired topo2 traffic overlay into topo2 view
Change-Id: I2b67af6abc10f737b8d3183d219d8c651bf57e31
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2.js b/web/gui/src/main/webapp/app/view/topo2/topo2.js
index c798927..cf13d11 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2.js
@@ -101,7 +101,7 @@
'Topo2BreadcrumbService', 'Topo2KeyCommandService', 'Topo2MapService',
'Topo2MapConfigService', 'Topo2ZoomService', 'Topo2SpriteLayerService',
'Topo2SummaryPanelService', 'Topo2DeviceDetailsPanel', 'Topo2ToolbarService',
- 'Topo2NoDevicesConnectedService',
+ 'Topo2NoDevicesConnectedService', 'Topo2OverlayService',
function (
_$scope_, _$log_, _$loc_,
@@ -111,7 +111,7 @@
_t2es_, _t2fs_, _t2is_,
_t2bcs_, _t2kcs_, _t2ms_,
_t2mcs_, _t2zs_, t2sls,
- summaryPanel, detailsPanel, t2tbs, t2ndcs
+ summaryPanel, detailsPanel, t2tbs, t2ndcs, t2os
) {
var params = _$loc_.search(),
dim,
@@ -198,6 +198,9 @@
// restoreConfigFromPrefs();
// ttbs.setDefaultOverlay(prefsState.ovid);
+ // ++ TEMPORARY HARD-CODE TRAFFIC OVERLAY ++
+ t2os.setOverlay('traffic-2-overlay');
+
summaryPanel.init(detailsPanel);
detailsPanel.init(summaryPanel);
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js b/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
index a9c9c1c..939b9d2 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
@@ -40,7 +40,7 @@
_keyListener: t2tbs.keyListener.bind(t2tbs)
}
- };
+ }
function init(_t2fs_, _t2tbs_) {
t2fs = _t2fs_;
@@ -48,9 +48,26 @@
bindCommands();
}
- function bindCommands() {
+ function bindCommands(additional) {
- ks.keyBindings(actionMap());
+ var am = actionMap(),
+ add = fs.isO(additional);
+
+ if (add) {
+ _.each(add, function (value, key) {
+ // filter out meta properties (e.g. _keyOrder)
+ if (!(key.startsWith('_'))) {
+ // don't allow re-definition of existing key bindings
+ if (am[key]) {
+ $log.warn('keybind: ' + key + ' already exists');
+ } else {
+ am[key] = [value.cb, value.tt];
+ }
+ }
+ });
+ }
+
+ ks.keyBindings(am);
ks.gestureNotes([
['click', 'Select the item and show details'],
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js b/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
index ce662fb..808ee69 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
@@ -22,7 +22,7 @@
var t2os = 'Topo2OverlayService: ';
// injected refs
- var $log, $timeout, fs, gs, wss, api;
+ var $log, $timeout, fs, gs, wss, t2kcs, api;
// internal state
var overlays = {},
@@ -123,6 +123,16 @@
api = _api_;
}
+ function setOverlay(ovid) {
+ var ov = overlays[ovid];
+ if (!ov) {
+ $log.error('setOverlay: no such overlay ID: ' + ovid);
+ } else {
+ current = ov;
+ t2kcs.bindCommands(current.keyBindings);
+ }
+ }
+
function showHighlights(data) {
function doHighlight() {
_showHighlights(data);
@@ -152,17 +162,20 @@
angular.module('ovTopo2')
.factory('Topo2OverlayService', [
'$log', '$timeout', 'FnService', 'GlyphService', 'WebSocketService',
+ 'Topo2KeyCommandService',
- function (_$log_, _$timeout_, _fs_, _gs_, _wss_) {
+ function (_$log_, _$timeout_, _fs_, _gs_, _wss_, _t2kcs_) {
$log = _$log_;
$timeout = _$timeout_;
fs = _fs_;
gs = _gs_;
wss = _wss_;
+ t2kcs = _t2kcs_;
return {
register: register,
setApi: setApi,
+ setOverlay: setOverlay,
hooks: {
escape: escapeHook,
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js b/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
index 620d2c6..1edcdff 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
@@ -1,5 +1,22 @@
+/*
+ * 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.
+ *
+ */
+
(function () {
- 'use-strict';
+ 'use strict';
var instance;
@@ -109,4 +126,4 @@
return instance || new Toolbar();
}
]);
-})();
\ No newline at end of file
+}());
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Traffic.js b/web/gui/src/main/webapp/app/view/topo2/topo2Traffic.js
index 4515b8a..6ca4d5e 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Traffic.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Traffic.js
@@ -52,7 +52,7 @@
}
function showAllTraffic() {
- $log.debug('Topo2Traffic: Show All Traffic');
+ $log.debug('Topo2Traffic: Show All Traffic:', allTrafficTypes[allIndex]);
mode = 'allFlowPort';
wss.sendEvent('topo2RequestAllTraffic', {