2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 Sample Demo module. This contains the "business logic" for the topology
19 overlay that we are implementing.
26 var $log, fs, flash, wss;
29 var displayStart = 'sampleDisplayStart',
30 displayUpdate = 'sampleDisplayUpdate',
31 displayStop = 'sampleDisplayStop';
34 var currentMode = null;
37 // === ---------------------------
38 // === Helper functions
40 function sendDisplayStart(mode) {
41 wss.sendEvent(displayStart, {
46 function sendDisplayUpdate(what) {
47 wss.sendEvent(displayUpdate, {
48 id: what ? what.id : ''
52 function sendDisplayStop() {
53 wss.sendEvent(displayStop);
56 // === ---------------------------
57 // === Main API functions
59 function startDisplay(mode) {
60 if (currentMode === mode) {
61 $log.debug('(in mode', mode, 'already)');
64 sendDisplayStart(mode);
65 flash.flash('Starting display mode: ' + mode);
69 function updateDisplay(m) {
75 function stopDisplay() {
79 flash.flash('Canceling display mode');
85 // === ---------------------------
86 // === Module Factory Definition
88 angular.module('ovSampleTopov', [])
89 .factory('SampleTopovDemoService',
90 ['$log', 'FnService', 'FlashService', 'WebSocketService',
92 function (_$log_, _fs_, _flash_, _wss_) {
99 startDisplay: startDisplay,
100 updateDisplay: updateDisplay,
101 stopDisplay: stopDisplay