diff --git a/README.md b/README.md index ac0c807..715c68f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ ## Features +- Installation via single binary or container - Scalable to multiple replicas - No other backend services apart from S3 storage are required - Upload progress-bar and transfer statistics diff --git a/frontend/src/config.ts b/frontend/src/config.ts index fa9bc47..dbea796 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -2,7 +2,7 @@ class Expiration { id: string = ""; title: string = ""; days: number = 0; -}; +} export class Server { id: string = ""; diff --git a/frontend/src/index.ts b/frontend/src/index.ts index a9a350f..5c50519 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -97,7 +97,7 @@ async function startUpload(files: FileList) { new Notification("Upload completed", { body: `Upload of ${size} for ${upload.file.name} has been completed in ${dur}.`, - icon: 'gose-logo.svg', + icon: "gose-logo.svg", renotify: true, tag: upload.uploadID }); @@ -112,7 +112,7 @@ async function startUpload(files: FileList) { if (params.notify_browser) { new Notification("Upload failed", { body: `Upload failed: ${e.status} - ${e.statusText}`, - icon: 'gose-logo.svg', + icon: "gose-logo.svg", }); } } finally { @@ -183,16 +183,16 @@ function updateExpiration(server: Server) { selExpirationClasses.innerHTML = ""; for (let cls of server.expiration) { - var opt = document.createElement('option'); + var opt = document.createElement("option"); opt.value = cls.id; opt.innerHTML = cls.title; selExpirationClasses.appendChild(opt); } if (server.expiration.length > 1) { - divExpiration.classList.remove('d-none'); + divExpiration.classList.remove("d-none"); } else { - divExpiration.classList.add('d-none'); + divExpiration.classList.add("d-none"); } } @@ -209,7 +209,7 @@ function getUploadParams(): UploadParams { params.server = selServers.value; params.notify_browser = cbNotifyBrowser.checked; - if (selExpiration.value != "") { + if (selExpiration.value !== "") { params.expiration = selExpiration.value; } @@ -222,23 +222,23 @@ function getUploadParams(): UploadParams { function onConfig(config: Config) { let selServers = document.getElementById("servers") as HTMLSelectElement; - let divServers = document.getElementById('config-servers'); + let divServers = document.getElementById("config-servers"); for (let svr of config.servers) { - var opt = document.createElement('option'); + var opt = document.createElement("option"); opt.value = svr.id; opt.innerHTML = svr.title; selServers.appendChild(opt); } if (config.servers.length > 1) { - divServers.classList.remove('d-none'); + divServers.classList.remove("d-none"); } - selServers.addEventListener('change', (ev) => { + selServers.addEventListener("change", (ev) => { for (let svr of config.servers) { let opt = ev.target as HTMLOptionElement; - if (svr.id == opt.value) { + if (svr.id === opt.value) { updateExpiration(svr); } } @@ -255,7 +255,7 @@ function onConfig(config: Config) { divNotifyMail.classList.remove("d-none"); } - if (config.features.notify_browser && 'Notification' in window) { + if (config.features.notify_browser && "Notification" in window) { let divNotifyBrowser = document.getElementById("config-notify-browser"); divNotifyBrowser.classList.remove("d-none"); } @@ -304,15 +304,15 @@ export async function load() { } else { divNotifyMailAddress.classList.add("d-none"); } - }) + }); // Enable desktop notifications - if ('Notification' in window) { + if ("Notification" in window) { let swNotifyBrowser = document.getElementById("notify-browser") as HTMLInputElement; - if (Notification.permission == "granted") { + if (Notification.permission === "granted") { swNotifyBrowser.checked = true; - } else if (Notification.permission == "denied") { + } else if (Notification.permission === "denied") { swNotifyBrowser.disabled = true; } swNotifyBrowser.addEventListener("change", setupNotification); diff --git a/frontend/src/progress-stream.ts b/frontend/src/progress-stream.ts deleted file mode 100644 index 2253c5b..0000000 --- a/frontend/src/progress-stream.ts +++ /dev/null @@ -1,36 +0,0 @@ -class Callbacks { - [key: string]: any -} - -export class ProgressStream extends TransformStream { - constructor(cbs: Callbacks, total: number) { - super({ - start() { - this.started = Date.now(); - this.running = 0; - this.total = total; - this.transferred = 0; - this.speed = 0; - this.eta = Infinity; - - cbs.start(this); - cbs.progress(this); - }, // required. - async transform(chunk, controller) { - controller.enqueue(await chunk); - - this.transferred += chunk.length; - this.elapsed = Date.now() - this.started; - this.speed = this.transferred / (this.elapsed / 1e3); // elapsed is expressed in mili-seconds - this.eta = (this.total - this.transferred) / this.speed; - - cbs.progress(this); - }, - flush() { - this.elapsed = Date.now() - this.started; - - cbs.finish(this); - } - }); - } -} diff --git a/frontend/src/upload.ts b/frontend/src/upload.ts index 35de403..2e0391e 100644 --- a/frontend/src/upload.ts +++ b/frontend/src/upload.ts @@ -85,7 +85,7 @@ export class Upload { etags.push(etagExpected); parts.push({ - etag: etag, + etag, part_number: i + 1 }); } diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index bd6e1cf..e056e81 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -35,7 +35,7 @@ module.exports = { rules: [ { test: /\.tsx?$/, - use: 'ts-loader', + use: "ts-loader", exclude: /node_modules/, }, {