blob: ac381ff87136da363ebad4569cd4dfa87ca3855f [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 Module.
19 Defines behavior for viewing protected intents .
20 */
21
22(function () {
23 'use strict';
24
25 // injected refs
Steven Burrows1c2a9682017-07-14 16:52:46 +010026 var flash, wss;
Andrea Campanella732ea832017-02-06 09:25:59 -080027
Simon Huntcaed0412017-08-12 13:49:17 -070028 // function to be replaced by the localization bundle function
29 var topoLion = function (x) {
30 return '#tproti#' + x + '#';
31 };
32
Andrea Campanella732ea832017-02-06 09:25:59 -080033 // 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 Huntcaed0412017-08-12 13:49:17 -070046 flash.flash(topoLion('fl_monitoring_canceled'));
Andrea Campanella732ea832017-02-06 09:25:59 -080047 return true;
48 }
49
50 // force the system to create a single intent selection
51 function showProtectedIntent(data) {
52 wss.sendEvent('selectProtectedIntent', data);
Simon Huntcaed0412017-08-12 13:49:17 -070053 flash.flash(topoLion('fl_selecting_intent') + ' ' + data.key);
Andrea Campanella732ea832017-02-06 09:25:59 -080054 showingProtectedIntent = true;
55 }
56
57 // === -----------------------------------------------------
58 // === MODULE DEFINITION ===
59
60 angular.module('ovTopo')
61 .factory('TopoProtectedIntentsService',
Steven Burrows1c2a9682017-07-14 16:52:46 +010062 ['FlashService', 'WebSocketService',
Andrea Campanella732ea832017-02-06 09:25:59 -080063
Steven Burrows1c2a9682017-07-14 16:52:46 +010064 function (_flash_, _wss_) {
Andrea Campanella732ea832017-02-06 09:25:59 -080065 flash = _flash_;
66 wss = _wss_;
67
68 return {
Steven Burrows1c2a9682017-07-14 16:52:46 +010069 // TODO: Remove references
70 initProtectedIntents: function (_api_) {},
Andrea Campanella732ea832017-02-06 09:25:59 -080071 destroyProtectedIntents: function () { },
Simon Huntcaed0412017-08-12 13:49:17 -070072 setLionBundle: function (bundle) { topoLion = bundle; },
Andrea Campanella732ea832017-02-06 09:25:59 -080073
74 // invoked from toolbar overlay buttons or keystrokes
75 cancelHighlights: cancelHighlights,
Steven Burrows1c2a9682017-07-14 16:52:46 +010076 showProtectedIntent: showProtectedIntent,
Andrea Campanella732ea832017-02-06 09:25:59 -080077 };
78 }]);
79}());