From 9150dd5e735a1b93ff09e02da58e21300b3e2d54 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 29 Jul 2023 13:41:12 +0530 Subject: [PATCH] zone.js: added resync menu for zone list items. --- DnsServerCore/www/js/zone.js | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index 49a8c831..bdf0498a 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -377,6 +377,19 @@ function refreshZones(checkDisplay, pageNumber) { var isReadOnlyZone = zones[i].internal; + var showResyncMenu; + + switch (zones[i].type) { + case "Secondary": + case "Stub": + showResyncMenu = true; + break; + + default: + showResyncMenu = false; + break; + } + var hideOptionsMenu; switch (zones[i].type) { @@ -410,6 +423,10 @@ function refreshZones(checkDisplay, pageNumber) { tableHtmlRows += "
  • Disable
  • "; } + if (showResyncMenu) { + tableHtmlRows += "
  • Resync
  • "; + } + if (!hideOptionsMenu) { tableHtmlRows += "
  • Zone Options
  • "; } @@ -1176,6 +1193,45 @@ function saveZonePermissions(objBtn) { }); } +function resyncZoneMenu(objMenuItem) { + var mnuItem = $(objMenuItem); + + var id = mnuItem.attr("data-id"); + var zone = mnuItem.attr("data-zone"); + var zoneType = mnuItem.attr("data-zone-type"); + + if (zoneType == "Secondary") { + if (!confirm("The resync action will perform a full zone transfer (AXFR). You will need to check the logs to confirm if the resync action was successful.\r\n\r\nAre you sure you want to resync the '" + zone + "' zone?")) + return; + } + else { + if (!confirm("The resync action will perform a full zone refresh. You will need to check the logs to confirm if the resync action was successful.\r\n\r\nAre you sure you want to resync the '" + zone + "' zone?")) + return; + } + + var btn = $("#btnZoneRowOption" + id); + var originalBtnHtml = btn.html(); + btn.prop("disabled", true); + btn.html(""); + + HTTPRequest({ + url: "/api/zones/resync?token=" + sessionData.token + "&zone=" + zone, + success: function (responseJSON) { + btn.prop("disabled", false); + btn.html(originalBtnHtml); + + showAlert("success", "Resync Triggered!", "Zone '" + zone + "' resync was triggered successfully. Please check the Logs for confirmation."); + }, + error: function () { + btn.prop("disabled", false); + btn.html(originalBtnHtml); + }, + invalidToken: function () { + showPageLogin(); + } + }); +} + function resyncZone(objBtn, zone) { if ($("#titleEditZoneType").text() == "Secondary") { if (!confirm("The resync action will perform a full zone transfer (AXFR). You will need to check the logs to confirm if the resync action was successful.\r\n\r\nAre you sure you want to resync the '" + zone + "' zone?"))