diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index c2f68f96..67b2b27e 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -448,6 +448,13 @@ function refreshZones(checkDisplay, pageNumber) { tableHtmlRows += "
  • Permissions
  • "; } + switch (zones[i].type) { + case "Primary": + case "Forwarder": + tableHtmlRows += "
  • Clone Zone
  • "; + break; + } + if (!zones[i].internal) { tableHtmlRows += "
  • "; tableHtmlRows += "
  • Delete Zone
  • "; @@ -707,6 +714,57 @@ function deleteZone(objBtn) { }); } +function showCloneZoneModal(sourceZone) { + $("#lblCloneZoneZoneName").text(sourceZone === "." ? "" : sourceZone); + + $("#divCloneZoneAlert").html(""); + $("#txtCloneZoneSourceZoneName").val(sourceZone); + $("#txtCloneZoneZoneName").val(""); + + $("#modalCloneZone").modal("show"); + + setTimeout(function () { + $("#txtCloneZoneZoneName").focus(); + }, 1000); +} + +function cloneZone(objBtn) { + var divCloneZoneAlert = $("#divCloneZoneAlert"); + + var sourceZone = $("#txtCloneZoneSourceZoneName").val(); + + var zone = $("#txtCloneZoneZoneName").val(); + if ((zone == null) || (zone === "")) { + showAlert("warning", "Missing!", "Please enter a domain name for the new zone.", divCloneZoneAlert); + $("#txtCloneZoneZoneName").focus(); + return; + } + + var btn = $(objBtn); + btn.button("loading"); + + HTTPRequest({ + url: "/api/zones/clone?token=" + sessionData.token + "&zone=" + zone + "&sourceZone=" + sourceZone, + success: function (responseJSON) { + btn.button("reset"); + $("#modalCloneZone").modal("hide"); + + refreshZones(); + + showAlert("success", "Zone Cloned!", "Zone was cloned from successfully."); + }, + error: function () { + btn.button("reset"); + }, + invalidToken: function () { + btn.button("reset"); + $("#modalCloneZone").modal("hide"); + showPageLogin(); + }, + objAlertPlaceholder: divCloneZoneAlert + }); +} + function showConvertZoneModal(zone, type) { var lblConvertZoneZoneName = $("#lblConvertZoneZoneName");