webapp: implemented UI for new features like new zone types, ANAME records, Forwarder records and option to set glue addresses.

This commit is contained in:
Shreyas Zare
2020-06-13 13:56:33 +05:30
parent 0e3ef7be3e
commit 525be58d79
2 changed files with 551 additions and 93 deletions

View File

@@ -309,17 +309,23 @@
<thead>
<tr>
<th>Zone</th>
<th>Type</th>
<th>Status</th>
<th>Expiry</th>
<th></th>
</tr>
</thead>
<tbody id="tableZonesBody">
<tr>
<td>localhost</td>
<td>Primary</td>
<td>Expired</td>
<td>Date</td>
<td>Edit Disable Delete</td>
</tr>
</tbody>
<tfoot id="tableZonesFooter">
<tr><td colspan="2"><b>Total Records: 1</b></td></tr>
<tr><td colspan="5"><b>Total Records: 1</b></td></tr>
</tfoot>
</table>
</div>
@@ -332,9 +338,12 @@
<div style="padding: 10px 0px;">
<div style="float: left;">
<h3 id="titleEditZone" style="margin: 4px 0;">example.com</h3>
<span id="titleEditZoneType" class="label label-default">Primary</span>
<span id="titleEditZoneStatus" class="label label-success">Enabled</span>
<span id="titleEditZoneExpiry" style="font-size: 10px; font-weight: bold;">Expiry: 01 Jan 2020 00:00:00</span>
</div>
<div style="float: right; padding: 2px 0px;">
<button type="button" class="btn btn-primary" onclick="showAddRecordModal();">Add Record</button>
<button id="btnEditZoneAddRecord" type="button" class="btn btn-primary" onclick="showAddRecordModal();">Add Record</button>
</div>
<div style="clear: both;"></div>
</div>
@@ -1412,9 +1421,99 @@
<div class="form-group">
<label for="txtAddZone" class="col-sm-4 control-label">Zone</label>
<div class="col-sm-7">
<input id="txtAddZone" type="text" class="form-control" placeholder="example.com">
<input id="txtAddZone" type="text" class="form-control" placeholder="example.com or 192.168.0.0/24 or 2001:db8::/64">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Type</label>
<div class="col-sm-7">
<div class="radio">
<label>
<input type="radio" name="rdAddZoneType" id="rdAddZoneTypePrimary" value="Primary" checked>
Primary Zone (default)
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneType" id="rdAddZoneTypeSecondary" value="Secondary">
Secondary Zone
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneType" id="rdAddZoneTypeStub" value="Stub">
Stub Zone
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneType" id="rdAddZoneTypeForwarder" value="Forwarder">
Conditional Forwarder Zone
</label>
</div>
</div>
</div>
<div class="form-group" id="divAddZoneMasterNameServer">
<label for="txtAddZoneMasterNameServer" class="col-sm-4 control-label">Master Name Server (Optional)</label>
<div class="col-sm-7">
<input id="txtAddZoneMasterNameServer" type="text" class="form-control" placeholder="ns1.example.com">
</div>
</div>
<div class="form-group" id="divAddZoneGlueAddresses">
<label for="txtAddZoneGlueAddresses" class="col-sm-4 control-label">Glue Addresses (Optional)</label>
<div class="col-sm-7">
<input id="txtAddZoneGlueAddresses" type="text" class="form-control" placeholder="192.168.1.1, 2001:db8::">
</div>
</div>
<div class="form-group" id="divAddZoneForwarderProtocol">
<label class="col-sm-4 control-label">Protocol</label>
<div class="col-sm-7">
<div class="radio">
<label>
<input type="radio" name="rdAddZoneForwarderProtocol" id="rdAddZoneForwarderProtocolUdp" value="Udp" checked>
DNS-over-UDP (default)
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneForwarderProtocol" value="Tcp">
DNS-over-TCP
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneForwarderProtocol" value="Tls">
DNS-over-TLS
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneForwarderProtocol" value="Https">
DNS-over-HTTPS
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddZoneForwarderProtocol" value="HttpsJson">
DNS-over-HTTPS (JSON)
</label>
</div>
</div>
</div>
<div class="form-group" id="divAddZoneForwarder">
<label for="txtAddZoneForwarder" class="col-sm-4 control-label">Forwarder</label>
<div class="col-sm-7">
<input id="txtAddZoneForwarder" type="text" class="form-control" placeholder="8.8.8.8">
</div>
</div>
</div>
<div class="modal-footer">
<button id="btnAddZone" type="submit" class="btn btn-primary" data-loading-text="Adding..." onclick="addZone(); return false;">Add</button>
@@ -1457,6 +1556,8 @@
<option>AAAA</option>
<option>SRV</option>
<option>CAA</option>
<option>ANAME</option>
<option id="optEditRecordTypeFwd">FWD</option>
</select>
</div>
</div>
@@ -1476,8 +1577,35 @@
<input id="txtAddEditRecordDataValue" type="text" class="form-control">
</div>
</div>
<div id="divAddEditRecordDataPtr" class="form-group">
<div class="col-sm-offset-4 col-sm-7">
<div class="checkbox">
<label>
<input id="chkAddEditRecordDataPtr" type="checkbox"> <span id="chkAddEditRecordDataPtrLabel">Add reverse (PTR) record</span>
</label>
</div>
</div>
</div>
</div>
<div id="divAddEditRecordDataNs" style="display: none;">
<div class="form-group">
<label for="txtAddEditRecordDataNsNameServer" class="col-sm-4 control-label">Name Server</label>
<div class="col-sm-7">
<input id="txtAddEditRecordDataNsNameServer" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="txtAddEditRecordDataNsGlue" class="col-sm-4 control-label">Glue Addresses</label>
<div class="col-sm-7">
<input id="txtAddEditRecordDataNsGlue" type="text" class="form-control">
</div>
</div>
</div>
<div id="divEditRecordDataSoa" style="display: none;">
<div class="form-group">
<label for="txtEditRecordDataSoaMasterNameServer" class="col-sm-4 control-label">Master Name Server</label>
@@ -1521,6 +1649,12 @@
<input id="txtEditRecordDataSoaMinimum" type="number" class="form-control" style="width: 100px;">
</div>
</div>
<div class="form-group">
<label for="txtEditRecordDataSoaGlue" class="col-sm-4 control-label">Glue Addresses</label>
<div class="col-sm-7">
<input id="txtEditRecordDataSoaGlue" type="text" class="form-control">
</div>
</div>
</div>
@@ -1589,6 +1723,51 @@
</div>
</div>
<div id="divAddEditRecordDataForwarder" style="display: none;">
<div class="form-group">
<label class="col-sm-4 control-label">Protocol</label>
<div class="col-sm-7">
<div class="radio">
<label>
<input type="radio" name="rdAddEditRecordDataForwarderProtocol" id="rdAddEditRecordDataForwarderProtocolUdp" value="Udp" checked>
DNS-over-UDP (default)
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddEditRecordDataForwarderProtocol" id="rdAddEditRecordDataForwarderProtocolTcp" value="Tcp">
DNS-over-TCP
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddEditRecordDataForwarderProtocol" id="rdAddEditRecordDataForwarderProtocolTls" value="Tls">
DNS-over-TLS
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddEditRecordDataForwarderProtocol" id="rdAddEditRecordDataForwarderProtocolHttps" value="Https">
DNS-over-HTTPS
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdAddEditRecordDataForwarderProtocol" id="rdAddEditRecordDataForwarderProtocolHttpsJson" value="HttpsJson">
DNS-over-HTTPS (JSON)
</label>
</div>
</div>
</div>
<div class="form-group">
<label for="txtAddEditRecordDataForwarder" class="col-sm-4 control-label">Forwarder</label>
<div class="col-sm-7">
<input id="txtAddEditRecordDataForwarder" type="text" class="form-control" placeholder="8.8.8.8">
</div>
</div>
</div>
</div>
<div class="modal-footer">

