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 Module. |
| 19 | Defines behavior for viewing protected intents . |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
| 25 | // injected refs |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 26 | var flash, wss; |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 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 '#tproti#' + x + '#'; |
| 31 | }; |
| 32 | |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 33 | // internal state |
| 34 | var showingProtectedIntent = null; |
| 35 | |
| 36 | // === ------------------------------------------------------------- |
| 37 | // protected intent requests invoked from keystrokes or toolbar buttons... |
| 38 | |
| 39 | function cancelHighlights() { |
| 40 | if (!showingProtectedIntent) { |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | showingProtectedIntent = false; |
| 45 | wss.sendEvent('cancelProtectedIntentHighlight'); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 46 | flash.flash(topoLion('fl_monitoring_canceled')); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 47 | return true; |
| 48 | } |
| 49 | |
| 50 | // force the system to create a single intent selection |
| 51 | function showProtectedIntent(data) { |
| 52 | wss.sendEvent('selectProtectedIntent', data); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 53 | flash.flash(topoLion('fl_selecting_intent') + ' ' + data.key); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 54 | showingProtectedIntent = true; |
| 55 | } |
| 56 | |
| 57 | // === ----------------------------------------------------- |
| 58 | // === MODULE DEFINITION === |
| 59 | |
| 60 | angular.module('ovTopo') |
| 61 | .factory('TopoProtectedIntentsService', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 62 | ['FlashService', 'WebSocketService', |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 63 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 64 | function (_flash_, _wss_) { |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 65 | flash = _flash_; |
| 66 | wss = _wss_; |
| 67 | |
| 68 | return { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 69 | // TODO: Remove references |
| 70 | initProtectedIntents: function (_api_) {}, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 71 | destroyProtectedIntents: function () { }, |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 72 | setLionBundle: function (bundle) { topoLion = bundle; }, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 73 | |
| 74 | // invoked from toolbar overlay buttons or keystrokes |
| 75 | cancelHighlights: cancelHighlights, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 76 | showProtectedIntent: showProtectedIntent, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 77 | }; |
| 78 | }]); |
| 79 | }()); |