diff --git a/app/templates/index.html b/app/templates/index.html index d7cf388..7bd5663 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -11,6 +11,7 @@ button { padding: 8px 16px; cursor: pointer; border: none; border-radius: 4px; margin-right: 5px; margin-top: 5px; font-size: 14px; } .btn-subscribe { background: #007bff; color: white; } .btn-unsubscribe { background: #dc3545; color: white; } + .btn-push { background: #28a745; color: white; } .status-ok { color: #28a745; font-size: 13px; } .status-warn { color: #dc3545; font-size: 13px; } hr { border: none; border-top: 1px solid #ccc; margin: 20px 0; } @@ -49,7 +50,6 @@ async function loadProjects() { return []; } - // Cache setzen: subscribedNames.clear(); data.projects.forEach(proj => subscribedNames.add(proj.name)); @@ -65,7 +65,6 @@ async function loadProjects() { const card = document.createElement("div"); card.className = "project-card"; - // ✅ NEU: Zeige Berechtigungs-Status! const writeStatus = proj.can_write ? '✅ Schreibfrei' : '❌ Nur Lesen'; @@ -77,6 +76,7 @@ async function loadProjects() { ${proj.has_git ? '📦 Git Repository' : ''}
+
@@ -88,6 +88,30 @@ async function loadProjects() { return data.projects; } +async function pushProject(projectName) { + const commitMsg = prompt("Commit-Nachricht:", "AI-bearbeitete Änderungen"); + if (!commitMsg) return; // Abgebrochen + + try { + const res = await fetch(`${API_BASE}/api/push/${projectName}`, { + method: "POST", + headers: {"Content-Type": "application/json"} + }); + + const data = await res.json(); + + if (data.success) { + alert(`✅ ${projectName} erfolgreich gepusht!\n\n${data.output || ''}`); + loadProjects(); // Refresh + } else { + alert(`❌ Push fehlgeschlagen: ${data.error || 'Unbekannter Fehler'}`); + } + } catch (err) { + console.error(err); + alert("❌ Verbindungsfehler beim Pushen"); + } +} + async function unsubscribe(name) { if (!confirm(`Möchtest du '${name}' wirklich deabonnieren?\nDer komplette Ordner wird geloescht!`)) return; @@ -107,7 +131,7 @@ async function unsubscribe(name) { } } -let allRepos = []; // Globaler Cache für Repositories +let allRepos = []; async function loadRepos() { try { @@ -132,7 +156,6 @@ async function loadRepos() { titleEl.innerHTML = `Gitea Repositories (${allRepos.length})`; - // Sortiere: Abonnierte zuerst, dann nicht abonnierte const subscribed = allRepos.filter(r => subscribedNames.has(r.name)); const notSubscribed = allRepos.filter(r => !subscribedNames.has(r.name)); @@ -167,7 +190,7 @@ function addRepoCard(repo, container) { } async function subscribe(repo) { - if (subscribedNames.has(repo.name)) return; // Schon abonniert! + if (subscribedNames.has(repo.name)) return; const target = prompt("Gewünschter Name (Standard: Repo-Name):") || repo.name; @@ -187,8 +210,8 @@ async function subscribe(repo) { } } -// Starte beim Laden: ✅ MIT ABSOLUTEN URLS! -loadProjects().then(() => loadRepos()); +loadProjects().then(() => loadRepos()); + \ No newline at end of file