View File

@@ -1,6 +1,6 @@
/*
Technitium DNS Server
Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
Copyright (C) 2020 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,6 +17,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$(function () {
$("input[type=radio][name=rdAddZoneType]").change(function () {
var zoneType = $('input[name=rdAddZoneType]:checked').val();
switch (zoneType) {
case "Primary":
$("#divAddZoneMasterNameServer").hide();
$("#divAddZoneGlueAddresses").hide();
$("#divAddZoneForwarderProtocol").hide();
$("#divAddZoneForwarder").hide();
break;
case "Secondary":
case "Stub":
$("#divAddZoneMasterNameServer").show();
$("#divAddZoneGlueAddresses").show();
$("#divAddZoneForwarderProtocol").hide();
$("#divAddZoneForwarder").hide();
break;
case "Forwarder":
$("#divAddZoneMasterNameServer").hide();
$("#divAddZoneGlueAddresses").hide();
$("#divAddZoneForwarderProtocol").show();
$("#divAddZoneForwarder").show();
break;
}
});
});
function refreshZones(checkDisplay) {
if (checkDisplay == null)
checkDisplay = false;
@@ -41,24 +72,47 @@ function refreshZones(checkDisplay) {
for (var i = 0; i < zones.length; i++) {
var id = Math.floor(Math.random() * 10000);
var zoneName = zones[i].zoneName;
var name = zones[i].name;
if (zoneName === "")
zoneName = ".";
if (name === "")
name = ".";
tableHtmlRows += "<tr id=\"trZone" + id + "\"><td>" + htmlEncode(zoneName) + "</td>";
tableHtmlRows += "<td align=\"right\"><button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" onclick=\"showEditZone('" + zoneName + "');\">Edit</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnEnableZone" + id + "\" class=\"btn btn-default\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (zones[i].disabled ? "" : " display: none;") + "\" onclick=\"enableZone(this, '" + zoneName + "');\" data-loading-text=\"Enabling...\">Enable</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnDisableZone" + id + "\" class=\"btn btn-warning\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (!zones[i].disabled ? "" : " display: none;") + "\" onclick=\"disableZone(this, '" + zoneName + "');\" data-loading-text=\"Disabling...\">Disable</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" onclick=\"deleteZone(this, '" + zoneName + "');\" data-loading-text=\"Deleting...\">Delete</button></td></tr>";
var type;
if (zones[i].internal)
type = "Internal";
else
type = zones[i].type;
var status;
if (zones[i].disabled)
status = "<span id=\"tdStatus" + id + "\" class=\"label label-warning\">Disabled</span>";
else if (zones[i].isExpired)
status = "<span id=\"tdStatus" + id + "\" class=\"label label-danger\">Expired</span>";
else
status = "<span id=\"tdStatus" + id + "\" class=\"label label-success\">Enabled</span>";
var expiry = zones[i].expiry;
if (expiry == null)
expiry = "&nbsp;";
var isReadOnlyZone = zones[i].internal || (zones[i].type === "Secondary");
tableHtmlRows += "<tr id=\"trZone" + id + "\"><td>" + htmlEncode(name) + "</td>";
tableHtmlRows += "<td><span class=\"label label-default\">" + type + "</span></td>";
tableHtmlRows += "<td>" + status + "</td>";
tableHtmlRows += "<td>" + expiry + "</td>";
tableHtmlRows += "<td align=\"right\"><button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" onclick=\"showEditZone('" + name + "');\">" + (isReadOnlyZone ? "View" : "Edit") + "</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnEnableZone" + id + "\" class=\"btn btn-default\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (zones[i].disabled ? "" : " display: none;") + "\" onclick=\"enableZone(this, '" + name + "');\" data-loading-text=\"Enabling...\"" + (zones[i].internal ? " disabled" : "") + ">Enable</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnDisableZone" + id + "\" class=\"btn btn-warning\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (!zones[i].disabled ? "" : " display: none;") + "\" onclick=\"disableZone(this, '" + name + "');\" data-loading-text=\"Disabling...\"" + (zones[i].internal ? " disabled" : "") + ">Disable</button>";
tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" onclick=\"deleteZone(this, '" + name + "');\" data-loading-text=\"Deleting...\"" + (zones[i].internal ? " disabled" : "") + ">Delete</button></td></tr>";
}
$("#tableZonesBody").html(tableHtmlRows);
if (zones.length > 0)
$("#tableZonesFooter").html("<tr><td colspan=\"2\"><b>Total Zones: " + zones.length + "</b></td></tr>");
$("#tableZonesFooter").html("<tr><td colspan=\"5\"><b>Total Zones: " + zones.length + "</b></td></tr>");
else
$("#tableZonesFooter").html("<tr><td colspan=\"2\" align=\"center\">No Zones Found</td></tr>");
$("#tableZonesFooter").html("<tr><td colspan=\"5\" align=\"center\">No Zones Found</td></tr>");
divViewZonesLoader.hide();
divViewZones.show();
@@ -87,6 +141,8 @@ function enableZone(objBtn, domain) {
$("#btnEnableZone" + id).hide();
$("#btnDisableZone" + id).show();
$("#tdStatus" + id).attr("class", "label label-success");
$("#tdStatus" + id).html("Enabled");
showAlert("success", "Zone Enabled!", "Zone was enabled successfully.");
},
@@ -115,6 +171,8 @@ function disableZone(objBtn, domain) {
$("#btnEnableZone" + id).show();
$("#btnDisableZone" + id).hide();
$("#tdStatus" + id).attr("class", "label label-warning");
$("#tdStatus" + id).html("Disabled");
showAlert("success", "Zone Disabled!", "Zone was disabled successfully.");
},
@@ -144,9 +202,9 @@ function deleteZone(objBtn, domain) {
var totalZones = $('#tableZones >tbody >tr').length;
if (totalZones > 0)
$("#tableZonesFooter").html("<tr><td colspan=\"2\"><b>Total Zones: " + totalZones + "</b></td></tr>");
$("#tableZonesFooter").html("<tr><td colspan=\"5\"><b>Total Zones: " + totalZones + "</b></td></tr>");
else
$("#tableZonesFooter").html("<tr><td colspan=\"2\" align=\"center\">No Zones Found</td></tr>");
$("#tableZonesFooter").html("<tr><td colspan=\"5\" align=\"center\">No Zones Found</td></tr>");
showAlert("success", "Zone Deleted!", "Zone was deleted successfully.");
},
@@ -163,6 +221,17 @@ function showAddZoneModal() {
$("#divAddZoneAlert").html("");
$("#txtAddZone").val("");
$("#rdAddZoneTypePrimary").prop("checked", true);
$("#txtAddZoneMasterNameServer").val("");
$("#txtAddZoneGlueAddresses").val("");
$("#rdAddZoneForwarderProtocolUdp").prop("checked", true);
$("#txtAddZoneForwarder").val("");
$("#divAddZoneMasterNameServer").hide();
$("#divAddZoneGlueAddresses").hide();
$("#divAddZoneForwarderProtocol").hide();
$("#divAddZoneForwarder").hide();
$("#btnAddZone").button('reset');
$("#modalAddZone").modal("show");
@@ -178,13 +247,40 @@ function addZone() {
return;
}
var type = $('input[name=rdAddZoneType]:checked').val();
var parameters;
switch (type) {
case "Secondary":
case "Stub":
parameters = "&masterNameServer=" + $("#txtAddZoneMasterNameServer").val() + "&glueAddresses=" + $("#txtAddZoneGlueAddresses").val();
break;
case "Forwarder":
var forwarder = $("#txtAddZoneForwarder").val();
if ((forwarder === null) || (forwarder === "")) {
showAlert("warning", "Missing!", "Please enter a forwarder server name to add zone.", divAddZoneAlert);
$("#divAddZoneForwarder").focus();
return;
}
parameters = "&protocol=" + $('input[name=rdAddZoneForwarderProtocol]:checked').val() + "&forwarder=" + forwarder;
break;
default:
parameters = "";
break;
}
var btn = $("#btnAddZone").button('loading');
HTTPRequest({
url: "/api/createZone?token=" + token + "&domain=" + domain,
url: "/api/createZone?token=" + token + "&domain=" + domain + "&type=" + type + parameters,
success: function (responseJSON) {
$("#modalAddZone").modal("hide");
showEditZone(domain);
showEditZone(responseJSON.response.domain);
showAlert("success", "Zone Added!", "Zone was added successfully.");
},
@@ -210,6 +306,65 @@ function showEditZone(domain) {
HTTPRequest({
url: "/api/getRecords?token=" + token + "&domain=" + domain,
success: function (responseJSON) {
var type;
if (responseJSON.response.zone.internal)
type = "Internal";
else
type = responseJSON.response.zone.type;
var status;
if (responseJSON.response.zone.disabled)
status = "Disabled";
else if (responseJSON.response.zone.isExpired)
status = "Expired";
else
status = "Enabled";
var expiry = responseJSON.response.zone.expiry;
if (expiry == null)
expiry = "&nbsp;";
else
expiry = "Expiry: " + expiry;
$("#titleEditZoneType").html(type);
$("#titleEditZoneStatus").html(status);
$("#titleEditZoneExpiry").html(expiry);
switch (status) {
case "Disabled":
$("#titleEditZoneStatus").attr("class", "label label-warning");
break;
case "Expired":
$("#titleEditZoneStatus").attr("class", "label label-danger");
break;
case "Enabled":
$("#titleEditZoneStatus").attr("class", "label label-success");
break;
}
var hideActionButtons = false;
switch (type) {
case "Internal":
case "Secondary":
$("#btnEditZoneAddRecord").hide();
$("#optEditRecordTypeFwd").hide();
hideActionButtons = true;
break;
case "Forwarder":
$("#btnEditZoneAddRecord").show();
$("#optEditRecordTypeFwd").show();
break;
default:
$("#btnEditZoneAddRecord").show();
$("#optEditRecordTypeFwd").hide();
break;
}
var records = responseJSON.response.records;
var tableHtmlRows = "";
@@ -233,14 +388,28 @@ function showEditZone(domain) {
switch (records[i].type.toUpperCase()) {
case "A":
case "NS":
case "CNAME":
case "PTR":
case "TXT":
case "AAAA":
case "ANAME":
tableHtmlRows += "<td style=\"overflow-wrap: anywhere;\">" + htmlEncode(records[i].rData.value) + "</td>";
break;
case "NS":
tableHtmlRows += "<td style=\"overflow-wrap: anywhere;\"><b>Name Server:</b> " + htmlEncode(records[i].rData.value);
if (records[i].rData.glue != null) {
tableHtmlRows += "<br /><b>Glue Addresses:</b> " + records[i].rData.glue;
additionalDataAttributes = "data-record-glue=\"" + htmlEncode(records[i].rData.glue) + "\" ";
} else {
additionalDataAttributes = "data-record-glue=\"\" ";
}
tableHtmlRows += "</td>";
break;
case "SOA":
tableHtmlRows += "<td style=\"overflow-wrap: anywhere;\"><b>Master Name Server:</b> " + htmlEncode(records[i].rData.masterNameServer) +
"<br /><b>Responsible Person:</b> " + htmlEncode(records[i].rData.responsiblePerson) +
@@ -248,9 +417,19 @@ function showEditZone(domain) {
"<br /><b>Refresh:</b> " + htmlEncode(records[i].rData.refresh) +
"<br /><b>Retry:</b> " + htmlEncode(records[i].rData.retry) +
"<br /><b>Expire:</b> " + htmlEncode(records[i].rData.expire) +
"<br /><b>Minimum:</b> " + htmlEncode(records[i].rData.minimum) + "</td>";
"<br /><b>Minimum:</b> " + htmlEncode(records[i].rData.minimum);
additionalDataAttributes = "data-record-mname=\"" + htmlEncode(records[i].rData.masterNameServer) + "\" " +
if (records[i].rData.glue != null) {
tableHtmlRows += "<br /><b>Glue Addresses:</b> " + records[i].rData.glue;
additionalDataAttributes = "data-record-glue=\"" + htmlEncode(records[i].rData.glue) + "\" ";
} else {
additionalDataAttributes = "data-record-glue=\"\" ";
}
tableHtmlRows += "</td>";
additionalDataAttributes += "data-record-mname=\"" + htmlEncode(records[i].rData.masterNameServer) + "\" " +
"data-record-rperson=\"" + htmlEncode(records[i].rData.responsiblePerson) + "\" " +
"data-record-serial=\"" + htmlEncode(records[i].rData.serial) + "\" " +
"data-record-refresh=\"" + htmlEncode(records[i].rData.refresh) + "\" " +
@@ -286,17 +465,31 @@ function showEditZone(domain) {
"data-record-tag=\"" + htmlEncode(records[i].rData.tag) + "\" ";
break;
case "FWD":
tableHtmlRows += "<td style=\"overflow-wrap: anywhere;\"><b>Protocol: </b> " + htmlEncode(records[i].rData.protocol) +
"<br /><b>Forwarder:</b> " + htmlEncode(records[i].rData.value) + "</td>";
additionalDataAttributes = "data-record-protocol=\"" + htmlEncode(records[i].rData.protocol) + "\" ";
break;
default:
tableHtmlRows += "<td style=\"overflow-wrap: anywhere;\"><b>RDATA:</b> " + htmlEncode(records[i].rData.value) + "</td>";
break;
}
tableHtmlRows += "<td align=\"right\">";
tableHtmlRows += "<div id=\"data" + id + "\" data-record-name=\"" + htmlEncode(records[i].name) + "\" data-record-type=\"" + records[i].type + "\" data-record-ttl=\"" + records[i].ttl + "\" data-record-value=\"" + htmlEncode(records[i].rData.value) + "\" " + additionalDataAttributes + " data-record-disabled=\"" + records[i].disabled + "\" style=\"display: none;\"></div>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" data-id=\"" + id + "\" onclick=\"showEditRecordModal(this);\">Edit</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-default\" id=\"btnEnableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, false);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + " data-loading-text=\"Enabling...\">Enable</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-warning\" id=\"btnDisableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (!records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, true);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + " data-loading-text=\"Disabling...\">Disable</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" data-loading-text=\"Deleting...\" data-id=\"" + id + "\" onclick=\"deleteRecord(this);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + ">Delete</button></td></tr>";
if (hideActionButtons) {
tableHtmlRows += "<td align=\"right\">&nbsp;</td>";
}
else {
tableHtmlRows += "<td align=\"right\">";
tableHtmlRows += "<div id=\"data" + id + "\" data-record-name=\"" + htmlEncode(records[i].name) + "\" data-record-type=\"" + records[i].type + "\" data-record-ttl=\"" + records[i].ttl + "\" data-record-value=\"" + htmlEncode(records[i].rData.value) + "\" " + additionalDataAttributes + " data-record-disabled=\"" + records[i].disabled + "\" style=\"display: none;\"></div>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" data-id=\"" + id + "\" onclick=\"showEditRecordModal(this);\">Edit</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-default\" id=\"btnEnableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, false);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + " data-loading-text=\"Enabling...\">Enable</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-warning\" id=\"btnDisableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;" + (!records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, true);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + " data-loading-text=\"Disabling...\">Disable</button>";
tableHtmlRows += "<button type=\"button\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 6px 0;\" data-loading-text=\"Deleting...\" data-id=\"" + id + "\" onclick=\"deleteRecord(this);\"" + (records[i].type.toUpperCase() === "SOA" ? " disabled" : "") + ">Delete</button></td>";
}
tableHtmlRows += "</tr>";
}
$("#titleEditZone").text(domain);
@@ -334,6 +527,13 @@ function clearAddEditForm() {
$("#divAddEditRecordData").show();
$("#lblAddEditRecordDataValue").text("IPv4 Address");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordDataPtr").show();
$("#chkAddEditRecordDataPtr").prop("checked", false);
$("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
$("#divAddEditRecordDataNs").hide();
$("#txtAddEditRecordDataNsNameServer").val("");
$("#txtAddEditRecordDataNsGlue").val("");
$("#divEditRecordDataSoa").hide();
$("#txtEditRecordDataSoaMasterNameServer").val("");
@@ -359,6 +559,11 @@ function clearAddEditForm() {
$("#txtAddEditRecordDataCaaTag").val("");
$("#txtAddEditRecordDataCaaValue").val("");
$("#divAddEditRecordDataForwarder").hide();
$("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true);
$("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr('disabled', false);
$("#txtAddEditRecordDataForwarder").val("");
$("#btnAddEditRecord").button("reset");
}
@@ -379,25 +584,38 @@ function modifyAddRecordForm() {
var type = $("#optAddEditRecordType").val();
$("#divAddEditRecordData").hide();
$("#divAddEditRecordDataPtr").hide();
$("#divAddEditRecordDataNs").hide();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
$("#divAddEditRecordDataForwarder").hide();
switch (type) {
case "A":
$("#lblAddEditRecordDataValue").text("IPv4 Address");
$("#txtAddEditRecordDataValue").val("");
$("#chkAddEditRecordDataPtr").prop("checked", false);
$("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
$("#divAddEditRecordDataPtr").show();
break;
case "AAAA":
$("#lblAddEditRecordDataValue").text("IPv6 Address");
$("#txtAddEditRecordDataValue").val("");
$("#chkAddEditRecordDataPtr").prop("checked", false);
$("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
$("#divAddEditRecordData").show();
$("#divAddEditRecordDataPtr").show();
break;
case "NS":
$("#lblAddEditRecordDataValue").text("Domain Name");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
$("#txtAddEditRecordDataNsNameServer").val("");
$("#txtAddEditRecordDataNsGlue").val("");
$("#divAddEditRecordDataNs").show();
break;
case "SOA":
@@ -408,61 +626,28 @@ function modifyAddRecordForm() {
$("#txtEditRecordDataSoaRetry").val("");
$("#txtEditRecordDataSoaExpire").val("");
$("#txtEditRecordDataSoaMinimum").val("");
$("#divAddEditRecordData").hide();
$("#txtEditRecordDataSoaGlue").val("");
$("#divEditRecordDataSoa").show();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "CNAME":
$("#lblAddEditRecordDataValue").text("Domain Name");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "PTR":
case "CNAME":
case "ANAME":
$("#lblAddEditRecordDataValue").text("Domain Name");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "MX":
$("#txtAddEditRecordDataMxPreference").val("");
$("#txtAddEditRecordDataMxExchange").val("");
$("#divAddEditRecordData").hide();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").show();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "TXT":
$("#lblAddEditRecordDataValue").text("Text Data");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "AAAA":
$("#lblAddEditRecordDataValue").text("IPv6 Address");
$("#txtAddEditRecordDataValue").val("");
$("#divAddEditRecordData").show();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").hide();
break;
case "SRV":
@@ -471,23 +656,21 @@ function modifyAddRecordForm() {
$("#txtAddEditRecordDataSrvWeight").val("");
$("#txtAddEditRecordDataSrvPort").val("");
$("#txtAddEditRecordDataSrvTarget").val("");
$("#divAddEditRecordData").hide();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").show();
$("#divAddEditRecordDataCaa").hide();
break;
case "CAA":
$("#txtAddEditRecordDataCaaFlags").val("");
$("#txtAddEditRecordDataCaaTag").val("");
$("#txtAddEditRecordDataCaaValue").val("");
$("#divAddEditRecordData").hide();
$("#divEditRecordDataSoa").hide();
$("#divAddEditRecordDataMx").hide();
$("#divAddEditRecordDataSrv").hide();
$("#divAddEditRecordDataCaa").show();
break;
case "FWD":
$("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true);
$("#txtAddEditRecordDataForwarder").val("");
$("#divAddEditRecordDataForwarder").show();
break;
}
}
@@ -521,10 +704,20 @@ function addRecord() {
switch (type) {
case "A":
case "NS":
case "AAAA":
var value = $("#txtAddEditRecordDataValue").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter an IP address to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataValue").focus();
return;
}
apiUrl += "&value=" + encodeURIComponent(value) + "&ptr=" + $("#chkAddEditRecordDataPtr").prop('checked');
break;
case "PTR":
case "TXT":
case "AAAA":
case "ANAME":
var value = $("#txtAddEditRecordDataValue").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
@@ -545,7 +738,7 @@ function addRecord() {
var value = $("#txtAddEditRecordDataValue").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
showAlert("warning", "Missing!", "Please enter a domain name to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataValue").focus();
return;
}
@@ -553,6 +746,19 @@ function addRecord() {
apiUrl += "&value=" + encodeURIComponent(value);
break;
case "NS":
var value = $("#txtAddEditRecordDataNsNameServer").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter a name server to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataNsNameServer").focus();
return;
}
var glue = $("#txtAddEditRecordDataNsGlue").val();
apiUrl += "&value=" + encodeURIComponent(value) + "&glue=" + encodeURIComponent(glue);
break;
case "MX":
var preference = $("#txtAddEditRecordDataMxPreference").val();
if (preference === "")
@@ -560,7 +766,7 @@ function addRecord() {
var value = $("#txtAddEditRecordDataMxExchange").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter an mail exchange domain name into the exchange field.", divAddEditRecordAlert);
showAlert("warning", "Missing!", "Please enter a mail exchange domain name to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataMxExchange").focus();
return;
}
@@ -624,6 +830,17 @@ function addRecord() {
apiUrl += "&flags=" + flags + "&tag=" + encodeURIComponent(tag) + "&value=" + encodeURIComponent(value);
break;
case "FWD":
var value = $("#txtAddEditRecordDataForwarder").val();
if (value === "") {
showAlert("warning", "Missing!", "Please enter a domain name or IP address or URL as a forwarder to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataForwarder").focus();
return;
}
apiUrl += "&protocol=" + $('input[name=rdAddEditRecordDataForwarderProtocol]:checked').val() + "&value=" + value;
break;
}
btn.button("loading");
@@ -671,14 +888,24 @@ function showEditRecordModal(objBtn) {
switch (type) {
case "A":
case "NS":
case "AAAA":
$("#txtAddEditRecordDataValue").val(divData.attr("data-record-value"));
$("#chkAddEditRecordDataPtr").prop("checked", false);
$("#chkAddEditRecordDataPtrLabel").text("Update reverse (PTR) record");
break;
case "CNAME":
case "PTR":
case "TXT":
case "AAAA":
case "ANAME":
$("#txtAddEditRecordDataValue").val(divData.attr("data-record-value"));
break;
case "NS":
$("#txtAddEditRecordDataNsNameServer").val(divData.attr("data-record-value"));
$("#txtAddEditRecordDataNsGlue").val(divData.attr("data-record-glue"));
break;
case "SOA":
$("#txtEditRecordDataSoaMasterNameServer").val(divData.attr("data-record-mname"));
$("#txtEditRecordDataSoaResponsiblePerson").val(divData.attr("data-record-rperson"));
@@ -687,6 +914,7 @@ function showEditRecordModal(objBtn) {
$("#txtEditRecordDataSoaRetry").val(divData.attr("data-record-retry"));
$("#txtEditRecordDataSoaExpire").val(divData.attr("data-record-expire"));
$("#txtEditRecordDataSoaMinimum").val(divData.attr("data-record-minimum"));
$("#txtEditRecordDataSoaGlue").val(divData.attr("data-record-glue"));
break;
case "MX":
@@ -707,6 +935,12 @@ function showEditRecordModal(objBtn) {
$("#txtAddEditRecordDataCaaValue").val(divData.attr("data-record-value"));
break;
case "FWD":
$("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr('disabled', true);
$("#rdAddEditRecordDataForwarderProtocol" + divData.attr("data-record-protocol")).prop("checked", true);
$("#txtAddEditRecordDataForwarder").val(divData.attr("data-record-value"));
break;
default:
showAlert("warning", "Not Supported!", "Record type not supported for edit.");
return;
@@ -760,10 +994,20 @@ function updateRecord() {
switch (type) {
case "A":
case "NS":
case "AAAA":
var newValue = $("#txtAddEditRecordDataValue").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter an IP address to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataValue").focus();
return;
}
apiUrl += "&newValue=" + encodeURIComponent(newValue) + "&ptr=" + $("#chkAddEditRecordDataPtr").prop('checked');
break;
case "PTR":
case "TXT":
case "AAAA":
case "ANAME":
var newValue = $("#txtAddEditRecordDataValue").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
@@ -784,7 +1028,7 @@ function updateRecord() {
var newValue = $("#txtAddEditRecordDataValue").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
showAlert("warning", "Missing!", "Please enter a domain name to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataValue").focus();
return;
}
@@ -792,6 +1036,19 @@ function updateRecord() {
apiUrl += "&newValue=" + encodeURIComponent(newValue);
break;
case "NS":
var newValue = $("#txtAddEditRecordDataNsNameServer").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter a name server to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataNsNameServer").focus();
return;
}
var glue = $("#txtAddEditRecordDataNsGlue").val();
apiUrl += "&newValue=" + encodeURIComponent(newValue) + "&glue=" + encodeURIComponent(glue);
break;
case "SOA":
var masterNameServer = $("#txtEditRecordDataSoaMasterNameServer").val();
if (masterNameServer === "") {
@@ -842,13 +1099,16 @@ function updateRecord() {
return;
}
var glue = $("#txtEditRecordDataSoaGlue").val();
apiUrl += "&masterNameServer=" + encodeURIComponent(masterNameServer) +
"&responsiblePerson=" + encodeURIComponent(responsiblePerson) +
"&serial=" + encodeURIComponent(serial) +
"&refresh=" + encodeURIComponent(refresh) +
"&retry=" + encodeURIComponent(retry) +
"&expire=" + encodeURIComponent(expire) +
"&minimum=" + encodeURIComponent(minimum);
"&minimum=" + encodeURIComponent(minimum) +
"&glue=" + encodeURIComponent(glue);
break;
case "MX":
@@ -858,7 +1118,7 @@ function updateRecord() {
var newValue = $("#txtAddEditRecordDataMxExchange").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter an mail exchange domain name into the exchange field.", divAddEditRecordAlert);
showAlert("warning", "Missing!", "Please enter a mail exchange domain name to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataMxExchange").focus();
return;
}
@@ -927,6 +1187,17 @@ function updateRecord() {
apiUrl += "&flags=" + flags + "&tag=" + encodeURIComponent(tag) + "&newFlags=" + newFlags + "&newTag=" + encodeURIComponent(newTag) + "&newValue=" + encodeURIComponent(newValue);
break;
case "FWD":
var newValue = $("#txtAddEditRecordDataForwarder").val();
if (newValue === "") {
showAlert("warning", "Missing!", "Please enter a domain name or IP address or URL as a forwarder to add the record.", divAddEditRecordAlert);
$("#txtAddEditRecordDataForwarder").focus();
return;
}
apiUrl += "&protocol=" + $('input[name=rdAddEditRecordDataForwarderProtocol]:checked').val() + "&newValue=" + newValue;
break;
}
btn.button('loading');
@@ -978,6 +1249,10 @@ function updateRecordState(objBtn, disable) {
case "CAA":
apiUrl += "&flags=" + divData.attr("data-record-flags") + "&tag=" + encodeURIComponent(divData.attr("data-record-tag"));
break;
case "FWD":
apiUrl += "&protocol=" + divData.attr("data-record-protocol");
break;
}
btn.button('loading');
@@ -1034,6 +1309,10 @@ function deleteRecord(objBtn) {
case "CAA":
apiUrl += "&flags=" + divData.attr("data-record-flags") + "&tag=" + encodeURIComponent(divData.attr("data-record-tag"));
break;
case "FWD":
apiUrl += "&protocol=" + divData.attr("data-record-protocol");
break;
}
btn.button('loading');