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') { |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 86 | if (id == 'pce-lsp-type-cr') { |
| 87 | p.append('input').attr({ |
| 88 | type: type, |
| 89 | name: name, |
| 90 | id: id, |
| 91 | checked: 'checked', |
| 92 | class: 'radioButtonSpace' |
| 93 | }); |
| 94 | } else { |
| 95 | p.append('input').attr({ |
| 96 | type: type, |
| 97 | name: name, |
| 98 | id: id, |
| 99 | class: 'radioButtonSpace' |
| 100 | }); |
| 101 | } |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 102 | } else { |
| 103 | p.append('input').attr({ |
| 104 | type: type, |
| 105 | name: name, |
| 106 | id: id |
| 107 | }); |
| 108 | } |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 109 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 110 | p.append('span').text(nameField); |
| 111 | p.append('br'); |
| 112 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 113 | |
| 114 | //Add the bandwidth related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 115 | addAttribute('band-width-name', 'band-width-box', 'Band Width', 'checkbox'); |
| 116 | addAttribute('band-width-value-name', 'band-width-value', null, 'number'); |
| 117 | addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio'); |
| 118 | addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 119 | addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 120 | //Add the cost type related inputs. |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 121 | addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox'); |
| 122 | addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio'); |
| 123 | addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio'); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 124 | //Add the LSP type related inputs. |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 125 | p.append('span').text("Lsp Type *"); |
| 126 | p.append('br'); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 127 | addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio'); |
| 128 | addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio'); |
| 129 | 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] | 130 | //Add the tunnel name |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 131 | p.append('span').text("Tunnel Name *"); |
| 132 | p.append('br'); |
| 133 | addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', null, 'text'); |
| 134 | p.append('span').text("* indicates mandatory fields"); |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 135 | return content; |
| 136 | } |
| 137 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 138 | function createUserTextUpdate(data) { |
| 139 | var content = ds.createDiv(), |
| 140 | form = content.append('form'), |
| 141 | p = form.append('p'); |
| 142 | |
| 143 | p.append('span').text('Tunnel IDs'); |
| 144 | p.append('br'); |
| 145 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 146 | for (var idx = 0; idx < data.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 147 | p.append('input').attr({ |
| 148 | id: 'tunnel-id-'+idx, |
| 149 | type: 'radio', |
| 150 | name: 'tunnel-id-name', |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 151 | value: data.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 152 | }); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 153 | idx++; |
| 154 | p.append('span').text(data.a[idx]); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 155 | p.append('br'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 156 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 157 | return content; |
| 158 | } |
| 159 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 160 | function createUserTextUpdatePathEvent(data) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 161 | var content = ds.createDiv(), |
| 162 | form = content.append('form'), |
| 163 | p = form.append('p'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 164 | var constType; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 165 | |
| 166 | function addAttribute(name, id, nameField, type) { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 167 | if (type == 'radio') { |
| 168 | p.append('input').attr({ |
| 169 | type: type, |
| 170 | name: name, |
| 171 | id: id, |
| 172 | class: 'radioButtonSpace' |
| 173 | }); |
| 174 | } |
| 175 | else { |
| 176 | p.append('input').attr({ |
| 177 | type: type, |
| 178 | name: name, |
| 179 | id: id |
| 180 | }); |
| 181 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 182 | |
| 183 | p.append('span').text(nameField); |
| 184 | p.append('br'); |
| 185 | } |
| 186 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 187 | data.a.forEach( function (val, idx) { |
| 188 | if (val == 'Tunnel') { |
| 189 | constType = 'TUNNEL'; |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | if (val == 'BandWidth') { |
| 194 | constType = 'BW'; |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | if (val == 'CostType') { |
| 199 | constType = 'CT'; |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | if (constType == 'TUNNEL') { |
| 204 | p.append('span').text('Tunnel Id: '); |
| 205 | p.append('span').text(val); |
| 206 | p.append('br'); |
| 207 | tunnelIdUpd = val; |
| 208 | } |
| 209 | |
| 210 | if (constType == 'BW') { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 211 | //addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); |
| 212 | p.append('span').text('Band Width'); |
| 213 | p.append('br'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 214 | p.append('input').attr({ |
| 215 | id: 'update-band-width-value', |
| 216 | type: 'number', |
| 217 | name: 'band-width-value-name', |
| 218 | value: val |
| 219 | }); |
| 220 | p.append('br'); |
| 221 | p.append('input').attr({ |
| 222 | id: 'update-band-bps-val', |
| 223 | type: 'radio', |
| 224 | name: 'pce-band-type', |
| 225 | checked: 'checked', |
| 226 | class: 'radioButtonSpace' |
| 227 | }); |
| 228 | p.append('span').text('bps'); |
| 229 | p.append('br'); |
| 230 | addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio'); |
| 231 | addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 232 | addAttribute('pce-band-type', 'update-band-none-val', 'none', 'radio'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | if (constType == 'CT') { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 236 | //addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); |
| 237 | p.append('span').text('Cost Type'); |
| 238 | p.append('br'); |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 239 | if (val == 'COST') { |
| 240 | p.append('input').attr({ |
| 241 | id: 'update-pce-cost-type-igp', |
| 242 | type: 'radio', |
| 243 | name: 'pce-cost-type-value', |
| 244 | checked: 'checked', |
| 245 | class: 'radioButtonSpace' |
| 246 | }); |
| 247 | p.append('span').text('IGP'); |
| 248 | p.append('br'); |
| 249 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 250 | 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] | 251 | |
| 252 | } else { |
| 253 | addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio'); |
| 254 | p.append('input').attr({ |
| 255 | id: 'update-pce-cost-type-te', |
| 256 | type: 'radio', |
| 257 | name: 'pce-cost-type-value', |
| 258 | checked: 'checked', |
| 259 | class: 'radioButtonSpace' |
| 260 | }); |
| 261 | p.append('span').text('TE'); |
| 262 | p.append('br'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 263 | 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] | 264 | } |
| 265 | } |
| 266 | } ); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 267 | |
| 268 | return content; |
| 269 | } |
| 270 | |
| 271 | function createUserTextRemove(data) { |
| 272 | |
| 273 | var content = ds.createDiv(), |
| 274 | form = content.append('form'), |
| 275 | p = form.append('p'); |
| 276 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 277 | p.append('span').text('Tunnels'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 278 | p.append('br'); |
| 279 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 280 | for (var idx = 0; idx < data.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 281 | p.append('input').attr({ |
| 282 | id: 'tunnel-id-remove-'+idx, |
| 283 | type: 'checkbox', |
| 284 | name: 'tunnel-id-name-remove', |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 285 | value: data.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 286 | }); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 287 | idx++; |
| 288 | p.append('span').text(data.a[idx]); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 289 | p.append('br'); |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 290 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 291 | |
| 292 | return content; |
| 293 | } |
| 294 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 295 | function createUserTextQuery(data) { |
| 296 | |
| 297 | var content = ds.createDiv(), |
| 298 | form = content.append('form'), |
| 299 | p = form.append('p'); |
| 300 | |
| 301 | p.append('span').text('Tunnels'); |
| 302 | p.append('br'); |
| 303 | |
| 304 | for (var idx =0; idx < data.a.length; idx++) { |
| 305 | p.append('input').attr({ |
| 306 | id: 'tunnel-id-query-'+idx, |
| 307 | type: 'radio', |
| 308 | name: 'tunnel-id-name-query', |
| 309 | value: data.a[idx] |
| 310 | }); |
| 311 | idx++; |
| 312 | p.append('span').text(data.a[idx]); |
| 313 | p.append('br'); |
| 314 | } |
| 315 | return content; |
| 316 | } |
| 317 | |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 318 | function isChecked(cboxId) { |
| 319 | return d3.select('#' + cboxId).property('checked'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 320 | } |
| 321 | |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 322 | function getCheckedValue(cboxId) { |
| 323 | return d3.select('#' + cboxId).property('value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | function showTunnelInformation(data) { |
| 327 | wss.unbindHandlers(handlerMap); |
| 328 | tunnelNameData = data; |
| 329 | |
| 330 | function dOkUpdate() { |
| 331 | var tdString = '' ; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 332 | for (var idx = 0; idx < tunnelNameData.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 333 | var tunnelName = isChecked('tunnel-id-'+idx); |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 334 | if (tunnelName) { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 335 | tdString = tunnelNameData.a[idx]; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 336 | } |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 337 | idx++; |
| 338 | } |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 339 | //send event to server for getting the tunnel information. |
| 340 | if (tdString != null) { |
| 341 | handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle; |
| 342 | wss.bindHandlers(handlerMapShowUpdate); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 343 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 344 | wss.sendEvent(updatePathmsgInfo, { |
| 345 | tunnelid: tdString |
| 346 | }); |
| 347 | } |
| 348 | //constraintsUpdateDialog(tdString); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 349 | $log.debug('Dialog OK button clicked'); |
| 350 | } |
| 351 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 352 | tds.openDialog() |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 353 | .setTitle('Available LSPs with selected device') |
| 354 | .addContent(createUserTextUpdate(data)) |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 355 | .addOk(dOkUpdate, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 356 | .addCancel(dClose, 'Close') |
| 357 | .bindKeys(); |
| 358 | } |
| 359 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 360 | function dOkUpdateEvent() { |
| 361 | $log.debug('Select constraints for update path Dialog OK button pressed'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 362 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 363 | var bandValue = null, |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 364 | bandType = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 365 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 366 | bandValue = getCheckedValue('update-band-width-value'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 367 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 368 | if (isChecked('update-band-kbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 369 | bandType = 'kbps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 370 | } else if (isChecked('update-band-mbps-val')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 371 | bandType = 'mbps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 372 | } else if (isChecked('update-band-bps-val')) { |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 373 | bandType = 'bps'; |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 374 | } else if (isChecked('update-band-none-val')) { |
| 375 | bandType = null; |
| 376 | bandValue = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 377 | } |
| 378 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 379 | var costTypeVal = null; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 380 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 381 | if (isChecked('update-pce-cost-type-igp')) { |
| 382 | costTypeVal = 'igp'; |
| 383 | } else if (isChecked('update-pce-cost-type-te')) { |
| 384 | costTypeVal = 'te'; |
| 385 | } else if (isChecked('update-pce-cost-type-none')) { |
| 386 | costTypeVal = null; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | wss.sendEvent(updatePathmsg, { |
| 390 | bw: bandValue, |
| 391 | bwtype: bandType, |
| 392 | ctype: costTypeVal, |
MaheshRaju-Huawei | bb59107 | 2016-06-17 17:47:16 +0530 | [diff] [blame] | 393 | tunnelid: tunnelIdUpd |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 394 | }); |
| 395 | |
| 396 | flash.flash('update path message'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 397 | |
| 398 | } |
| 399 | |
| 400 | function showTunnelInformationRemove(data) { |
| 401 | |
| 402 | wss.unbindHandlers(handlerMapRem); |
| 403 | tunnelNameDataRemove = data; |
| 404 | tds.openDialog() |
| 405 | .setTitle('Available Tunnels for remove') |
| 406 | .addContent(createUserTextRemove(data)) |
Mahesh Raju-Huawei | 31d31c0 | 2016-06-04 17:20:57 +0530 | [diff] [blame] | 407 | .addOk(dOkRemove, 'OK') |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 408 | .addCancel(dClose, 'Close') |
| 409 | .bindKeys(); |
| 410 | } |
| 411 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 412 | function showTunnelInformationQuery(data) { |
| 413 | |
| 414 | wss.unbindHandlers(handlerMapshowQuery); |
| 415 | tunnelNameDataQuery = data; |
| 416 | tds.openDialog() |
| 417 | .setTitle('Available Tunnels for highlight') |
| 418 | .addContent(createUserTextQuery(data)) |
| 419 | .addOk(dOkQuery, 'OK') |
| 420 | .addCancel(dClose, 'Close') |
| 421 | .bindKeys(); |
| 422 | } |
| 423 | |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 424 | function showTunnelInfoUpdateMsgHandle(data) { |
| 425 | |
| 426 | wss.unbindHandlers(handlerMapShowUpdate); |
| 427 | tunnelDataUpdateInfo = data; |
| 428 | tds.openDialog() |
| 429 | .setTitle('Constrainst selection for update') |
| 430 | .addContent(createUserTextUpdatePathEvent(data)) |
| 431 | .addOk(dOkUpdateEvent, 'OK') |
| 432 | .addCancel(dClose, 'Close') |
| 433 | .bindKeys(); |
| 434 | } |
| 435 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 436 | //setup path |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 437 | function setMode(node) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 438 | |
| 439 | function dOk() { |
| 440 | var bandWidth = isChecked('band-width-box'), |
| 441 | bandValue = null, |
| 442 | bandType = null; |
| 443 | |
| 444 | if (bandWidth) { |
| 445 | bandValue = getCheckedValue('band-width-value'); |
| 446 | |
| 447 | if (isChecked('band-kpbs-val')) { |
| 448 | bandType = 'kbps'; |
| 449 | } else if (isChecked('band-mpbs-val')) { |
| 450 | bandType = 'mbps'; |
Mahesh Raju-Huawei | d8eaf97 | 2016-06-16 19:08:24 +0530 | [diff] [blame] | 451 | } else if (isChecked('band-bps-val')) { |
| 452 | bandType = 'bps'; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | var costType = isChecked('pce-cost-type'), |
| 457 | costTypeVal = null; |
| 458 | |
| 459 | if (costType) { |
| 460 | if (isChecked('pce-cost-type-igp')) { |
| 461 | costTypeVal = 'igp'; |
| 462 | } else if (isChecked('pce-cost-type-te')) { |
| 463 | costTypeVal = 'te'; |
| 464 | } |
| 465 | } |
| 466 | |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 467 | var lspTypeVal = null; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 468 | |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 469 | if (isChecked('pce-lsp-type-cr')) { |
| 470 | lspTypeVal = 'cr'; |
| 471 | } else if (isChecked('pce-lsp-type-srbe')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 472 | lspTypeVal = 'srbe'; |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 473 | } else if (isChecked('pce-lsp-type-srte')) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 474 | lspTypeVal = 'srte'; |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | wss.sendEvent(setPathmsg, { |
Mahesh Raju-Huawei | 0f977ef | 2016-06-14 17:26:22 +0530 | [diff] [blame] | 478 | srid: node[0], |
| 479 | dsid: node[1], |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 480 | bw: bandValue, |
| 481 | bwtype: bandType, |
| 482 | ctype: costTypeVal, |
| 483 | lsptype: lspTypeVal, |
| 484 | tunnelname: getCheckedValue('pce-tunnel-name-id') |
| 485 | }); |
| 486 | |
| 487 | flash.flash('create path message'); |
| 488 | $log.debug('Dialog OK button clicked'); |
| 489 | } |
| 490 | |
| 491 | tds.openDialog() |
| 492 | .setTitle('constraints selection') |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 493 | .addContent(createUserText()) |
| 494 | .addOk(dOk, 'OK') |
| 495 | .addCancel(dClose, 'Close') |
| 496 | .bindKeys(); |
| 497 | } |
| 498 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 499 | function updatePath(node) { |
| 500 | |
| 501 | wss.sendEvent(updatePathmsgQuery, { |
| 502 | srid: node[0], |
| 503 | dsid: node[1] |
| 504 | }); |
| 505 | |
| 506 | handlerMap[showTunnelInfoMsg] = showTunnelInformation; |
| 507 | wss.bindHandlers(handlerMap); |
| 508 | |
| 509 | flash.flash('update path message'); |
| 510 | } |
| 511 | |
| 512 | function dOkRemove() { |
| 513 | |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 514 | for (var idx = 0; idx < tunnelNameDataRemove.a.length; idx++) { |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 515 | var tunnelNameVal = isChecked('tunnel-id-remove-'+idx); |
| 516 | if (tunnelNameVal) { |
| 517 | wss.sendEvent(remPathmsg, { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 518 | tunnelid: tunnelNameDataRemove.a[idx] |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 519 | }); |
| 520 | } |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 521 | idx++; |
| 522 | } |
| 523 | |
| 524 | flash.flash('remove path message'); |
| 525 | } |
| 526 | |
| 527 | function dOkQuery() { |
| 528 | |
| 529 | for (var idx = 0; idx < tunnelNameDataQuery.a.length; idx++) { |
| 530 | var tunnelNameVal = isChecked('tunnel-id-query-'+idx); |
| 531 | if (tunnelNameVal) { |
| 532 | wss.sendEvent(showTunnelHighlightMsg, { |
| 533 | tunnelid: tunnelNameDataQuery.a[idx] |
| 534 | }); |
| 535 | } |
| 536 | idx++; |
| 537 | } |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 538 | |
MaheshRaju-Huawei | aec67f8 | 2016-07-18 16:39:25 +0530 | [diff] [blame] | 539 | flash.flash('query path message'); |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | function remPath(node) { |
| 543 | wss.sendEvent(remPathmsgQuery, { |
| 544 | srid: node[0], |
| 545 | dsid: node[1] |
| 546 | }); |
| 547 | |
| 548 | handlerMapRem[showTunnelInfoRemoveMsg] = showTunnelInformationRemove; |
| 549 | wss.bindHandlers(handlerMapRem); |
| 550 | } |
| 551 | |
| 552 | function queryTunnelDisplay() { |
MaheshRaju-Huawei | 4bf9f2d | 2016-07-01 19:03:18 +0530 | [diff] [blame] | 553 | handlerMapshowQuery[showTunnelInfoQuery] = showTunnelInformationQuery; |
| 554 | wss.bindHandlers(handlerMapshowQuery); |
| 555 | |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 556 | wss.sendEvent(queryDisplayTunnelMsg); |
| 557 | } |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 558 | // === --------------------------- |
| 559 | // === Module Factory Definition |
| 560 | |
| 561 | angular.module('ovPcewebTopov', []) |
| 562 | .factory('PcewebTopovDemoService', |
| 563 | ['$log', 'FnService', 'FlashService', 'WebSocketService', |
| 564 | 'TopoPanelService', 'NavService', 'TopoDialogService', 'DialogService', |
| 565 | |
| 566 | function (_$log_, _fs_, _flash_, _wss_, _tps_, _ns_,_tds_, _ds_) { |
| 567 | $log = _$log_; |
| 568 | fs = _fs_; |
| 569 | flash = _flash_; |
| 570 | wss = _wss_; |
| 571 | tps = _tps_; |
| 572 | ns = _ns_; |
| 573 | tds = _tds_; |
| 574 | ds = _ds_; |
| 575 | |
| 576 | return { |
| 577 | setSrc: setSrc, |
| 578 | setDst: setDst, |
| 579 | clear: clear, |
Mahesh Raju-Huawei | 2cfa535 | 2016-05-27 20:09:51 +0530 | [diff] [blame] | 580 | setMode: setMode, |
| 581 | updatePath: updatePath, |
| 582 | remPath: remPath, |
| 583 | queryTunnelDisplay: queryTunnelDisplay |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 584 | }; |
| 585 | }]); |
| 586 | }()); |