blob: c8b92952882778f8f4d32487eaf80b3360b2e7f8 [file] [log] [blame]
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05301/*
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/*PCE topology overlay web application implementation.*/
18
19(function () {
20 'use strict';
21
22 // injected refs
23 var $log, fs, flash, wss, tps, ns, tds, ds;
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +053024 var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd, tunnelNameDataQuery;
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053025 // constants
26 var srcMessage = 'pceTopovSetSrc',
27 dstMessage = 'pceTopovSetDst',
28 clearMessage = 'pceTopovClear',
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +053029 setPathmsg = 'pceTopovSetMode',
30 updatePathmsgQuery = 'pceTopovUpdateQuery',
31 remPathmsgQuery = 'pceTopovRemQuery',
32 updatePathmsg = 'pceTopovUpdate',
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +053033 updatePathmsgInfo = 'updatePathmsgInfo',
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +053034 remPathmsg = 'pceTopovRem',
35 showTunnelInfoMsg = 'pceTopovShowTunnels',
36 queryDisplayTunnelMsg = 'pceTopovTunnelDisplay',
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +053037 showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem',
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +053038 showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate',
39 showTunnelInfoQuery = 'pceTopovShowTunnelsQuery',
40 showTunnelHighlightMsg = 'pceTopovshowTunnelHighlightMsg';
41
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053042 // internal state
43 var currentMode = null;
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +053044 var handlerMap = {},
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +053045 handlerMapRem = {},
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +053046 handlerMapshowQuery = {},
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +053047 handlerMapShowUpdate = {};
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053048 // === ---------------------------
49 // === Helper functions
50
51 // === ---------------------------
52 // === Main API functions
53
54 function setSrc(node) {
55 wss.sendEvent(srcMessage, {
56 id: node.id,
57 type: node.type
58 });
59 flash.flash('Source node: ' + node.id);
60 }
61
62 function setDst(node) {
63 wss.sendEvent(dstMessage, {
64 id: node.id,
65 type: node.type
66 });
67 flash.flash('Destination node: ' + node.id);
68 }
69
70 function clear() {
71 wss.sendEvent(clearMessage);
72 flash.flash('Cleared source and destination');
73 }
74
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053075 function dClose() {
76 $log.debug('Dialog Close button clicked (or Esc pressed)');
77 }
78
79 function createUserText() {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +053080 var content = ds.createDiv('constraints-input'),
81 form = content.append('form'),
82 p = form.append('p');
83
84 function addAttribute(name, id, nameField, type) {
Mahesh Raju-Huawei0f977ef2016-06-14 17:26:22 +053085 if (type == 'radio') {
86 p.append('input').attr({
87 type: type,
88 name: name,
89 id: id,
90 class: 'radioButtonSpace'
91 });
92 } else {
93 p.append('input').attr({
94 type: type,
95 name: name,
96 id: id
97 });
98 }
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +053099
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530100 p.append('span').text(nameField);
101 p.append('br');
102 }
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530103
104 //Add the bandwidth related inputs.
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530105 addAttribute('band-width-name', 'band-width-box', 'Band Width', 'checkbox');
106 addAttribute('band-width-value-name', 'band-width-value', null, 'number');
107 addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio');
108 addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530109 addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio');
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530110 //Add the cost type related inputs.
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530111 addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox');
112 addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio');
113 addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio');
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530114 //Add the LSP type related inputs.
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530115 addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type *', 'checkbox');
Mahesh Raju-Huawei31d31c02016-06-04 17:20:57 +0530116 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio');
117 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio');
118 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530119 //Add the tunnel name
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530120 p.append('span').text("Tunnel Name *");
121 p.append('br');
122 addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', null, 'text');
123 p.append('span').text("* indicates mandatory fields");
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530124 return content;
125 }
126
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530127 function createUserTextUpdate(data) {
128 var content = ds.createDiv(),
129 form = content.append('form'),
130 p = form.append('p');
131
132 p.append('span').text('Tunnel IDs');
133 p.append('br');
134
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530135 for (var idx = 0; idx < data.a.length; idx++) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530136 p.append('input').attr({
137 id: 'tunnel-id-'+idx,
138 type: 'radio',
139 name: 'tunnel-id-name',
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530140 value: data.a[idx]
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530141 });
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530142 idx++;
143 p.append('span').text(data.a[idx]);
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530144 p.append('br');
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530145 }
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530146 return content;
147 }
148
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530149 function createUserTextUpdatePathEvent(data) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530150 var content = ds.createDiv(),
151 form = content.append('form'),
152 p = form.append('p');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530153 var constType;
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530154
155 function addAttribute(name, id, nameField, type) {
Mahesh Raju-Huawei0f977ef2016-06-14 17:26:22 +0530156 if (type == 'radio') {
157 p.append('input').attr({
158 type: type,
159 name: name,
160 id: id,
161 class: 'radioButtonSpace'
162 });
163 }
164 else {
165 p.append('input').attr({
166 type: type,
167 name: name,
168 id: id
169 });
170 }
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530171
172 p.append('span').text(nameField);
173 p.append('br');
174 }
175
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530176 data.a.forEach( function (val, idx) {
177 if (val == 'Tunnel') {
178 constType = 'TUNNEL';
179 return;
180 }
181
182 if (val == 'BandWidth') {
183 constType = 'BW';
184 return;
185 }
186
187 if (val == 'CostType') {
188 constType = 'CT';
189 return;
190 }
191
192 if (constType == 'TUNNEL') {
193 p.append('span').text('Tunnel Id: ');
194 p.append('span').text(val);
195 p.append('br');
196 tunnelIdUpd = val;
197 }
198
199 if (constType == 'BW') {
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530200 //addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox');
201 p.append('span').text('Band Width');
202 p.append('br');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530203 p.append('input').attr({
204 id: 'update-band-width-value',
205 type: 'number',
206 name: 'band-width-value-name',
207 value: val
208 });
209 p.append('br');
210 p.append('input').attr({
211 id: 'update-band-bps-val',
212 type: 'radio',
213 name: 'pce-band-type',
214 checked: 'checked',
215 class: 'radioButtonSpace'
216 });
217 p.append('span').text('bps');
218 p.append('br');
219 addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio');
220 addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio');
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530221 addAttribute('pce-band-type', 'update-band-none-val', 'none', 'radio');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530222 }
223
224 if (constType == 'CT') {
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530225 //addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox');
226 p.append('span').text('Cost Type');
227 p.append('br');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530228 if (val == 'COST') {
229 p.append('input').attr({
230 id: 'update-pce-cost-type-igp',
231 type: 'radio',
232 name: 'pce-cost-type-value',
233 checked: 'checked',
234 class: 'radioButtonSpace'
235 });
236 p.append('span').text('IGP');
237 p.append('br');
238 addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio');
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530239 addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530240
241 } else {
242 addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio');
243 p.append('input').attr({
244 id: 'update-pce-cost-type-te',
245 type: 'radio',
246 name: 'pce-cost-type-value',
247 checked: 'checked',
248 class: 'radioButtonSpace'
249 });
250 p.append('span').text('TE');
251 p.append('br');
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530252 addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530253 }
254 }
255 } );
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530256
257 return content;
258 }
259
260 function createUserTextRemove(data) {
261
262 var content = ds.createDiv(),
263 form = content.append('form'),
264 p = form.append('p');
265
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530266 p.append('span').text('Tunnels');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530267 p.append('br');
268
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530269 for (var idx = 0; idx < data.a.length; idx++) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530270 p.append('input').attr({
271 id: 'tunnel-id-remove-'+idx,
272 type: 'checkbox',
273 name: 'tunnel-id-name-remove',
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530274 value: data.a[idx]
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530275 });
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530276 idx++;
277 p.append('span').text(data.a[idx]);
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530278 p.append('br');
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530279 }
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530280
281 return content;
282 }
283
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530284 function createUserTextQuery(data) {
285
286 var content = ds.createDiv(),
287 form = content.append('form'),
288 p = form.append('p');
289
290 p.append('span').text('Tunnels');
291 p.append('br');
292
293 for (var idx =0; idx < data.a.length; idx++) {
294 p.append('input').attr({
295 id: 'tunnel-id-query-'+idx,
296 type: 'radio',
297 name: 'tunnel-id-name-query',
298 value: data.a[idx]
299 });
300 idx++;
301 p.append('span').text(data.a[idx]);
302 p.append('br');
303 }
304 return content;
305 }
306
Mahesh Raju-Huawei31d31c02016-06-04 17:20:57 +0530307 function isChecked(cboxId) {
308 return d3.select('#' + cboxId).property('checked');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530309 }
310
Mahesh Raju-Huawei31d31c02016-06-04 17:20:57 +0530311 function getCheckedValue(cboxId) {
312 return d3.select('#' + cboxId).property('value');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530313 }
314
315 function showTunnelInformation(data) {
316 wss.unbindHandlers(handlerMap);
317 tunnelNameData = data;
318
319 function dOkUpdate() {
320 var tdString = '' ;
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530321 for (var idx = 0; idx < tunnelNameData.a.length; idx++) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530322 var tunnelName = isChecked('tunnel-id-'+idx);
Mahesh Raju-Huawei31d31c02016-06-04 17:20:57 +0530323 if (tunnelName) {
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530324 tdString = tunnelNameData.a[idx];
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530325 }
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530326 idx++;
327 }
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530328 //send event to server for getting the tunnel information.
329 if (tdString != null) {
330 handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle;
331 wss.bindHandlers(handlerMapShowUpdate);
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530332
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530333 wss.sendEvent(updatePathmsgInfo, {
334 tunnelid: tdString
335 });
336 }
337 //constraintsUpdateDialog(tdString);
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530338 $log.debug('Dialog OK button clicked');
339 }
340
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530341 tds.openDialog()
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530342 .setTitle('Available LSPs with selected device')
343 .addContent(createUserTextUpdate(data))
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530344 .addOk(dOkUpdate, 'OK')
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530345 .addCancel(dClose, 'Close')
346 .bindKeys();
347 }
348
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530349 function dOkUpdateEvent() {
350 $log.debug('Select constraints for update path Dialog OK button pressed');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530351
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530352 var bandValue = null,
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530353 bandType = null;
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530354
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530355 bandValue = getCheckedValue('update-band-width-value');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530356
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530357 if (isChecked('update-band-kbps-val')) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530358 bandType = 'kbps';
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530359 } else if (isChecked('update-band-mbps-val')) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530360 bandType = 'mbps';
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530361 } else if (isChecked('update-band-bps-val')) {
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530362 bandType = 'bps';
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530363 } else if (isChecked('update-band-none-val')) {
364 bandType = null;
365 bandValue = null;
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530366 }
367
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530368 var costTypeVal = null;
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530369
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530370 if (isChecked('update-pce-cost-type-igp')) {
371 costTypeVal = 'igp';
372 } else if (isChecked('update-pce-cost-type-te')) {
373 costTypeVal = 'te';
374 } else if (isChecked('update-pce-cost-type-none')) {
375 costTypeVal = null;
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530376 }
377
378 wss.sendEvent(updatePathmsg, {
379 bw: bandValue,
380 bwtype: bandType,
381 ctype: costTypeVal,
MaheshRaju-Huaweibb591072016-06-17 17:47:16 +0530382 tunnelid: tunnelIdUpd
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530383 });
384
385 flash.flash('update path message');
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530386
387 }
388
389 function showTunnelInformationRemove(data) {
390
391 wss.unbindHandlers(handlerMapRem);
392 tunnelNameDataRemove = data;
393 tds.openDialog()
394 .setTitle('Available Tunnels for remove')
395 .addContent(createUserTextRemove(data))
Mahesh Raju-Huawei31d31c02016-06-04 17:20:57 +0530396 .addOk(dOkRemove, 'OK')
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530397 .addCancel(dClose, 'Close')
398 .bindKeys();
399 }
400
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530401 function showTunnelInformationQuery(data) {
402
403 wss.unbindHandlers(handlerMapshowQuery);
404 tunnelNameDataQuery = data;
405 tds.openDialog()
406 .setTitle('Available Tunnels for highlight')
407 .addContent(createUserTextQuery(data))
408 .addOk(dOkQuery, 'OK')
409 .addCancel(dClose, 'Close')
410 .bindKeys();
411 }
412
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530413 function showTunnelInfoUpdateMsgHandle(data) {
414
415 wss.unbindHandlers(handlerMapShowUpdate);
416 tunnelDataUpdateInfo = data;
417 tds.openDialog()
418 .setTitle('Constrainst selection for update')
419 .addContent(createUserTextUpdatePathEvent(data))
420 .addOk(dOkUpdateEvent, 'OK')
421 .addCancel(dClose, 'Close')
422 .bindKeys();
423 }
424
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530425 //setup path
Mahesh Raju-Huawei0f977ef2016-06-14 17:26:22 +0530426 function setMode(node) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530427
428 function dOk() {
429 var bandWidth = isChecked('band-width-box'),
430 bandValue = null,
431 bandType = null;
432
433 if (bandWidth) {
434 bandValue = getCheckedValue('band-width-value');
435
436 if (isChecked('band-kpbs-val')) {
437 bandType = 'kbps';
438 } else if (isChecked('band-mpbs-val')) {
439 bandType = 'mbps';
Mahesh Raju-Huaweid8eaf972016-06-16 19:08:24 +0530440 } else if (isChecked('band-bps-val')) {
441 bandType = 'bps';
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530442 }
443 }
444
445 var costType = isChecked('pce-cost-type'),
446 costTypeVal = null;
447
448 if (costType) {
449 if (isChecked('pce-cost-type-igp')) {
450 costTypeVal = 'igp';
451 } else if (isChecked('pce-cost-type-te')) {
452 costTypeVal = 'te';
453 }
454 }
455
456 var lspType = isChecked('pce-lsp-type'),
457 lspTypeVal = null;
458
459 if (lspType) {
460 if (isChecked('pce-lsp-type-cr')) {
461 lspTypeVal = 'cr';
462 } else if (isChecked('pce-lsp-type-srbe')) {
463 lspTypeVal = 'srbe';
464 } else if (isChecked('pce-lsp-type-srte')) {
465 lspTypeVal = 'srte';
466 }
467 }
468
469 wss.sendEvent(setPathmsg, {
Mahesh Raju-Huawei0f977ef2016-06-14 17:26:22 +0530470 srid: node[0],
471 dsid: node[1],
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530472 bw: bandValue,
473 bwtype: bandType,
474 ctype: costTypeVal,
475 lsptype: lspTypeVal,
476 tunnelname: getCheckedValue('pce-tunnel-name-id')
477 });
478
479 flash.flash('create path message');
480 $log.debug('Dialog OK button clicked');
481 }
482
483 tds.openDialog()
484 .setTitle('constraints selection')
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530485 .addContent(createUserText())
486 .addOk(dOk, 'OK')
487 .addCancel(dClose, 'Close')
488 .bindKeys();
489 }
490
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530491 function updatePath(node) {
492
493 wss.sendEvent(updatePathmsgQuery, {
494 srid: node[0],
495 dsid: node[1]
496 });
497
498 handlerMap[showTunnelInfoMsg] = showTunnelInformation;
499 wss.bindHandlers(handlerMap);
500
501 flash.flash('update path message');
502 }
503
504 function dOkRemove() {
505
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530506 for (var idx = 0; idx < tunnelNameDataRemove.a.length; idx++) {
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530507 var tunnelNameVal = isChecked('tunnel-id-remove-'+idx);
508 if (tunnelNameVal) {
509 wss.sendEvent(remPathmsg, {
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530510 tunnelid: tunnelNameDataRemove.a[idx]
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530511 });
512 }
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530513 idx++;
514 }
515
516 flash.flash('remove path message');
517 }
518
519 function dOkQuery() {
520
521 for (var idx = 0; idx < tunnelNameDataQuery.a.length; idx++) {
522 var tunnelNameVal = isChecked('tunnel-id-query-'+idx);
523 if (tunnelNameVal) {
524 wss.sendEvent(showTunnelHighlightMsg, {
525 tunnelid: tunnelNameDataQuery.a[idx]
526 });
527 }
528 idx++;
529 }
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530530
531 flash.flash('remove path message');
532 }
533
534 function remPath(node) {
535 wss.sendEvent(remPathmsgQuery, {
536 srid: node[0],
537 dsid: node[1]
538 });
539
540 handlerMapRem[showTunnelInfoRemoveMsg] = showTunnelInformationRemove;
541 wss.bindHandlers(handlerMapRem);
542 }
543
544 function queryTunnelDisplay() {
MaheshRaju-Huawei4bf9f2d2016-07-01 19:03:18 +0530545 handlerMapshowQuery[showTunnelInfoQuery] = showTunnelInformationQuery;
546 wss.bindHandlers(handlerMapshowQuery);
547
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530548 wss.sendEvent(queryDisplayTunnelMsg);
549 }
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530550 // === ---------------------------
551 // === Module Factory Definition
552
553 angular.module('ovPcewebTopov', [])
554 .factory('PcewebTopovDemoService',
555 ['$log', 'FnService', 'FlashService', 'WebSocketService',
556 'TopoPanelService', 'NavService', 'TopoDialogService', 'DialogService',
557
558 function (_$log_, _fs_, _flash_, _wss_, _tps_, _ns_,_tds_, _ds_) {
559 $log = _$log_;
560 fs = _fs_;
561 flash = _flash_;
562 wss = _wss_;
563 tps = _tps_;
564 ns = _ns_;
565 tds = _tds_;
566 ds = _ds_;
567
568 return {
569 setSrc: setSrc,
570 setDst: setDst,
571 clear: clear,
Mahesh Raju-Huawei2cfa5352016-05-27 20:09:51 +0530572 setMode: setMode,
573 updatePath: updatePath,
574 remPath: remPath,
575 queryTunnelDisplay: queryTunnelDisplay
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +0530576 };
577 }]);
578}());