Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
31
images/edit/edit.css
Normal file
31
images/edit/edit.css
Normal 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');
|
||||
|
||||
#edit {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
table:first-of-type tbody tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
tbody tr:last-of-type {
|
||||
border: none;
|
||||
}
|
111
images/edit/edit.js
Normal file
111
images/edit/edit.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, regionNames, apiGet, apiPut, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.created = "created";
|
||||
elements.description = "description";
|
||||
elements.imageLabel = "image-label";
|
||||
elements.label = "label";
|
||||
elements.nav = "navlink";
|
||||
elements.navActive = "navlink-active";
|
||||
elements.saveButton = "save-button";
|
||||
elements.size = "size";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.created = {};
|
||||
ui.description = {};
|
||||
ui.imageLabel = {};
|
||||
ui.label = {};
|
||||
ui.saveButton = {};
|
||||
ui.size = {};
|
||||
|
||||
// Callback for image API call
|
||||
var displayImage = function(response)
|
||||
{
|
||||
ui.imageLabel.innerHTML = response.label;
|
||||
ui.label.value = response.label;
|
||||
var createDate = new Date(response.created + "Z");
|
||||
ui.created.innerHTML = createDate.toLocaleString();
|
||||
ui.size.innerHTML = response.size;
|
||||
ui.description.value = response.description;
|
||||
ui.saveButton.disabled = false;
|
||||
};
|
||||
|
||||
// Handler for save button
|
||||
var handleSave = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"label": ui.label.value,
|
||||
"description": ui.description.value
|
||||
};
|
||||
|
||||
apiPut("/images/" + data.params.iid, req, function(response)
|
||||
{
|
||||
location.href = "/images";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
// We need an image ID, so die if we don't have it
|
||||
if (!data.params.iid) {
|
||||
alert("No image ID supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Highlight the Linodes nav link
|
||||
var navLinks = document.getElementsByClassName(elements.nav);
|
||||
for (var i = 0; i < navLinks.length; i++) {
|
||||
if (navLinks[i].pathname == "/linodes/")
|
||||
navLinks[i].className = elements.navActive;
|
||||
}
|
||||
|
||||
// Get element references
|
||||
ui.created = document.getElementById(elements.created);
|
||||
ui.description = document.getElementById(elements.description);
|
||||
ui.imageLabel = document.getElementById(elements.imageLabel);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
ui.saveButton = document.getElementById(elements.saveButton);
|
||||
ui.size = document.getElementById(elements.size);
|
||||
|
||||
// Attach event handlers
|
||||
ui.saveButton.addEventListener("click", handleSave);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/images/" + data.params.iid, displayImage, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
68
images/edit/index.shtml
Normal file
68
images/edit/index.shtml
Normal 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 - Edit Image</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="edit.css" />
|
||||
<script src="edit.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="top-links"><a href="/linodes">Linodes</a> » <a href="/images">Images</a> » <span id="image-label" class="top-links-title"></span></div>
|
||||
<div id="edit">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Image</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Label</td>
|
||||
<td><input id="label" type="text" size="69" /></td>
|
||||
<td><span class="info">See also: <a href="https://www.linode.com/docs/platform/linode-images" target="_blank">Using Linode Images</a></span></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Created</td>
|
||||
<td id="created"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Size</td>
|
||||
<td><span id="size"></span> MB</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Description</td>
|
||||
<td><textarea id="description" rows="4" cols="78"></textarea></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td><button disabled id="save-button" type="button">Save Changes</button></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user