Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 Toolbar Module. |
| 19 | Defines functions for manipulating the toolbar. |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | |
| 24 | // injected references |
| 25 | var $log, tbs; |
| 26 | |
| 27 | var api, toolbar; |
| 28 | |
| 29 | // buttons (named for keystroke) |
| 30 | var O, I, D, H, M, P, B; |
| 31 | var togSummary, togInstances, togDetails, |
| 32 | togHosts, togOffline, togPorts, togBackground; |
| 33 | |
| 34 | function init(_api_) { |
| 35 | api = _api_; |
| 36 | } |
| 37 | |
| 38 | function getActions() { |
| 39 | togSummary = api.getActionEntry('O'); |
| 40 | togInstances = api.getActionEntry('I'); |
| 41 | togDetails = api.getActionEntry('D'); |
| 42 | |
| 43 | togHosts = api.getActionEntry('H'); |
| 44 | togOffline = api.getActionEntry('M'); |
| 45 | togPorts = api.getActionEntry('P'); |
| 46 | togBackground = api.getActionEntry('B'); |
| 47 | } |
| 48 | |
| 49 | function entryCallback(entry) { |
| 50 | return entry[0]; |
| 51 | } |
| 52 | |
| 53 | function entryToolTip(entry) { |
| 54 | return entry[1]; |
| 55 | } |
| 56 | |
| 57 | function createToolbar() { |
| 58 | getActions(); |
| 59 | // in actions, function reference is entry[0], tooltip is entry[1] |
| 60 | toolbar = tbs.createToolbar('topo-tbar'); |
| 61 | toolbar.addToggle('summary-tog', 'unknown', true, |
| 62 | entryCallback(togSummary), entryToolTip(togSummary)); |
| 63 | toolbar.addToggle('instance-tog', 'unknown', true, |
| 64 | entryCallback(togInstances), entryToolTip(togInstances)); |
| 65 | toolbar.addToggle('details-tog', 'unknown', true, |
| 66 | entryCallback(togDetails), entryToolTip(togDetails)); |
| 67 | toolbar.addSeparator(); |
| 68 | |
| 69 | toolbar.addToggle('hosts-tog', 'endstation', false, |
| 70 | entryCallback(togHosts), entryToolTip(togHosts)); |
| 71 | toolbar.addToggle('offline-tog', 'unknown', true, |
| 72 | entryCallback(togOffline), entryToolTip(togOffline)); |
| 73 | toolbar.addToggle('ports-tog', 'unknown', true, |
| 74 | entryCallback(togPorts), entryToolTip(togPorts)); |
| 75 | toolbar.addToggle('bkgrnd-tog', 'unknown', true, |
| 76 | entryCallback(togBackground), entryToolTip(togBackground)); |
| 77 | |
| 78 | toolbar.hide(); |
| 79 | } |
| 80 | |
| 81 | angular.module('ovTopo') |
| 82 | .factory('TopoToolbarService', ['$log', 'ToolbarService', |
| 83 | |
| 84 | function (_$log_, _tbs_) { |
| 85 | $log = _$log_; |
| 86 | tbs = _tbs_; |
| 87 | |
| 88 | return { |
| 89 | init: init, |
| 90 | createToolbar: createToolbar |
| 91 | }; |
| 92 | }]); |
| 93 | }()); |