Added all DNS functionality
This commit is contained in:
36
dns/resource_delete/index.shtml
Normal file
36
dns/resource_delete/index.shtml
Normal file
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - Remove Record</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="resource_delete.css" />
|
||||
<script src="resource_delete.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="top-links"><a href="/dns">DNS Manager</a> » <span id="domain-tag"><a id="domain-tag-link" href=""></a> » </span><a id="domain-label" href="/dns/domain?did=0"></a> » <span class="top-links-title">Remove Record</span></div>
|
||||
<div id="resource-delete">
|
||||
<p>Are you sure you want to delete this <span id="record-type"></span> record?</p>
|
||||
<button disabled id="delete-button" type="button">Yes, delete this sucker</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
22
dns/resource_delete/resource_delete.css
Normal file
22
dns/resource_delete/resource_delete.css
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
#resource-delete {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
121
dns/resource_delete/resource_delete.js
Normal file
121
dns/resource_delete/resource_delete.js
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiDelete, apiGet, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.deleteButton = "delete-button";
|
||||
elements.domainLabel = "domain-label";
|
||||
elements.domainTag = "domain-tag";
|
||||
elements.domainTagLink = "domain-tag-link";
|
||||
elements.recordType = "record-type";
|
||||
elements.topLinksTitle = "top-links-title";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.deleteButton = {};
|
||||
ui.domainLabel = {};
|
||||
ui.domainTag = {};
|
||||
ui.domainTagLink = {};
|
||||
ui.recordType = {};
|
||||
ui.topLinksTitle = {};
|
||||
|
||||
// Callback for domain details API call
|
||||
var displayDetails = function(response)
|
||||
{
|
||||
// Set page title and header stuff
|
||||
document.title += " // " + response.domain;
|
||||
ui.domainLabel.innerHTML = response.domain;
|
||||
if (response.tags.length == 1) {
|
||||
ui.domainTagLink.href = "/dns?tag=" + response.tags[0];
|
||||
ui.domainTagLink.innerHTML = "(" + response.tags[0] + ")";
|
||||
ui.domainTag.style.display = "inline";
|
||||
}
|
||||
};
|
||||
|
||||
// Callback for record details API call
|
||||
var displayRecord = function(response)
|
||||
{
|
||||
ui.recordType.innerHTML = response.type;
|
||||
if (response.name && response.name.length != 0)
|
||||
ui.topLinksTitle.innerHTML += " " + response.name;
|
||||
else
|
||||
ui.topLinksTitle.innerHTML += " " + response.target;
|
||||
ui.deleteButton.disabled = false;
|
||||
};
|
||||
|
||||
// Click handler for delete button
|
||||
var handleDelete = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
apiDelete("/domains/" + data.params.did + "/records/" + data.params.rid, function(response)
|
||||
{
|
||||
location.href = "/dns/domain?did=" + data.params.did;
|
||||
});
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// We also need a resource ID
|
||||
if (!data.params.rid) {
|
||||
alert("No resource 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.deleteButton = document.getElementById(elements.deleteButton);
|
||||
ui.domainLabel = document.getElementById(elements.domainLabel);
|
||||
ui.domainTag = document.getElementById(elements.domainTag);
|
||||
ui.domainTagLink = document.getElementById(elements.domainTagLink);
|
||||
ui.recordType = document.getElementById(elements.recordType);
|
||||
ui.topLinksTitle = document.getElementsByClassName(elements.topLinksTitle)[0];
|
||||
|
||||
// Attach event handlers
|
||||
ui.deleteButton.addEventListener("click", handleDelete);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/domains/" + data.params.did, displayDetails, null);
|
||||
apiGet("/domains/" + data.params.did + "/records/" + data.params.rid, displayRecord, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
Reference in New Issue
Block a user