Jian Li | 3bc6ef1 | 2017-05-04 21:51:41 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Jian Li | 3bc6ef1 | 2017-05-04 21:51:41 +0900 | [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 -- Mapping Management Topology Overlay |
| 19 | */ |
| 20 | (function () { |
| 21 | 'use strict'; |
| 22 | |
| 23 | // injected references |
| 24 | var $log, tov, mts, ns; |
| 25 | |
| 26 | var viewbox = '-1 -1 19 19'; |
| 27 | |
| 28 | // mapping glyph (view box 20x20) |
| 29 | var mapping = 'M8,0C4.687,0,2,2.687,2,6c0,3.854,4.321,8.663,5,9.398C7.281,' + |
| 30 | '15.703,7.516,16,8,16s0.719-0.297,1-0.602 C9.679,14.663,14,9.854,14,6C14,' + |
| 31 | '2.687,11.313,0,8,0z M8,10c-2.209,0-4-1.791-4-4s1.791-4,4-4s4,1.791,4,' + |
| 32 | '4S10.209,10,8,10z M8,4 C6.896,4,6,4.896,6,6s0.896,2,2,2s2-0.896,2-2S9.104,4,8,4z'; |
| 33 | |
| 34 | // overlay definition |
| 35 | var overlay = { |
| 36 | overlayId: 'mapping-overlay', |
| 37 | glyphId: '*mapping', |
| 38 | tooltip: 'Mappings Overlay', |
| 39 | glyphs: { |
| 40 | mapping: { |
| 41 | vb: viewbox, |
| 42 | d: mapping |
| 43 | } |
| 44 | }, |
| 45 | activate: function () { |
| 46 | $log.debug("Mapping topology overlay ACTIVATED"); |
| 47 | mts.startDisplay(); |
| 48 | }, |
| 49 | deactivate: function () { |
| 50 | mts.stopDisplay(); |
| 51 | $log.debug("Mapping topology overlay DEACTIVATED"); |
| 52 | }, |
| 53 | buttons: { |
| 54 | mappings: { |
| 55 | gid: '*mapping', |
| 56 | tt: 'Show mappings for this device', |
| 57 | cb: function (data) { |
| 58 | $log.debug('Show mappings for this device. data:', data); |
| 59 | ns.navTo("mapping", {devId: data.id}); |
| 60 | } |
| 61 | } |
| 62 | }, |
| 63 | hooks: { |
| 64 | // hooks for when the selection changes... |
| 65 | empty: function () { |
| 66 | selectionCallback('empty'); |
| 67 | }, |
| 68 | single: function (data) { |
| 69 | selectionCallback('single', data); |
| 70 | }, |
| 71 | multi: function (selectOrder) { |
| 72 | selectionCallback('multi', selectOrder); |
| 73 | tov.addDetailButton('mappings'); |
| 74 | } |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | function selectionCallback(x, d) { |
| 79 | $log.debug('Selection callback', x, d); |
| 80 | } |
| 81 | |
| 82 | // invoke code to register with the overlay service |
| 83 | angular.module('ovMappingTopo') |
| 84 | .run(['$log', 'TopoOverlayService', 'MappingTopoService', 'NavService', |
| 85 | |
| 86 | function (_$log_, _tov_, _mts_, _ns_) { |
| 87 | $log = _$log_; |
| 88 | tov = _tov_; |
| 89 | mts = _mts_; |
| 90 | ns = _ns_; |
| 91 | tov.register(overlay); |
| 92 | }]); |
| 93 | |
| 94 | }()); |