Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 1 | /* |
Simon Hunt | 8ead3a2 | 2015-01-06 11:00:15 -0800 | [diff] [blame] | 2 | * Copyright 2014,2015 Open Networking Laboratory |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [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 | ONOS GUI -- Topology View Module |
| 19 | |
| 20 | @author Simon Hunt |
| 21 | */ |
| 22 | |
| 23 | (function () { |
| 24 | 'use strict'; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame^] | 25 | |
| 26 | var moduleDependencies = [ |
| 27 | 'onosUtil', |
| 28 | 'onosSvg' |
| 29 | ]; |
| 30 | |
| 31 | // references to injected services etc. |
| 32 | var $log, ks, gs; |
| 33 | |
| 34 | // DOM elements |
| 35 | var defs; |
| 36 | |
| 37 | // Internal state |
| 38 | // ... |
| 39 | |
| 40 | // Note: "exported" state should be properties on 'self' variable |
| 41 | |
| 42 | var keyBindings = { |
| 43 | W: [logWarning, 'log a warning'], |
| 44 | E: [logError, 'log an error'] |
| 45 | }; |
| 46 | |
| 47 | // ----------------- |
| 48 | // these functions are necessarily temporary examples.... |
| 49 | function logWarning() { |
| 50 | $log.warn('You have been warned!'); |
| 51 | } |
| 52 | function logError() { |
| 53 | $log.error('You are erroneous!'); |
| 54 | } |
| 55 | // ----------------- |
| 56 | |
| 57 | function setUpKeys() { |
| 58 | ks.keyBindings(keyBindings); |
| 59 | } |
| 60 | |
| 61 | function setUpDefs() { |
| 62 | defs = d3.select('#ov-topo svg').append('defs'); |
| 63 | gs.loadDefs(defs); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | angular.module('ovTopo', moduleDependencies) |
| 68 | |
| 69 | .controller('OvTopoCtrl', [ |
| 70 | '$log', 'KeyService', 'GlyphService', |
| 71 | |
| 72 | function (_$log_, _ks_, _gs_) { |
| 73 | var self = this; |
| 74 | |
| 75 | $log = _$log_; |
| 76 | ks = _ks_; |
| 77 | gs = _gs_; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 78 | |
| 79 | self.message = 'Topo View Rocks!'; |
| 80 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame^] | 81 | setUpKeys(); |
| 82 | setUpDefs(); |
| 83 | |
| 84 | $log.log('OvTopoCtrl has been created'); |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 85 | }]); |
| 86 | }()); |