Import page in the web UI, worker service and import monitoring
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 43s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s

- New Import page: upload an export (with upload progress) or, when the
  server has a Last.fm API key, import straight from a Last.fm username;
  jobs list with live progress, counts, errors and cancelling
- docker compose runs the import worker from the API image; the API
  image no longer sets PROMETHEUS_MULTIPROC_DIR (gunicorn.conf.py does,
  and other commands must not inherit multiprocess mode)
- Prometheus scrapes the worker; Usage dashboard gains an Imports row;
  ImportWorkerDown and ImportJobsWaiting alerts
- README and .env.example document imports and LASTFM_API_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 15:10:15 +01:00
1 parent eebd7b8730
commit e40a074a64
12 files changed
+754 -3

No files matched your search

+43
View File
@@ -87,3 +87,46 @@ export function describeError(error) {
}
return error.message;
}
// Multipart upload with progress (fetch can't report upload progress).
export function upload(path, formData, onProgress) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("POST", `${apiBase}/api/v1${path}`);
const token = getToken();
if (token) xhr.setRequestHeader("Authorization", `Bearer ${token}`);
xhr.upload.addEventListener("progress", (event) => {
if (event.lengthComputable) onProgress?.(event.loaded / event.total);
});
xhr.addEventListener("error", () =>
reject(new ApiError(0, "network", `Can't reach the Scrobbler API at ${apiBase}. Check that it's running.`)),
);
xhr.addEventListener("load", () => {
let data = null;
try {
data = JSON.parse(xhr.responseText);
} catch {
// Not JSON (e.g. a proxy's error page)
}
if (xhr.status === 401) {
setToken(null);
redirectToLogin();
return;
}
if (xhr.status >= 200 && xhr.status < 300) {
resolve(data);
return;
}
const error = data?.error ?? {};
reject(
new ApiError(
xhr.status,
error.code ?? "error",
error.message ?? (xhr.status === 413 ? "That file is too large." : `Upload failed (${xhr.status}).`),
error.details,
),
);
});
xhr.send(formData);
});
}