+
+ if (content.privilege === 'WRITE') {
+ var button = one.lib.dashlet.button.single("Add Gateway IP Address",
+ one.f.switchmanager.subnetGatewayConfig.id.dashlet.addIPAddress, "btn-primary", "btn-mini");
+ var $button = one.lib.dashlet.button.button(button);
+ $button.click(function() {
+ var $modal = one.f.switchmanager.subnetGatewayConfig.modal.initialize.gateway();
+ $modal.modal();
+ });
+ $dashlet.append($button);
+
+ // Delete gateway ip address button
+ var button = one.lib.dashlet.button.single("Delete Gateway IP Address(es)",
+ one.f.switchmanager.subnetGatewayConfig.id.dashlet.removeIPAddress, "btn-primary", "btn-mini");
+ var $button = one.lib.dashlet.button.button(button);
+ $button.click(function() {
+ var requestData = {};
+ var gatewaysToDelete = [];
+ var checkedCheckBoxes = $("input:checked", $(this).closest(".dashlet").find("table"));
+ checkedCheckBoxes.each(function(index, value) {
+ gatewaysToDelete.push(checkedCheckBoxes[index].id);
+ });
+ if (gatewaysToDelete.length > 0) {
+ requestData["gatewaysToDelete"] = gatewaysToDelete.toString();
+ var url = one.f.switchmanager.rootUrl + "/subnetGateway/delete";
+ one.f.switchmanager.subnetGatewayConfig.ajax.main(url, requestData, function(response) {
+ if (response.status == true) {
+ // refresh dashlet by passing dashlet div as param
+ one.f.switchmanager.subnetGatewayConfig.dashlet($("#right-bottom .dashlet"));
+ } else {
+ alert(response.message);
+ }
+ });
+ }
+ });
+ $dashlet.append($button);
+
+ // Add Ports button
+ var button = one.lib.dashlet.button.single("Add Ports",
+ one.f.switchmanager.subnetGatewayConfig.id.dashlet.addPorts, "btn-primary", "btn-mini");
+ var $button = one.lib.dashlet.button.button(button);
+ $button.click(function() {
+ var $modal = one.f.switchmanager.subnetGatewayConfig.modal.initialize.ports();
+ $modal.modal();
+ });
+ $dashlet.append($button);
+ }
+