Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 1 | /* |
| 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; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 24 | var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd; |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 25 | // constants |
| 26 | var srcMessage = 'pceTopovSetSrc', |
| 27 | dstMessage = 'pceTopovSetDst', |
| 28 | clearMessage = 'pceTopovClear', |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 29 | setPathmsg = 'pceTopovSetMode', |
| 30 | updatePathmsgQuery = 'pceTopovUpdateQuery', |
| 31 | remPathmsgQuery = 'pceTopovRemQuery', |
| 32 | updatePathmsg = 'pceTopovUpdate', |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 33 | updatePathmsgInfo = 'updatePathmsgInfo', |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 34 | remPathmsg = 'pceTopovRem', |
| 35 | showTunnelInfoMsg = 'pceTopovShowTunnels', |
| 36 | queryDisplayTunnelMsg = 'pceTopovTunnelDisplay', |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 37 | showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem', |
| 38 | showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate'; |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 39 | // internal state |
| 40 | var currentMode = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 41 | var handlerMap = {}, |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 42 | handlerMapRem = {}, |
| 43 | handlerMapShowUpdate = {}; |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 44 | // === --------------------------- |
| 45 | // === Helper functions |
| 46 | |
| 47 | // === --------------------------- |
| 48 | // === Main API functions |
| 49 | |
| 50 | function setSrc(node) { |
| 51 | wss.sendEvent(srcMessage, { |
| 52 | id: node.id, |
| 53 | type: node.type |
| 54 | }); |
| 55 | flash.flash('Source node: ' + node.id); |
| 56 | } |
| 57 | |
| 58 | function setDst(node) { |
| 59 | wss.sendEvent(dstMessage, { |
| 60 | id: node.id, |
| 61 | type: node.type |
| 62 | }); |
| 63 | flash.flash('Destination node: ' + node.id); |
| 64 | } |
| 65 | |
| 66 | function clear() { |
| 67 | wss.sendEvent(clearMessage); |
| 68 | flash.flash('Cleared source and destination'); |
| 69 | } |
| 70 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 71 | function dClose() { |
| 72 | $log.debug('Dialog Close button clicked (or Esc pressed)'); |
| 73 | } |
| 74 | |
| 75 | function createUserText() { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 76 | var content = ds.createDiv('constraints-input'), |
| 77 | form = content.append('form'), |
| 78 | p = form.append('p'); |
| 79 | |
| 80 | function addAttribute(name, id, nameField, type) { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 81 | if (type == 'radio') { |
| 82 | p.append('input').attr({ |
| 83 | type: type, |
| 84 | name: name, |
| 85 | id: id, |
| 86 | class: 'radioButtonSpace' |
| 87 | }); |
| 88 | } else { |
| 89 | p.append('input').attr({ |
| 90 | type: type, |
| 91 | name: name, |
| 92 | id: id |
| 93 | }); |
| 94 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 95 | p.append('span').text(nameField); |
| 96 | p.append('br'); |
| 97 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 98 | |
| 99 | //Add the bandwidth related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 100 | addAttribute('band-width-name', 'band-width-box', 'Band Width', 'checkbox'); |
| 101 | addAttribute('band-width-value-name', 'band-width-value', null, 'number'); |
| 102 | addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio'); |
| 103 | addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 104 | addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 105 | //Add the cost type related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 106 | addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox'); |
| 107 | addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio'); |
| 108 | addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 109 | //Add the LSP type related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 110 | addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type', 'checkbox'); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 111 | addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio'); |
| 112 | addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio'); |
| 113 | addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 114 | //Add the tunnel name |
| 115 | addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', 'Tunnel Name', 'text'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 116 | |
| 117 | return content; |
| 118 | } |
| 119 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 120 | function createUserTextUpdate(data) { |
| 121 | var content = ds.createDiv(), |
| 122 | form = content.append('form'), |
| 123 | p = form.append('p'); |
| 124 | |
| 125 | p.append('span').text('Tunnel IDs'); |
| 126 | p.append('br'); |
| 127 | |
| 128 | data.a.forEach( function (val, idx) { |
| 129 | p.append('input').attr({ |
| 130 | id: 'tunnel-id-'+idx, |
| 131 | type: 'radio', |
| 132 | name: 'tunnel-id-name', |
| 133 | value: val |
| 134 | }); |
| 135 | |
| 136 | p.append('span').text(val); |
| 137 | p.append('br'); |
| 138 | |
| 139 | } ); |
| 140 | |
| 141 | return content; |
| 142 | } |
| 143 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 144 | function createUserTextUpdatePathEvent(data) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 145 | var content = ds.createDiv(), |
| 146 | form = content.append('form'), |
| 147 | p = form.append('p'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 148 | var constType; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 149 | |
| 150 | function addAttribute(name, id, nameField, type) { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 151 | if (type == 'radio') { |
| 152 | p.append('input').attr({ |
| 153 | type: type, |
| 154 | name: name, |
| 155 | id: id, |
| 156 | class: 'radioButtonSpace' |
| 157 | }); |
| 158 | } |
| 159 | else { |
| 160 | p.append('input').attr({ |
| 161 | type: type, |
| 162 | name: name, |
| 163 | id: id |
| 164 | }); |
| 165 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 166 | |
| 167 | p.append('span').text(nameField); |
| 168 | p.append('br'); |
| 169 | } |
| 170 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 171 | data.a.forEach( function (val, idx) { |
| 172 | if (val == 'Tunnel') { |
| 173 | constType = 'TUNNEL'; |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | if (val == 'BandWidth') { |
| 178 | constType = 'BW'; |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | if (val == 'CostType') { |
| 183 | constType = 'CT'; |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | if (constType == 'TUNNEL') { |
| 188 | p.append('span').text('Tunnel Id: '); |
| 189 | p.append('span').text(val); |
| 190 | p.append('br'); |
| 191 | tunnelIdUpd = val; |
| 192 | } |
| 193 | |
| 194 | if (constType == 'BW') { |
| 195 | addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); |
| 196 | p.append('input').attr({ |
| 197 | id: 'update-band-width-value', |
| 198 | type: 'number', |
| 199 | name: 'band-width-value-name', |
| 200 | value: val |
| 201 | }); |
| 202 | p.append('br'); |
| 203 | p.append('input').attr({ |
| 204 | id: 'update-band-bps-val', |
| 205 | type: 'radio', |
| 206 | name: 'pce-band-type', |
| 207 | checked: 'checked', |
| 208 | class: 'radioButtonSpace' |
| 209 | }); |
| 210 | p.append('span').text('bps'); |
| 211 | p.append('br'); |
| 212 | addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio'); |
| 213 | addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio'); |
| 214 | } |
| 215 | |
| 216 | if (constType == 'CT') { |
| 217 | addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); |
| 218 | if (val == 'COST') { |
| 219 | p.append('input').attr({ |
| 220 | id: 'update-pce-cost-type-igp', |
| 221 | type: 'radio', |
| 222 | name: 'pce-cost-type-value', |
| 223 | checked: 'checked', |
| 224 | class: 'radioButtonSpace' |
| 225 | }); |
| 226 | p.append('span').text('IGP'); |
| 227 | p.append('br'); |
| 228 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio'); |
| 229 | |
| 230 | } else { |
| 231 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio'); |
| 232 | p.append('input').attr({ |
| 233 | id: 'update-pce-cost-type-te', |
| 234 | type: 'radio', |
| 235 | name: 'pce-cost-type-value', |
| 236 | checked: 'checked', |
| 237 | class: 'radioButtonSpace' |
| 238 | }); |
| 239 | p.append('span').text('TE'); |
| 240 | p.append('br'); |
| 241 | } |
| 242 | } |
| 243 | } ); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 244 | |
| 245 | return content; |
| 246 | } |
| 247 | |
| 248 | function createUserTextRemove(data) { |
| 249 | |
| 250 | var content = ds.createDiv(), |
| 251 | form = content.append('form'), |
| 252 | p = form.append('p'); |
| 253 | |
| 254 | p.append('span').text('Tunnel IDs'); |
| 255 | p.append('br'); |
| 256 | |
| 257 | data.a.forEach( function (val, idx) { |
| 258 | p.append('input').attr({ |
| 259 | id: 'tunnel-id-remove-'+idx, |
| 260 | type: 'checkbox', |
| 261 | name: 'tunnel-id-name-remove', |
| 262 | value: val |
| 263 | }); |
| 264 | |
| 265 | p.append('span').text(val); |
| 266 | p.append('br'); |
| 267 | } ); |
| 268 | |
| 269 | return content; |
| 270 | } |
| 271 | |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 272 | function isChecked(cboxId) { |
| 273 | return d3.select('#' + cboxId).property('checked'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 274 | } |
| 275 | |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 276 | function getCheckedValue(cboxId) { |
| 277 | return d3.select('#' + cboxId).property('value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | function showTunnelInformation(data) { |
| 281 | wss.unbindHandlers(handlerMap); |
| 282 | tunnelNameData = data; |
| 283 | |
| 284 | function dOkUpdate() { |
| 285 | var tdString = '' ; |
| 286 | tunnelNameData.a.forEach( function (val, idx) { |
| 287 | var tunnelName = isChecked('tunnel-id-'+idx); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 288 | if (tunnelName) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 289 | tdString = val; |
| 290 | } |
| 291 | } ); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 292 | //send event to server for getting the tunnel information. |
| 293 | if (tdString != null) { |
| 294 | handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle; |
| 295 | wss.bindHandlers(handlerMapShowUpdate); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 296 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 297 | wss.sendEvent(updatePathmsgInfo, { |
| 298 | tunnelid: tdString |
| 299 | }); |
| 300 | } |
| 301 | //constraintsUpdateDialog(tdString); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 302 | $log.debug('Dialog OK button clicked'); |
| 303 | } |
| 304 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 305 | tds.openDialog() |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 306 | .setTitle('Available LSPs with selected device') |
| 307 | .addContent(createUserTextUpdate(data)) |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 308 | .addOk(dOkUpdate, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 309 | .addCancel(dClose, 'Close') |
| 310 | .bindKeys(); |
| 311 | } |
| 312 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 313 | function dOkUpdateEvent() { |
| 314 | $log.debug('Select constraints for update path Dialog OK button pressed'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 315 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 316 | var bandWidth = isChecked('update-band-width-box'), |
| 317 | bandValue = null, |
| 318 | bandType = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 319 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 320 | if (bandWidth) { |
| 321 | bandValue = getCheckedValue('update-band-width-value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 322 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 323 | if (isChecked('update-band-kbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 324 | bandType = 'kbps'; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 325 | } else if (isChecked('update-band-mbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 326 | bandType = 'mbps'; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 327 | } else if (isChecked('update-band-bps-val')) { |
| 328 | bandType = 'bps'; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 329 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 330 | } |
| 331 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 332 | var costType = isChecked('update-pce-cost-type'), |
| 333 | costTypeVal = null; |
| 334 | |
| 335 | if (costType) { |
| 336 | if (isChecked('update-pce-cost-type-igp')) { |
| 337 | costTypeVal = 'igp'; |
| 338 | } else if (isChecked('update-pce-cost-type-te')) { |
| 339 | costTypeVal = 'te'; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | wss.sendEvent(updatePathmsg, { |
| 344 | bw: bandValue, |
| 345 | bwtype: bandType, |
| 346 | ctype: costTypeVal, |
MaheshRaju-Huawei | bb59107 | 2016-06-17 17:47:16 +0530 | [diff] [blame^] | 347 | tunnelid: tunnelIdUpd |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 348 | }); |
| 349 | |
| 350 | flash.flash('update path message'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 351 | |
| 352 | } |
| 353 | |
| 354 | function showTunnelInformationRemove(data) { |
| 355 | |
| 356 | wss.unbindHandlers(handlerMapRem); |
| 357 | tunnelNameDataRemove = data; |
| 358 | tds.openDialog() |
| 359 | .setTitle('Available Tunnels for remove') |
| 360 | .addContent(createUserTextRemove(data)) |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 361 | .addOk(dOkRemove, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 362 | .addCancel(dClose, 'Close') |
| 363 | .bindKeys(); |
| 364 | } |
| 365 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 366 | function showTunnelInfoUpdateMsgHandle(data) { |
| 367 | |
| 368 | wss.unbindHandlers(handlerMapShowUpdate); |
| 369 | tunnelDataUpdateInfo = data; |
| 370 | tds.openDialog() |
| 371 | .setTitle('Constrainst selection for update') |
| 372 | .addContent(createUserTextUpdatePathEvent(data)) |
| 373 | .addOk(dOkUpdateEvent, 'OK') |
| 374 | .addCancel(dClose, 'Close') |
| 375 | .bindKeys(); |
| 376 | } |
| 377 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 378 | //setup path |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 379 | function setMode(node) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 380 | |
| 381 | function dOk() { |
| 382 | var bandWidth = isChecked('band-width-box'), |
| 383 | bandValue = null, |
| 384 | bandType = null; |
| 385 | |
| 386 | if (bandWidth) { |
| 387 | bandValue = getCheckedValue('band-width-value'); |
| 388 | |
| 389 | if (isChecked('band-kpbs-val')) { |
| 390 | bandType = 'kbps'; |
| 391 | } else if (isChecked('band-mpbs-val')) { |
| 392 | bandType = 'mbps'; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 393 | } else if (isChecked('band-bps-val')) { |
| 394 | bandType = 'bps'; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
| 398 | var costType = isChecked('pce-cost-type'), |
| 399 | costTypeVal = null; |
| 400 | |
| 401 | if (costType) { |
| 402 | if (isChecked('pce-cost-type-igp')) { |
| 403 | costTypeVal = 'igp'; |
| 404 | } else if (isChecked('pce-cost-type-te')) { |
| 405 | costTypeVal = 'te'; |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | var lspType = isChecked('pce-lsp-type'), |
| 410 | lspTypeVal = null; |
| 411 | |
| 412 | if (lspType) { |
| 413 | if (isChecked('pce-lsp-type-cr')) { |
| 414 | lspTypeVal = 'cr'; |
| 415 | } else if (isChecked('pce-lsp-type-srbe')) { |
| 416 | lspTypeVal = 'srbe'; |
| 417 | } else if (isChecked('pce-lsp-type-srte')) { |
| 418 | lspTypeVal = 'srte'; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | wss.sendEvent(setPathmsg, { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 423 | srid: node[0], |
| 424 | dsid: node[1], |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 425 | bw: bandValue, |
| 426 | bwtype: bandType, |
| 427 | ctype: costTypeVal, |
| 428 | lsptype: lspTypeVal, |
| 429 | tunnelname: getCheckedValue('pce-tunnel-name-id') |
| 430 | }); |
| 431 | |
| 432 | flash.flash('create path message'); |
| 433 | $log.debug('Dialog OK button clicked'); |
| 434 | } |
| 435 | |
| 436 | tds.openDialog() |
| 437 | .setTitle('constraints selection') |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 438 | .addContent(createUserText()) |
| 439 | .addOk(dOk, 'OK') |
| 440 | .addCancel(dClose, 'Close') |
| 441 | .bindKeys(); |
| 442 | } |
| 443 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 444 | function updatePath(node) { |
| 445 | |
| 446 | wss.sendEvent(updatePathmsgQuery, { |
| 447 | srid: node[0], |
| 448 | dsid: node[1] |
| 449 | }); |
| 450 | |
| 451 | handlerMap[showTunnelInfoMsg] = showTunnelInformation; |
| 452 | wss.bindHandlers(handlerMap); |
| 453 | |
| 454 | flash.flash('update path message'); |
| 455 | } |
| 456 | |
| 457 | function dOkRemove() { |
| 458 | |
| 459 | tunnelNameDataRemove.a.forEach( function (val, idx) { |
| 460 | var tunnelNameVal = isChecked('tunnel-id-remove-'+idx); |
| 461 | if (tunnelNameVal) { |
| 462 | wss.sendEvent(remPathmsg, { |
| 463 | tunnelid: val |
| 464 | }); |
| 465 | } |
| 466 | } ); |
| 467 | |
| 468 | flash.flash('remove path message'); |
| 469 | } |
| 470 | |
| 471 | function remPath(node) { |
| 472 | wss.sendEvent(remPathmsgQuery, { |
| 473 | srid: node[0], |
| 474 | dsid: node[1] |
| 475 | }); |
| 476 | |
| 477 | handlerMapRem[showTunnelInfoRemoveMsg] = showTunnelInformationRemove; |
| 478 | wss.bindHandlers(handlerMapRem); |
| 479 | } |
| 480 | |
| 481 | function queryTunnelDisplay() { |
| 482 | wss.sendEvent(queryDisplayTunnelMsg); |
| 483 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 484 | // === --------------------------- |
| 485 | // === Module Factory Definition |
| 486 | |
| 487 | angular.module('ovPcewebTopov', []) |
| 488 | .factory('PcewebTopovDemoService', |
| 489 | ['$log', 'FnService', 'FlashService', 'WebSocketService', |
| 490 | 'TopoPanelService', 'NavService', 'TopoDialogService', 'DialogService', |
| 491 | |
| 492 | function (_$log_, _fs_, _flash_, _wss_, _tps_, _ns_,_tds_, _ds_) { |
| 493 | $log = _$log_; |
| 494 | fs = _fs_; |
| 495 | flash = _flash_; |
| 496 | wss = _wss_; |
| 497 | tps = _tps_; |
| 498 | ns = _ns_; |
| 499 | tds = _tds_; |
| 500 | ds = _ds_; |
| 501 | |
| 502 | return { |
| 503 | setSrc: setSrc, |
| 504 | setDst: setDst, |
| 505 | clear: clear, |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 506 | setMode: setMode, |
| 507 | updatePath: updatePath, |
| 508 | remPath: remPath, |
| 509 | queryTunnelDisplay: queryTunnelDisplay |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 510 | }; |
| 511 | }]); |
| 512 | }()); |