diff --git a/dns/dns.js b/dns/dns.js index dca48c2..780f7a9 100644 --- a/dns/dns.js +++ b/dns/dns.js @@ -51,7 +51,10 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js var name = document.createElement("td"); var nameLink = document.createElement("a"); - nameLink.href = "/dns/domain?did=" + domain.id; + if (domain.type == "master") + nameLink.href = "/dns/domain?did=" + domain.id; + else + nameLink.href = "/dns/domain_slave?did=" + domain.id; nameLink.innerHTML = domain.domain; name.appendChild(nameLink); row.appendChild(name); @@ -71,7 +74,10 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js var options = document.createElement("td"); options.className = elements.centerCell; var editLink = document.createElement("a"); - editLink.href = "/dns/domain?did=" + domain.id; + if (domain.type == "master") + editLink.href = "/dns/domain?did=" + domain.id; + else + editLink.href = "/dns/domain_slave?did=" + domain.id; editLink.innerHTML = "Edit"; var separator = document.createElement("span"); separator.innerHTML = " | "; diff --git a/dns/domain/domain.js b/dns/domain/domain.js index 4d55e18..f2547b8 100644 --- a/dns/domain/domain.js +++ b/dns/domain/domain.js @@ -320,6 +320,12 @@ import { settings, elements, apiGet, parseParams, setupHeader } from "/global.js { data.domain = response; + // Redirect if this is a slave zone + if (data.domain.type == "slave") { + location.href = "/dns/domain_slave?did=" + data.domain.id; + return; + } + // Set page title and header stuff document.title += " // " + data.domain.domain; ui.domainLabel.innerHTML = data.domain.domain; diff --git a/dns/domain_slave/domain_slave.css b/dns/domain_slave/domain_slave.css new file mode 100644 index 0000000..4e4d59d --- /dev/null +++ b/dns/domain_slave/domain_slave.css @@ -0,0 +1,32 @@ +/* + * This file is part of Linode Manager Classic. + * + * Linode Manager Classic is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Linode Manager Classic is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Linode Manager Classic. If not, see . + */ + +@import url('/global.css'); + +#domain-slave { + padding: 0px 15px 15px; +} + +tbody tr td:first-of-type { + font-weight: bold; + text-align: right; + white-space: nowrap; +} + +tbody tr:last-of-type { + border: none; +} diff --git a/dns/domain_slave/domain_slave.js b/dns/domain_slave/domain_slave.js new file mode 100644 index 0000000..282f6b1 --- /dev/null +++ b/dns/domain_slave/domain_slave.js @@ -0,0 +1,149 @@ +/* + * This file is part of Linode Manager Classic. + * + * Linode Manager Classic is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Linode Manager Classic is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Linode Manager Classic. If not, see . + */ + +import { settings, elements, apiGet, apiPut, parseParams, setupHeader } from "/global.js"; + +(function() +{ + // Element names specific to this page + elements.domain = "domain"; + elements.domainLabel = "domain-label"; + elements.domainTag = "domain-tag"; + elements.domainTagLink = "domain-tag-link"; + elements.masters = "masters"; + elements.saveButton = "save-button"; + elements.tags = "tags"; + elements.transfers = "transfers"; + + // Data recieved from API calls + var data = {}; + data.domain = {}; + + // Static references to UI elements + var ui = {}; + ui.domain = {}; + ui.domainLabel = {}; + ui.domainTag = {}; + ui.domainTagLink = {}; + ui.masters = {}; + ui.saveButton = {}; + ui.tags = {}; + ui.transfers = {}; + + // Callback for domain details API call + var displayDetails = function(response) + { + data.domain = response; + + // Redirect if this is a master zone + if (data.domain.type == "master") { + location.href = "/dns/domain?did=" + data.domain.id; + return; + } + + // Set page title and header stuff + document.title += " // " + data.domain.domain; + ui.domainLabel.innerHTML = data.domain.domain; + if (data.domain.tags.length == 1) { + ui.domainTagLink.href = "/dns?tag=" + data.domain.tags[0]; + ui.domainTagLink.innerHTML = "(" + data.domain.tags[0] + ")"; + ui.domainTag.style.display = "inline"; + } + + // Set form info + ui.domain.value = data.domain.domain; + ui.tags.value = data.domain.tags.join(","); + ui.masters.value = data.domain.master_ips.join("\n"); + ui.transfers.value = data.domain.axfr_ips.join("\n"); + + ui.saveButton.disabled = false; + }; + + // Click handler for save button + var handleSave = function(event) + { + if (event.currentTarget.disabled) + return; + + // This request can take a few seconds, + // so disable the button to prevent antsy users from double-submitting + ui.saveButton.disabled = true; + + var req = { + "domain": ui.domain.value, + "tags": [], + "master_ips": [], + "axfr_ips": [] + }; + + if (ui.tags.value.length) + req.tags = ui.tags.value.split(","); + if (ui.masters.value.length) + var masterLines = ui.masters.value.split("\n"); + for (var i = 0; i < masterLines.length; i++) + req.master_ips = req.master_ips.concat(masterLines[i].split(";")); + if (ui.transfers.value.length) { + var transferLines = ui.transfers.value.split("\n"); + for (var i = 0; i < transferLines.length; i++) + req.axfr_ips = req.axfr_ips.concat(transferLines[i].split(";")); + } + + apiPut("/domains/" + data.params.did, req, function(response) + { + location.href = "/dns"; + }); + }; + + // Initial setup + var setup = function() + { + // Parse URL parameters + data.params = parseParams(); + + // We need a domain ID, so die if we don't have it + if (!data.params.did) { + alert("No domain ID supplied!"); + return; + } + + setupHeader(); + + // Update links on page to include proper Linode ID + var anchors = document.getElementsByTagName("a"); + for (var i = 0; i < anchors.length; i++) + anchors[i].href = anchors[i].href.replace("did=0", "did=" + data.params.did); + + // Get element references + ui.domain = document.getElementById(elements.domain); + ui.domainLabel = document.getElementById(elements.domainLabel); + ui.domainTag = document.getElementById(elements.domainTag); + ui.domainTagLink = document.getElementById(elements.domainTagLink); + ui.masters = document.getElementById(elements.masters); + ui.saveButton = document.getElementById(elements.saveButton); + ui.tags = document.getElementById(elements.tags); + ui.transfers = document.getElementById(elements.transfers); + + // Attach event handlers + ui.saveButton.addEventListener("click", handleSave); + + // Get data from API + apiGet("/domains/" + data.params.did, displayDetails, null); + }; + + // Attach onload handler + window.addEventListener("load", setup); +})(); diff --git a/dns/domain_slave/index.shtml b/dns/domain_slave/index.shtml new file mode 100644 index 0000000..e062a83 --- /dev/null +++ b/dns/domain_slave/index.shtml @@ -0,0 +1,73 @@ + + + + + + LMC - Edit Domain + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Edit a Slave Zone
Domain
TagsGroup domains together using tags! (comma-separated)
Masters + The IP addresses of the master DNS servers for this zone.
+ Semicolon or new line delimited. (maximum: 6) +
Domain Transfers + The IP addresses allowed to AXFR this entire zone.
+ Semicolon or new line delimited. (maximum: 6) +
+
+
+ +