Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
31
images/create/create.css
Normal file
31
images/create/create.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');
|
||||
|
||||
#create {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
tbody tr:last-of-type {
|
||||
border: none;
|
||||
}
|
||||
|
||||
tbody tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
155
images/create/create.js
Normal file
155
images/create/create.js
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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, apiPost, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.createButton = "create-button";
|
||||
elements.description = "description";
|
||||
elements.diskLabel = "disk-label";
|
||||
elements.label = "label";
|
||||
elements.linodeLabel = "linode-label";
|
||||
elements.linodeTag = "linode-tag";
|
||||
elements.linodeTagLink = "linode-tag-link";
|
||||
elements.nav = "navlink";
|
||||
elements.navActive = "navlink-active";
|
||||
elements.size = "size";
|
||||
elements.type = "type";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
data.disk = {};
|
||||
data.linode = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.createButton = {};
|
||||
ui.description = {};
|
||||
ui.diskLabel = {};
|
||||
ui.label = {};
|
||||
ui.linodeLabel = {};
|
||||
ui.linodeTag = {};
|
||||
ui.linodeTagLink = {};
|
||||
ui.size = {};
|
||||
ui.type = {};
|
||||
|
||||
// Create button handler
|
||||
var handleCreate = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"disk_id": data.disk.id,
|
||||
"label": ui.label.value
|
||||
};
|
||||
if (ui.description.value.length)
|
||||
req.description = ui.description.value;
|
||||
|
||||
apiPost("/images", req, function(response)
|
||||
{
|
||||
location.href = "/linodes/dashboard?lid=" + data.params.lid;
|
||||
});
|
||||
};
|
||||
|
||||
// Callback for linode details API call
|
||||
var displayDetails = function(response)
|
||||
{
|
||||
data.linode = response;
|
||||
|
||||
// Set page title and header stuff
|
||||
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 image API call
|
||||
var displayDisk = function(response)
|
||||
{
|
||||
data.disk = response;
|
||||
|
||||
// Display disk label in page header
|
||||
ui.diskLabel.innerHTML = data.disk.label;
|
||||
|
||||
// Fill in details
|
||||
ui.label.value = data.disk.label;
|
||||
ui.type.innerHTML = data.disk.filesystem;
|
||||
ui.size.innerHTML = data.disk.size;
|
||||
ui.createButton.disabled = false;
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
// We need an Linode ID, so die if we don't have it
|
||||
if (!data.params.lid) {
|
||||
alert("No Linode ID supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
// We also need a disk ID
|
||||
if (!data.params.did) {
|
||||
alert("No disk ID supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Update links on page to include proper Linode and disk IDs
|
||||
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);
|
||||
anchors[i].href = anchors[i].href.replace("did=0", "did=" + data.params.did);
|
||||
}
|
||||
|
||||
// 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.createButton = document.getElementById(elements.createButton);
|
||||
ui.description = document.getElementById(elements.description);
|
||||
ui.diskLabel = document.getElementById(elements.diskLabel);
|
||||
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.size = document.getElementById(elements.size);
|
||||
ui.type = document.getElementById(elements.type);
|
||||
|
||||
// Attach event handlers
|
||||
ui.createButton.addEventListener("click", handleCreate);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/linode/instances/" + data.params.lid, displayDetails, null);
|
||||
apiGet("/linode/instances/" + data.params.lid + "/disks/" + data.params.did, displayDisk, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
68
images/create/index.shtml
Normal file
68
images/create/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 - Create Image</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="create.css" />
|
||||
<script src="create.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> » <span id="linode-tag"><a id="linode-tag-link" href=""></a> » </span><a id="linode-label" href="/linodes/dashboard?lid=0"></a> » <a id="disk-label" href="/linodes/disk?did=0&lid=0"></a> » <span class="top-links-title">Imageize Disk Image</span></div>
|
||||
<div id="create">
|
||||
<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="50" /></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>Type</td>
|
||||
<td id="type"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Disk 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="create-button" type="button">Create Image</button></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
26
images/delete/delete.css
Normal file
26
images/delete/delete.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');
|
||||
|
||||
#delete {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
#label {
|
||||
font-weight: bold;
|
||||
}
|
85
images/delete/delete.js
Normal file
85
images/delete/delete.js
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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, apiDelete, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.deleteButton = "delete-button";
|
||||
elements.label = "label";
|
||||
elements.nav = "navlink";
|
||||
elements.navActive = "navlink-active";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.deleteButton = {};
|
||||
ui.label = {};
|
||||
|
||||
// Callback for image API call
|
||||
var displayImage = function(response)
|
||||
{
|
||||
ui.label.innerHTML = response.label;
|
||||
};
|
||||
|
||||
// Handler for delete button
|
||||
var handleDelete = function(event)
|
||||
{
|
||||
apiDelete("/images/" + data.params.iid, 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.deleteButton = document.getElementById(elements.deleteButton);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
|
||||
// Attach event handlers
|
||||
ui.deleteButton.addEventListener("click", handleDelete);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/images/" + data.params.iid, displayImage, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
36
images/delete/index.shtml
Normal file
36
images/delete/index.shtml
Normal file
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
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 - Delete Image</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="delete.css" />
|
||||
<script src="delete.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 class="top-links-title">Delete Image</span></div>
|
||||
<div id="delete">
|
||||
<p>Are you sure you want to delete the image <span id="label"></span>?</p>
|
||||
<button id="delete-button" type="button">Yes, delete this sucker</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
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>
|
26
images/images.css
Normal file
26
images/images.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');
|
||||
|
||||
table td:nth-of-type(6) {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#images {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
141
images/images.js
Normal file
141
images/images.js
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.lmcRow = "lmc-tr1";
|
||||
elements.lmcRowAlt = "lmc-tr2";
|
||||
elements.loading = "loading";
|
||||
elements.imageBody = "image-body";
|
||||
elements.nav = "navlink";
|
||||
elements.navActive = "navlink-active";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
data.images = [];
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.loading = {};
|
||||
ui.imageBody = {};
|
||||
|
||||
// Generates a table row for an image
|
||||
var createImageRow = function(image, alt)
|
||||
{
|
||||
var row = document.createElement("tr");
|
||||
if (alt)
|
||||
row.className = elements.lmcRowAlt;
|
||||
else
|
||||
row.className = elements.lmcRow;
|
||||
|
||||
var label = document.createElement("td");
|
||||
label.innerHTML = image.label;
|
||||
row.appendChild(label);
|
||||
|
||||
var size = document.createElement("td");
|
||||
size.innerHTML = image.size + " MB";
|
||||
row.appendChild(size);
|
||||
|
||||
var type = document.createElement("td");
|
||||
type.innerHTML = image.type;
|
||||
row.appendChild(type);
|
||||
|
||||
var created = document.createElement("td");
|
||||
var now = new Date();
|
||||
var createDate = new Date(image.created + "Z");
|
||||
created.innerHTML = timeString(now - createDate, true);
|
||||
row.appendChild(created);
|
||||
|
||||
var expires = document.createElement("td");
|
||||
if (image.expiry) {
|
||||
var expireDate = new Date(image.expiry + "Z");
|
||||
expires.innerHTML = timeString(now - expireDate, true);
|
||||
}
|
||||
row.appendChild(expires);
|
||||
|
||||
var options = document.createElement("td");
|
||||
var edit = document.createElement("a");
|
||||
edit.href = "/images/edit?iid=" + image.id;
|
||||
edit.innerHTML = "Edit";
|
||||
var separator = document.createElement("span");
|
||||
separator.innerHTML = " | ";
|
||||
var del = document.createElement("a");
|
||||
del.href = "/images/delete?iid=" + image.id;
|
||||
del.innerHTML = "Delete";
|
||||
options.appendChild(edit);
|
||||
options.appendChild(separator);
|
||||
options.appendChild(del);
|
||||
row.appendChild(options);
|
||||
|
||||
return row;
|
||||
};
|
||||
|
||||
// Callback for images API call
|
||||
var displayImages = function(response)
|
||||
{
|
||||
// Add images to array
|
||||
data.images = data.images.concat(response.data);
|
||||
|
||||
// Request
|
||||
if (response.page != response.pages) {
|
||||
var progress = (response.page / response.pages) * 100;
|
||||
progress = progress.toFixed(0);
|
||||
ui.loading.innerHTML = "Loading " + progress + "%...";
|
||||
var filter = {
|
||||
"vendor": null
|
||||
};
|
||||
apiGet("/images?page=" + (response.page + 1), displayImages, filter);
|
||||
}
|
||||
|
||||
// Insert images
|
||||
ui.loading.remove();
|
||||
for (var i = 0; i < data.images.length; i++)
|
||||
ui.imageBody.appendChild(createImageRow(data.images[i], i % 2));
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
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.loading = document.getElementById(elements.loading);
|
||||
ui.imageBody = document.getElementById(elements.imageBody);
|
||||
|
||||
// Get data from API
|
||||
var filter = {
|
||||
"vendor": null
|
||||
};
|
||||
apiGet("/images", displayImages, filter);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
51
images/index.shtml
Normal file
51
images/index.shtml
Normal file
@ -0,0 +1,51 @@
|
||||
<!--
|
||||
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 - Linode Images</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="images.css" />
|
||||
<script src="images.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> » <span class="top-links-title">Images</span></div>
|
||||
<div id="images">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Image</td>
|
||||
<td>Size</td>
|
||||
<td>Type</td>
|
||||
<td>Created</td>
|
||||
<td>Expires</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="image-body">
|
||||
<tr class="lmc-tr1">
|
||||
<td id="loading" colspan="6">Loading...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user