kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 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 | 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', |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 30 | displayStop = 'alarmTopovDisplayStop'; |
| 31 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 32 | |
| 33 | // === --------------------------- |
| 34 | // === Helper functions |
| 35 | |
Andrea Campanella | 49f8838 | 2017-01-30 10:37:32 -0800 | [diff] [blame] | 36 | function sendDisplayStart() { |
| 37 | wss.sendEvent(displayStart); |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | function sendDisplayStop() { |
| 41 | wss.sendEvent(displayStop); |
| 42 | } |
| 43 | |
| 44 | // === --------------------------- |
| 45 | // === Main API functions |
| 46 | |
Andrea Campanella | 49f8838 | 2017-01-30 10:37:32 -0800 | [diff] [blame] | 47 | function startDisplay() { |
| 48 | sendDisplayStart(); |
| 49 | flash.flash('Showing alarm counts on devices'); |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | function stopDisplay() { |
Andrea Campanella | 49f8838 | 2017-01-30 10:37:32 -0800 | [diff] [blame] | 53 | sendDisplayStop(); |
| 54 | flash.flash('Canceling alarm counts on devices'); |
| 55 | return true; |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 56 | } |
| 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, |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 73 | stopDisplay: stopDisplay |
| 74 | }; |
| 75 | }]); |
| 76 | }()); |