blob: 8200606502e3bc9363860b1395cb9b19d1c000df [file] [log] [blame]
Jian Li3bc6ef12017-05-04 21:51:41 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jian Li3bc6ef12017-05-04 21:51:41 +09003 *
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 (function () {
18 'use strict';
19
20 // injected refs
21 var $log, fs, flash, wss;
22
23 // constants
24 var displayStart = 'mappingsTopoDisplayStart',
25 displayStop = 'mappingsTopoDisplayStop';
26
27
28 // === ---------------------------
29 // === Helper functions
30
31 function sendDisplayStart() {
32 wss.sendEvent(displayStart);
33 }
34
35 function sendDisplayStop() {
36 wss.sendEvent(displayStop);
37 }
38
39 // === ---------------------------
40 // === Main API functions
41
42 function startDisplay() {
43 sendDisplayStart();
44 flash.flash('Showing mappings on devices');
45 }
46
47 function stopDisplay() {
48 sendDisplayStop();
49 flash.flash('Canceling mappings on devices');
50 return true;
51 }
52
53 angular.module('ovMappingTopo', [])
54 .factory('MappingTopoService',
55 ['$log', 'FnService', 'FlashService', 'WebSocketService',
56
57 function (_$log_, _fs_, _flash_, _wss_) {
58 $log = _$log_;
59 fs = _fs_;
60 flash = _flash_;
61 wss = _wss_;
62
63 return {
64 startDisplay: startDisplay,
65 stopDisplay: stopDisplay
66 };
67 }]);
68}());