Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 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 | |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 28 | // function to be replaced by the localization bundle function |
| 29 | var topoLion = function (x) { |
| 30 | return '#tprotiov#' + x + '#'; |
| 31 | }; |
| 32 | |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 33 | // NOTE: no internal state here -- see topoProtectedIntents for that |
| 34 | |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 35 | // traffic overlay definition |
| 36 | var overlay = { |
| 37 | overlayId: 'protectedIntent', |
| 38 | glyphId: 'm_ips', |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 39 | tooltip: function () { return topoLion('ov_tt_protected_intents'); }, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 40 | |
| 41 | activate: function () { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 42 | $log.debug('Protected Intent overlay ACTIVATED'); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 43 | }, |
| 44 | |
| 45 | deactivate: function () { |
| 46 | tpis.cancelHighlights(); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 47 | $log.debug('Protected Intent overlay DEACTIVATED'); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 48 | }, |
| 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 Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 56 | // intent visualization hooks |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 57 | acceptIntent: function (type) { |
| 58 | // accept only intents with type "Protected" |
| 59 | return (type.startsWith('Protected')); |
| 60 | }, |
| 61 | showIntent: function (info) { |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 62 | tpis.showProtectedIntent(info); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 63 | }, |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 64 | // localization bundle injection hook |
| 65 | injectLion: function (bundle) { |
| 66 | topoLion = bundle; |
| 67 | tpis.setLionBundle(bundle); |
| 68 | }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 69 | }, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 70 | }; |
| 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 | }()); |