|
347 | 347 | displayPassiveDevices = !displayPassiveDevices |
348 | 348 | }; |
349 | 349 |
|
| 350 | + saveView = function (topoSaveURI, CSRFToken) { |
| 351 | + var topoSaveName = document.getElementById('topoSaveName').value.trim(); |
| 352 | + var saveButton = document.getElementById('saveTopologyView'); |
| 353 | + var saveResultLabel = document.getElementById('saveResult'); |
| 354 | + saveButton.setAttribute('disabled', true); |
| 355 | + saveResultLabel.setAttribute('innerHTML', 'Processing'); |
| 356 | + $.ajax({ |
| 357 | + type: 'POST', |
| 358 | + url: topoSaveURI, |
| 359 | + data: { |
| 360 | + 'name': topoSaveName, |
| 361 | + 'topology': JSON.stringify(topo.data()), |
| 362 | + 'layout_context': JSON.stringify({ |
| 363 | + 'initialLayout': initialLayout, |
| 364 | + 'displayUnconnected': !displayUnconnected, |
| 365 | + 'undisplayedRoles': undisplayedRoles, |
| 366 | + 'undisplayedDeviceTags': undisplayedDeviceTags, |
| 367 | + 'displayPassiveDevices': !displayPassiveDevices, |
| 368 | + 'displayLogicalMultiCableLinks': displayLogicalMultiCableLinks, |
| 369 | + 'requestGET': requestGET, |
| 370 | + }) |
| 371 | + }, |
| 372 | + headers: {'X-CSRFToken': CSRFToken}, |
| 373 | + success: function (response) { |
| 374 | + saveResultLabel.innerHTML = 'Success'; |
| 375 | + saveButton.removeAttribute('disabled'); |
| 376 | + console.log(response); |
| 377 | + }, |
| 378 | + error: function (response) { |
| 379 | + saveResultLabel.innerHTML = 'Failed'; |
| 380 | + console.log(response); |
| 381 | + } |
| 382 | + }) |
| 383 | + }; |
| 384 | + |
350 | 385 | topo.on('topologyGenerated', function(){ |
351 | 386 | showHideUndonnected(); |
352 | 387 | showHidePassiveDevices(); |
|
360 | 395 | undisplayedDeviceTags.forEach(function(deviceTag){ |
361 | 396 | showHideDevicesByTag(deviceTag, false); |
362 | 397 | }); |
| 398 | + topologySavedData['nodes'].forEach(function(node){ |
| 399 | + topo.graph().getVertex(node['id']).position({'x': node.x, 'y': node.y}); |
| 400 | + }); |
363 | 401 | }); |
364 | 402 |
|
365 | 403 | // Create an application instance |
|
0 commit comments