blob: 6eabe4febae6a6ca2a673cd85aedbce9344bee42 [file] [log] [blame]
Andrea Campanella732ea832017-02-06 09:25:59 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Andrea Campanella732ea832017-02-06 09:25:59 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Topology Protected Intents Overlay Module.
19 Defines behavior for viewing different multiple Protected Intents.
20 Installed as a Topology Overlay.
21 */
22(function () {
23 'use strict';
24
25 // injected refs
26 var $log, tov, tpis;
27
Simon Huntcaed0412017-08-12 13:49:17 -070028 // function to be replaced by the localization bundle function
29 var topoLion = function (x) {
30 return '#tprotiov#' + x + '#';
31 };
32
Andrea Campanella732ea832017-02-06 09:25:59 -080033 // NOTE: no internal state here -- see topoProtectedIntents for that
34
Andrea Campanella732ea832017-02-06 09:25:59 -080035 // traffic overlay definition
36 var overlay = {
37 overlayId: 'protectedIntent',
38 glyphId: 'm_ips',
Simon Huntcaed0412017-08-12 13:49:17 -070039 tooltip: function () { return topoLion('ov_tt_protected_intents'); },
Andrea Campanella732ea832017-02-06 09:25:59 -080040
41 activate: function () {
Steven Burrows1c2a9682017-07-14 16:52:46 +010042 $log.debug('Protected Intent overlay ACTIVATED');
Andrea Campanella732ea832017-02-06 09:25:59 -080043 },
44
45 deactivate: function () {
46 tpis.cancelHighlights();
Simon Huntcaed0412017-08-12 13:49:17 -070047 $log.debug('Protected Intent overlay DEACTIVATED');
Andrea Campanella732ea832017-02-06 09:25:59 -080048 },
49
50 hooks: {
51 // hook for handling escape key
52 escape: function () {
53 // Must return true to consume ESC, false otherwise.
54 return tpis.cancelHighlights();
55 },
Simon Huntcaed0412017-08-12 13:49:17 -070056 // intent visualization hooks
Andrea Campanella732ea832017-02-06 09:25:59 -080057 acceptIntent: function (type) {
58 // accept only intents with type "Protected"
59 return (type.startsWith('Protected'));
60 },
61 showIntent: function (info) {
Andrea Campanella732ea832017-02-06 09:25:59 -080062 tpis.showProtectedIntent(info);
Steven Burrows1c2a9682017-07-14 16:52:46 +010063 },
Simon Huntcaed0412017-08-12 13:49:17 -070064 // localization bundle injection hook
65 injectLion: function (bundle) {
66 topoLion = bundle;
67 tpis.setLionBundle(bundle);
68 },
Steven Burrows1c2a9682017-07-14 16:52:46 +010069 },
Andrea Campanella732ea832017-02-06 09:25:59 -080070 };
71
72 // invoke code to register with the overlay service
73 angular.module('ovTopo')
74 .run(['$log', 'TopoOverlayService', 'TopoProtectedIntentsService',
75
76 function (_$log_, _tov_, _tpis_) {
77 $log = _$log_;
78 tov = _tov_;
79 tpis = _tpis_;
80 tov.register(overlay);
81 }]);
82
83}());