Initial commit. Implemented OAuth, Linodes, volumes, and images

This commit is contained in:
2020-01-10 00:24:59 -05:00
commit 9915ef3413
121 changed files with 14776 additions and 0 deletions

53
linodes/rdns/index.shtml Normal file
View File

@ -0,0 +1,53 @@
<!--
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 - Reverse DNS</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="rdns.css" />
<script src="rdns.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/linode_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="top-links"><a href="/linodes">Linodes</a> » <span id="linode-tag"><a id="linode-tag-link" href=""></a> » </span><a id="linode-label" href="/linodes/dashboard?lid=0"></a> » <a href="/linodes/remote_access?lid=0">Remote Access</a> » <span class="top-links-title">Reverse DNS</span></div>
<div id="rdns">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Reverse DNS</td>
</tr>
<tr>
<td>IP Address</td>
<td>Target</td>
</tr>
</thead>
<tbody id="rdns-body">
<tr id="save-row" class="lmc-tr3">
<td></td>
<td><button disabled id="save-button" type="button">Save Changes</button></td>
</tr>
</tbody>
</table>
<p>Note: Forward DNS must already be set up for reverse DNS to be applied. Leaving any value blank will reset it to the default.</p>
</div>
</div>
</body>
</html>

34
linodes/rdns/rdns.css Normal file
View File

@ -0,0 +1,34 @@
/*
* 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');
p {
text-align: center;
}
#rdns {
padding: 0px 15px 15px;
}
tbody tr td:first-of-type {
font-weight: bold;
}
tbody tr:last-of-type {
border: none;
}

166
linodes/rdns/rdns.js Normal file
View File

@ -0,0 +1,166 @@
/*
* 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, apiGet, apiPut, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.linodeLabel = "linode-label";
elements.linodeTag = "linode-tag";
elements.linodeTagLink = "linode-tag-link";
elements.lmcRow = "lmc-tr3";
elements.rdnsBody = "rdns-body";
elements.rdnsTarget = "rdns-target";
elements.saveButton = "save-button";
elements.saveRow = "save-row";
elements.subnav = "subnav-link";
elements.subnavActive = "subnav-link-active";
// Data recieved from API calls
var data = {};
data.linode = {};
// Static references to UI elements
var ui = {};
ui.linodeLabel = {};
ui.linodeTag = {};
ui.linodeTagLink = {};
ui.rdnsBody = {};
ui.saveButton = {};
ui.saveRow = {};
// Temporary state
var state = {};
state.numReqs = 0;
state.numReturns = 0;
// Callback for linode details API call
var displayDetails = function(response)
{
data.linode = response;
// Set page title and header stuff
document.title += " // " + data.linode.label;
ui.linodeLabel.innerHTML = data.linode.label;
if (data.linode.tags.length == 1) {
ui.linodeTagLink.href = "/linodes?tag=" + data.linode.tags[0];
ui.linodeTagLink.innerHTML = "(" + data.linode.tags[0] + ")";
ui.linodeTag.style.display = "inline";
}
};
// Callback for linode net info API call
var displayNetInfo = function(response)
{
var ips = response.ipv4["public"];
ips.push(response.ipv6.slaac);
// Add IPs to table
for (var i = 0; i < ips.length; i++) {
var row = document.createElement("tr");
row.className = elements.lmcRow;
var addrCell = document.createElement("td");
addrCell.innerHTML = ips[i].address;
var targetCell = document.createElement("td");
var target = document.createElement("input");
target.id = ips[i].address;
target.className = elements.rdnsTarget;
target.type = "text";
target.placeholder = "host.yourdomain.com";
target.size = "36";
target.value = ips[i].rdns;
targetCell.appendChild(target);
row.appendChild(addrCell);
row.appendChild(targetCell);
ui.rdnsBody.insertBefore(row, ui.saveRow);
}
ui.saveButton.disabled = false;
};
// Event handler for save button
var handleSave = function(event)
{
if (event.currentTarget.disabled)
return;
var targets = document.getElementsByClassName(elements.rdnsTarget);
state.numReqs = targets.length;
state.numReturns = 0;
// Submit request for each IP
for (var i = 0; i < targets.length; i++) {
var req = {};
if (!targets[i].value.length)
req.rdns = null;
else
req.rdns = targets[i].value;
apiPut("/linode/instances/" + data.params.lid + "/ips/" + targets[i].id, req, function(response) {
state.numReturns++;
if (state.numReturns >= state.numReqs)
location.href = "/linodes/remote_access?lid=" + data.params.lid;
});
}
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
// We need a Linode ID, so die if we don't have it
if (!data.params.lid) {
alert("No Linode 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("lid=0", "lid=" + data.params.lid);
// Highlight the remote access subnav link
var subnavLinks = document.getElementsByClassName(elements.subnav);
for (var i = 0; i < subnavLinks.length; i++) {
if (subnavLinks[i].pathname == "/linodes/remote_access")
subnavLinks[i].className += " " + elements.subnavActive;
}
// Get element references
ui.linodeLabel = document.getElementById(elements.linodeLabel);
ui.linodeTag = document.getElementById(elements.linodeTag);
ui.linodeTagLink = document.getElementById(elements.linodeTagLink);
ui.rdnsBody = document.getElementById(elements.rdnsBody);
ui.saveButton = document.getElementById(elements.saveButton);
ui.saveRow = document.getElementById(elements.saveRow);
// Attach event handlers
ui.saveButton.addEventListener("click", handleSave);
// Get data from API
apiGet("/linode/instances/" + data.params.lid, displayDetails, null);
apiGet("/linode/instances/" + data.params.lid + "/ips", displayNetInfo, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();