Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
49
linodes/ip_remove/index.shtml
Normal file
49
linodes/ip_remove/index.shtml
Normal file
@ -0,0 +1,49 @@
|
||||
<!--
|
||||
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 - IP Remove</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="ip_remove.css" />
|
||||
<script src="ip_remove.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">IP Remove</span></div>
|
||||
<div id="ip-remove">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td id="label" colspan="2"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IP Address</td>
|
||||
<td>Remove It</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ip-body"></tbody>
|
||||
</table>
|
||||
<button disabled id="remove-button" type="button">Remove Selected IPs</button>
|
||||
<p><strong>Note</strong>: The IP address selected will be immediately removed. This is not reversible.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
40
linodes/ip_remove/ip_remove.css
Normal file
40
linodes/ip_remove/ip_remove.css
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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');
|
||||
|
||||
button {
|
||||
display: block;
|
||||
margin: 10px 0 0 auto;
|
||||
}
|
||||
|
||||
#ip-remove {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
td:nth-of-type(1) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td:nth-of-type(2) {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
176
linodes/ip_remove/ip_remove.js
Normal file
176
linodes/ip_remove/ip_remove.js
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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, apiDelete, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.info = "info";
|
||||
elements.ipBody = "ip-body";
|
||||
elements.label = "label";
|
||||
elements.linodeLabel = "linode-label";
|
||||
elements.linodeTag = "linode-tag";
|
||||
elements.linodeTagLink = "linode-tag-link";
|
||||
elements.lmcRow = "lmc-tr1";
|
||||
elements.lmcRowAlt = "lmc-tr2";
|
||||
elements.removeBox = "remove-box";
|
||||
elements.removeButton = "remove-button";
|
||||
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.ipBody = {};
|
||||
ui.label = {};
|
||||
ui.linodeLabel = {};
|
||||
ui.linodeTag = {};
|
||||
ui.linodeTagLink = {};
|
||||
ui.removeButton = {};
|
||||
|
||||
// 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;
|
||||
ui.label.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)
|
||||
{
|
||||
// Insert public IPs into table
|
||||
for (var i = 0; i < response.ipv4["public"].length; i++) {
|
||||
var row = document.createElement("tr");
|
||||
if (i % 2)
|
||||
row.className = elements.lmcRowAlt;
|
||||
else
|
||||
row.className = elements.lmcRow;
|
||||
|
||||
var ipCell = document.createElement("td");
|
||||
var ip = document.createElement("span");
|
||||
ip.innerHTML = response.ipv4["public"][i].address;
|
||||
ipCell.appendChild(ip);
|
||||
if (response.ipv4["public"][i].rdns) {
|
||||
var br = document.createElement("br");
|
||||
var rdns = document.createElement("span");
|
||||
rdns.className = elements.info;
|
||||
rdns.innerHTML = response.ipv4["public"][i].rdns;
|
||||
ipCell.appendChild(br);
|
||||
ipCell.appendChild(rdns);
|
||||
}
|
||||
|
||||
var removeCell = document.createElement("td");
|
||||
var removeBox = document.createElement("input");
|
||||
removeBox.id = response.ipv4["public"][i].address;
|
||||
removeBox.className = elements.removeBox;
|
||||
removeBox.type = "checkbox";
|
||||
removeCell.appendChild(removeBox);
|
||||
|
||||
row.appendChild(ipCell);
|
||||
row.appendChild(removeCell);
|
||||
ui.ipBody.appendChild(row);
|
||||
}
|
||||
|
||||
ui.removeButton.disabled = false;
|
||||
};
|
||||
|
||||
// Event handler for remove button
|
||||
var handleRemove = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var ips = document.getElementsByClassName(elements.removeBox);
|
||||
state.numReqs = ips.length;
|
||||
state.numReturns = 0;
|
||||
|
||||
// Submit removal request for each IP
|
||||
for (var i = 0; i < ips.length; i++) {
|
||||
if (!ips[i].checked)
|
||||
continue;
|
||||
|
||||
apiDelete("/linode/instances/" + data.params.lid + "/ips/" + ips[i].id, 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.ipBody = document.getElementById(elements.ipBody);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
ui.linodeLabel = document.getElementById(elements.linodeLabel);
|
||||
ui.linodeTag = document.getElementById(elements.linodeTag);
|
||||
ui.linodeTagLink = document.getElementById(elements.linodeTagLink);
|
||||
ui.removeButton = document.getElementById(elements.removeButton);
|
||||
|
||||
// Attach event handlers
|
||||
ui.removeButton.addEventListener("click", handleRemove);
|
||||
|
||||
// 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);
|
||||
})();
|
Reference in New Issue
Block a user