blob: d521f53c499e960444ca06dd280c20c8f1b70a46 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
kmcpeakeb172d5f2015-12-10 11:30:43 +00003 *
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 Alarm Demo module. This contains the "business logic" for the topology
19 overlay that we are implementing.
20 */
21
22(function () {
23 'use strict';
24
25 // injected refs
26 var $log, fs, flash, wss;
27
28 // constants
29 var displayStart = 'alarmTopovDisplayStart',
kmcpeakeb172d5f2015-12-10 11:30:43 +000030 displayStop = 'alarmTopovDisplayStop';
31
kmcpeakeb172d5f2015-12-10 11:30:43 +000032
33 // === ---------------------------
34 // === Helper functions
35
Andrea Campanella49f88382017-01-30 10:37:32 -080036 function sendDisplayStart() {
37 wss.sendEvent(displayStart);
kmcpeakeb172d5f2015-12-10 11:30:43 +000038 }
39
40 function sendDisplayStop() {
41 wss.sendEvent(displayStop);
42 }
43
44 // === ---------------------------
45 // === Main API functions
46
Andrea Campanella49f88382017-01-30 10:37:32 -080047 function startDisplay() {
48 sendDisplayStart();
49 flash.flash('Showing alarm counts on devices');
kmcpeakeb172d5f2015-12-10 11:30:43 +000050 }
51
52 function stopDisplay() {
Andrea Campanella49f88382017-01-30 10:37:32 -080053 sendDisplayStop();
54 flash.flash('Canceling alarm counts on devices');
55 return true;
kmcpeakeb172d5f2015-12-10 11:30:43 +000056 }
57
58 // === ---------------------------
59 // === Module Factory Definition
60
61 angular.module('ovAlarmTopov', [])
62 .factory('AlarmTopovDemoService',
63 ['$log', 'FnService', 'FlashService', 'WebSocketService',
64
65 function (_$log_, _fs_, _flash_, _wss_) {
66 $log = _$log_;
67 fs = _fs_;
68 flash = _flash_;
69 wss = _wss_;
70
71 return {
72 startDisplay: startDisplay,
kmcpeakeb172d5f2015-12-10 11:30:43 +000073 stopDisplay: stopDisplay
74 };
75 }]);
76}());