Upload per ZIP-Tool (1/1)
This commit is contained in:
1 parent
dfb5849659
commit
25d5da1419
2 files changed
+52
-11
No files matched your search
@@ -13,7 +13,9 @@ Gitea-Server kommuniziert.
|
|||||||
"Verbinden & Repos laden" klicken.
|
"Verbinden & Repos laden" klicken.
|
||||||
2. Konto/Organisation wählen, dann bestehendes Repo aus der Liste wählen
|
2. Konto/Organisation wählen, dann bestehendes Repo aus der Liste wählen
|
||||||
**oder** einen neuen Namen eingeben und "Repo erstellen" klicken.
|
**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.
|
4. Commit-Nachricht anpassen (optional) und "Jetzt hochladen" klicken.
|
||||||
|
|
||||||
Vorhandene Dateien mit gleichem Pfad werden aktualisiert statt doppelt
|
Vorhandene Dateien mit gleichem Pfad werden aktualisiert statt doppelt
|
||||||
|
|||||||
+49
-10
@@ -62,8 +62,11 @@
|
|||||||
.disabled-section{opacity:.45;pointer-events:none;}
|
.disabled-section{opacity:.45;pointer-events:none;}
|
||||||
details{margin-top:10px;font-size:.85rem;color:var(--muted);}
|
details{margin-top:10px;font-size:.85rem;color:var(--muted);}
|
||||||
details summary{cursor:pointer;color:var(--text);}
|
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);}
|
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);
|
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);}
|
font-size:.8rem;padding:18px 24px;border-top:1px solid var(--border);}
|
||||||
footer a{color:var(--muted);text-decoration:none;margin-right:16px;}
|
footer a{color:var(--muted);text-decoration:none;margin-right:16px;}
|
||||||
@@ -142,12 +145,18 @@
|
|||||||
<h2><span class="step-num">3</span>ZIP-Datei wählen</h2>
|
<h2><span class="step-num">3</span>ZIP-Datei wählen</h2>
|
||||||
<input type="file" id="zipFile" accept=".zip">
|
<input type="file" id="zipFile" accept=".zip">
|
||||||
<label class="checkline"><input type="checkbox" id="stripRoot" checked> Obersten Ordner aus der ZIP entfernen</label>
|
<label class="checkline"><input type="checkbox" id="stripRoot" checked> Obersten Ordner aus der ZIP entfernen</label>
|
||||||
<label class="checkline"><input type="checkbox" id="removeMissing"> Dateien im Repo löschen, die nicht mehr in der ZIP enthalten sind</label>
|
<label class="checkline"><input type="checkbox" id="removeMissing"> Dateien im Repo löschen, die nicht mehr in der ZIP enthalten sind (abgewählte Dateien zählen als vorhanden, werden nicht gelöscht)</label>
|
||||||
<div id="zipStatus" class="status"></div>
|
<div id="zipStatus" class="status"></div>
|
||||||
<details id="fileListDetails" style="display:none;">
|
<div id="fileListDetails" style="display:none;">
|
||||||
<summary>Enthaltene Dateien anzeigen</summary>
|
<div class="checkline" style="justify-content:space-between;margin-top:14px;">
|
||||||
|
<span>Dateien zum Hochladen auswählen:</span>
|
||||||
|
<span>
|
||||||
|
<button type="button" class="secondary small" id="btnSelectAll">Alle</button>
|
||||||
|
<button type="button" class="secondary small" id="btnSelectNone">Keine</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div id="fileList"></div>
|
<div id="fileList"></div>
|
||||||
</details>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card disabled-section" id="uploadCard">
|
<div class="card disabled-section" id="uploadCard">
|
||||||
@@ -457,22 +466,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
entries.forEach(function(e){ e.selected = true; });
|
||||||
state.zipFiles = entries;
|
state.zipFiles = entries;
|
||||||
enable("uploadCard");
|
enable("uploadCard");
|
||||||
setStatus("zipStatus", entries.length + " Datei(en) gefunden, bereit zum Hochladen.", "ok");
|
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";
|
el("fileListDetails").style.display = "block";
|
||||||
}catch(e){
|
}catch(e){
|
||||||
setStatus("zipStatus", "ZIP konnte nicht gelesen werden: " + e.message, "err");
|
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 "<label><input type='checkbox' data-idx='" + i + "'" + (f.selected ? " checked" : "") +
|
||||||
|
"><span>" + f.path + "</span></label>";
|
||||||
|
}).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 ----
|
// ---- Schritt 4: Hochladen ----
|
||||||
el("btnUpload").addEventListener("click", async function(){
|
el("btnUpload").addEventListener("click", async function(){
|
||||||
if(!state.repo || !state.zipFiles){
|
if(!state.repo || !state.zipFiles){
|
||||||
setStatus("uploadStatus", "Bitte erst Repo wählen und ZIP einlesen.", "err");
|
setStatus("uploadStatus", "Bitte erst Repo wählen und ZIP einlesen.", "err");
|
||||||
return;
|
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");
|
var btn = el("btnUpload");
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
el("log").innerHTML = "";
|
el("log").innerHTML = "";
|
||||||
@@ -492,9 +528,12 @@
|
|||||||
logLine("Hinweis: Konnte bestehenden Stand nicht lesen (evtl. leeres Repo) - " + e.message, false);
|
logLine("Hinweis: Konnte bestehenden Stand nicht lesen (evtl. leeres Repo) - " + e.message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newPaths = {};
|
// Alle Pfade aus der ZIP (auch abgewählte) gelten als "vorhanden" -
|
||||||
var operations = state.zipFiles.map(function(f){
|
// eine Datei nur abzuwählen soll sie nie löschen, nur nicht überschreiben.
|
||||||
newPaths[f.path] = true;
|
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 };
|
var op = { path: f.path, content: f.base64 };
|
||||||
if(existing.hasOwnProperty(f.path)){ op.operation = "update"; op.sha = existing[f.path]; }
|
if(existing.hasOwnProperty(f.path)){ op.operation = "update"; op.sha = existing[f.path]; }
|
||||||
else{ op.operation = "create"; }
|
else{ op.operation = "create"; }
|
||||||
@@ -503,7 +542,7 @@
|
|||||||
|
|
||||||
if(el("removeMissing").checked){
|
if(el("removeMissing").checked){
|
||||||
Object.keys(existing).forEach(function(p){
|
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] });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user