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

31
volumes/clone/clone.css Normal file
View File

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

112
volumes/clone/clone.js Normal file
View File

@ -0,0 +1,112 @@
/*
* 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, apiPost, parseParams, regionNames, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.cloneButton = "clone-button";
elements.label = "label";
elements.location = "location";
elements.newLabel = "new-label";
elements.size = "size";
elements.volumeLabel = "volume-label";
// Data recieved from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.cloneButton = {};
ui.label = {};
ui.location = {};
ui.newLabel = {};
ui.size = {};
ui.volumeLabel = {};
// Callback for volume API call
var displayVolume = function(response)
{
// Set page title and header stuff
document.title += " // " + response.label;
ui.volumeLabel.innerHTML = response.label;
// Populate info table
ui.label.innerHTML = response.label;
ui.size.innerHTML = response.size;
if (regionNames[response.region])
ui.location.innerHTML = regionNames[response.region];
else
ui.location.innerHTML = response.region;
ui.cloneButton.disabled = false;
};
// Click handler for clone button
var handleClone = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"label": ui.newLabel.value
};
apiPost("/volumes/" + data.params.vid + "/clone", req, function(response)
{
location.href = "/volumes";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
// We need a volume ID, so die if we don't have it
if (!data.params.vid) {
alert("No volume ID supplied!");
return;
}
setupHeader();
// Update links on page to include proper volume ID
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++)
anchors[i].href = anchors[i].href.replace("vid=0", "vid=" + data.params.vid);
// Get element references
ui.cloneButton = document.getElementById(elements.cloneButton);
ui.label = document.getElementById(elements.label);
ui.location = document.getElementById(elements.location);
ui.newLabel = document.getElementById(elements.newLabel);
ui.size = document.getElementById(elements.size);
ui.volumeLabel = document.getElementById(elements.volumeLabel);
// Attach event handlers
ui.cloneButton.addEventListener("click", handleClone);
// Get data from API
apiGet("/volumes/" + data.params.vid, displayVolume, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

68
volumes/clone/index.shtml Normal file
View File

@ -0,0 +1,68 @@
<!--
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 - Clone a Volume</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="clone.css" />
<script src="clone.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<div id="main-content" class="wrapper">
<div id="top-links"><a href="/volumes">Volumes</a> » <a id="volume-label" href="/volumes/settings?vid=0"></a> » <span class="top-links-title">Clone a Volume</span></div>
<div id="clone">
<table class="lmc-table">
<thead>
<tr>
<td colspan="3">Clone a Volume</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Volume being cloned</td>
<td id="label"></td>
<td></td>
</tr>
<tr class="lmc-tr3">
<td>Size</td>
<td><span id="size"></span> GiB</td>
<td class="info">The size of the new volume</td>
</tr>
<tr class="lmc-tr3">
<td>Location</td>
<td id="location"></td>
<td class="info">The datacenter where the new clone will be created</td>
</tr>
<tr class="lmc-tr3">
<td>Label for newly cloned volume</td>
<td><input id="new-label" type="text" /></td>
<td></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button disabled id="clone-button" type="button">Clone this Volume!</button></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>