blob: f3b444d87dea9960b2a6e7ca2942d686ce72026c [file] [log] [blame]
Steven Burrows37549ee2016-09-21 14:41:39 +01001/*
2* Copyright 2016-present 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(function () {
18
19 // Injected Services
20 var ks, t2ps;
21 var topo2ForceService;
22
23 // Commmands
24 var actionMap = {
25 L: [cycleDeviceLabels, 'Cycle device labels']
26 };
27
28 function init(t2fs) {
29 topo2ForceService = t2fs;
30 bindCommands();
31 }
32
33 function bindCommands() {
34
35 ks.keyBindings(actionMap);
36
37 ks.gestureNotes([
38 ['click', 'Select the item and show details'],
39 ['shift-click', 'Toggle selection state'],
40 ['drag', 'Reposition (and pin) device / host'],
41 ['cmd-scroll', 'Zoom in / out'],
42 ['cmd-drag', 'Pan']
43 ]);
44 }
45
46 function cycleDeviceLabels() {
47 var deviceLabelIndex = t2ps.get('dlbls') + 1;
48 t2ps.set('dlbls', deviceLabelIndex % 3);
49 topo2ForceService.updateNodes();
50 }
51
52 angular.module('ovTopo2')
53 .factory('Topo2KeyCommandService',
54 ['KeyService', 'Topo2PrefsService',
55
56 function (_ks_, _t2ps_) {
57
58 t2ps = _t2ps_;
59 ks = _ks_;
60
61 return {
62 init: init,
63 bindCommands: bindCommands
64 };
65 }
66 ]);
67})();