ONOS-1479 -- GUI - augmenting topology view for extensibility: WIP.
Change-Id: I11820a9ff8f446c0d10a0311cee5ce448c15f402
diff --git a/web/gui/src/main/webapp/_sdh/overlaywork/AppUiTopoOverlay.java b/web/gui/src/main/webapp/_sdh/overlaywork/AppUiTopoOverlay.java
index f6a8341..c6d00cc 100644
--- a/web/gui/src/main/webapp/_sdh/overlaywork/AppUiTopoOverlay.java
+++ b/web/gui/src/main/webapp/_sdh/overlaywork/AppUiTopoOverlay.java
@@ -18,7 +18,7 @@
package org.meowster.over;
import org.onosproject.ui.UiTopoOverlay;
-import org.onosproject.ui.topo.ButtonDescriptor;
+import org.onosproject.ui.topo.ButtonId;
import org.onosproject.ui.topo.PropertyPanel;
import org.onosproject.ui.topo.TopoConstants.CoreButtons;
import org.onosproject.ui.topo.TopoConstants.Glyphs;
@@ -36,12 +36,8 @@
private static final String MY_TITLE = "I changed the title";
private static final String MY_VERSION = "Beta-1.0.0042";
- private static final ButtonDescriptor FOO_DESCRIPTOR =
- new ButtonDescriptor("foo", "chain", "A FOO action");
-
- private static final ButtonDescriptor BAR_DESCRIPTOR =
- new ButtonDescriptor("bar", "*banner", "A BAR action");
-
+ private static final ButtonId FOO_BUTTON = new ButtonId("foo");
+ private static final ButtonId BAR_BUTTON = new ButtonId("bar");
public AppUiTopoOverlay() {
super(OVERLAY_ID);
@@ -68,8 +64,8 @@
pp.title(MY_TITLE);
pp.removeProps(LATITUDE, LONGITUDE);
- pp.addButton(FOO_DESCRIPTOR)
- .addButton(BAR_DESCRIPTOR);
+ pp.addButton(FOO_BUTTON)
+ .addButton(BAR_BUTTON);
pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
.removeButtons(CoreButtons.SHOW_GROUP_VIEW);
diff --git a/web/gui/src/main/webapp/_sdh/overlaywork/topov.js b/web/gui/src/main/webapp/_sdh/overlaywork/topov.js
index 0b5eac8..068c30c 100644
--- a/web/gui/src/main/webapp/_sdh/overlaywork/topov.js
+++ b/web/gui/src/main/webapp/_sdh/overlaywork/topov.js
@@ -3,7 +3,10 @@
'use strict';
// injected refs
- var $log;
+ var $log, tov;
+
+ // internal state
+ var someStateValue = true;
// our overlay definition
var overlay = {
@@ -27,40 +30,127 @@
}
},
- activate: activateOverlay,
- deactivate: deactivateOverlay,
+ activate: function () {
+ $log.debug("sample topology overlay ACTIVATED");
+ },
+ deactivate: function () {
+ $log.debug("sample topology overlay DEACTIVATED");
+ },
- // button callbacks matching button identifiers
- buttonActions: {
- foo: fooCb,
- bar: barCb
+
+
+
+
+ // detail panel button definitions
+ buttons: {
+ foo: {
+ gid: 'chain',
+ tt: 'A FOO action',
+ cb: function (data) {
+ $log.debug('FOO action invoked with data:', data);
+ }
+ },
+ bar: {
+ gid: '*banner',
+ tt: 'A BAR action',
+ cb: function (data) {
+ $log.debug('BAR action invoked with data:', data);
+ }
+ }
+ },
+
+ // Key bindings for traffic overlay buttons
+ // NOTE: fully qual. button ID is derived from overlay-id and key-name
+ keyBindings: {
+ V: {
+ cb: buttonCallback,
+ tt: 'Uses the V key',
+ gid: '*banner'
+ },
+ F: {
+ cb: buttonCallback,
+ tt: 'Uses the F key',
+ gid: 'chain'
+ },
+ G: {
+ cb: buttonCallback,
+ tt: 'Uses the G key',
+ gid: 'crown'
+ },
+
+ T: {
+ cb: buttonCallback,
+ tt: 'Uses the T key',
+ gid: 'switch'
+ },
+
+ R: {
+ cb: buttonCallback,
+ tt: 'Uses the R key',
+ gid: 'endstation'
+ },
+
+ 0: {
+ cb: buttonCallback,
+ tt: 'Uses the ZERO key',
+ gid: 'xMark'
+ },
+
+ _keyOrder: [
+ '0', 'V', 'F', 'G', 'T', 'R'
+ ]
+
+ // NOTE: T and R should be rejected (not installed)
+ // T is reserved for 'toggle Theme'
+ // R is reserved for 'Reset pan and zoom'
+ },
+
+ hooks: {
+ // hook for handling escape key
+ // Must return true to consume ESC, false otherwise.
+ escape: cancelState,
+
+ // hooks for when the selection changes...
+ empty: function () {
+ selectionCallback('empty');
+ },
+ single: function (data) {
+ selectionCallback('single', data);
+ },
+ multi: function (selectOrder) {
+ selectionCallback('multi', selectOrder);
+ tov.addDetailButton('foo');
+ tov.addDetailButton('bar');
+ }
}
+
};
- function fooCb(data) {
- $log.debug('FOO callback with data:', data);
+ // invoked when the escape key is pressed
+ function cancelState() {
+ if (someStateValue) {
+ someStateValue = false;
+ // we consumed the ESC event
+ return true;
+ }
+ return false;
}
- function barCb(data) {
- $log.debug('BAR callback with data:', data);
+ function buttonCallback(x) {
+ $log.debug('Toolbar-button callback', x);
}
- // === implementation of overlay API (essentially callbacks)
- function activateOverlay() {
- $log.debug("sample topology overlay ACTIVATED");
+ function selectionCallback(x, d) {
+ $log.debug('Selection callback', x, d);
}
- function deactivateOverlay() {
- $log.debug("sample topology overlay DEACTIVATED");
- }
-
-
// invoke code to register with the overlay service
angular.module('ovSample')
.run(['$log', 'TopoOverlayService',
- function (_$log_, tov) {
+ function (_$log_, _tov_) {
$log = _$log_;
+ tov = _tov_;
tov.register(overlay);
}]);