From 2d2824cc6c435adf03ea6526cbf4eb43b5049994 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 14 Jun 2020 15:45:23 +0530 Subject: [PATCH] webapp: updated UI to allow editing glue addresses for secondary and stub zones. --- DnsServerCore/www/js/zone.js | 89 ++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index 5cae17a9..0793fe70 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -353,14 +353,10 @@ function showEditZone(domain) { break; } - var hideActionButtons = false; - switch (type) { case "Internal": case "Secondary": $("#btnEditZoneAddRecord").hide(); - $("#optEditRecordTypeFwd").hide(); - hideActionButtons = true; break; case "Forwarder": @@ -502,16 +498,58 @@ function showEditZone(domain) { break; } + var hideActionButtons = false; + var disableEditRecordModalFields = false; + var disableEnableDisableDeleteButtons = false; + + switch (type) { + case "Internal": + hideActionButtons = true; + break; + + case "Secondary": + switch (records[i].type) { + case "NS": + case "SOA": + disableEditRecordModalFields = true; + disableEnableDisableDeleteButtons = true; + break; + + default: + hideActionButtons = true; + break; + } + break; + + case "Stub": + switch (records[i].type) { + case "NS": + case "SOA": + disableEditRecordModalFields = true; + disableEnableDisableDeleteButtons = true; + break; + } + break; + + default: + switch (records[i].type) { + case "SOA": + disableEnableDisableDeleteButtons = true; + break; + } + break; + } + if (hideActionButtons) { tableHtmlRows += " "; } else { tableHtmlRows += ""; - tableHtmlRows += "
"; + tableHtmlRows += "
"; tableHtmlRows += ""; - tableHtmlRows += ""; - tableHtmlRows += ""; - tableHtmlRows += ""; + tableHtmlRows += ""; + tableHtmlRows += ""; + tableHtmlRows += ""; } tableHtmlRows += ""; @@ -542,8 +580,9 @@ function showEditZone(domain) { function clearAddEditForm() { $("#divAddEditRecordAlert").html(""); - $("#optAddEditRecordType").prop("disabled", false); $("#txtAddEditRecordName").prop("disabled", false); + $("#optAddEditRecordType").prop("disabled", false); + $("#txtAddEditRecordTtl").prop("disabled", false); $("#txtAddEditRecordName").val(""); $("#optAddEditRecordType").val("A"); @@ -557,10 +596,18 @@ function clearAddEditForm() { $("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record"); $("#divAddEditRecordDataNs").hide(); + $("#txtAddEditRecordDataNsNameServer").prop("disabled", false); $("#txtAddEditRecordDataNsNameServer").val(""); $("#txtAddEditRecordDataNsGlue").val(""); $("#divEditRecordDataSoa").hide(); + $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", false); + $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", false); + $("#txtEditRecordDataSoaSerial").prop("disabled", false); + $("#txtEditRecordDataSoaRefresh").prop("disabled", false); + $("#txtEditRecordDataSoaRetry").prop("disabled", false); + $("#txtEditRecordDataSoaExpire").prop("disabled", false); + $("#txtEditRecordDataSoaMinimum").prop("disabled", false); $("#txtEditRecordDataSoaPrimaryNameServer").val(""); $("#txtEditRecordDataSoaResponsiblePerson").val(""); $("#txtEditRecordDataSoaSerial").val(""); @@ -911,6 +958,8 @@ function showEditRecordModal(objBtn) { $("#txtAddEditRecordName").val(name); $("#txtAddEditRecordTtl").val(ttl) + var disableEditRecordModalFields = divData.attr("data-record-disable-modal-fields") === "true"; + switch (type) { case "A": case "AAAA": @@ -929,6 +978,13 @@ function showEditRecordModal(objBtn) { case "NS": $("#txtAddEditRecordDataNsNameServer").val(divData.attr("data-record-value")); $("#txtAddEditRecordDataNsGlue").val(divData.attr("data-record-glue")); + + if (disableEditRecordModalFields) { + $("#txtAddEditRecordName").prop("disabled", true); + $("#txtAddEditRecordTtl").prop("disabled", true); + + $("#txtAddEditRecordDataNsNameServer").prop("disabled", true); + } break; case "SOA": @@ -940,6 +996,20 @@ function showEditRecordModal(objBtn) { $("#txtEditRecordDataSoaExpire").val(divData.attr("data-record-expire")); $("#txtEditRecordDataSoaMinimum").val(divData.attr("data-record-minimum")); $("#txtEditRecordDataSoaGlue").val(divData.attr("data-record-glue")); + + $("#txtAddEditRecordName").prop("disabled", true); + + if (disableEditRecordModalFields) { + $("#txtAddEditRecordTtl").prop("disabled", true); + + $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", true); + $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", true); + $("#txtEditRecordDataSoaSerial").prop("disabled", true); + $("#txtEditRecordDataSoaRefresh").prop("disabled", true); + $("#txtEditRecordDataSoaRetry").prop("disabled", true); + $("#txtEditRecordDataSoaExpire").prop("disabled", true); + $("#txtEditRecordDataSoaMinimum").prop("disabled", true); + } break; case "MX": @@ -971,7 +1041,6 @@ function showEditRecordModal(objBtn) { return; } - $("#txtAddEditRecordName").prop("disabled", (type === "SOA")); $("#optAddEditRecordType").prop("disabled", true); $("#btnAddEditRecord").attr("data-id", id);