pcewebTopovOverlay.js
4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// PCE web topology overlay - client side
//
// This is the glue that binds our business logic (in pcewebTopovDemo.js)
// to the overlay framework.
(function () {
'use strict';
// injected refs
var $log, tov, pps;
// internal state should be kept in the service module (not here)
var selection;
// our overlay definition
var overlay = {
// NOTE: this must match the ID defined in AppUiTopovOverlay
overlayId: 'PCE-web-overlay',
glyphId: 'topo',
tooltip: 'PCE web Topo Overlay',
activate: function () {
$log.debug("PCE web topology overlay ACTIVATED");
},
deactivate: function () {
pps.clear();
$log.debug("PCE web topology overlay DEACTIVATED");
},
// These glyphs get installed using the overlayId as a prefix.
// e.g. 'src' is installed as 'PCE-web-overlay-src'
// They can be referenced (from this overlay) as '*src'
// That is, the '*' prefix stands in for 'PCE-web-overlay-'
glyphs: {
jp: {
vb: '0 0 110 110',
d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' +
'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z'
},
},
// Key bindings for PCE web overlay buttons
// NOTE: fully qual. button ID is derived from overlay-id and key-name
keyBindings: {
1: {
cb: function () {
pps.setMode(selection);
},
tt: 'Setup path',
gid: 'plus'
},
2: {
cb: function () {
pps.updatePath(selection);
},
tt: 'Update path',
gid: '*jp'
},
3: {
cb: function () {
pps.remPath(selection);
},
tt: 'Remove path',
gid: 'minus'
},
4: {
cb: function () {
pps.queryTunnelDisplay();
},
tt: 'Show Tunnels',
gid: 'checkMark'
},
_keyOrder: [
'1', '2', '3', '4'
]
},
hooks: {
// hook for handling escape key
// Must return true to consume ESC, false otherwise.
escape: function () {
selectionCallback();
pps.setSrc();
pps.setDst();
return true;
},
// hooks for when the selection changes...
empty: function () {
selectionCallback();
},
single: function (data) {
selectionCallback(data);
},
multi: function (selectOrder) {
selectionCallback(selectOrder);
},
modifylinkdata: function (data, extra) {
$log.debug("Modify link data", data, extra);
function sep() {
data.propOrder.push('-');
}
function add(key) {
var val = extra[key];
if (val !== undefined) {
data.propOrder.push(key);
data.props[key] = val;
}
}
sep();
add('Src port');
add('Dst port');
add('Te metric');
add('Bandwidth');
return data;
}
}
};
function selectionCallback(d) {
$log.debug('Selection callback', d);
selection = d;
}
// invoke code to register with the overlay service
angular.module('ovPcewebTopov')
.run(['$log', 'TopoOverlayService', 'PcewebTopovDemoService',
function (_$log_, _tov_, _pps_) {
$log = _$log_;
tov = _tov_;
pps = _pps_;
tov.register(overlay);
}]);
}());