diff --git a/README.md b/README.md index a7e848f..e7510a2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Gitea-Server kommuniziert. "Verbinden & Repos laden" klicken. 2. Konto/Organisation wählen, dann bestehendes Repo aus der Liste wählen **oder** einen neuen Namen eingeben und "Repo erstellen" klicken. -3. ZIP-Datei auswählen. +3. ZIP-Datei auswählen. Danach lässt sich jede enthaltene Datei einzeln abhaken - abgewählte Dateien werden + beim Hochladen übersprungen (auch dann nicht gelöscht, wenn "Dateien löschen, die nicht mehr in der ZIP + enthalten sind" aktiv ist). 4. Commit-Nachricht anpassen (optional) und "Jetzt hochladen" klicken. Vorhandene Dateien mit gleichem Pfad werden aktualisiert statt doppelt diff --git a/index.html b/index.html index a3deec9..2b0893a 100644 --- a/index.html +++ b/index.html @@ -62,8 +62,11 @@ .disabled-section{opacity:.45;pointer-events:none;} details{margin-top:10px;font-size:.85rem;color:var(--muted);} details summary{cursor:pointer;color:var(--text);} - #fileList{max-height:150px;overflow-y:auto;margin-top:8px;font-family:ui-monospace,Consolas,monospace; + #fileList{max-height:220px;overflow-y:auto;margin-top:8px;font-family:ui-monospace,Consolas,monospace; font-size:.78rem;background:var(--panel-alt);border-radius:6px;padding:8px;border:1px solid var(--border);} + #fileList label{display:flex;align-items:center;padding:3px 0;color:var(--text);margin:0;} + #fileList label input{margin-right:8px;flex:0 0 auto;} + #fileList label span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;} footer{display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px;color:var(--muted); font-size:.8rem;padding:18px 24px;border-top:1px solid var(--border);} footer a{color:var(--muted);text-decoration:none;margin-right:16px;} @@ -142,12 +145,18 @@

3ZIP-Datei wählen

- +
- +
@@ -457,22 +466,49 @@ } } } + entries.forEach(function(e){ e.selected = true; }); state.zipFiles = entries; enable("uploadCard"); setStatus("zipStatus", entries.length + " Datei(en) gefunden, bereit zum Hochladen.", "ok"); - el("fileList").textContent = entries.map(function(e){ return e.path; }).join("\n"); + renderFileList(); el("fileListDetails").style.display = "block"; }catch(e){ setStatus("zipStatus", "ZIP konnte nicht gelesen werden: " + e.message, "err"); } }); + function renderFileList(){ + var container = el("fileList"); + container.innerHTML = state.zipFiles.map(function(f, i){ + return ""; + }).join(""); + container.querySelectorAll("input[type=checkbox]").forEach(function(cb){ + cb.addEventListener("change", function(){ + state.zipFiles[parseInt(this.getAttribute("data-idx"), 10)].selected = this.checked; + }); + }); + } + el("btnSelectAll").addEventListener("click", function(){ + state.zipFiles.forEach(function(f){ f.selected = true; }); + renderFileList(); + }); + el("btnSelectNone").addEventListener("click", function(){ + state.zipFiles.forEach(function(f){ f.selected = false; }); + renderFileList(); + }); + // ---- Schritt 4: Hochladen ---- el("btnUpload").addEventListener("click", async function(){ if(!state.repo || !state.zipFiles){ setStatus("uploadStatus", "Bitte erst Repo wählen und ZIP einlesen.", "err"); return; } + var selectedFiles = state.zipFiles.filter(function(f){ return f.selected; }); + if(selectedFiles.length === 0){ + setStatus("uploadStatus", "Keine Datei ausgewählt.", "err"); + return; + } var btn = el("btnUpload"); btn.disabled = true; el("log").innerHTML = ""; @@ -492,9 +528,12 @@ logLine("Hinweis: Konnte bestehenden Stand nicht lesen (evtl. leeres Repo) - " + e.message, false); } - var newPaths = {}; - var operations = state.zipFiles.map(function(f){ - newPaths[f.path] = true; + // Alle Pfade aus der ZIP (auch abgewählte) gelten als "vorhanden" - + // eine Datei nur abzuwählen soll sie nie löschen, nur nicht überschreiben. + var allZipPaths = {}; + state.zipFiles.forEach(function(f){ allZipPaths[f.path] = true; }); + + var operations = selectedFiles.map(function(f){ var op = { path: f.path, content: f.base64 }; if(existing.hasOwnProperty(f.path)){ op.operation = "update"; op.sha = existing[f.path]; } else{ op.operation = "create"; } @@ -503,7 +542,7 @@ if(el("removeMissing").checked){ Object.keys(existing).forEach(function(p){ - if(!newPaths[p]) operations.push({ path: p, operation: "delete", sha: existing[p] }); + if(!allZipPaths[p]) operations.push({ path: p, operation: "delete", sha: existing[p] }); }); }