blob: 20193dd5fdf132420edab55dbe295c0c2159f04e [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 Module.
19 Defines behavior for viewing protected intents .
20 */
21
22(function () {
23 'use strict';
24
25 // injected refs
26 var $log, fs, flash, wss, api;
27
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',
57 ['$log', 'FnService', 'FlashService', 'WebSocketService',
58
59 function (_$log_, _fs_, _flash_, _wss_) {
60 $log = _$log_;
61 fs = _fs_;
62 flash = _flash_;
63 wss = _wss_;
64
65 return {
66 initProtectedIntents: function (_api_) { api = _api_; },
67 destroyProtectedIntents: function () { },
68
69 // invoked from toolbar overlay buttons or keystrokes
70 cancelHighlights: cancelHighlights,
71 showProtectedIntent: showProtectedIntent
72 };
73 }]);
74}());