From 6476f7543d81ec530e1456286eb1d2c8ab55808d Mon Sep 17 00:00:00 2001
From: "L. Bradley LaBoon"
Date: Wed, 26 May 2021 19:44:30 -0400
Subject: [PATCH] Implement image uploads
---
global.js | 28 +++++++-
images/images.css | 2 +-
images/images.js | 4 ++
images/index.shtml | 4 +-
images/upload/index.shtml | 72 +++++++++++++++++++
images/upload/upload.css | 31 ++++++++
images/upload/upload.js | 147 ++++++++++++++++++++++++++++++++++++++
7 files changed, 285 insertions(+), 3 deletions(-)
create mode 100644 images/upload/index.shtml
create mode 100644 images/upload/upload.css
create mode 100644 images/upload/upload.js
diff --git a/global.js b/global.js
index 40f94ce..3c59045 100644
--- a/global.js
+++ b/global.js
@@ -645,6 +645,32 @@ function oauthPost(endpoint, data, callback)
xmlhttp.send(data.toString());
}
+// Make an object storage HTTP PUT request
+function objPut(url, data, progress, callback)
+{
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.upload.addEventListener("progress", progress);
+ xmlhttp.open("PUT", url, true);
+ xmlhttp.setRequestHeader("Content-Type", "application/octet-stream");
+
+ xmlhttp.onreadystatechange = function()
+ {
+ if (xmlhttp.readyState != 4)
+ return;
+
+ if (xmlhttp.status >= 400) {
+ console.log("Error " + xmlhttp.status);
+ console.log("PUT " + url);
+ alert("An error occurred during file upload!");
+ return;
+ }
+
+ callback();
+ };
+
+ xmlhttp.send(data);
+}
+
// Parse URL parameters
function parseParams()
{
@@ -766,4 +792,4 @@ function translateKernel(slug, element)
apiGet("/linode/kernels/" + slug, callback, null);
}
-export { settings, elements, regionNames, apiDelete, apiGet, apiPost, apiPut, md5, migrateETA, oauthPost, oauthScopes, parseParams, setupHeader, eventTitles, timeString, translateKernel };
+export { settings, elements, regionNames, apiDelete, apiGet, apiPost, apiPut, md5, migrateETA, oauthPost, oauthScopes, objPut, parseParams, setupHeader, eventTitles, timeString, translateKernel };
diff --git a/images/images.css b/images/images.css
index 59df3f1..163b1fd 100644
--- a/images/images.css
+++ b/images/images.css
@@ -17,7 +17,7 @@
@import url('/global.css');
-table td:nth-of-type(6) {
+table td:nth-of-type(7) {
text-align: right;
}
diff --git a/images/images.js b/images/images.js
index e4402a4..801063f 100644
--- a/images/images.js
+++ b/images/images.js
@@ -49,6 +49,10 @@ import { settings, elements, regionNames, apiGet, parseParams, setupHeader, time
label.innerHTML = image.label;
row.appendChild(label);
+ var status = document.createElement("td");
+ status.innerHTML = image.status.charAt(0).toUpperCase() + image.status.slice(1).replace(/_/g, " ");
+ row.appendChild(status);
+
var size = document.createElement("td");
size.innerHTML = image.size + " MB";
row.appendChild(size);
diff --git a/images/index.shtml b/images/index.shtml
index 7cbe6a2..2b428ae 100644
--- a/images/index.shtml
+++ b/images/index.shtml
@@ -32,6 +32,7 @@ along with Linode Manager Classic. If not, see .
Image |
+ Status |
Size |
Type |
Created |
@@ -41,10 +42,11 @@ along with Linode Manager Classic. If not, see .
- Loading... |
+ Loading... |
+ Upload a Custom Image
+
+
+
diff --git a/images/upload/index.shtml b/images/upload/index.shtml
new file mode 100644
index 0000000..57b3ea5
--- /dev/null
+++ b/images/upload/index.shtml
@@ -0,0 +1,72 @@
+
+
+
+