[ONOS-5523]ProtectedIntentsOverlay
Change-Id: Ief409aacf7e82655881f658718ac0ca50a3c8cc9
diff --git a/web/gui/src/main/webapp/app/view/topo/topoForce.js b/web/gui/src/main/webapp/app/view/topo/topoForce.js
index 948939b..03d8477 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoForce.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoForce.js
@@ -24,7 +24,7 @@
// injected refs
var $log, $timeout, fs, sus, ts, flash, wss, tov,
- tis, tms, td3, tss, tts, tos, fltr, tls, uplink, svg;
+ tis, tms, td3, tss, tts, tos, fltr, tls, uplink, svg, tpis;
// configuration
var linkConfig = {
@@ -1052,9 +1052,10 @@
'TopoOverlayService', 'TopoInstService', 'TopoModelService',
'TopoD3Service', 'TopoSelectService', 'TopoTrafficService',
'TopoObliqueService', 'TopoFilterService', 'TopoLinkService',
+ 'TopoProtectedIntentsService',
function (_$log_, _$timeout_, _fs_, _sus_, _ts_, _flash_, _wss_, _tov_,
- _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_) {
+ _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_, _tpis_) {
$log = _$log_;
$timeout = _$timeout_;
fs = _fs_;
@@ -1071,6 +1072,7 @@
tos = _tos_;
fltr = _fltr_;
tls = _tls_;
+ tpis = _tpis_;
ts.addListener(updateLinksAndNodes);
@@ -1093,6 +1095,7 @@
td3.initD3(mkD3Api());
tss.initSelect(mkSelectApi());
tts.initTraffic(mkTrafficApi());
+ tpis.initProtectedIntents(mkTrafficApi());
tos.initOblique(mkObliqueApi(uplink, fltr));
fltr.initFilter(mkFilterApi());
tls.initLink(mkLinkApi(svg, uplink), td3);
@@ -1136,6 +1139,7 @@
tls.destroyLink();
tos.destroyOblique();
tts.destroyTraffic();
+ tpis.destroyProtectedIntents();
tss.destroySelect();
td3.destroyD3();
tms.destroyModel();
diff --git a/web/gui/src/main/webapp/app/view/topo/topoProtectedIntent.js b/web/gui/src/main/webapp/app/view/topo/topoProtectedIntent.js
new file mode 100644
index 0000000..20193dd
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/topo/topoProtectedIntent.js
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Topology Protected Intents Module.
+ Defines behavior for viewing protected intents .
+ */
+
+(function () {
+ 'use strict';
+
+ // injected refs
+ var $log, fs, flash, wss, api;
+
+ // internal state
+ var showingProtectedIntent = null;
+
+ // === -------------------------------------------------------------
+ // protected intent requests invoked from keystrokes or toolbar buttons...
+
+ function cancelHighlights() {
+ if (!showingProtectedIntent) {
+ return false;
+ }
+
+ showingProtectedIntent = false;
+ wss.sendEvent('cancelProtectedIntentHighlight');
+ flash.flash('Monitoring canceled');
+ return true;
+ }
+
+ // force the system to create a single intent selection
+ function showProtectedIntent(data) {
+ wss.sendEvent('selectProtectedIntent', data);
+ flash.flash('Selecting Intent ' + data.key);
+ showingProtectedIntent = true;
+ }
+
+ // === -----------------------------------------------------
+ // === MODULE DEFINITION ===
+
+ angular.module('ovTopo')
+ .factory('TopoProtectedIntentsService',
+ ['$log', 'FnService', 'FlashService', 'WebSocketService',
+
+ function (_$log_, _fs_, _flash_, _wss_) {
+ $log = _$log_;
+ fs = _fs_;
+ flash = _flash_;
+ wss = _wss_;
+
+ return {
+ initProtectedIntents: function (_api_) { api = _api_; },
+ destroyProtectedIntents: function () { },
+
+ // invoked from toolbar overlay buttons or keystrokes
+ cancelHighlights: cancelHighlights,
+ showProtectedIntent: showProtectedIntent
+ };
+ }]);
+}());
diff --git a/web/gui/src/main/webapp/app/view/topo/topoProtectedIntentOverlay.js b/web/gui/src/main/webapp/app/view/topo/topoProtectedIntentOverlay.js
new file mode 100644
index 0000000..ab9114f
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/topo/topoProtectedIntentOverlay.js
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Topology Protected Intents Overlay Module.
+ Defines behavior for viewing different multiple Protected Intents.
+ Installed as a Topology Overlay.
+ */
+(function () {
+ 'use strict';
+
+ // injected refs
+ var $log, tov, tpis;
+
+ // NOTE: no internal state here -- see topoProtectedIntents for that
+
+ // NOTE: providing button disabling requires too big a refactoring of
+ // the button factory etc. Will have to be done another time.
+
+
+ // traffic overlay definition
+ var overlay = {
+ overlayId: 'protectedIntent',
+ glyphId: 'm_ips',
+ tooltip: 'Protected Intents Overlay',
+
+ activate: function () {
+ $log.debug("Protected Intent overlay ACTIVATED");
+ },
+
+ deactivate: function () {
+ tpis.cancelHighlights();
+ $log.debug("Protected Intent DEACTIVATED");
+ },
+
+ hooks: {
+ // hook for handling escape key
+ escape: function () {
+ // Must return true to consume ESC, false otherwise.
+ return tpis.cancelHighlights();
+ },
+ // intent visualization hook
+ acceptIntent: function (type) {
+ // accept only intents with type "Protected"
+ return (type.startsWith('Protected'));
+ },
+ showIntent: function (info) {
+ $log.debug('^^ topoProtectedIntentsOverlay.showintent() ^^', info);
+ tpis.showProtectedIntent(info);
+ }
+ }
+ };
+
+ // invoke code to register with the overlay service
+ angular.module('ovTopo')
+ .run(['$log', 'TopoOverlayService', 'TopoProtectedIntentsService',
+
+ function (_$log_, _tov_, _tpis_) {
+ $log = _$log_;
+ tov = _tov_;
+ tpis = _tpis_;
+ tov.register(overlay);
+ }]);
+
+}());
diff --git a/web/gui/src/main/webapp/app/view/topo/topoSelect.js b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
index cfd2fb3..724b43c 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoSelect.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
@@ -23,7 +23,7 @@
'use strict';
// injected refs
- var $log, fs, wss, tov, tps, tts, ns, sus;
+ var $log, fs, wss, tov, tps, tts, ns, sus, tpis;
// api to topoForce
var api;
@@ -306,9 +306,9 @@
.factory('TopoSelectService',
['$log', 'FnService', 'WebSocketService', 'TopoOverlayService',
'TopoPanelService', 'TopoTrafficService', 'NavService',
- 'SvgUtilService',
+ 'SvgUtilService', 'TopoProtectedIntentsService',
- function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_, _sus_) {
+ function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_, _sus_, _tpis_) {
$log = _$log_;
fs = _fs_;
wss = _wss_;
@@ -317,6 +317,7 @@
tts = _tts_;
ns = _ns_;
sus = _sus_;
+ tpis= _tpis_;
function initSelect(_api_) {
api = _api_;
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index 9f85a21..cf1812e 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -190,6 +190,8 @@
<script src="app/view/topo/topoSprite.js"></script>
<script src="app/view/topo/topoTraffic.js"></script>
<script src="app/view/topo/topoTrafficNew.js"></script>
+ <script src="app/view/topo/topoProtectedIntent.js"></script>
+ <script src="app/view/topo/topoProtectedIntentOverlay.js"></script>
<script src="app/view/topo/topoToolbar.js"></script>
<script src="app/view/device/device.js"></script>
<script src="app/view/flow/flow.js"></script>