Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
98
linodes/add/add.css
Normal file
98
linodes/add/add.css
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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');
|
||||
|
||||
#add-button {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 0 auto;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#datacenters {
|
||||
font-size: 18px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.instance-category {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.instance-category p {
|
||||
color: #808080;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.instance-type {
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #DDD;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
width: 135px;
|
||||
}
|
||||
|
||||
.instance-type h3 {
|
||||
border-bottom: 1px solid #D4D4D4;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.instance-type p {
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
margin: 10px 0px 0px 0px;
|
||||
}
|
||||
|
||||
.instance-type-active {
|
||||
background-color: #5FABFF;
|
||||
}
|
||||
|
||||
.instance-type-active p {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#instances {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
#location {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
#right-links {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#submit {
|
||||
padding: 15px;
|
||||
}
|
151
linodes/add/add.js
Normal file
151
linodes/add/add.js
Normal file
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.addButton = "add-button";
|
||||
elements.datacenters = "datacenters";
|
||||
elements.instanceType = "instance-type";
|
||||
elements.instanceTypeActive = "instance-type-active";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
data.params = {};
|
||||
data.linodeTypes = [];
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.datacenters = {};
|
||||
|
||||
var createLinodeTypeButton = function(type)
|
||||
{
|
||||
var typeButton = document.createElement("div");
|
||||
typeButton.id = type.id;
|
||||
typeButton.className = elements.instanceType;
|
||||
var label = document.createElement("h3");
|
||||
label.innerHTML = type.label;
|
||||
var storage = document.createElement("p");
|
||||
storage.innerHTML = (type.disk / 1024) + "GB Storage";
|
||||
var cpu = document.createElement("p");
|
||||
cpu.innerHTML = type.vcpus + " CPU Core";
|
||||
if (type.vcpus > 1)
|
||||
cpu.innerHTML = cpu.innerHTML + "s";
|
||||
var transfer = document.createElement("p");
|
||||
transfer.innerHTML = type.transfer + "GB XFER";
|
||||
var cost = document.createElement("p");
|
||||
cost.innerHTML = "$" + type.price.monthly + "/mo or (" + type.price.hourly + "/hr)";
|
||||
typeButton.appendChild(label);
|
||||
typeButton.appendChild(storage);
|
||||
typeButton.appendChild(cpu);
|
||||
typeButton.appendChild(transfer);
|
||||
typeButton.appendChild(cost);
|
||||
typeButton.addEventListener("click", handleTypeButtonClick);
|
||||
|
||||
var list = document.getElementById(type["class"]);
|
||||
list.appendChild(typeButton);
|
||||
};
|
||||
|
||||
var displayRegions = function(response)
|
||||
{
|
||||
for (var i = 0; i < response.data.length; i++) {
|
||||
var dc = document.createElement("option");
|
||||
dc.value = response.data[i].id;
|
||||
if (regionNames[response.data[i].id])
|
||||
dc.innerHTML = regionNames[response.data[i].id];
|
||||
else
|
||||
dc.innerHTML = response.data[i].id;
|
||||
ui.datacenters.appendChild(dc);
|
||||
}
|
||||
|
||||
// Request the next page if there are more pages
|
||||
if (response.page != response.pages)
|
||||
apiGet("/regions?page=" + (response.page + 1), displayRegions, null);
|
||||
};
|
||||
|
||||
var displayTypes = function(response)
|
||||
{
|
||||
// Add types to array
|
||||
data.linodeTypes = data.linodeTypes.concat(response.data);
|
||||
|
||||
// Request the next page if there are more pages
|
||||
if (response.page != response.pages) {
|
||||
apiGet("/linode/types?page=" + (response.page + 1), displayTypes, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert types
|
||||
for (var i = 0; i < data.linodeTypes.length; i++)
|
||||
createLinodeTypeButton(data.linodeTypes[i]);
|
||||
};
|
||||
|
||||
var handleAddLinode = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var selectedPlan = document.getElementsByClassName(elements.instanceTypeActive);
|
||||
if (selectedPlan.length == 0) {
|
||||
alert("You must select a plan.");
|
||||
return;
|
||||
}
|
||||
|
||||
var request = {
|
||||
"type": selectedPlan[0].id,
|
||||
"region": ui.datacenters.value
|
||||
};
|
||||
if (data.params.tag)
|
||||
request.tags = [data.params.tag];
|
||||
apiPost("/linode/instances", request, function(response)
|
||||
{
|
||||
location.href = "/linodes/dashboard?lid=" + response.id;
|
||||
});
|
||||
};
|
||||
|
||||
var handleTypeButtonClick = function(event)
|
||||
{
|
||||
// Deselect any selected plans
|
||||
var selected = document.getElementsByClassName(elements.instanceTypeActive);
|
||||
for (var i = 0; i < selected.length; i++)
|
||||
selected[i].className = selected[i].className.replace(elements.instanceTypeActive, "");
|
||||
|
||||
// Select the clicked plan
|
||||
event.currentTarget.className += " " + elements.instanceTypeActive;
|
||||
};
|
||||
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
ui.datacenters = document.getElementById(elements.datacenters);
|
||||
|
||||
// Register add button handler
|
||||
document.getElementById(elements.addButton).addEventListener("click", handleAddLinode);
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get linode types and regions
|
||||
apiGet("/linode/types", displayTypes, null);
|
||||
apiGet("/regions", displayRegions, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
70
linodes/add/index.shtml
Normal file
70
linodes/add/index.shtml
Normal file
@ -0,0 +1,70 @@
|
||||
<!--
|
||||
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 - Add a Linode</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="add.css" />
|
||||
<script src="add.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="top-links">
|
||||
<span id="left-links"><a href="/linodes">Linodes</a> » <strong>Add a Linode</strong></span>
|
||||
<span id="right-links"><a href="/volumes">Manage Volumes</a> | <a href="/images">Manage Images</a> | <a href="/stackscripts">Manage StackScripts</a></span>
|
||||
</div>
|
||||
<div id="instances">
|
||||
<h2>Select an instance type</h2>
|
||||
<div class="instance-category">
|
||||
<h3>Nanode Instances</h3>
|
||||
<p>Nanode instances are good for low-duty workloads, where performance isn't critical.</p>
|
||||
<div id="nanode"></div>
|
||||
</div>
|
||||
<div class="instance-category">
|
||||
<h3>Standard Instances</h3>
|
||||
<p>Standard instances are good for medium-duty workloads and are a good mix of performance, resources, and price.</p>
|
||||
<div id="standard"></div>
|
||||
</div>
|
||||
<div class="instance-category">
|
||||
<h3>Dedicated CPU Instances</h3>
|
||||
<p>Dedicated CPU instances are good for full-duty workloads where consistent performance is important.</p>
|
||||
<div id="dedicated"></div>
|
||||
</div>
|
||||
<div class="instance-category">
|
||||
<h3>High Memory Instances</h3>
|
||||
<p>High Memory instances favor RAM over other resources, and can be good for memory hungry use cases like caching and in-memory databases.</p>
|
||||
<div id="highmem"></div>
|
||||
</div>
|
||||
<div class="instance-category">
|
||||
<h3>GPU Instances</h3>
|
||||
<p>Linodes with dedicated GPUs accelerate highly specialized applications such as machine learning, AI, and video transcoding.</p>
|
||||
<div id="gpu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="location">
|
||||
<h2>Location</h2>
|
||||
<select id="datacenters"></select>
|
||||
</div>
|
||||
<div id="submit">
|
||||
<button id="add-button" type="button">Add this Linode!</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user