Fix: admin.html wird beim Update automatisch mitgespeichert (v1.2.3)
Blob-URL-Ansatz rückgängig gemacht (localStorage-Problem), stattdessen beide Dateien gemeinsam per showSaveFilePicker aktualisieren. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
65
index.html
65
index.html
@@ -1713,7 +1713,7 @@
|
|||||||
// ============================================================
|
// ============================================================
|
||||||
// CONSTANTS & CHAPTER CONFIG
|
// CONSTANTS & CHAPTER CONFIG
|
||||||
// ============================================================
|
// ============================================================
|
||||||
const APP_VERSION = '1.2.2';
|
const APP_VERSION = '1.2.3';
|
||||||
const GITEA_RAW = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde/raw';
|
const GITEA_RAW = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde/raw';
|
||||||
const GITEA_API = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde';
|
const GITEA_API = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde';
|
||||||
function giteaUrl(path) { return `${GITEA_RAW}/${path}?ref=main`; }
|
function giteaUrl(path) { return `${GITEA_RAW}/${path}?ref=main`; }
|
||||||
@@ -1893,7 +1893,7 @@ function renderStammvertreterSection() {
|
|||||||
if (!container) return;
|
if (!container) return;
|
||||||
const list = loadStammvertreter();
|
const list = loadStammvertreter();
|
||||||
if (list.length === 0) {
|
if (list.length === 0) {
|
||||||
container.innerHTML = `<div style="color:var(--muted);font-size:0.82rem;padding:2px 0 8px;">Noch keine gespeichert. → <a href="#" onclick="openAdminPanel();return false;" style="color:var(--red);">Admin öffnen</a> zum Importieren aus anderen Chaptern.</div>`;
|
container.innerHTML = `<div style="color:var(--muted);font-size:0.82rem;padding:2px 0 8px;">Noch keine gespeichert. → <a href="admin.html" target="_blank" style="color:var(--red);">Admin öffnen</a> zum Importieren aus anderen Chaptern.</div>`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
@@ -4346,23 +4346,38 @@ async function downloadUpdate(version) {
|
|||||||
}
|
}
|
||||||
} catch(e) { alert('Keine Serververbindung möglich.'); return; }
|
} catch(e) { alert('Keine Serververbindung möglich.'); return; }
|
||||||
|
|
||||||
let html;
|
let html, adminHtml;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(giteaUrl('index.html'), { cache: 'no-store' });
|
const [r1, r2] = await Promise.all([
|
||||||
html = await res.text();
|
fetch(giteaUrl('index.html'), { cache: 'no-store' }),
|
||||||
|
fetch(giteaUrl('admin.html'), { cache: 'no-store' }),
|
||||||
|
]);
|
||||||
|
html = await r1.text();
|
||||||
|
adminHtml = await r2.text();
|
||||||
} catch(e) { alert('Download fehlgeschlagen: ' + e.message); return; }
|
} catch(e) { alert('Download fehlgeschlagen: ' + e.message); return; }
|
||||||
|
|
||||||
if ('showSaveFilePicker' in window) {
|
if ('showSaveFilePicker' in window) {
|
||||||
try {
|
try {
|
||||||
const fileHandle = await window.showSaveFilePicker({
|
const fh1 = await window.showSaveFilePicker({
|
||||||
suggestedName: 'index.html',
|
suggestedName: 'index.html',
|
||||||
types: [{ description: 'HTML-Datei', accept: { 'text/html': ['.html'] } }],
|
types: [{ description: 'HTML-Datei', accept: { 'text/html': ['.html'] } }],
|
||||||
id: 'bni-update',
|
id: 'bni-update',
|
||||||
startIn: 'documents',
|
startIn: 'documents',
|
||||||
});
|
});
|
||||||
const writable = await fileHandle.createWritable();
|
const w1 = await fh1.createWritable();
|
||||||
await writable.write(html);
|
await w1.write(html);
|
||||||
await writable.close();
|
await w1.close();
|
||||||
|
|
||||||
|
const fh2 = await window.showSaveFilePicker({
|
||||||
|
suggestedName: 'admin.html',
|
||||||
|
types: [{ description: 'HTML-Datei', accept: { 'text/html': ['.html'] } }],
|
||||||
|
id: 'bni-update',
|
||||||
|
startIn: 'documents',
|
||||||
|
});
|
||||||
|
const w2 = await fh2.createWritable();
|
||||||
|
await w2.write(adminHtml);
|
||||||
|
await w2.close();
|
||||||
|
|
||||||
if (confirm('Update erfolgreich eingespielt!\n\nSeite jetzt neu laden?')) location.reload();
|
if (confirm('Update erfolgreich eingespielt!\n\nSeite jetzt neu laden?')) location.reload();
|
||||||
return;
|
return;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -4372,13 +4387,15 @@ async function downloadUpdate(version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback für Browser ohne File System Access API
|
// Fallback für Browser ohne File System Access API
|
||||||
const blob = new Blob([html], { type: 'text/html' });
|
for (const [name, content] of [['index.html', html], ['admin.html', adminHtml]]) {
|
||||||
const a = document.createElement('a');
|
const blob = new Blob([content], { type: 'text/html' });
|
||||||
a.href = URL.createObjectURL(blob);
|
const a = document.createElement('a');
|
||||||
a.download = 'index.html';
|
a.href = URL.createObjectURL(blob);
|
||||||
a.click();
|
a.download = name;
|
||||||
URL.revokeObjectURL(a.href);
|
a.click();
|
||||||
alert('Datei wurde heruntergeladen.\nBitte die alte index.html damit ersetzen und die Seite neu laden.');
|
URL.revokeObjectURL(a.href);
|
||||||
|
}
|
||||||
|
alert('Dateien wurden heruntergeladen.\nBitte index.html und admin.html ersetzen und die Seite neu laden.');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchChapterMembersFromGitea() {
|
async function fetchChapterMembersFromGitea() {
|
||||||
@@ -4492,7 +4509,7 @@ function renderAdminPanel() {
|
|||||||
</div>
|
</div>
|
||||||
<button class="btn btn-secondary btn-sm" style="width:100%;margin-bottom:6px;" onclick="fetchChapterMembersFromGitea()">🔄 Mitglieder vom Server laden</button>
|
<button class="btn btn-secondary btn-sm" style="width:100%;margin-bottom:6px;" onclick="fetchChapterMembersFromGitea()">🔄 Mitglieder vom Server laden</button>
|
||||||
<div style="font-size:0.78rem;color:var(--muted);margin-bottom:16px;">Letzter Download: ${lastSync}</div>
|
<div style="font-size:0.78rem;color:var(--muted);margin-bottom:16px;">Letzter Download: ${lastSync}</div>
|
||||||
<button onclick="openAdminPanel()" class="btn btn-primary btn-sm" style="width:100%;display:block;margin-bottom:16px;">⚙ Admin-Panel öffnen</button>
|
<a href="admin.html" target="_blank" class="btn btn-primary btn-sm" style="width:100%;display:block;text-align:center;text-decoration:none;margin-bottom:16px;">⚙ Admin-Panel öffnen</a>
|
||||||
` : `<div style="color:var(--muted);font-size:0.88rem;margin-bottom:20px;">Kein Chapter aktiviert.</div>`}
|
` : `<div style="color:var(--muted);font-size:0.88rem;margin-bottom:20px;">Kein Chapter aktiviert.</div>`}
|
||||||
<div style="border-top:1px solid var(--border);padding-top:14px;margin-bottom:14px;">
|
<div style="border-top:1px solid var(--border);padding-top:14px;margin-bottom:14px;">
|
||||||
<div style="font-size:0.78rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:1px;margin-bottom:10px;">Einstellungen</div>
|
<div style="font-size:0.78rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:1px;margin-bottom:10px;">Einstellungen</div>
|
||||||
@@ -4509,20 +4526,6 @@ function renderAdminPanel() {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openAdminPanel() {
|
|
||||||
try {
|
|
||||||
const res = await fetch(giteaUrl('admin.html'), { cache: 'no-store' });
|
|
||||||
if (!res.ok) throw new Error('Nicht erreichbar');
|
|
||||||
const html = await res.text();
|
|
||||||
const blob = new Blob([html], { type: 'text/html' });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
window.open(url, '_blank', 'noopener');
|
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 10000);
|
|
||||||
} catch(e) {
|
|
||||||
alert('Admin-Panel konnte nicht geladen werden.\nBitte Internetverbindung prüfen.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmSwitchChapter() {
|
function confirmSwitchChapter() {
|
||||||
if (!confirm('Chapter wechseln?\n\nAlle lokalen Daten dieses Chapters werden gelöscht. Fortfahren?')) return;
|
if (!confirm('Chapter wechseln?\n\nAlle lokalen Daten dieses Chapters werden gelöscht. Fortfahren?')) return;
|
||||||
clearChapterData();
|
clearChapterData();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"notes": "Admin-Panel immer aktuell vom Server"
|
"notes": "Timer-Schalter im Admin-Menü"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user