From faca53432fc21dacc4cbba078add4a38427cfca9 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 27 Mar 2021 16:49:14 +0530 Subject: [PATCH] webapp: implemented add record overwrite option. minor refactoring changes. --- DnsServerCore/www/js/zone.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index c9dc6c64..533d7cd7 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -98,7 +98,7 @@ $(function () { if (dataApps[i].name == appName) { for (var j = 0; j < dataApps[i].details.length; j++) { if (dataApps[i].details[j].classPath == classPath) { - $("#txtAddEditRecordDataData").val(dataApps[i].details[j].dataTemplate); + $("#txtAddEditRecordDataData").val(dataApps[i].details[j].recordDataTemplate); return; } } @@ -684,6 +684,7 @@ function showEditZone(domain) { function clearAddEditForm() { $("#divAddEditRecordAlert").html(""); + $("#txtAddEditRecordName").prop("placeholder", "@"); $("#txtAddEditRecordName").prop("disabled", false); $("#optAddEditRecordType").prop("disabled", false); $("#txtAddEditRecordTtl").prop("disabled", false); @@ -754,6 +755,9 @@ function clearAddEditForm() { $("#optAddEditRecordDataClassPath").attr('disabled', false); $("#txtAddEditRecordDataData").val(""); + $("#divAddEditRecordOverwrite").show(); + $("#chkAddEditRecordOverwrite").prop("checked", false); + $("#btnAddEditRecord").button("reset"); } @@ -817,7 +821,7 @@ function showAddRecordModalNow(apps) { }, 1000); } -function modifyAddRecordForm() { +function modifyAddRecordFormByType() { $("#divAddEditRecordAlert").html(""); $("#txtAddEditRecordName").prop("placeholder", "@"); @@ -958,7 +962,9 @@ function addRecord() { if (ttl === "") ttl = 3600; - var apiUrl = "/api/addRecord?token=" + token + "&domain=" + encodeURIComponent(domain) + "&type=" + type + "&ttl=" + ttl; + var overwrite = $("#chkAddEditRecordOverwrite").prop('checked'); + + var apiUrl = "/api/addRecord?token=" + token + "&domain=" + encodeURIComponent(domain) + "&type=" + type + "&ttl=" + ttl + "&overwrite=" + overwrite; switch (type) { case "A": @@ -1204,7 +1210,8 @@ function showEditRecordModal(objBtn) { $("#lblAddEditRecordZoneName").text(zone); $("#optEditRecordTypeSoa").show(); $("#optAddEditRecordType").val(type); - modifyAddRecordForm(); + $("#divAddEditRecordOverwrite").hide(); + modifyAddRecordFormByType(); $("#txtAddEditRecordName").val(name); $("#txtAddEditRecordTtl").val(ttl)