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; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 24 | var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd, tunnelNameDataQuery; |
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', |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 38 | showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate', |
| 39 | showTunnelInfoQuery = 'pceTopovShowTunnelsQuery', |
| 40 | showTunnelHighlightMsg = 'pceTopovshowTunnelHighlightMsg'; |
| 41 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 42 | // internal state |
| 43 | var currentMode = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 44 | var handlerMap = {}, |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 45 | handlerMapRem = {}, |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 46 | handlerMapshowQuery = {}, |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 47 | handlerMapShowUpdate = {}; |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 48 | // === --------------------------- |
| 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-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 75 | function dClose() { |
| 76 | $log.debug('Dialog Close button clicked (or Esc pressed)'); |
| 77 | } |
| 78 | |
| 79 | function createUserText() { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 80 | 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-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 85 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 99 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 100 | p.append('span').text(nameField); |
| 101 | p.append('br'); |
| 102 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 103 | |
| 104 | //Add the bandwidth related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 105 | 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-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 109 | addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 110 | //Add the cost type related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 111 | 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-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 114 | //Add the LSP type related inputs. |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 115 | addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type *', 'checkbox'); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 116 | 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-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 119 | //Add the tunnel name |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 120 | 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-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 124 | return content; |
| 125 | } |
| 126 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 127 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 135 | for (var idx = 0; idx < data.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 136 | p.append('input').attr({ |
| 137 | id: 'tunnel-id-'+idx, |
| 138 | type: 'radio', |
| 139 | name: 'tunnel-id-name', |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 140 | value: data.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 141 | }); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 142 | idx++; |
| 143 | p.append('span').text(data.a[idx]); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 144 | p.append('br'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 145 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 146 | return content; |
| 147 | } |
| 148 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 149 | function createUserTextUpdatePathEvent(data) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 150 | var content = ds.createDiv(), |
| 151 | form = content.append('form'), |
| 152 | p = form.append('p'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 153 | var constType; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 154 | |
| 155 | function addAttribute(name, id, nameField, type) { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 156 | 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-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 171 | |
| 172 | p.append('span').text(nameField); |
| 173 | p.append('br'); |
| 174 | } |
| 175 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 176 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 200 | //addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); |
| 201 | p.append('span').text('Band Width'); |
| 202 | p.append('br'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 203 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 221 | addAttribute('pce-band-type', 'update-band-none-val', 'none', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | if (constType == 'CT') { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 225 | //addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); |
| 226 | p.append('span').text('Cost Type'); |
| 227 | p.append('br'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 228 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 239 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 240 | |
| 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 252 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | } ); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 256 | |
| 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 266 | p.append('span').text('Tunnels'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 267 | p.append('br'); |
| 268 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 269 | for (var idx = 0; idx < data.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 270 | p.append('input').attr({ |
| 271 | id: 'tunnel-id-remove-'+idx, |
| 272 | type: 'checkbox', |
| 273 | name: 'tunnel-id-name-remove', |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 274 | value: data.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 275 | }); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 276 | idx++; |
| 277 | p.append('span').text(data.a[idx]); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 278 | p.append('br'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 279 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 280 | |
| 281 | return content; |
| 282 | } |
| 283 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 284 | 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-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 307 | function isChecked(cboxId) { |
| 308 | return d3.select('#' + cboxId).property('checked'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 309 | } |
| 310 | |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 311 | function getCheckedValue(cboxId) { |
| 312 | return d3.select('#' + cboxId).property('value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | function showTunnelInformation(data) { |
| 316 | wss.unbindHandlers(handlerMap); |
| 317 | tunnelNameData = data; |
| 318 | |
| 319 | function dOkUpdate() { |
| 320 | var tdString = '' ; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 321 | for (var idx = 0; idx < tunnelNameData.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 322 | var tunnelName = isChecked('tunnel-id-'+idx); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 323 | if (tunnelName) { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 324 | tdString = tunnelNameData.a[idx]; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 325 | } |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 326 | idx++; |
| 327 | } |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 328 | //send event to server for getting the tunnel information. |
| 329 | if (tdString != null) { |
| 330 | handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle; |
| 331 | wss.bindHandlers(handlerMapShowUpdate); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 332 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 333 | wss.sendEvent(updatePathmsgInfo, { |
| 334 | tunnelid: tdString |
| 335 | }); |
| 336 | } |
| 337 | //constraintsUpdateDialog(tdString); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 338 | $log.debug('Dialog OK button clicked'); |
| 339 | } |
| 340 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 341 | tds.openDialog() |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 342 | .setTitle('Available LSPs with selected device') |
| 343 | .addContent(createUserTextUpdate(data)) |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 344 | .addOk(dOkUpdate, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 345 | .addCancel(dClose, 'Close') |
| 346 | .bindKeys(); |
| 347 | } |
| 348 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 349 | function dOkUpdateEvent() { |
| 350 | $log.debug('Select constraints for update path Dialog OK button pressed'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 351 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 352 | var bandValue = null, |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 353 | bandType = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 354 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 355 | bandValue = getCheckedValue('update-band-width-value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 356 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 357 | if (isChecked('update-band-kbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 358 | bandType = 'kbps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 359 | } else if (isChecked('update-band-mbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 360 | bandType = 'mbps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 361 | } else if (isChecked('update-band-bps-val')) { |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 362 | bandType = 'bps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 363 | } else if (isChecked('update-band-none-val')) { |
| 364 | bandType = null; |
| 365 | bandValue = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 366 | } |
| 367 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 368 | var costTypeVal = null; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 369 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 370 | 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-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | wss.sendEvent(updatePathmsg, { |
| 379 | bw: bandValue, |
| 380 | bwtype: bandType, |
| 381 | ctype: costTypeVal, |
MaheshRaju-Huawei | bb59107 | 2016-06-17 17:47:16 +0530 | [diff] [blame] | 382 | tunnelid: tunnelIdUpd |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 383 | }); |
| 384 | |
| 385 | flash.flash('update path message'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 386 | |
| 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-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 396 | .addOk(dOkRemove, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 397 | .addCancel(dClose, 'Close') |
| 398 | .bindKeys(); |
| 399 | } |
| 400 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 401 | 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-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 413 | 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-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 425 | //setup path |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 426 | function setMode(node) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 427 | |
| 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-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 440 | } else if (isChecked('band-bps-val')) { |
| 441 | bandType = 'bps'; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 442 | } |
| 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-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 470 | srid: node[0], |
| 471 | dsid: node[1], |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 472 | 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-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 485 | .addContent(createUserText()) |
| 486 | .addOk(dOk, 'OK') |
| 487 | .addCancel(dClose, 'Close') |
| 488 | .bindKeys(); |
| 489 | } |
| 490 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 491 | 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 506 | for (var idx = 0; idx < tunnelNameDataRemove.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 507 | var tunnelNameVal = isChecked('tunnel-id-remove-'+idx); |
| 508 | if (tunnelNameVal) { |
| 509 | wss.sendEvent(remPathmsg, { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 510 | tunnelid: tunnelNameDataRemove.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 511 | }); |
| 512 | } |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 513 | 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-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 530 | |
| 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-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 545 | handlerMapshowQuery[showTunnelInfoQuery] = showTunnelInformationQuery; |
| 546 | wss.bindHandlers(handlerMapshowQuery); |
| 547 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 548 | wss.sendEvent(queryDisplayTunnelMsg); |
| 549 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 550 | // === --------------------------- |
| 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-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 572 | setMode: setMode, |
| 573 | updatePath: updatePath, |
| 574 | remPath: remPath, |
| 575 | queryTunnelDisplay: queryTunnelDisplay |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 576 | }; |
| 577 | }]); |
| 578 | }()); |