blob: 085ff4b8f509986d7ca016fc1d854cdeb1f2bf8f [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
28 // internal state
29 var showingProtectedIntent = null;
30
31 // === -------------------------------------------------------------
32 // protected intent requests invoked from keystrokes or toolbar buttons...
33
34 function cancelHighlights() {
35 if (!showingProtectedIntent) {
36 return false;
37 }
38
39 showingProtectedIntent = false;
40 wss.sendEvent('cancelProtectedIntentHighlight');
41 flash.flash('Monitoring canceled');
42 return true;
43 }
44
45 // force the system to create a single intent selection
46 function showProtectedIntent(data) {
47 wss.sendEvent('selectProtectedIntent', data);
48 flash.flash('Selecting Intent ' + data.key);
49 showingProtectedIntent = true;
50 }
51
52 // === -----------------------------------------------------
53 // === MODULE DEFINITION ===
54
55 angular.module('ovTopo')
56 .factory('TopoProtectedIntentsService',
Steven Burrows1c2a9682017-07-14 16:52:46 +010057 ['FlashService', 'WebSocketService',
Andrea Campanella732ea832017-02-06 09:25:59 -080058
Steven Burrows1c2a9682017-07-14 16:52:46 +010059 function (_flash_, _wss_) {
Andrea Campanella732ea832017-02-06 09:25:59 -080060 flash = _flash_;
61 wss = _wss_;
62
63 return {
Steven Burrows1c2a9682017-07-14 16:52:46 +010064 // TODO: Remove references
65 initProtectedIntents: function (_api_) {},
Andrea Campanella732ea832017-02-06 09:25:59 -080066 destroyProtectedIntents: function () { },
67
68 // invoked from toolbar overlay buttons or keystrokes
69 cancelHighlights: cancelHighlights,
Steven Burrows1c2a9682017-07-14 16:52:46 +010070 showProtectedIntent: showProtectedIntent,
Andrea Campanella732ea832017-02-06 09:25:59 -080071 };
72 }]);
73}());