Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
26
volumes/detach/detach.css
Normal file
26
volumes/detach/detach.css
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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');
|
||||
|
||||
#detach {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
#label {
|
||||
font-weight: bold;
|
||||
}
|
111
volumes/detach/detach.js
Normal file
111
volumes/detach/detach.js
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.detachButton = "detach-button";
|
||||
elements.label = "label";
|
||||
elements.linodeLabel = "linode-label";
|
||||
elements.volumeLabel = "volume-label";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
data.volume = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.detachButton = {};
|
||||
ui.label = {};
|
||||
ui.linodeLabel = {};
|
||||
ui.volumeLabel = {};
|
||||
|
||||
// Callback for attached linode API call
|
||||
var displayLinode = function(response)
|
||||
{
|
||||
ui.linodeLabel.innerHTML = response.label;
|
||||
ui.detachButton.disabled = false;
|
||||
};
|
||||
|
||||
// Callback for volume API call
|
||||
var displayVolume = function(response)
|
||||
{
|
||||
data.volume = response;
|
||||
|
||||
// Redirect to settings if unattached
|
||||
if (!data.volume.linode_id)
|
||||
location.href = "/volumes/settings?vid=" + data.params.vid;
|
||||
|
||||
// Set page title and header stuff
|
||||
document.title += " // " + data.volume.label;
|
||||
ui.volumeLabel.innerHTML = data.volume.label;
|
||||
ui.label.innerHTML = data.volume.label;
|
||||
ui.linodeLabel.href = "/linodes/dashboard?lid=" + data.volume.linode_id;
|
||||
|
||||
// Get linode info
|
||||
apiGet("/linode/instances/" + data.volume.linode_id, displayLinode, null);
|
||||
};
|
||||
|
||||
// Click handler for detach button
|
||||
var handleDetach = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
apiPost("/volumes/" + data.params.vid + "/detach", {}, function(response)
|
||||
{
|
||||
location.href = "/linodes/dashboard?lid=" + data.volume.linode_id;
|
||||
});
|
||||
};
|
||||
|
||||
// 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.detachButton = document.getElementById(elements.detachButton);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
ui.linodeLabel = document.getElementById(elements.linodeLabel);
|
||||
ui.volumeLabel = document.getElementById(elements.volumeLabel);
|
||||
|
||||
// Attach event handlers
|
||||
ui.detachButton.addEventListener("click", handleDetach);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/volumes/" + data.params.vid, displayVolume, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
37
volumes/detach/index.shtml
Normal file
37
volumes/detach/index.shtml
Normal file
@ -0,0 +1,37 @@
|
||||
<!--
|
||||
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 - Detach Volume</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="detach.css" />
|
||||
<script src="detach.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">Detach Volume</span></div>
|
||||
<div id="detach">
|
||||
<p>The "<span id="label"></span>" volume will be detached from the <a id="linode-label"></a> Linode.</p>
|
||||
<p>It will be removed from all config profiles.</p>
|
||||
<button disabled id="detach-button" type="button">Detach</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user