From 6d1dbeb0e59f42399d140f0b1e22763392e5b88d Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Thu, 29 Aug 2013 18:37:03 -0500 Subject: [PATCH] Fix undefined event, add check prior to delete Also changed remove button colors to btn-danger Change-Id: If1166199b3713132c2c00db4e25d5bc06f26e07a Signed-off-by: Andrew Kim --- .../web/devices/src/main/resources/js/page.js | 32 +++++++++++++------ .../web/flows/src/main/resources/js/page.js | 10 ++++-- .../src/main/resources/WEB-INF/jsp/login.jsp | 2 +- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index a138eb909e..103757264c 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -492,8 +492,8 @@ one.f.switchmanager.subnetGatewayConfig = { $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.single("Delete Gateway IP Address", + one.f.switchmanager.subnetGatewayConfig.id.dashlet.removeIPAddress, "btn-danger", "btn-mini"); var $button = one.lib.dashlet.button.button(button); $button.click(function() { var requestData = {}; @@ -502,6 +502,10 @@ one.f.switchmanager.subnetGatewayConfig = { checkedCheckBoxes.each(function(index, value) { gatewaysToDelete.push(checkedCheckBoxes[index].id); }); + if (checkedCheckBoxes.size() === 0) { + alert('Please select at least one gateway'); + return false; + } if (gatewaysToDelete.length > 0) { requestData["gatewaysToDelete"] = gatewaysToDelete.toString(); var url = one.f.switchmanager.rootUrl + "/subnetGateway/delete"; @@ -542,7 +546,7 @@ one.f.switchmanager.subnetGatewayConfig = { $("#" + one.f.switchmanager.subnetGatewayConfig.id.dashlet.datagrid).find(':checkbox').prop('checked', $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll).is(':checked')); }); - $(".subnetGatewayConfig").click(function(){ + $(".subnetGatewayConfig").click(function(e){ if (!$('.subnetGatewayConfig[type=checkbox]:not(:checked)').length) { $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll) .prop("checked", @@ -552,7 +556,7 @@ one.f.switchmanager.subnetGatewayConfig = { .prop("checked", false); } - event.stopPropagation(); + e.stopPropagation(); }); }); }); @@ -893,7 +897,7 @@ one.f.switchmanager.staticRouteConfig = { $dashlet.append($button); // Delete static route button - var button = one.lib.dashlet.button.single("Delete Static Route(s)", one.f.switchmanager.staticRouteConfig.id.dashlet.remove, "btn-primary", "btn-mini"); + var button = one.lib.dashlet.button.single("Delete Static Route(s)", one.f.switchmanager.staticRouteConfig.id.dashlet.remove, "btn-danger", "btn-mini"); var $button = one.lib.dashlet.button.button(button); $button.click(function() { var requestData = {}; @@ -903,6 +907,10 @@ one.f.switchmanager.staticRouteConfig = { checkedCheckBoxes.each(function(index, value) { routesToDelete.push(checkedCheckBoxes[index].id); }); + if (checkedCheckBoxes.size() === 0) { + alert('Please select at least one static route'); + return false; + } if (routesToDelete.length > 0) { requestData["routesToDelete"] = routesToDelete.toString(); var url = one.f.switchmanager.rootUrl + "/staticRoute/delete"; @@ -933,7 +941,7 @@ one.f.switchmanager.staticRouteConfig = { $("#" + one.f.switchmanager.staticRouteConfig.id.dashlet.datagrid).find(':checkbox').prop('checked', $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll).is(':checked')); }); - $(".staticRoute").click(function(){ + $(".staticRoute").click(function(e){ if (!$('.staticRoute[type=checkbox]:not(:checked)').length) { $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll) .prop("checked", @@ -943,7 +951,7 @@ one.f.switchmanager.staticRouteConfig = { .prop("checked", false); } - event.stopPropagation(); + e.stopPropagation(); }); }); }); @@ -1124,7 +1132,7 @@ one.f.switchmanager.spanPortConfig = { $dashlet.append($button); // Delete span port button - var button = one.lib.dashlet.button.single("Delete SPAN Port(s)", one.f.switchmanager.spanPortConfig.id.dashlet.remove, "btn-primary", "btn-mini"); + var button = one.lib.dashlet.button.single("Delete SPAN Port(s)", one.f.switchmanager.spanPortConfig.id.dashlet.remove, "btn-danger", "btn-mini"); var $button = one.lib.dashlet.button.button(button); $button.click(function() { @@ -1134,6 +1142,10 @@ one.f.switchmanager.spanPortConfig = { checkedCheckBoxes.each(function(index, value) { spanPortsToDelete += decodeURIComponent(checkedCheckBoxes[index].getAttribute("spanPort")) + "###"; }); + if (checkedCheckBoxes.size() === 0) { + alert('Please select at least one SPAN port'); + return false; + } var requestData = {}; requestData["spanPortsToDelete"] = spanPortsToDelete; @@ -1165,7 +1177,7 @@ one.f.switchmanager.spanPortConfig = { $("#" + one.f.switchmanager.spanPortConfig.id.dashlet.datagrid).find(':checkbox').prop('checked', $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll).is(':checked')); }); - $(".spanPortConfig").click(function(){ + $(".spanPortConfig").click(function(e){ if (!$('.spanPortConfig[type=checkbox]:not(:checked)').length) { $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll) .prop("checked", @@ -1175,7 +1187,7 @@ one.f.switchmanager.spanPortConfig = { .prop("checked", false); } - event.stopPropagation(); + e.stopPropagation(); }); }); }); diff --git a/opendaylight/web/flows/src/main/resources/js/page.js b/opendaylight/web/flows/src/main/resources/js/page.js index 3dcf9e3006..b8eb29aaa7 100644 --- a/opendaylight/web/flows/src/main/resources/js/page.js +++ b/opendaylight/web/flows/src/main/resources/js/page.js @@ -330,11 +330,15 @@ one.f.flows = { $modal.modal(); }); $dashlet.append($button); - var button = one.lib.dashlet.button.single("Remove Flow Entry", one.f.flows.id.dashlet.removeMultiple, "btn-primary", "btn-mini"); + var button = one.lib.dashlet.button.single("Remove Flow Entry", one.f.flows.id.dashlet.removeMultiple, "btn-danger", "btn-mini"); var $button = one.lib.dashlet.button.button(button); $button.click(function() { var checkedCheckBoxes = $('.flowEntry[type=checkbox]:checked'); + if (checkedCheckBoxes.size() === 0) { + alert('Please select at least one flow'); + return false; + } var requestData = []; @@ -400,7 +404,7 @@ one.f.flows = { var node = $td.find("span").data("nodeid"); one.f.flows.detail(id, node); }); - $(".flowEntry").click(function(){ + $(".flowEntry").click(function(e){ if (!$('.flowEntry[type=checkbox]:not(:checked)').length) { $("#"+one.f.flows.id.dashlet.datagrid.selectAllFlows) .prop("checked", @@ -410,7 +414,7 @@ one.f.flows = { .prop("checked", false); } - event.stopPropagation(); + e.stopPropagation(); }); }); }); diff --git a/opendaylight/web/root/src/main/resources/WEB-INF/jsp/login.jsp b/opendaylight/web/root/src/main/resources/WEB-INF/jsp/login.jsp index b9d32b1d3d..e2d1dd37e0 100644 --- a/opendaylight/web/root/src/main/resources/WEB-INF/jsp/login.jsp +++ b/opendaylight/web/root/src/main/resources/WEB-INF/jsp/login.jsp @@ -13,7 +13,7 @@ - + <% String filePath = "/WEB-INF/jsp/customlogin.jsp"; URL fileURL = pageContext.getServletContext().getResource(filePath); -- 2.36.6