diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js
index ee819daf..08508332 100644
--- a/DnsServerCore/www/js/zone.js
+++ b/DnsServerCore/www/js/zone.js
@@ -812,7 +812,7 @@ function toggleHideDnssecRecords(hideDnssecRecords) {
showEditZone($("#titleEditZone").text());
}
-function showEditZone(domain) {
+function showEditZone(zone) {
var divViewZonesLoader = $("#divViewZonesLoader");
var divViewZones = $("#divViewZones");
var divEditZone = $("#divEditZone");
@@ -822,22 +822,22 @@ function showEditZone(domain) {
divViewZonesLoader.show();
HTTPRequest({
- url: "/api/zone/getRecords?token=" + token + "&domain=" + domain,
+ url: "/api/zone/getRecords?token=" + token + "&domain=" + zone,
success: function (responseJSON) {
- var type;
+ var zoneType;
if (responseJSON.response.zone.internal)
- type = "Internal";
+ zoneType = "Internal";
else
- type = responseJSON.response.zone.type;
+ zoneType = responseJSON.response.zone.type;
switch (responseJSON.response.zone.dnssecStatus) {
case "SignedWithNSEC":
case "SignedWithNSEC3":
- $("#tdDnssecStatusEditZone").show();
+ $("#titleDnssecStatusEditZone").show();
break;
default:
- $("#tdDnssecStatusEditZone").hide();
+ $("#titleDnssecStatusEditZone").hide();
break;
}
@@ -855,8 +855,8 @@ function showEditZone(domain) {
else
expiry = "Expiry: " + moment(expiry).local().format("YYYY-MM-DD HH:mm:ss");
- $("#titleEditZoneType").html(type);
- $("#tdStatusEditZone").html(status);
+ $("#titleEditZoneType").html(zoneType);
+ $("#titleStatusEditZone").html(status);
$("#titleEditZoneExpiry").html(expiry);
if (responseJSON.response.zone.internal)
@@ -866,19 +866,19 @@ function showEditZone(domain) {
switch (status) {
case "Disabled":
- $("#tdStatusEditZone").attr("class", "label label-warning");
+ $("#titleStatusEditZone").attr("class", "label label-warning");
break;
case "Expired":
- $("#tdStatusEditZone").attr("class", "label label-danger");
+ $("#titleStatusEditZone").attr("class", "label label-danger");
break;
case "Enabled":
- $("#tdStatusEditZone").attr("class", "label label-success");
+ $("#titleStatusEditZone").attr("class", "label label-success");
break;
}
- switch (type) {
+ switch (zoneType) {
case "Internal":
case "Secondary":
case "Stub":
@@ -930,7 +930,7 @@ function showEditZone(domain) {
$("#btnEditZoneDeleteZone").show();
}
- switch (type) {
+ switch (zoneType) {
case "Secondary":
case "Stub":
$("#btnZoneResync").show();
@@ -941,7 +941,7 @@ function showEditZone(domain) {
break;
}
- switch (type) {
+ switch (zoneType) {
case "Primary":
case "Secondary":
$("#btnZoneOptions").show();
@@ -954,7 +954,7 @@ function showEditZone(domain) {
var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true");
- switch (type) {
+ switch (zoneType) {
case "Primary":
$("#divZoneDnssecOptions").show();
@@ -1035,490 +1035,10 @@ function showEditZone(domain) {
}
recordCount++;
- var id = Math.floor(Math.random() * 10000);
-
- var name = records[i].name.toLowerCase();
- if (name === "")
- name = ".";
-
- if (name === domain)
- name = "@";
- else
- name = name.replace("." + domain, "");
-
- tableHtmlRows += "
| " + htmlEncode(name) + " | ";
- tableHtmlRows += "" + records[i].type + " | ";
- tableHtmlRows += "" + records[i].ttl + " | ";
-
- var lastUsedOn;
-
- if (records[i].lastUsedOn == "0001-01-01T00:00:00")
- lastUsedOn = moment(records[i].lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (never)";
- else
- lastUsedOn = moment(records[i].lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (" + moment(records[i].lastUsedOn).fromNow() + ")";
-
- var additionalDataAttributes = "";
-
- switch (records[i].type.toUpperCase()) {
- case "A":
- case "AAAA":
- tableHtmlRows += "" + htmlEncode(records[i].rData.ipAddress);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-ip-address=\"" + htmlEncode(records[i].rData.ipAddress) + "\" ";
- break;
-
- case "NS":
- tableHtmlRows += "Name Server: " + htmlEncode(records[i].rData.nameServer);
-
- if (records[i].glueRecords != null) {
- tableHtmlRows += " Glue Addresses: " + records[i].glueRecords;
-
- additionalDataAttributes = "data-record-glue=\"" + htmlEncode(records[i].glueRecords) + "\" ";
- } else {
- additionalDataAttributes = "data-record-glue=\"\" ";
- }
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes += "data-record-name-server=\"" + htmlEncode(records[i].rData.nameServer) + "\" ";
- break;
-
- case "CNAME":
- tableHtmlRows += "" + htmlEncode(records[i].rData.cname);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-cname=\"" + htmlEncode(records[i].rData.cname) + "\" ";
- break;
-
- case "SOA":
- tableHtmlRows += "Primary Name Server: " + htmlEncode(records[i].rData.primaryNameServer) +
- " Responsible Person: " + htmlEncode(records[i].rData.responsiblePerson) +
- " Serial: " + htmlEncode(records[i].rData.serial) +
- " Refresh: " + htmlEncode(records[i].rData.refresh) +
- " Retry: " + htmlEncode(records[i].rData.retry) +
- " Expire: " + htmlEncode(records[i].rData.expire) +
- " Minimum: " + htmlEncode(records[i].rData.minimum);
-
- if (records[i].rData.primaryAddresses != null) {
- tableHtmlRows += " Primary Name Server Addresses: " + records[i].rData.primaryAddresses;
-
- additionalDataAttributes = "data-record-paddresses=\"" + htmlEncode(records[i].rData.primaryAddresses) + "\" ";
- } else {
- additionalDataAttributes = "data-record-paddresses=\"\" ";
- }
-
- if (records[i].rData.zoneTransferProtocol != null) {
- tableHtmlRows += " Zone Transfer Protocol: XFR-over-" + records[i].rData.zoneTransferProtocol.toUpperCase();
-
- additionalDataAttributes += "data-record-zonetransferprotocol=\"" + htmlEncode(records[i].rData.zoneTransferProtocol) + "\" ";
- } else {
- additionalDataAttributes += "data-record-zonetransferprotocol=\"\" ";
- }
-
- if (records[i].rData.tsigKeyName != null) {
- tableHtmlRows += " TSIG Key Name: " + records[i].rData.tsigKeyName;
-
- additionalDataAttributes += "data-record-tsigkeyname=\"" + htmlEncode(records[i].rData.tsigKeyName) + "\" ";
- } else {
- additionalDataAttributes += "data-record-tsigkeyname=\"\" ";
- }
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes += "data-record-pname=\"" + htmlEncode(records[i].rData.primaryNameServer) + "\" " +
- "data-record-rperson=\"" + htmlEncode(records[i].rData.responsiblePerson) + "\" " +
- "data-record-serial=\"" + htmlEncode(records[i].rData.serial) + "\" " +
- "data-record-refresh=\"" + htmlEncode(records[i].rData.refresh) + "\" " +
- "data-record-retry=\"" + htmlEncode(records[i].rData.retry) + "\" " +
- "data-record-expire=\"" + htmlEncode(records[i].rData.expire) + "\" " +
- "data-record-minimum=\"" + htmlEncode(records[i].rData.minimum) + "\" ";
- break;
-
- case "PTR":
- tableHtmlRows += "" + htmlEncode(records[i].rData.ptrName);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-ptr-name=\"" + htmlEncode(records[i].rData.ptrName) + "\" ";
- break;
-
- case "MX":
- tableHtmlRows += "Preference: " + htmlEncode(records[i].rData.preference) +
- " Exchange: " + htmlEncode(records[i].rData.exchange);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-preference=\"" + htmlEncode(records[i].rData.preference) + "\" " +
- "data-record-exchange=\"" + htmlEncode(records[i].rData.exchange) + "\" ";
- break;
-
- case "TXT":
- tableHtmlRows += "" + htmlEncode(records[i].rData.text);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-text=\"" + htmlEncode(records[i].rData.text) + "\" ";
- break;
-
- case "SRV":
- tableHtmlRows += "Priority: " + htmlEncode(records[i].rData.priority) +
- " Weight: " + htmlEncode(records[i].rData.weight) +
- " Port: " + htmlEncode(records[i].rData.port) +
- " Target: " + htmlEncode(records[i].rData.target);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-priority=\"" + htmlEncode(records[i].rData.priority) + "\" " +
- "data-record-weight=\"" + htmlEncode(records[i].rData.weight) + "\" " +
- "data-record-port=\"" + htmlEncode(records[i].rData.port) + "\" " +
- "data-record-target=\"" + htmlEncode(records[i].rData.target) + "\" ";
- break;
-
- case "DNAME":
- tableHtmlRows += "" + htmlEncode(records[i].rData.dname);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-dname=\"" + htmlEncode(records[i].rData.dname) + "\" ";
- break;
-
- case "DS":
- tableHtmlRows += "Key Tag: " + htmlEncode(records[i].rData.keyTag) +
- " Algorithm: " + htmlEncode(records[i].rData.algorithm) +
- " Digest Type: " + htmlEncode(records[i].rData.digestType) +
- " Digest: " + htmlEncode(records[i].rData.digest);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-key-tag=\"" + htmlEncode(records[i].rData.keyTag) + "\" " +
- "data-record-algorithm=\"" + htmlEncode(records[i].rData.algorithm) + "\" " +
- "data-record-digest-type=\"" + htmlEncode(records[i].rData.digestType) + "\" " +
- "data-record-digest=\"" + htmlEncode(records[i].rData.digest) + "\" ";
- break;
-
- case "RRSIG":
- tableHtmlRows += "Type Covered: " + htmlEncode(records[i].rData.typeCovered) +
- " Algorithm: " + htmlEncode(records[i].rData.algorithm) +
- " Labels: " + htmlEncode(records[i].rData.labels) +
- " Original TTL: " + htmlEncode(records[i].rData.originalTtl) +
- " Signature Expiration: " + moment(records[i].rData.signatureExpiration).local().format("YYYY-MM-DD HH:mm:ss") +
- " Signature Inception: " + moment(records[i].rData.signatureInception).local().format("YYYY-MM-DD HH:mm:ss") +
- " Key Tag: " + htmlEncode(records[i].rData.keyTag) +
- " Signer's Name: " + htmlEncode(records[i].rData.signersName) +
- " Signature: " + htmlEncode(records[i].rData.signature);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "";
- break;
-
- case "NSEC":
- var nsecTypes = null;
-
- for (var j = 0; j < records[i].rData.types.length; j++) {
- if (nsecTypes == null)
- nsecTypes = records[i].rData.types[j];
- else
- nsecTypes += ", " + records[i].rData.types[j];
- }
-
- tableHtmlRows += "Next Domain Name: " + htmlEncode(records[i].rData.nextDomainName) +
- " Types: " + htmlEncode(nsecTypes);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "";
- break;
-
- case "DNSKEY":
- tableHtmlRows += "Flags: " + htmlEncode(records[i].rData.flags) +
- " Protocol: " + htmlEncode(records[i].rData.protocol) +
- " Algorithm: " + htmlEncode(records[i].rData.algorithm) +
- " Public Key: " + htmlEncode(records[i].rData.publicKey);
-
- if (records[i].rData.dnsKeyState == null)
- tableHtmlRows += " ";
- else
- tableHtmlRows += "
Key State: " + htmlEncode(records[i].rData.dnsKeyState);
-
- tableHtmlRows += " Computed Key Tag: " + htmlEncode(records[i].rData.computedKeyTag);
-
- if (records[i].rData.computedDigests != null) {
- tableHtmlRows += " Computed Digests: ";
-
- for (var j = 0; j < records[i].rData.computedDigests.length; j++) {
- tableHtmlRows += " " + htmlEncode(records[i].rData.computedDigests[j].digestType) + ": " + htmlEncode(records[i].rData.computedDigests[j].digest)
- }
- }
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "";
- break;
-
- case "NSEC3":
- var nsec3Types = null;
-
- for (var j = 0; j < records[i].rData.types.length; j++) {
- if (nsec3Types == null)
- nsec3Types = records[i].rData.types[j];
- else
- nsec3Types += ", " + records[i].rData.types[j];
- }
-
- tableHtmlRows += "Hash Algorithm: " + htmlEncode(records[i].rData.hashAlgorithm) +
- " Flags: " + htmlEncode(records[i].rData.flags) +
- " Iterations: " + htmlEncode(records[i].rData.iterations) +
- " Salt: " + htmlEncode(records[i].rData.salt) +
- " Next Hashed Owner Name: " + htmlEncode(records[i].rData.nextHashedOwnerName) +
- " Types: " + htmlEncode(nsec3Types);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "";
- break;
-
- case "NSEC3PARAM":
- tableHtmlRows += "Hash Algorithm: " + htmlEncode(records[i].rData.hashAlgorithm) +
- " Flags: " + htmlEncode(records[i].rData.flags) +
- " Iterations: " + htmlEncode(records[i].rData.iterations) +
- " Salt: " + htmlEncode(records[i].rData.salt);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "";
- break;
-
- case "CAA":
- tableHtmlRows += "Flags: " + htmlEncode(records[i].rData.flags) +
- " Tag: " + htmlEncode(records[i].rData.tag) +
- " Authority: " + htmlEncode(records[i].rData.value);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-flags=\"" + htmlEncode(records[i].rData.flags) + "\" " +
- "data-record-tag=\"" + htmlEncode(records[i].rData.tag) + "\" " +
- "data-record-value=\"" + htmlEncode(records[i].rData.value) + "\" ";
- break;
-
- case "ANAME":
- tableHtmlRows += "" + htmlEncode(records[i].rData.aname);
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-aname=\"" + htmlEncode(records[i].rData.aname) + "\" ";
- break;
-
- case "FWD":
- tableHtmlRows += "Protocol: " + htmlEncode(records[i].rData.protocol) +
- " Forwarder: " + htmlEncode(records[i].rData.forwarder) +
- " Enable DNSSEC Validation: " + htmlEncode(records[i].rData.dnssecValidation) +
- " Proxy Type: " + htmlEncode(records[i].rData.proxyType);
-
- if (records[i].rData.proxyType !== "None") {
- tableHtmlRows += " Proxy Address: " + htmlEncode(records[i].rData.proxyAddress) +
- " Proxy Port: " + htmlEncode(records[i].rData.proxyPort) +
- " Proxy Username: " + htmlEncode(records[i].rData.proxyUsername) +
- " Proxy Password: ************";
- }
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-protocol=\"" + htmlEncode(records[i].rData.protocol) + "\" " +
- "data-record-forwarder=\"" + htmlEncode(records[i].rData.forwarder) + "\" " +
- "data-record-dnssec-validation=\"" + htmlEncode(records[i].rData.dnssecValidation) + "\" " +
- "data-record-proxy-type=\"" + htmlEncode(records[i].rData.proxyType) + "\" ";
-
- if (records[i].rData.proxyType != "None") {
- additionalDataAttributes += "data-record-proxy-address=\"" + htmlEncode(records[i].rData.proxyAddress) + "\" " +
- "data-record-proxy-port=\"" + htmlEncode(records[i].rData.proxyPort) + "\" " +
- "data-record-proxy-username=\"" + htmlEncode(records[i].rData.proxyUsername) + "\" " +
- "data-record-proxy-password=\"" + htmlEncode(records[i].rData.proxyPassword) + "\" ";
- }
- break;
-
- case "APP":
- tableHtmlRows += "App Name: " + htmlEncode(records[i].rData.appName) +
- " Class Path: " + htmlEncode(records[i].rData.classPath) +
- " Record Data: " + (records[i].rData.data == "" ? "" : "" + htmlEncode(records[i].rData.data) + " ");
-
- tableHtmlRows += "
Last Used: " + lastUsedOn;
-
- if ((records[i].comments != null) && (records[i].comments.length > 0))
- tableHtmlRows += " Comments: " + htmlEncode(records[i].comments) + " ";
-
- tableHtmlRows += " | ";
-
- additionalDataAttributes = "data-record-app-name=\"" + htmlEncode(records[i].rData.appName) + "\" " +
- "data-record-classpath=\"" + htmlEncode(records[i].rData.classPath) + "\" " +
- "data-record-data=\"" + htmlEncode(records[i].rData.data) + "\"";
- break;
-
- default:
- tableHtmlRows += "RDATA: " + htmlEncode(records[i].rData.value) + " | ";
- break;
- }
-
- var hideActionButtons = false;
- var disableEnableDisableDeleteButtons = false;
-
- switch (type) {
- case "Internal":
- hideActionButtons = true;
- break;
-
- case "Secondary":
- switch (records[i].type) {
- case "SOA":
- disableEnableDisableDeleteButtons = true;
- break;
-
- default:
- hideActionButtons = true;
- break;
- }
- break;
-
- case "Stub":
- switch (records[i].type) {
- case "SOA":
- disableEnableDisableDeleteButtons = true;
- break;
-
- case "NS":
- if (name == "@")
- hideActionButtons = true;
-
- break;
- }
- break;
-
- default:
- switch (records[i].type) {
- case "SOA":
- disableEnableDisableDeleteButtons = true;
- break;
-
- case "DNSKEY":
- case "RRSIG":
- case "NSEC":
- case "NSEC3":
- case "NSEC3PARAM":
- hideActionButtons = true;
- break;
- }
- break;
- }
-
- if (hideActionButtons) {
- tableHtmlRows += " | ";
- }
- else {
- tableHtmlRows += "";
- tableHtmlRows += "";
- tableHtmlRows += "";
- tableHtmlRows += "";
- tableHtmlRows += "";
- tableHtmlRows += " | ";
- }
-
- tableHtmlRows += "
";
+ tableHtmlRows += getZoneRecordRowHtml(i, zone, zoneType, records[i]);
}
- $("#titleEditZone").text(domain);
+ $("#titleEditZone").text(zone);
$("#tableEditZoneBody").html(tableHtmlRows);
if (recordCount > 0)
@@ -1540,6 +1060,490 @@ function showEditZone(domain) {
});
}
+function getZoneRecordRowHtml(id, zone, zoneType, record) {
+ var name = record.name.toLowerCase();
+ if (name === "")
+ name = ".";
+
+ if (name === zone)
+ name = "@";
+ else
+ name = name.replace("." + zone, "");
+
+ var tableHtmlRow = "| " + htmlEncode(name) + " | ";
+ tableHtmlRow += "" + record.type + " | ";
+ tableHtmlRow += "" + record.ttl + " | ";
+
+ var lastUsedOn;
+
+ if (record.lastUsedOn == "0001-01-01T00:00:00")
+ lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (never)";
+ else
+ lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (" + moment(record.lastUsedOn).fromNow() + ")";
+
+ var additionalDataAttributes = "";
+
+ switch (record.type.toUpperCase()) {
+ case "A":
+ case "AAAA":
+ tableHtmlRow += "" + htmlEncode(record.rData.ipAddress);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-ip-address=\"" + htmlEncode(record.rData.ipAddress) + "\" ";
+ break;
+
+ case "NS":
+ tableHtmlRow += "Name Server: " + htmlEncode(record.rData.nameServer);
+
+ if (record.glueRecords != null) {
+ tableHtmlRow += " Glue Addresses: " + record.glueRecords;
+
+ additionalDataAttributes = "data-record-glue=\"" + htmlEncode(record.glueRecords) + "\" ";
+ } else {
+ additionalDataAttributes = "data-record-glue=\"\" ";
+ }
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes += "data-record-name-server=\"" + htmlEncode(record.rData.nameServer) + "\" ";
+ break;
+
+ case "CNAME":
+ tableHtmlRow += "" + htmlEncode(record.rData.cname);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-cname=\"" + htmlEncode(record.rData.cname) + "\" ";
+ break;
+
+ case "SOA":
+ tableHtmlRow += "Primary Name Server: " + htmlEncode(record.rData.primaryNameServer) +
+ " Responsible Person: " + htmlEncode(record.rData.responsiblePerson) +
+ " Serial: " + htmlEncode(record.rData.serial) +
+ " Refresh: " + htmlEncode(record.rData.refresh) +
+ " Retry: " + htmlEncode(record.rData.retry) +
+ " Expire: " + htmlEncode(record.rData.expire) +
+ " Minimum: " + htmlEncode(record.rData.minimum);
+
+ if (record.rData.primaryAddresses != null) {
+ tableHtmlRow += " Primary Name Server Addresses: " + record.rData.primaryAddresses;
+
+ additionalDataAttributes = "data-record-paddresses=\"" + htmlEncode(record.rData.primaryAddresses) + "\" ";
+ } else {
+ additionalDataAttributes = "data-record-paddresses=\"\" ";
+ }
+
+ if (record.rData.zoneTransferProtocol != null) {
+ tableHtmlRow += " Zone Transfer Protocol: XFR-over-" + record.rData.zoneTransferProtocol.toUpperCase();
+
+ additionalDataAttributes += "data-record-zonetransferprotocol=\"" + htmlEncode(record.rData.zoneTransferProtocol) + "\" ";
+ } else {
+ additionalDataAttributes += "data-record-zonetransferprotocol=\"\" ";
+ }
+
+ if (record.rData.tsigKeyName != null) {
+ tableHtmlRow += " TSIG Key Name: " + record.rData.tsigKeyName;
+
+ additionalDataAttributes += "data-record-tsigkeyname=\"" + htmlEncode(record.rData.tsigKeyName) + "\" ";
+ } else {
+ additionalDataAttributes += "data-record-tsigkeyname=\"\" ";
+ }
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes += "data-record-pname=\"" + htmlEncode(record.rData.primaryNameServer) + "\" " +
+ "data-record-rperson=\"" + htmlEncode(record.rData.responsiblePerson) + "\" " +
+ "data-record-serial=\"" + htmlEncode(record.rData.serial) + "\" " +
+ "data-record-refresh=\"" + htmlEncode(record.rData.refresh) + "\" " +
+ "data-record-retry=\"" + htmlEncode(record.rData.retry) + "\" " +
+ "data-record-expire=\"" + htmlEncode(record.rData.expire) + "\" " +
+ "data-record-minimum=\"" + htmlEncode(record.rData.minimum) + "\" ";
+ break;
+
+ case "PTR":
+ tableHtmlRow += "" + htmlEncode(record.rData.ptrName);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-ptr-name=\"" + htmlEncode(record.rData.ptrName) + "\" ";
+ break;
+
+ case "MX":
+ tableHtmlRow += "Preference: " + htmlEncode(record.rData.preference) +
+ " Exchange: " + htmlEncode(record.rData.exchange);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-preference=\"" + htmlEncode(record.rData.preference) + "\" " +
+ "data-record-exchange=\"" + htmlEncode(record.rData.exchange) + "\" ";
+ break;
+
+ case "TXT":
+ tableHtmlRow += "" + htmlEncode(record.rData.text);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-text=\"" + htmlEncode(record.rData.text) + "\" ";
+ break;
+
+ case "SRV":
+ tableHtmlRow += "Priority: " + htmlEncode(record.rData.priority) +
+ " Weight: " + htmlEncode(record.rData.weight) +
+ " Port: " + htmlEncode(record.rData.port) +
+ " Target: " + htmlEncode(record.rData.target);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-priority=\"" + htmlEncode(record.rData.priority) + "\" " +
+ "data-record-weight=\"" + htmlEncode(record.rData.weight) + "\" " +
+ "data-record-port=\"" + htmlEncode(record.rData.port) + "\" " +
+ "data-record-target=\"" + htmlEncode(record.rData.target) + "\" ";
+ break;
+
+ case "DNAME":
+ tableHtmlRow += "" + htmlEncode(record.rData.dname);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-dname=\"" + htmlEncode(record.rData.dname) + "\" ";
+ break;
+
+ case "DS":
+ tableHtmlRow += "Key Tag: " + htmlEncode(record.rData.keyTag) +
+ " Algorithm: " + htmlEncode(record.rData.algorithm) +
+ " Digest Type: " + htmlEncode(record.rData.digestType) +
+ " Digest: " + htmlEncode(record.rData.digest);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-key-tag=\"" + htmlEncode(record.rData.keyTag) + "\" " +
+ "data-record-algorithm=\"" + htmlEncode(record.rData.algorithm) + "\" " +
+ "data-record-digest-type=\"" + htmlEncode(record.rData.digestType) + "\" " +
+ "data-record-digest=\"" + htmlEncode(record.rData.digest) + "\" ";
+ break;
+
+ case "RRSIG":
+ tableHtmlRow += "Type Covered: " + htmlEncode(record.rData.typeCovered) +
+ " Algorithm: " + htmlEncode(record.rData.algorithm) +
+ " Labels: " + htmlEncode(record.rData.labels) +
+ " Original TTL: " + htmlEncode(record.rData.originalTtl) +
+ " Signature Expiration: " + moment(record.rData.signatureExpiration).local().format("YYYY-MM-DD HH:mm:ss") +
+ " Signature Inception: " + moment(record.rData.signatureInception).local().format("YYYY-MM-DD HH:mm:ss") +
+ " Key Tag: " + htmlEncode(record.rData.keyTag) +
+ " Signer's Name: " + htmlEncode(record.rData.signersName) +
+ " Signature: " + htmlEncode(record.rData.signature);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "";
+ break;
+
+ case "NSEC":
+ var nsecTypes = null;
+
+ for (var j = 0; j < record.rData.types.length; j++) {
+ if (nsecTypes == null)
+ nsecTypes = record.rData.types[j];
+ else
+ nsecTypes += ", " + record.rData.types[j];
+ }
+
+ tableHtmlRow += "Next Domain Name: " + htmlEncode(record.rData.nextDomainName) +
+ " Types: " + htmlEncode(nsecTypes);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "";
+ break;
+
+ case "DNSKEY":
+ tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) +
+ " Protocol: " + htmlEncode(record.rData.protocol) +
+ " Algorithm: " + htmlEncode(record.rData.algorithm) +
+ " Public Key: " + htmlEncode(record.rData.publicKey);
+
+ if (record.rData.dnsKeyState == null)
+ tableHtmlRow += " ";
+ else
+ tableHtmlRow += "
Key State: " + htmlEncode(record.rData.dnsKeyState);
+
+ tableHtmlRow += " Computed Key Tag: " + htmlEncode(record.rData.computedKeyTag);
+
+ if (record.rData.computedDigests != null) {
+ tableHtmlRow += " Computed Digests: ";
+
+ for (var j = 0; j < record.rData.computedDigests.length; j++) {
+ tableHtmlRow += " " + htmlEncode(record.rData.computedDigests[j].digestType) + ": " + htmlEncode(record.rData.computedDigests[j].digest)
+ }
+ }
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "";
+ break;
+
+ case "NSEC3":
+ var nsec3Types = null;
+
+ for (var j = 0; j < record.rData.types.length; j++) {
+ if (nsec3Types == null)
+ nsec3Types = record.rData.types[j];
+ else
+ nsec3Types += ", " + record.rData.types[j];
+ }
+
+ tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) +
+ " Flags: " + htmlEncode(record.rData.flags) +
+ " Iterations: " + htmlEncode(record.rData.iterations) +
+ " Salt: " + htmlEncode(record.rData.salt) +
+ " Next Hashed Owner Name: " + htmlEncode(record.rData.nextHashedOwnerName) +
+ " Types: " + htmlEncode(nsec3Types);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "";
+ break;
+
+ case "NSEC3PARAM":
+ tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) +
+ " Flags: " + htmlEncode(record.rData.flags) +
+ " Iterations: " + htmlEncode(record.rData.iterations) +
+ " Salt: " + htmlEncode(record.rData.salt);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "";
+ break;
+
+ case "CAA":
+ tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) +
+ " Tag: " + htmlEncode(record.rData.tag) +
+ " Authority: " + htmlEncode(record.rData.value);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-flags=\"" + htmlEncode(record.rData.flags) + "\" " +
+ "data-record-tag=\"" + htmlEncode(record.rData.tag) + "\" " +
+ "data-record-value=\"" + htmlEncode(record.rData.value) + "\" ";
+ break;
+
+ case "ANAME":
+ tableHtmlRow += "" + htmlEncode(record.rData.aname);
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-aname=\"" + htmlEncode(record.rData.aname) + "\" ";
+ break;
+
+ case "FWD":
+ tableHtmlRow += "Protocol: " + htmlEncode(record.rData.protocol) +
+ " Forwarder: " + htmlEncode(record.rData.forwarder) +
+ " Enable DNSSEC Validation: " + htmlEncode(record.rData.dnssecValidation) +
+ " Proxy Type: " + htmlEncode(record.rData.proxyType);
+
+ if (record.rData.proxyType !== "None") {
+ tableHtmlRow += " Proxy Address: " + htmlEncode(record.rData.proxyAddress) +
+ " Proxy Port: " + htmlEncode(record.rData.proxyPort) +
+ " Proxy Username: " + htmlEncode(record.rData.proxyUsername) +
+ " Proxy Password: ************";
+ }
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-protocol=\"" + htmlEncode(record.rData.protocol) + "\" " +
+ "data-record-forwarder=\"" + htmlEncode(record.rData.forwarder) + "\" " +
+ "data-record-dnssec-validation=\"" + htmlEncode(record.rData.dnssecValidation) + "\" " +
+ "data-record-proxy-type=\"" + htmlEncode(record.rData.proxyType) + "\" ";
+
+ if (record.rData.proxyType != "None") {
+ additionalDataAttributes += "data-record-proxy-address=\"" + htmlEncode(record.rData.proxyAddress) + "\" " +
+ "data-record-proxy-port=\"" + htmlEncode(record.rData.proxyPort) + "\" " +
+ "data-record-proxy-username=\"" + htmlEncode(record.rData.proxyUsername) + "\" " +
+ "data-record-proxy-password=\"" + htmlEncode(record.rData.proxyPassword) + "\" ";
+ }
+ break;
+
+ case "APP":
+ tableHtmlRow += "App Name: " + htmlEncode(record.rData.appName) +
+ " Class Path: " + htmlEncode(record.rData.classPath) +
+ " Record Data: " + (record.rData.data == "" ? "" : "" + htmlEncode(record.rData.data) + " ");
+
+ tableHtmlRow += "
Last Used: " + lastUsedOn;
+
+ if ((record.comments != null) && (record.comments.length > 0))
+ tableHtmlRow += " Comments: " + htmlEncode(record.comments) + " ";
+
+ tableHtmlRow += " | ";
+
+ additionalDataAttributes = "data-record-app-name=\"" + htmlEncode(record.rData.appName) + "\" " +
+ "data-record-classpath=\"" + htmlEncode(record.rData.classPath) + "\" " +
+ "data-record-data=\"" + htmlEncode(record.rData.data) + "\"";
+ break;
+
+ default:
+ tableHtmlRow += "RDATA: " + htmlEncode(record.rData.value) + " | ";
+ break;
+ }
+
+ var hideActionButtons = false;
+ var disableEnableDisableDeleteButtons = false;
+
+ switch (zoneType) {
+ case "Internal":
+ hideActionButtons = true;
+ break;
+
+ case "Secondary":
+ switch (record.type) {
+ case "SOA":
+ disableEnableDisableDeleteButtons = true;
+ break;
+
+ default:
+ hideActionButtons = true;
+ break;
+ }
+ break;
+
+ case "Stub":
+ switch (record.type) {
+ case "SOA":
+ disableEnableDisableDeleteButtons = true;
+ break;
+
+ case "NS":
+ if (name == "@")
+ hideActionButtons = true;
+
+ break;
+ }
+ break;
+
+ default:
+ switch (record.type) {
+ case "SOA":
+ disableEnableDisableDeleteButtons = true;
+ break;
+
+ case "DNSKEY":
+ case "RRSIG":
+ case "NSEC":
+ case "NSEC3":
+ case "NSEC3PARAM":
+ hideActionButtons = true;
+ break;
+ }
+ break;
+ }
+
+ if (hideActionButtons) {
+ tableHtmlRow += " | ";
+ }
+ else {
+ tableHtmlRow += "";
+ tableHtmlRow += "";
+ tableHtmlRow += "";
+ tableHtmlRow += "";
+ tableHtmlRow += "";
+ tableHtmlRow += " | ";
+ }
+
+ tableHtmlRow += "
";
+
+ return tableHtmlRow;
+}
+
function clearAddEditForm() {
$("#divAddEditRecordAlert").html("");
@@ -2131,7 +2135,22 @@ function addRecord() {
url: apiUrl,
success: function (responseJSON) {
$("#modalAddEditRecord").modal("hide");
- showEditZone(zone);
+
+ if (overwrite) {
+ showEditZone(zone);
+ }
+ else {
+ var zoneType;
+ if (responseJSON.response.zone.internal)
+ zoneType = "Internal";
+ else
+ zoneType = responseJSON.response.zone.type;
+
+ var id = Math.floor(Math.random() * 1000000);
+ var tableHtmlRow = getZoneRecordRowHtml(id, zone, zoneType, responseJSON.response.addedRecord);
+ $("#tableEditZoneBody").prepend(tableHtmlRow);
+ }
+
showAlert("success", "Record Added!", "Resource record was added successfully.");
},
error: function () {
@@ -2818,7 +2837,16 @@ function updateRecord() {
url: apiUrl,
success: function (responseJSON) {
$("#modalAddEditRecord").modal("hide");
- showEditZone(zone);
+
+ var zoneType;
+ if (responseJSON.response.zone.internal)
+ zoneType = "Internal";
+ else
+ zoneType = responseJSON.response.zone.type;
+
+ var tableHtmlRow = getZoneRecordRowHtml(id, zone, zoneType, responseJSON.response.updatedRecord);
+ $("#trZoneRecord" + id).replaceWith(tableHtmlRow);
+
showAlert("success", "Record Updated!", "Resource record was updated successfully.");
},
error: function () {
@@ -3010,8 +3038,13 @@ function deleteRecord(objBtn) {
HTTPRequest({
url: apiUrl,
success: function (responseJSON) {
- $("#tr" + id).remove();
- $("#tableEditZoneFooter").html("| Total Records: " + $('#tableEditZone >tbody >tr').length + " |
");
+ $("#trZoneRecord" + id).remove();
+
+ var recordCount = $('#tableEditZone >tbody >tr').length;
+ if (recordCount > 0)
+ $("#tableEditZoneFooter").html("| Total Records: " + recordCount + " |
");
+ else
+ $("#tableEditZoneFooter").html("| No Records Found |
");
showAlert("success", "Record Deleted!", "Resource record was deleted successfully.");
},
@@ -3091,7 +3124,22 @@ function signPrimaryZone() {
btn.button('reset');
$("#modalDnssecSignZone").modal("hide");
- showEditZone(zone);
+ var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true");
+ if (zoneHideDnssecRecords) {
+ $("#titleDnssecStatusEditZone").show();
+
+ $("#lnkZoneDnssecSignZone").hide();
+
+ $("#lnkZoneDnssecHideRecords").hide();
+ $("#lnkZoneDnssecShowRecords").show();
+
+ $("#lnkZoneDnssecProperties").show();
+ $("#lnkZoneDnssecUnsignZone").show();
+ }
+ else {
+ showEditZone(zone);
+ }
+
showAlert("success", "Zone Signed!", "The primary zone was signed successfully.");
},
error: function () {
@@ -3126,7 +3174,22 @@ function unsignPrimaryZone() {
btn.button('reset');
$("#modalDnssecUnsignZone").modal("hide");
- showEditZone(zone);
+ var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true");
+ if (zoneHideDnssecRecords) {
+ $("#titleDnssecStatusEditZone").hide();
+
+ $("#lnkZoneDnssecSignZone").show();
+
+ $("#lnkZoneDnssecHideRecords").hide();
+ $("#lnkZoneDnssecShowRecords").hide();
+
+ $("#lnkZoneDnssecProperties").hide();
+ $("#lnkZoneDnssecUnsignZone").hide();
+ }
+ else {
+ showEditZone(zone);
+ }
+
showAlert("success", "Zone Unsigned!", "The primary zone was unsigned successfully.");
},
error: function () {
@@ -3524,7 +3587,9 @@ function changeDnssecNxProof(objBtn) {
btn.button('reset');
- showEditZone(zone);
+ var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true");
+ if (!zoneHideDnssecRecords)
+ showEditZone(zone);
showAlert("success", "Proof Changed!", "The proof of non-existence was changed successfully.", divDnssecPropertiesAlert);
},