Compare commits
No commits in common. "b1f190d65a5f52916914170d9fbc6393a8eed404" and "4c4db6a734df0172d6289d4a6923fdc09d3f6784" have entirely different histories.
b1f190d65a
...
4c4db6a734
62
global.js
62
global.js
@ -35,38 +35,36 @@ var elements = {
|
|||||||
"username": "username"
|
"username": "username"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Region names for legacy DCs no longer in the API
|
// Regions (Linode doesn't provide "friendly" names via the API)
|
||||||
var regionNames = {
|
var regionNames = {
|
||||||
"us-east-1b": "Newark 2, NJ",
|
"us-central": "Dallas, TX, USA",
|
||||||
"philadelphia": "Philadelphia, PA",
|
"us-west": "Fremont, CA, USA",
|
||||||
"absecon": "Absecon, NJ"
|
"us-southeast": "Atlanta, GA, USA",
|
||||||
};
|
"us-east": "Newark, NJ, USA",
|
||||||
|
"us-east-1b": "Newark 2, NJ, USA",
|
||||||
// Group contries into regions for easier selection
|
"eu-west": "London, England, UK",
|
||||||
var countryContinents = {
|
"ap-south": "Singapore, SG",
|
||||||
"us": "na",
|
"eu-central": "Frankfurt, DE",
|
||||||
"gb": "eu",
|
"ap-northeast": "Tokyo, JP",
|
||||||
"jp": "ap",
|
"ap-northeast-1a": "Tokyo 2, JP",
|
||||||
"sg": "ap",
|
"ca-central": "Toronto, ON, CA",
|
||||||
"de": "eu",
|
"ap-west": "Mumbai, IN",
|
||||||
"in": "ap",
|
"ap-southeast": "Sydney, NSW, AU",
|
||||||
"ca": "na",
|
"philadelphia": "Philadelphia, PA, USA",
|
||||||
"au": "ap",
|
"absecon": "Absecon, NJ, USA",
|
||||||
"fr": "eu",
|
"us-iad": "Washington DC, USA",
|
||||||
"br": "sa",
|
"us-ord": "Chicago, IL, USA",
|
||||||
"nl": "eu",
|
"fr-par": "Paris, FR",
|
||||||
"se": "eu",
|
"in-maa": "Chennai, IN",
|
||||||
"es": "eu",
|
"us-sea": "Seattle, WA, USA",
|
||||||
"it": "eu",
|
"br-gru": "San Paulo, BR",
|
||||||
"id": "ap",
|
"nl-ams": "Amsterdam, NL",
|
||||||
"nz": "ap",
|
"se-sto": "Stockholm, SE",
|
||||||
"pl": "eu",
|
"jp-osa": "Osaka, JP",
|
||||||
"za": "af",
|
"it-mil": "Milan, IT",
|
||||||
"my": "ap",
|
"id-cgk": "Jakarta, ID",
|
||||||
"hk": "ap",
|
"us-lax": "Los Angeles, CA, USA",
|
||||||
"co": "sa",
|
"us-mia": "Miami, FL, USA"
|
||||||
"mx": "na",
|
|
||||||
"cl": "sa"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Human-readable event titles
|
// Human-readable event titles
|
||||||
@ -864,4 +862,4 @@ function translateKernel(slug, element)
|
|||||||
apiGet("/linode/kernels/" + slug, callback, null);
|
apiGet("/linode/kernels/" + slug, callback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { settings, elements, regionNames, countryContinents, apiDelete, apiGet, apiPost, apiPut, drawSeries, md5, migrateETA, oauthPost, oauthScopes, objPut, parseParams, setupHeader, eventTitles, timeString, translateKernel };
|
export { settings, elements, regionNames, apiDelete, apiGet, apiPost, apiPut, drawSeries, md5, migrateETA, oauthPost, oauthScopes, objPut, parseParams, setupHeader, eventTitles, timeString, translateKernel };
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, apiPost, parseParams, setupHeader, timeString } from "/global.js";
|
import { settings, elements, regionNames, apiGet, apiPost, parseParams, setupHeader, timeString } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, apiDelete, parseParams, setupHeader, timeString } from "/global.js";
|
import { settings, elements, regionNames, apiGet, apiDelete, parseParams, setupHeader, timeString } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, apiPut, parseParams, setupHeader, timeString } from "/global.js";
|
import { settings, elements, regionNames, apiGet, apiPut, parseParams, setupHeader, timeString } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, parseParams, setupHeader, timeString } from "/global.js";
|
import { settings, elements, regionNames, apiGet, parseParams, setupHeader, timeString } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
|
@ -46,14 +46,7 @@ along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="lmc-tr3">
|
<tr class="lmc-tr3">
|
||||||
<td>Region</td>
|
<td>Region</td>
|
||||||
<td><select id="region">
|
<td><select id="region"></select></td>
|
||||||
<optgroup id="na" label="North America"></optgroup>
|
|
||||||
<optgroup id="eu" label="Europe"></optgroup>
|
|
||||||
<optgroup id="ap" label="Asia/Pacific"></optgroup>
|
|
||||||
<optgroup id="sa" label="South America"></optgroup>
|
|
||||||
<optgroup id="af" label="Africa"></optgroup>
|
|
||||||
<optgroup id="dc-other" label="Other"></optgroup>
|
|
||||||
</select></td>
|
|
||||||
<td class="info">
|
<td class="info">
|
||||||
For fastest initial upload, select the region that is geographically closest to you.<br />
|
For fastest initial upload, select the region that is geographically closest to you.<br />
|
||||||
Once uploaded you will be able to deploy the image to other regions.
|
Once uploaded you will be able to deploy the image to other regions.
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
|
|
||||||
@import url('/global.css');
|
@import url('/global.css');
|
||||||
|
|
||||||
optgroup {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-2 {
|
.step-2 {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, regionNames, countryContinents, apiGet, apiPost, objPut, parseParams, setupHeader } from "/global.js";
|
import { settings, elements, regionNames, apiGet, apiPost, objPut, parseParams, setupHeader } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
// Element names specific to this page
|
// Element names specific to this page
|
||||||
elements.dcOther = "dc-other";
|
|
||||||
elements.description = "description";
|
elements.description = "description";
|
||||||
elements.imageFile = "image-file";
|
elements.imageFile = "image-file";
|
||||||
elements.label = "label";
|
elements.label = "label";
|
||||||
@ -36,7 +35,6 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, ob
|
|||||||
|
|
||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
var ui = {};
|
var ui = {};
|
||||||
ui.dcOther = {};
|
|
||||||
ui.description = {};
|
ui.description = {};
|
||||||
ui.imageFile = {};
|
ui.imageFile = {};
|
||||||
ui.label = {};
|
ui.label = {};
|
||||||
@ -51,19 +49,11 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, ob
|
|||||||
for (var i = 0; i < response.data.length; i++) {
|
for (var i = 0; i < response.data.length; i++) {
|
||||||
var dc = document.createElement("option");
|
var dc = document.createElement("option");
|
||||||
dc.value = response.data[i].id;
|
dc.value = response.data[i].id;
|
||||||
if (response.data[i].label && response.data[i].label.length)
|
if (regionNames[response.data[i].id])
|
||||||
dc.innerHTML = response.data[i].label;
|
|
||||||
else if (regionNames[response.data[i].id])
|
|
||||||
dc.innerHTML = regionNames[response.data[i].id];
|
dc.innerHTML = regionNames[response.data[i].id];
|
||||||
else
|
else
|
||||||
dc.innerHTML = response.data[i].id;
|
dc.innerHTML = response.data[i].id;
|
||||||
var optgroup = null;
|
ui.region.appendChild(dc);
|
||||||
if (countryContinents[response.data[i].country])
|
|
||||||
optgroup = document.getElementById(countryContinents[response.data[i].country]);
|
|
||||||
if (!optgroup)
|
|
||||||
optgroup = ui.dcOther;
|
|
||||||
optgroup.style.display = "initial";
|
|
||||||
optgroup.appendChild(dc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.nextButton.disabled = false;
|
ui.nextButton.disabled = false;
|
||||||
@ -136,7 +126,6 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, ob
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get element references
|
// Get element references
|
||||||
ui.dcOther = document.getElementById(elements.dcOther);
|
|
||||||
ui.description = document.getElementById(elements.description);
|
ui.description = document.getElementById(elements.description);
|
||||||
ui.imageFile = document.getElementById(elements.imageFile);
|
ui.imageFile = document.getElementById(elements.imageFile);
|
||||||
ui.label = document.getElementById(elements.label);
|
ui.label = document.getElementById(elements.label);
|
||||||
|
@ -89,10 +89,6 @@ h3 {
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
optgroup {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#right-links {
|
#right-links {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, regionNames, countryContinents, apiGet, apiPost, parseParams, setupHeader } from "/global.js";
|
import { settings, elements, regionNames, apiGet, apiPost, parseParams, setupHeader } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
// Element names specific to this page
|
// Element names specific to this page
|
||||||
elements.addButton = "add-button";
|
elements.addButton = "add-button";
|
||||||
elements.datacenters = "datacenters";
|
elements.datacenters = "datacenters";
|
||||||
elements.dcOther = "dc-other";
|
|
||||||
elements.instanceType = "instance-type";
|
elements.instanceType = "instance-type";
|
||||||
elements.instanceTypeActive = "instance-type-active";
|
elements.instanceTypeActive = "instance-type-active";
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, pa
|
|||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
var ui = {};
|
var ui = {};
|
||||||
ui.datacenters = {};
|
ui.datacenters = {};
|
||||||
ui.dcOther = {};
|
|
||||||
|
|
||||||
var createLinodeTypeButton = function(type)
|
var createLinodeTypeButton = function(type)
|
||||||
{
|
{
|
||||||
@ -69,26 +67,16 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, pa
|
|||||||
for (var i = 0; i < response.data.length; i++) {
|
for (var i = 0; i < response.data.length; i++) {
|
||||||
var dc = document.createElement("option");
|
var dc = document.createElement("option");
|
||||||
dc.value = response.data[i].id;
|
dc.value = response.data[i].id;
|
||||||
if (response.data[i].label && response.data[i].label.length)
|
if (regionNames[response.data[i].id])
|
||||||
dc.innerHTML = response.data[i].label;
|
|
||||||
else if (regionNames[response.data[i].id])
|
|
||||||
dc.innerHTML = regionNames[response.data[i].id];
|
dc.innerHTML = regionNames[response.data[i].id];
|
||||||
else
|
else
|
||||||
dc.innerHTML = response.data[i].id;
|
dc.innerHTML = response.data[i].id;
|
||||||
var optgroup = null;
|
ui.datacenters.appendChild(dc);
|
||||||
if (countryContinents[response.data[i].country])
|
|
||||||
optgroup = document.getElementById(countryContinents[response.data[i].country]);
|
|
||||||
if (!optgroup)
|
|
||||||
optgroup = ui.dcOther;
|
|
||||||
optgroup.style.display = "initial";
|
|
||||||
optgroup.appendChild(dc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request the next page if there are more pages
|
// Request the next page if there are more pages
|
||||||
if (response.page != response.pages) {
|
if (response.page != response.pages)
|
||||||
apiGet("/regions?page=" + (response.page + 1), displayRegions, null);
|
apiGet("/regions?page=" + (response.page + 1), displayRegions, null);
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var displayTypes = function(response)
|
var displayTypes = function(response)
|
||||||
@ -147,7 +135,6 @@ import { settings, elements, regionNames, countryContinents, apiGet, apiPost, pa
|
|||||||
data.params = parseParams();
|
data.params = parseParams();
|
||||||
|
|
||||||
ui.datacenters = document.getElementById(elements.datacenters);
|
ui.datacenters = document.getElementById(elements.datacenters);
|
||||||
ui.dcOther = document.getElementById(elements.dcOther);
|
|
||||||
|
|
||||||
// Register add button handler
|
// Register add button handler
|
||||||
document.getElementById(elements.addButton).addEventListener("click", handleAddLinode);
|
document.getElementById(elements.addButton).addEventListener("click", handleAddLinode);
|
||||||
|
@ -65,14 +65,7 @@ along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
</div>
|
</div>
|
||||||
<div id="location">
|
<div id="location">
|
||||||
<h2>Location</h2>
|
<h2>Location</h2>
|
||||||
<select id="datacenters">
|
<select id="datacenters"></select>
|
||||||
<optgroup id="na" label="North America"></optgroup>
|
|
||||||
<optgroup id="eu" label="Europe"></optgroup>
|
|
||||||
<optgroup id="ap" label="Asia/Pacific"></optgroup>
|
|
||||||
<optgroup id="sa" label="South America"></optgroup>
|
|
||||||
<optgroup id="af" label="Africa"></optgroup>
|
|
||||||
<optgroup id="dc-other" label="Other"></optgroup>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="submit">
|
<div id="submit">
|
||||||
<button id="add-button" type="button">Add this Linode!</button>
|
<button id="add-button" type="button">Add this Linode!</button>
|
||||||
|
@ -50,7 +50,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
data.backup = {};
|
data.backup = {};
|
||||||
data.linode = {};
|
data.linode = {};
|
||||||
data.linodes = [];
|
data.linodes = [];
|
||||||
data.region = {};
|
|
||||||
data.types = [];
|
data.types = [];
|
||||||
|
|
||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
@ -90,7 +89,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
|
|
||||||
var plan = document.createElement("td");
|
var plan = document.createElement("td");
|
||||||
if (linode.type) {
|
if (linode.type) {
|
||||||
plan.innerHTML = linode.type;
|
|
||||||
for (var i = 0; i < data.types.length; i++) {
|
for (var i = 0; i < data.types.length; i++) {
|
||||||
if (data.types[i].id == linode.type) {
|
if (data.types[i].id == linode.type) {
|
||||||
plan.innerHTML = data.types[i].label;
|
plan.innerHTML = data.types[i].label;
|
||||||
@ -105,9 +103,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
row.appendChild(plan);
|
row.appendChild(plan);
|
||||||
|
|
||||||
var location = document.createElement("td");
|
var location = document.createElement("td");
|
||||||
if (data.region.label && data.region.label.length)
|
if (regionNames[linode.region])
|
||||||
location.innerHTML = data.region.label;
|
|
||||||
else if (regionNames[linode.region])
|
|
||||||
location.innerHTML = regionNames[linode.region];
|
location.innerHTML = regionNames[linode.region];
|
||||||
else
|
else
|
||||||
location.innerHTML = linode.region;
|
location.innerHTML = linode.region;
|
||||||
@ -140,15 +136,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
|
|
||||||
ui.backupType.innerHTML = data.backup.type;
|
ui.backupType.innerHTML = data.backup.type;
|
||||||
|
|
||||||
if (regionNames[data.backup.region]) {
|
|
||||||
ui.backupLocation.innerHTML = regionNames[data.backup.region];
|
|
||||||
ui.destLocation.innerHTML = regionNames[data.backup.region];
|
|
||||||
} else {
|
|
||||||
ui.backupLocation.innerHTML = data.backup.region;
|
|
||||||
ui.destLocation.innerHTML = data.backup.region;
|
|
||||||
}
|
|
||||||
apiGet("/regions/" + data.backup.region, displayRegion, null);
|
|
||||||
|
|
||||||
for (var i = 0; i < data.backup.configs.length; i++) {
|
for (var i = 0; i < data.backup.configs.length; i++) {
|
||||||
var li = document.createElement("li");
|
var li = document.createElement("li");
|
||||||
li.innerHTML = data.backup.configs[i];
|
li.innerHTML = data.backup.configs[i];
|
||||||
@ -165,7 +152,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
|
|
||||||
ui.backupSize.innerHTML = data.backup.totalSize + " MB";
|
ui.backupSize.innerHTML = data.backup.totalSize + " MB";
|
||||||
|
|
||||||
if (state.haveTypes)
|
if (state.haveTypes && data.linode.id)
|
||||||
insertTypes();
|
insertTypes();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,6 +169,18 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
ui.linodeTagLink.innerHTML = "(" + data.linode.tags[0] + ")";
|
ui.linodeTagLink.innerHTML = "(" + data.linode.tags[0] + ")";
|
||||||
ui.linodeTag.style.display = "inline";
|
ui.linodeTag.style.display = "inline";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display location
|
||||||
|
if (regionNames[data.linode.region]) {
|
||||||
|
ui.backupLocation.innerHTML = regionNames[data.linode.region];
|
||||||
|
ui.destLocation.innerHTML = regionNames[data.linode.region];
|
||||||
|
} else {
|
||||||
|
ui.backupLocation.innerHTML = data.linode.region;
|
||||||
|
ui.destLocation.innerHTML = data.linode.region;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.haveTypes && data.backup.id)
|
||||||
|
insertTypes();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback for linode disks API call
|
// Callback for linode disks API call
|
||||||
@ -239,7 +238,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
// Request the next page if there are more pages
|
// Request the next page if there are more pages
|
||||||
if (response.page != response.pages) {
|
if (response.page != response.pages) {
|
||||||
var filter = {
|
var filter = {
|
||||||
"region": data.backup.region
|
"region": data.linode.region
|
||||||
};
|
};
|
||||||
apiGet("/linode/instances?page=" + (response.page + 1), displayLinodes, filter);
|
apiGet("/linode/instances?page=" + (response.page + 1), displayLinodes, filter);
|
||||||
return;
|
return;
|
||||||
@ -255,17 +254,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback for region API call
|
|
||||||
var displayRegion = function(response)
|
|
||||||
{
|
|
||||||
data.region = response;
|
|
||||||
|
|
||||||
if (data.region.label && data.region.label.length) {
|
|
||||||
ui.backupLocation.innerHTML = response.label;
|
|
||||||
ui.destLocation.innerHTML = response.label;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback for linode types API call
|
// Callback for linode types API call
|
||||||
var displayTypes = function(response)
|
var displayTypes = function(response)
|
||||||
{
|
{
|
||||||
@ -279,7 +267,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.haveTypes = true;
|
state.haveTypes = true;
|
||||||
if (data.backup.id)
|
if (data.backup.id && data.linode.id)
|
||||||
insertTypes();
|
insertTypes();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -307,7 +295,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
var req = {
|
var req = {
|
||||||
"label": ui.destLabel.value,
|
"label": ui.destLabel.value,
|
||||||
"type": ui.destPlan.value,
|
"type": ui.destPlan.value,
|
||||||
"region": data.backup.region,
|
"region": data.linode.region,
|
||||||
"backup_id": data.backup.id
|
"backup_id": data.backup.id
|
||||||
};
|
};
|
||||||
var callback = function(response)
|
var callback = function(response)
|
||||||
@ -360,11 +348,11 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
ui.destPlan.appendChild(option);
|
ui.destPlan.appendChild(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSpace(null);
|
updatePrice(null);
|
||||||
ui.newLinode.disabled = false;
|
ui.newLinode.disabled = false;
|
||||||
|
|
||||||
var filter = {
|
var filter = {
|
||||||
"region": data.backup.region
|
"region": data.linode.region
|
||||||
};
|
};
|
||||||
apiGet("/linode/instances", displayLinodes, filter);
|
apiGet("/linode/instances", displayLinodes, filter);
|
||||||
};
|
};
|
||||||
@ -422,7 +410,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
ui.newLinode = document.getElementById(elements.newLinode);
|
ui.newLinode = document.getElementById(elements.newLinode);
|
||||||
|
|
||||||
// Register event handlers
|
// Register event handlers
|
||||||
ui.destPlan.addEventListener("input", updateSpace);
|
ui.destPlan.addEventListener("input", updatePrice);
|
||||||
ui.newLinode.addEventListener("click", handleCreate);
|
ui.newLinode.addEventListener("click", handleCreate);
|
||||||
|
|
||||||
// Get data from API
|
// Get data from API
|
||||||
@ -443,7 +431,7 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Update the price display
|
// Update the price display
|
||||||
var updateSpace = function(event)
|
var updatePrice = function(event)
|
||||||
{
|
{
|
||||||
// Find the selected type
|
// Find the selected type
|
||||||
var type = null;
|
var type = null;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, parseParams, regionNames, setupHeader, translateKernel } from "/global.js";
|
import { settings, elements, apiGet, apiPost, migrateETA, parseParams, regionNames, setupHeader, translateKernel } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
@ -25,7 +25,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
elements.configDiskRow = "config-disk-row";
|
elements.configDiskRow = "config-disk-row";
|
||||||
elements.configsNone = "configs-none";
|
elements.configsNone = "configs-none";
|
||||||
elements.configTable = "config-table-body";
|
elements.configTable = "config-table-body";
|
||||||
elements.dcOther = "dc-other";
|
|
||||||
elements.destBackups = "dest-backups";
|
elements.destBackups = "dest-backups";
|
||||||
elements.destBackupsPrice = "dest-backups-price";
|
elements.destBackupsPrice = "dest-backups-price";
|
||||||
elements.destLabel = "dest-label";
|
elements.destLabel = "dest-label";
|
||||||
@ -55,7 +54,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
data.configs = [];
|
data.configs = [];
|
||||||
data.disks = [];
|
data.disks = [];
|
||||||
data.linode = {};
|
data.linode = {};
|
||||||
data.regions = [];
|
|
||||||
data.types = [];
|
data.types = [];
|
||||||
|
|
||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
@ -64,7 +62,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
ui.configCloneTable = {};
|
ui.configCloneTable = {};
|
||||||
ui.configsNone = {};
|
ui.configsNone = {};
|
||||||
ui.configTable = {};
|
ui.configTable = {};
|
||||||
ui.dcOther = {};
|
|
||||||
ui.destBackups = {};
|
ui.destBackups = {};
|
||||||
ui.destBackupsPrice = {};
|
ui.destBackupsPrice = {};
|
||||||
ui.destLabel = {};
|
ui.destLabel = {};
|
||||||
@ -244,17 +241,7 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display the source location
|
// Display the source location
|
||||||
var region = null;
|
if (regionNames[data.linode.region])
|
||||||
for (var i = 0; i < data.regions.length; i++) {
|
|
||||||
if (data.regions[i].id == data.linode.region) {
|
|
||||||
region = data.regions[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (region && region.label && region.label.length)
|
|
||||||
ui.sourceLocation.innerHTML = region.label;
|
|
||||||
else if (regionNames[data.linode.region])
|
|
||||||
ui.sourceLocation.innerHTML = regionNames[data.linode.region];
|
ui.sourceLocation.innerHTML = regionNames[data.linode.region];
|
||||||
else
|
else
|
||||||
ui.sourceLocation.innerHTML = data.linode.region;
|
ui.sourceLocation.innerHTML = data.linode.region;
|
||||||
@ -303,8 +290,25 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
// Callback for regions API call
|
// Callback for regions API call
|
||||||
var displayRegions = function(response)
|
var displayRegions = function(response)
|
||||||
{
|
{
|
||||||
// Add regions to array
|
for (var i = 0; i < response.data.length; i++) {
|
||||||
data.regions = data.regions.concat(response.data);
|
// Add regions to selector
|
||||||
|
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.destLocation.appendChild(dc);
|
||||||
|
|
||||||
|
// Add optgroups to linode selector
|
||||||
|
var optgroup = document.createElement("optgroup");
|
||||||
|
optgroup.id = response.data[i].id;
|
||||||
|
if (regionNames[response.data[i].id])
|
||||||
|
optgroup.label = regionNames[response.data[i].id];
|
||||||
|
else
|
||||||
|
optgroup.label = response.data[i].label;
|
||||||
|
ui.destLinode.appendChild(optgroup);
|
||||||
|
}
|
||||||
|
|
||||||
// Request the next page if there are more pages
|
// Request the next page if there are more pages
|
||||||
if (response.page != response.pages) {
|
if (response.page != response.pages) {
|
||||||
@ -312,37 +316,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < data.regions.length; i++) {
|
|
||||||
// Add regions to selector
|
|
||||||
var dc = document.createElement("option");
|
|
||||||
dc.value = data.regions[i].id;
|
|
||||||
if (data.regions[i].label && data.regions[i].label.length)
|
|
||||||
dc.innerHTML = data.regions[i].label;
|
|
||||||
else if (regionNames[data.regions[i].id])
|
|
||||||
dc.innerHTML = regionNames[data.regions[i].id];
|
|
||||||
else
|
|
||||||
dc.innerHTML = data.regions[i].id;
|
|
||||||
var group = null;
|
|
||||||
if (countryContinents[data.regions[i].country])
|
|
||||||
group = document.getElementById(countryContinents[data.regions[i].country]);
|
|
||||||
if (!group)
|
|
||||||
group = ui.dcOther;
|
|
||||||
group.style.display = "initial";
|
|
||||||
group.appendChild(dc);
|
|
||||||
|
|
||||||
// Add optgroups to linode selector
|
|
||||||
var optgroup = document.createElement("optgroup");
|
|
||||||
optgroup.id = data.regions[i].id;
|
|
||||||
if (data.regions[i].label && data.regions[i].label.length)
|
|
||||||
optgroup.label = data.regions[i].label;
|
|
||||||
else if (regionNames[data.regions[i].id])
|
|
||||||
optgroup.label = regionNames[data.regions[i].id];
|
|
||||||
else
|
|
||||||
optgroup.label = data.regions[i].label;
|
|
||||||
ui.destLinode.appendChild(optgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
apiGet("/linode/instances/" + data.params.lid, displayDetails, null);
|
|
||||||
apiGet("/linode/instances", displayLinodes, null);
|
apiGet("/linode/instances", displayLinodes, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -442,7 +415,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
ui.configCloneTable = document.getElementById(elements.configCloneTable);
|
ui.configCloneTable = document.getElementById(elements.configCloneTable);
|
||||||
ui.configsNone = document.getElementById(elements.configsNone);
|
ui.configsNone = document.getElementById(elements.configsNone);
|
||||||
ui.configTable = document.getElementById(elements.configTable);
|
ui.configTable = document.getElementById(elements.configTable);
|
||||||
ui.dcOther = document.getElementById(elements.dcOther);
|
|
||||||
ui.destBackups = document.getElementById(elements.destBackups);
|
ui.destBackups = document.getElementById(elements.destBackups);
|
||||||
ui.destBackupsPrice = document.getElementById(elements.destBackupsPrice);
|
ui.destBackupsPrice = document.getElementById(elements.destBackupsPrice);
|
||||||
ui.destLabel = document.getElementById(elements.destLabel);
|
ui.destLabel = document.getElementById(elements.destLabel);
|
||||||
@ -470,6 +442,7 @@ import { settings, elements, apiGet, apiPost, countryContinents, migrateETA, par
|
|||||||
ui.destPlan.addEventListener("input", updatePrices);
|
ui.destPlan.addEventListener("input", updatePrices);
|
||||||
|
|
||||||
// Get data from API
|
// Get data from API
|
||||||
|
apiGet("/linode/instances/" + data.params.lid, displayDetails, null);
|
||||||
apiGet("/linode/instances/" + data.params.lid + "/configs", displayConfigs, null);
|
apiGet("/linode/instances/" + data.params.lid + "/configs", displayConfigs, null);
|
||||||
apiGet("/linode/instances/" + data.params.lid + "/disks", displayDisks, null);
|
apiGet("/linode/instances/" + data.params.lid + "/disks", displayDisks, null);
|
||||||
apiGet("/linode/types", displayTypes, null);
|
apiGet("/linode/types", displayTypes, null);
|
||||||
|
@ -142,14 +142,7 @@ along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="lmc-tr3 new-linode">
|
<tr class="lmc-tr3 new-linode">
|
||||||
<td>Location</td>
|
<td>Location</td>
|
||||||
<td><select id="dest-location">
|
<td><select id="dest-location"></select></td>
|
||||||
<optgroup id="na" label="North America"></optgroup>
|
|
||||||
<optgroup id="eu" label="Europe"></optgroup>
|
|
||||||
<optgroup id="ap" label="Asia/Pacific"></optgroup>
|
|
||||||
<optgroup id="sa" label="South America"></optgroup>
|
|
||||||
<optgroup id="af" label="Africa"></optgroup>
|
|
||||||
<optgroup id="dc-other" label="Other"></optgroup>
|
|
||||||
</select></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="lmc-tr3 new-linode">
|
<tr class="lmc-tr3 new-linode">
|
||||||
<td>Plan</td>
|
<td>Plan</td>
|
||||||
|
@ -48,7 +48,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
data.noTag = false;
|
data.noTag = false;
|
||||||
data.notifications = [];
|
data.notifications = [];
|
||||||
data.plans = [];
|
data.plans = [];
|
||||||
data.regions = [];
|
|
||||||
|
|
||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
var ui = {};
|
var ui = {};
|
||||||
@ -61,8 +60,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
var state = {};
|
var state = {};
|
||||||
state.haveLinodes = false;
|
state.haveLinodes = false;
|
||||||
state.haveNotifications = false;
|
state.haveNotifications = false;
|
||||||
state.haveRegions = false;
|
|
||||||
state.haveTypes = false;
|
|
||||||
|
|
||||||
var createLinodeRow = function(linode, alt)
|
var createLinodeRow = function(linode, alt)
|
||||||
{
|
{
|
||||||
@ -95,10 +92,8 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
plan.innerHTML = getPlanLabel(linode.type);
|
plan.innerHTML = getPlanLabel(linode.type);
|
||||||
else
|
else
|
||||||
plan.innerHTML = "Unknown";
|
plan.innerHTML = "Unknown";
|
||||||
if (plan.innerHTML == "") {
|
if (plan.innerHTML == "")
|
||||||
plan.innerHTML = linode.type;
|
|
||||||
translatePlan(linode.type, plan);
|
translatePlan(linode.type, plan);
|
||||||
}
|
|
||||||
var ip = document.createElement("td");
|
var ip = document.createElement("td");
|
||||||
ip.innerHTML = linode.ipv4[0];
|
ip.innerHTML = linode.ipv4[0];
|
||||||
var ipCount = 0;
|
var ipCount = 0;
|
||||||
@ -115,17 +110,8 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
plus.innerHTML = " (+" + ipCount + ")";
|
plus.innerHTML = " (+" + ipCount + ")";
|
||||||
ip.appendChild(plus);
|
ip.appendChild(plus);
|
||||||
}
|
}
|
||||||
var regionData = null;
|
|
||||||
for (var i = 0; i < data.regions.length; i++) {
|
|
||||||
if (data.regions[i].id == linode.region) {
|
|
||||||
regionData = data.regions[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var region = document.createElement("td");
|
var region = document.createElement("td");
|
||||||
if (regionData && regionData.label && regionData.label.length)
|
if (regionNames[linode.region])
|
||||||
region.innerHTML = regionData.label;
|
|
||||||
else if (regionNames[linode.region])
|
|
||||||
region.innerHTML = regionNames[linode.region];
|
region.innerHTML = regionNames[linode.region];
|
||||||
else
|
else
|
||||||
region.innerHTML = linode.region;
|
region.innerHTML = linode.region;
|
||||||
@ -326,19 +312,8 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
body.innerHTML = data.notifications[i].message;
|
body.innerHTML = data.notifications[i].message;
|
||||||
}
|
}
|
||||||
// Replace "this facility" with actual location for outages
|
// Replace "this facility" with actual location for outages
|
||||||
if (data.notifications[i].type == "outage" && data.notifications[i].entity && data.notifications[i].entity.type == "region") {
|
if (data.notifications[i].type == "outage" && data.notifications[i].entity && data.notifications[i].entity.type == "region" && regionNames[data.notifications[i].entity.id])
|
||||||
var region = null;
|
|
||||||
for (var j = 0; j < data.regions.length; j++) {
|
|
||||||
if (data.regions[j].id == data.notifications[i].entity.id) {
|
|
||||||
region = data.regions[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (region && region.label && region.label.length)
|
|
||||||
header.innerHTML = header.innerHTML.replace("this facility", region.label);
|
|
||||||
else if (regionNames[data.notifications[i].entity.id])
|
|
||||||
header.innerHTML = header.innerHTML.replace("this facility", regionNames[data.notifications[i].entity.id]);
|
header.innerHTML = header.innerHTML.replace("this facility", regionNames[data.notifications[i].entity.id]);
|
||||||
}
|
|
||||||
notification.appendChild(header);
|
notification.appendChild(header);
|
||||||
notification.appendChild(body);
|
notification.appendChild(body);
|
||||||
ui.notifications.appendChild(notification);
|
ui.notifications.appendChild(notification);
|
||||||
@ -404,8 +379,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.haveTypes = true;
|
|
||||||
if (state.haveRegions) {
|
|
||||||
// Get linodes
|
// Get linodes
|
||||||
var filters = null;
|
var filters = null;
|
||||||
if (data.params.tag)
|
if (data.params.tag)
|
||||||
@ -413,33 +386,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
"tags": data.params.tag
|
"tags": data.params.tag
|
||||||
};
|
};
|
||||||
apiGet("/linode/instances", displayLinodes, filters);
|
apiGet("/linode/instances", displayLinodes, filters);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var getRegions = function(response)
|
|
||||||
{
|
|
||||||
// Add regions to array
|
|
||||||
data.regions = data.regions.concat(response.data);
|
|
||||||
|
|
||||||
// Request the next page if there are more pages
|
|
||||||
if (response.page != response.pages) {
|
|
||||||
apiGet("/regions?page=" + (response.page + 1), getRegions, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.haveRegions = true;
|
|
||||||
if (state.haveTypes) {
|
|
||||||
// Get linodes
|
|
||||||
var filters = null;
|
|
||||||
if (data.params.tag)
|
|
||||||
filters = {
|
|
||||||
"tags": data.params.tag
|
|
||||||
};
|
|
||||||
apiGet("/linode/instances", displayLinodes, filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get notifications
|
|
||||||
apiGet("/account/notifications", displayNotifications, null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var insertLinodes = function()
|
var insertLinodes = function()
|
||||||
@ -479,9 +425,9 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
setupHeader();
|
setupHeader();
|
||||||
|
|
||||||
// Get linode and transfer info
|
// Get linode and transfer info
|
||||||
apiGet("/regions", getRegions, null);
|
|
||||||
apiGet("/linode/types", getPlans, null);
|
apiGet("/linode/types", getPlans, null);
|
||||||
apiGet("/account/transfer", displayTransfer, null);
|
apiGet("/account/transfer", displayTransfer, null);
|
||||||
|
apiGet("/account/notifications", displayNotifications, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
var translatePlan = function(name, cell)
|
var translatePlan = function(name, cell)
|
||||||
|
@ -21,10 +21,6 @@
|
|||||||
padding: 0px 15px 15px;
|
padding: 0px 15px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
optgroup {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
tbody tr td:first-of-type {
|
tbody tr td:first-of-type {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { settings, elements, apiGet, apiPost, countryContinents, parseParams, regionNames, setupHeader } from "/global.js";
|
import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHeader } from "/global.js";
|
||||||
|
|
||||||
(function()
|
(function()
|
||||||
{
|
{
|
||||||
// Element names specific to this page
|
// Element names specific to this page
|
||||||
elements.addButton = "add-button";
|
elements.addButton = "add-button";
|
||||||
elements.attachment = "attachment";
|
elements.attachment = "attachment";
|
||||||
elements.dcOther = "dc-other";
|
|
||||||
elements.label = "label";
|
elements.label = "label";
|
||||||
elements.location = "location";
|
elements.location = "location";
|
||||||
elements.size = "size";
|
elements.size = "size";
|
||||||
@ -36,7 +35,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, parseParams, re
|
|||||||
var ui = {};
|
var ui = {};
|
||||||
ui.addButton = {};
|
ui.addButton = {};
|
||||||
ui.attachment = {};
|
ui.attachment = {};
|
||||||
ui.dcOther = {};
|
|
||||||
ui.label = {};
|
ui.label = {};
|
||||||
ui.location = {};
|
ui.location = {};
|
||||||
ui.size = {};
|
ui.size = {};
|
||||||
@ -92,19 +90,11 @@ import { settings, elements, apiGet, apiPost, countryContinents, parseParams, re
|
|||||||
for (var i = 0; i < data.regions.length; i++) {
|
for (var i = 0; i < data.regions.length; i++) {
|
||||||
var loc = document.createElement("option");
|
var loc = document.createElement("option");
|
||||||
loc.value = data.regions[i].id;
|
loc.value = data.regions[i].id;
|
||||||
if (data.regions[i].label && data.regions[i].label.length)
|
if (regionNames[data.regions[i].id])
|
||||||
loc.innerHTML = data.regions[i].label;
|
|
||||||
else if (regionNames[data.regions[i].id])
|
|
||||||
loc.innerHTML = regionNames[data.regions[i].id];
|
loc.innerHTML = regionNames[data.regions[i].id];
|
||||||
else
|
else
|
||||||
loc.innerHTML = data.regions[i].id;
|
loc.innerHTML = data.regions[i].id;
|
||||||
var optgroup = null;
|
ui.location.appendChild(loc);
|
||||||
if (countryContinents[data.regions[i].country])
|
|
||||||
optgroup = document.getElementById(countryContinents[data.regions[i].country]);
|
|
||||||
if (!optgroup)
|
|
||||||
optgroup = ui.dcOther;
|
|
||||||
optgroup.style.display = "initial";
|
|
||||||
optgroup.appendChild(loc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request linodes in all the supported regions
|
// Request linodes in all the supported regions
|
||||||
@ -190,7 +180,6 @@ import { settings, elements, apiGet, apiPost, countryContinents, parseParams, re
|
|||||||
// Get element references
|
// Get element references
|
||||||
ui.addButton = document.getElementById(elements.addButton);
|
ui.addButton = document.getElementById(elements.addButton);
|
||||||
ui.attachment = document.getElementById(elements.attachment);
|
ui.attachment = document.getElementById(elements.attachment);
|
||||||
ui.dcOther = document.getElementById(elements.dcOther);
|
|
||||||
ui.label = document.getElementById(elements.label);
|
ui.label = document.getElementById(elements.label);
|
||||||
ui.location = document.getElementById(elements.location);
|
ui.location = document.getElementById(elements.location);
|
||||||
ui.size = document.getElementById(elements.size);
|
ui.size = document.getElementById(elements.size);
|
||||||
|
@ -50,12 +50,6 @@ along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
<td>
|
<td>
|
||||||
<select id="location">
|
<select id="location">
|
||||||
<option selected disabled value="0">Choose A Location</option>
|
<option selected disabled value="0">Choose A Location</option>
|
||||||
<optgroup id="na" label="North America"></optgroup>
|
|
||||||
<optgroup id="eu" label="Europe"></optgroup>
|
|
||||||
<optgroup id="ap" label="Asia/Pacific"></optgroup>
|
|
||||||
<optgroup id="sa" label="South America"></optgroup>
|
|
||||||
<optgroup id="af" label="Africa"></optgroup>
|
|
||||||
<optgroup id="dc-other" label="Other"></optgroup>
|
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="info">The datacenter where the new volume should be created</td>
|
<td class="info">The datacenter where the new volume should be created</td>
|
||||||
|
@ -39,13 +39,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
ui.size = {};
|
ui.size = {};
|
||||||
ui.volumeLabel = {};
|
ui.volumeLabel = {};
|
||||||
|
|
||||||
// Callback for region API call
|
|
||||||
var displayRegion = function(response)
|
|
||||||
{
|
|
||||||
if (response.label && response.label.length)
|
|
||||||
ui.location.innerHTML = response.label;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback for volume API call
|
// Callback for volume API call
|
||||||
var displayVolume = function(response)
|
var displayVolume = function(response)
|
||||||
{
|
{
|
||||||
@ -62,7 +55,6 @@ import { settings, elements, apiGet, apiPost, parseParams, regionNames, setupHea
|
|||||||
ui.location.innerHTML = response.region;
|
ui.location.innerHTML = response.region;
|
||||||
|
|
||||||
ui.cloneButton.disabled = false;
|
ui.cloneButton.disabled = false;
|
||||||
apiGet("/regions/" + response.region, displayRegion, null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Click handler for clone button
|
// Click handler for clone button
|
||||||
|
@ -83,13 +83,6 @@ import { settings, elements, regionNames, apiGet, apiPost, apiPut, parseParams,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback for region API call
|
|
||||||
var displayRegion = function(response)
|
|
||||||
{
|
|
||||||
if (response.label && response.label.length)
|
|
||||||
ui.location.innerHTML = response.label;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback for volume API call
|
// Callback for volume API call
|
||||||
var displayVolume = function(response)
|
var displayVolume = function(response)
|
||||||
{
|
{
|
||||||
@ -124,8 +117,6 @@ import { settings, elements, regionNames, apiGet, apiPost, apiPut, parseParams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.saveButton.disabled = false;
|
ui.saveButton.disabled = false;
|
||||||
|
|
||||||
apiGet("/regions/" + data.volume.region, displayRegion, null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Click handler for save button
|
// Click handler for save button
|
||||||
|
@ -28,7 +28,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
// Data recieved from API calls
|
// Data recieved from API calls
|
||||||
var data = {};
|
var data = {};
|
||||||
data.linodes = {};
|
data.linodes = {};
|
||||||
data.regions = [];
|
|
||||||
data.volumes = [];
|
data.volumes = [];
|
||||||
|
|
||||||
// Static references to UI elements
|
// Static references to UI elements
|
||||||
@ -36,11 +35,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
ui.loading = {};
|
ui.loading = {};
|
||||||
ui.volumeBody = {};
|
ui.volumeBody = {};
|
||||||
|
|
||||||
// Temporary state
|
|
||||||
var state = {};
|
|
||||||
state.haveRegions = false;
|
|
||||||
state.haveVolumes = false;
|
|
||||||
|
|
||||||
// Generates a table row for a volume
|
// Generates a table row for a volume
|
||||||
var createVolumeRow = function(volume, alt)
|
var createVolumeRow = function(volume, alt)
|
||||||
{
|
{
|
||||||
@ -65,17 +59,8 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
size.innerHTML = volume.size + " GiB";
|
size.innerHTML = volume.size + " GiB";
|
||||||
row.appendChild(size);
|
row.appendChild(size);
|
||||||
|
|
||||||
var regionData = null;
|
|
||||||
for (var i = 0; i < data.regions.length; i++) {
|
|
||||||
if (data.regions[i].id == volume.region) {
|
|
||||||
regionData = data.regions[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var region = document.createElement("td");
|
var region = document.createElement("td");
|
||||||
if (regionData && regionData.label && regionData.label.length)
|
if (regionNames[volume.region])
|
||||||
region.innerHTML = regionData.label;
|
|
||||||
else if (regionNames[volume.region])
|
|
||||||
region.innerHTML = regionNames[volume.region];
|
region.innerHTML = regionNames[volume.region];
|
||||||
else
|
else
|
||||||
region.innerHTML = volume.region;
|
region.innerHTML = volume.region;
|
||||||
@ -123,27 +108,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
return row;
|
return row;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback for regions API call
|
|
||||||
var displayRegions = function(response)
|
|
||||||
{
|
|
||||||
// Add regions to array
|
|
||||||
data.regions = data.regions.concat(response.data);
|
|
||||||
|
|
||||||
// Request the next page if there are more pages
|
|
||||||
if (response.page != response.pages) {
|
|
||||||
apiGet("/regions?page=" + (response.page + 1), displayRegions, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.haveRegions = true;
|
|
||||||
if (state.haveVolumes) {
|
|
||||||
// Insert volumes
|
|
||||||
ui.loading.remove();
|
|
||||||
for (var i = 0; i < data.volumes.length; i++)
|
|
||||||
ui.volumeBody.appendChild(createVolumeRow(data.volumes[i], i % 2));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback for volumes API call
|
// Callback for volumes API call
|
||||||
var displayVolumes = function(response)
|
var displayVolumes = function(response)
|
||||||
{
|
{
|
||||||
@ -163,13 +127,10 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
if (data.volumes.length == 0)
|
if (data.volumes.length == 0)
|
||||||
location.href = "/volumes/add";
|
location.href = "/volumes/add";
|
||||||
|
|
||||||
state.haveVolumes = true;
|
|
||||||
if (state.haveRegions) {
|
|
||||||
// Insert volumes
|
// Insert volumes
|
||||||
ui.loading.remove();
|
ui.loading.remove();
|
||||||
for (var i = 0; i < data.volumes.length; i++)
|
for (var i = 0; i < data.volumes.length; i++)
|
||||||
ui.volumeBody.appendChild(createVolumeRow(data.volumes[i], i % 2));
|
ui.volumeBody.appendChild(createVolumeRow(data.volumes[i], i % 2));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initial setup
|
// Initial setup
|
||||||
@ -186,7 +147,6 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader } fro
|
|||||||
|
|
||||||
// Get data from API
|
// Get data from API
|
||||||
apiGet("/volumes", displayVolumes, null);
|
apiGet("/volumes", displayVolumes, null);
|
||||||
apiGet("/regions", displayRegions, null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the label of a given linode ID and update a cell's contents
|
// Get the label of a given linode ID and update a cell's contents
|
||||||
|
Loading…
Reference in New Issue
Block a user