Add visible file upload label button, inline JS diagnostic badge, update TS event handlers

This commit is contained in:
2026-05-13 17:09:33 +02:00
parent 0b47d81c51
commit 3432d362e2
4 changed files with 43 additions and 13 deletions

View File

@@ -218,8 +218,16 @@ el('refresh-files').addEventListener('click', loadBrowseFiles);
// ── File upload ───────────────────────────────────────
(el('video-upload') as HTMLInputElement).addEventListener('change', function () {
if (this.files?.length) selectedFilePath = null; // will upload on submit
const videoUpload = el('video-upload') as HTMLInputElement;
const uploadName = el('upload-name');
videoUpload.addEventListener('change', function () {
if (this.files?.length) {
selectedFilePath = null; // will upload on submit
uploadName.textContent = `Selected: ${this.files[0].name} (${formatSize(this.files[0].size)})`;
} else {
uploadName.textContent = '';
}
});
// ── YouTube download ──────────────────────────────────
@@ -252,10 +260,9 @@ el('download-url').addEventListener('click', async () => {
el('new-job-form').addEventListener('submit', async (e) => {
e.preventDefault();
if (!selectedFilePath) {
const fileEl = el('video-upload') as HTMLInputElement;
if (fileEl.files?.length) {
if (videoUpload.files?.length) {
const formData = new FormData();
formData.append('video', fileEl.files[0]);
formData.append('video', videoUpload.files[0]);
try {
const headers: Record<string, string> = {};
if (authToken) headers['Authorization'] = `Basic ${authToken}`;
@@ -321,7 +328,8 @@ el('new-job-form').addEventListener('submit', async (e) => {
});
await apiJson('POST', `/api/jobs/${data.job.id}/start`);
selectedFilePath = null;
(el('video-upload') as HTMLInputElement).value = '';
videoUpload.value = '';
uploadName.textContent = '';
(el('new-job-form') as HTMLFormElement).reset();
switchTab('dashboard');
} catch (err: any) {