diff options
| author | Ole Mathias Aa. Heggem <olemathias.aa.heggem@gmail.com> | 2018-03-17 18:03:23 +0100 | 
|---|---|---|
| committer | Ole Mathias Aa. Heggem <olemathias.aa.heggem@gmail.com> | 2018-03-17 18:03:23 +0100 | 
| commit | dc97b997e8d6e5edc63c598c05090a8b98e79757 (patch) | |
| tree | 42762b3582ec8416cc70527c178dda6498b90f19 /web/js/nms-info-box.js | |
| parent | 8607a0880724eca35c220f7c26a138d9f0f50f72 (diff) | |
Added support for delete switches
Diffstat (limited to 'web/js/nms-info-box.js')
| -rw-r--r-- | web/js/nms-info-box.js | 26 | 
1 files changed, 26 insertions, 0 deletions
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js index 9a5edae..f1d1fa4 100644 --- a/web/js/nms-info-box.js +++ b/web/js/nms-info-box.js @@ -981,8 +981,16 @@ var switchEditPanel = function () {  		submit.classList.add("btn", "btn-primary");  		submit.id = "edit-submit-" + this.sw;  		submit.setAttribute("onclick","nmsInfoBox._windowHandler.doInPanel('" + this.id + "','save');"); +		submit.style = "margin-right: 5px";  		nav.appendChild(submit); +                var deleteButton = document.createElement("button"); +                deleteButton.innerHTML = "Delete switch"; +                deleteButton.classList.add("btn", "btn-danger"); +                deleteButton.id = "delete-submit-" + this.sw; +                deleteButton.setAttribute("onclick","nmsInfoBox._windowHandler.doInPanel('" + this.id + "','deleteSwitch');"); +                nav.appendChild(deleteButton); +  		var toggleDetails = document.createElement("button");  		toggleDetails.innerHTML = '<span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>';  		toggleDetails.classList.add("btn", "btn-default", "pull-right"); @@ -1026,6 +1034,24 @@ var switchEditPanel = function () {  			}  		});  	}; + +        this.deleteSwitch = function () { +	if(confirm("This will delete the switch: " + this.sw)) { +                var myData = [{'sysname': this.sw, 'deleted': true}];  +                myData = JSON.stringify(myData); +                $.ajax({ +                        type: "POST",  +                        url: "/api/write/switch-update", +                        dataType: "text",  +                        data:myData, +                        success: function (data, textStatus, jqXHR) { +                                nmsInfoBox.hide(); +                                nmsData.invalidate("switches"); +                                nmsData.invalidate("smanagement"); +                        } +                }); +        }; +	};  };  nmsInfoBox.addPanelType("switchEdit",switchEditPanel);  | 
