blob: ab9114fb686283caffc48bcbe79ff7a39e7715db [file] [log] [blame]
Andrea Campanella732ea832017-02-06 09:25:59 -08001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
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
28 // NOTE: no internal state here -- see topoProtectedIntents for that
29
30 // NOTE: providing button disabling requires too big a refactoring of
31 // the button factory etc. Will have to be done another time.
32
33
34 // traffic overlay definition
35 var overlay = {
36 overlayId: 'protectedIntent',
37 glyphId: 'm_ips',
38 tooltip: 'Protected Intents Overlay',
39
40 activate: function () {
41 $log.debug("Protected Intent overlay ACTIVATED");
42 },
43
44 deactivate: function () {
45 tpis.cancelHighlights();
46 $log.debug("Protected Intent DEACTIVATED");
47 },
48
49 hooks: {
50 // hook for handling escape key
51 escape: function () {
52 // Must return true to consume ESC, false otherwise.
53 return tpis.cancelHighlights();
54 },
55 // intent visualization hook
56 acceptIntent: function (type) {
57 // accept only intents with type "Protected"
58 return (type.startsWith('Protected'));
59 },
60 showIntent: function (info) {
61 $log.debug('^^ topoProtectedIntentsOverlay.showintent() ^^', info);
62 tpis.showProtectedIntent(info);
63 }
64 }
65 };
66
67 // invoke code to register with the overlay service
68 angular.module('ovTopo')
69 .run(['$log', 'TopoOverlayService', 'TopoProtectedIntentsService',
70
71 function (_$log_, _tov_, _tpis_) {
72 $log = _$log_;
73 tov = _tov_;
74 tpis = _tpis_;
75 tov.register(overlay);
76 }]);
77
78}());