From 38a97f8e3fa5a5a008ed591fc8b2fdfb6fef7abc Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Sat, 19 Mar 2016 19:54:14 +0100 Subject: NMS: Add basic add-switch interface --- web/nms.gathering.org/js/nms-info-box.js | 45 +++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 0175b6f..7e27ce7 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -65,6 +65,7 @@ nmsInfoBox._hide = function() nmsInfoBox._showing = ""; nmsInfoBox._editHide(); nmsInfoBox._snmpHide(); + nmsInfoBox._createHide(); } /* @@ -388,7 +389,7 @@ nmsInfoBox._editSave = function(sw, e) { var myData = nmsInfoBox._editStringify(sw); $.ajax({ type: "POST", - url: "/api/private/switch-add", + url: "/api/private/switch-update", dataType: "text", data:myData, success: function (data, textStatus, jqXHR) { @@ -398,3 +399,45 @@ nmsInfoBox._editSave = function(sw, e) { }); nmsInfoBox._editHide(); } + + +/* + * Display infobox for new switch + * + * TODO: Integrate and rebuild info-box display logic + */ +nmsInfoBox._createShow = function() +{ + var container = document.createElement("div"); + container.className = "col-md-5"; + container.id = "nmsInfoBox-create"; + container.style.zIndex = "999"; + + var swtop = document.getElementById("wrap"); + nmsInfoBox._hide(); + + container.innerHTML = '
Add new switch
'; + + swtop.appendChild(container); +} +nmsInfoBox._createSave = function(sw) { + var feedback = document.getElementById("create-switch-feedback"); + var myData = JSON.stringify([{'sysname':sw}]); + $.ajax({ + type: "POST", + url: "/api/private/switch-add", + dataType: "text", + data:myData, + success: function (data, textStatus, jqXHR) { + var result = JSON.parse(data); + if(result.switches_addded.length > 0) { + nmsInfoBox._createHide(); + } + } + }); +} +nmsInfoBox._createHide = function() { + var container = document.getElementById("nmsInfoBox-create"); + if (container != undefined) + container.parentNode.removeChild(container); +} -- cgit v1.2.3