Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [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 | /* |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 18 | ONOS GUI -- Topology View Module. |
| 19 | Module that contains the topology view variables |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 25 | // Injected Services |
| 26 | var flash; |
| 27 | |
| 28 | // Internal State |
| 29 | var dimensions, |
| 30 | viewOptions = { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 31 | linkPortHighlighting: true, |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 32 | }; |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 33 | |
| 34 | function newDim(_dimensions) { |
| 35 | dimensions = _dimensions; |
| 36 | } |
| 37 | |
| 38 | function getDimensions() { |
| 39 | return dimensions; |
| 40 | } |
| 41 | |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 42 | function togglePortHighlights(x) { |
| 43 | var kev = (x === 'keyev'), |
| 44 | on = kev ? !viewOptions.linkPortHighlighting : Boolean(x), |
| 45 | what = on ? 'Enable' : 'Disable'; |
| 46 | |
| 47 | viewOptions.linkPortHighlighting = on; |
| 48 | flash.flash(what + ' port highlighting'); |
| 49 | return on; |
| 50 | } |
| 51 | |
| 52 | function getPortHighlighting() { |
| 53 | return viewOptions.linkPortHighlighting; |
| 54 | } |
| 55 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 56 | angular.module('ovTopo2') |
| 57 | .factory('Topo2ViewService', |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 58 | ['FlashService', |
| 59 | function (_flash_) { |
| 60 | |
| 61 | flash = _flash_; |
| 62 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 63 | return { |
| 64 | newDim: newDim, |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 65 | getDimensions: getDimensions, |
| 66 | |
| 67 | togglePortHighlights: togglePortHighlights, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 68 | getPortHighlighting: getPortHighlighting, |
Steven Burrows | dfa52b0 | 2016-09-02 13:50:43 +0100 | [diff] [blame] | 69 | }; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 70 | }, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 71 | ] |
| 72 | ); |
| 73 | })(); |