This commit is contained in:
1 parent
63abaa819c
commit
63296e7ad3
7 files changed
+226
-19
No files matched your search
+65
-6
@@ -6404,6 +6404,7 @@ async function runHealthCheck(mode = 'manual', requestedHosters = null) {
|
||||
|
||||
// --- Settings ---
|
||||
let cloudLogBusy = false;
|
||||
let cloudLogBackfillBusy = false;
|
||||
let cloudLogLastStatus = null;
|
||||
const cloudLogErrors = {
|
||||
KEY_STORAGE_UNAVAILABLE: 'Der API-Key konnte nicht im sicheren Zugangsdaten-Speicher gesichert werden.',
|
||||
@@ -6422,7 +6423,12 @@ const cloudLogErrors = {
|
||||
INVALID_RESPONSE: 'Clouddrop hat eine unerwartete Antwort geliefert.',
|
||||
VERIFICATION_FAILED: 'Die Testdatei konnte nicht verifiziert werden.',
|
||||
RESPONSE_TOO_LARGE: 'Die Clouddrop-Antwort überschreitet die zulässige Größe.',
|
||||
LINE_TOO_LARGE: 'Ein Log-Eintrag überschreitet die zulässige Größe.'
|
||||
LINE_TOO_LARGE: 'Ein Log-Eintrag überschreitet die zulässige Größe.',
|
||||
CONNECTION_REQUIRED: 'Bitte die CloudDrop-Verbindung zuerst prüfen und aktivieren.',
|
||||
LOG_NOT_FOUND: 'Die aktuelle lokale Upload-Log-Datei wurde noch nicht angelegt.',
|
||||
LOG_READ_FAILED: 'Die aktuelle lokale Upload-Log-Datei konnte nicht vollständig gelesen werden. Bereits übernommene Einträge bleiben gespeichert.',
|
||||
LOG_TOO_LARGE: 'Die Upload-Log-Datei überschreitet das sichere Leselimit.',
|
||||
BACKFILL_CANCELED: 'Die Nachsynchronisierung wurde beendet. Bereits übernommene Einträge bleiben gespeichert.'
|
||||
};
|
||||
|
||||
function renderCloudLogStatus(status) {
|
||||
@@ -6430,14 +6436,34 @@ function renderCloudLogStatus(status) {
|
||||
if (!status || !document.getElementById('cloudLogPhase')) return;
|
||||
const phases = { disabled: 'Inaktiv', checking: 'Verbindung wird geprüft…', ready: 'Aktiv', syncing: 'Wird synchronisiert…', error: 'Synchronisierung fehlgeschlagen' };
|
||||
document.getElementById('cloudLogPhase').textContent = localizeUiText(phases[status.phase] || phases.disabled);
|
||||
document.getElementById('cloudLogPhase').dataset.phase = status.phase || 'disabled';
|
||||
const keyState = document.getElementById('cloudLogKeyState');
|
||||
if (keyState) {
|
||||
keyState.textContent = localizeUiText(status.hasApiKey ? 'API-Key gespeichert' : 'Kein API-Key gespeichert');
|
||||
keyState.dataset.saved = String(Boolean(status.hasApiKey));
|
||||
}
|
||||
document.getElementById('cloudLogIp').textContent = status.ip || '—';
|
||||
document.getElementById('cloudLogLastSync').textContent = status.lastSyncedAt
|
||||
? new Date(status.lastSyncedAt).toLocaleString(getUiLocale()) : localizeUiText('Noch nicht synchronisiert');
|
||||
document.getElementById('cloudLogPending').textContent = (Number(status.pendingFiles) || 0).toLocaleString(getUiLocale());
|
||||
const key = document.getElementById('cloudLogKeyInput');
|
||||
key.placeholder = localizeUiText(status.hasApiKey ? 'Gespeicherten API-Key verwenden' : 'API-Key eingeben');
|
||||
document.getElementById('cloudLogActivateBtn').disabled = cloudLogBusy;
|
||||
document.getElementById('cloudLogDisableBtn').disabled = cloudLogBusy || !status.enabled;
|
||||
const busy = cloudLogBusy || cloudLogBackfillBusy || status.backfillRunning;
|
||||
document.getElementById('cloudLogActivateBtn').disabled = busy;
|
||||
document.getElementById('cloudLogDisableBtn').disabled = busy || !status.enabled;
|
||||
const backfillButton = document.getElementById('cloudLogBackfillBtn');
|
||||
if (backfillButton) {
|
||||
backfillButton.disabled = busy || !status.enabled || !['ready', 'syncing'].includes(status.phase);
|
||||
backfillButton.textContent = localizeUiText(status.backfillRunning || cloudLogBackfillBusy ? 'Vorhandenes Log wird eingelesen…' : 'Vorhandenes Log nachsynchronisieren');
|
||||
}
|
||||
const backfillResult = document.getElementById('cloudLogBackfillResult');
|
||||
if (backfillResult) {
|
||||
backfillResult.hidden = !status.backfillResult;
|
||||
backfillResult.textContent = status.backfillResult
|
||||
? localizeUiText('Neu übernommen') + ': ' + Number(status.backfillResult.added || 0).toLocaleString(getUiLocale())
|
||||
+ ' · ' + localizeUiText('Bereits vorhanden') + ': ' + Number(status.backfillResult.skipped || 0).toLocaleString(getUiLocale())
|
||||
: '';
|
||||
}
|
||||
const error = document.getElementById('cloudLogError');
|
||||
error.hidden = !status.errorCode;
|
||||
error.textContent = status.errorCode ? localizeUiText(cloudLogErrors[status.errorCode] || cloudLogErrors.CONNECTION_FAILED) : '';
|
||||
@@ -6448,7 +6474,7 @@ async function refreshCloudLogStatus() {
|
||||
}
|
||||
|
||||
async function configureCloudLog(enabled) {
|
||||
if (cloudLogBusy) return;
|
||||
if (cloudLogBusy || cloudLogBackfillBusy || cloudLogLastStatus?.backfillRunning) return;
|
||||
cloudLogBusy = true;
|
||||
const key = document.getElementById('cloudLogKeyInput');
|
||||
document.getElementById('cloudLogActivateBtn').disabled = true;
|
||||
@@ -6469,6 +6495,28 @@ async function configureCloudLog(enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
async function backfillCloudLog() {
|
||||
if (cloudLogBusy || cloudLogBackfillBusy || cloudLogLastStatus?.backfillRunning) return;
|
||||
cloudLogBackfillBusy = true;
|
||||
renderCloudLogStatus(cloudLogLastStatus);
|
||||
try {
|
||||
const response = await window.api.backfillCloudLog();
|
||||
if (response?.status) renderCloudLogStatus(response.status);
|
||||
if (response?.ok) {
|
||||
showCopyToast(response.result?.added > 0
|
||||
? 'Vorhandene Log-Einträge wurden zur Synchronisierung übernommen.'
|
||||
: 'Keine fehlenden Log-Einträge gefunden.');
|
||||
} else {
|
||||
showCopyToast(cloudLogErrors[response?.errorCode] || cloudLogErrors.LOG_READ_FAILED, 6500, 'error');
|
||||
}
|
||||
} catch {
|
||||
showCopyToast(cloudLogErrors.LOG_READ_FAILED, 6500, 'error');
|
||||
} finally {
|
||||
cloudLogBackfillBusy = false;
|
||||
await refreshCloudLogStatus();
|
||||
}
|
||||
}
|
||||
|
||||
async function _renderLogPathsList(el) {
|
||||
if (!el || !window.api || !window.api.getLogPaths) return;
|
||||
try {
|
||||
@@ -6851,20 +6899,30 @@ function renderSettings() {
|
||||
</div>
|
||||
<div class="settings-section-label">Clouddrop-Log-Synchronisierung</div>
|
||||
<div class="cloud-log-settings">
|
||||
<div class="cloud-log-heading" aria-live="polite">
|
||||
<div><span class="cloud-log-heading-label">Status</span><strong class="cloud-log-phase" id="cloudLogPhase" data-phase="disabled">Inaktiv</strong></div>
|
||||
<span class="cloud-log-key-state" id="cloudLogKeyState" data-saved="false">Kein API-Key gespeichert</span>
|
||||
</div>
|
||||
<p class="hint">Erfolgreiche Uploads automatisch als TXT in einem Clouddrop-Ordner mit der öffentlichen IP-Adresse dieses Geräts speichern. Die Übertragung beginnt mit der Aktivierung und folgt dem gewählten Log-Datei-Modus.</p>
|
||||
<div class="cloud-log-key-row">
|
||||
<label for="cloudLogKeyInput">Clouddrop-API-Key</label>
|
||||
<input type="password" class="key-input" id="cloudLogKeyInput" autocomplete="off" spellcheck="false" placeholder="API-Key eingeben">
|
||||
<div class="cloud-log-key-actions">
|
||||
<button class="btn btn-secondary" type="button" id="cloudLogActivateBtn">Prüfen und aktivieren</button>
|
||||
<button class="btn btn-secondary" type="button" id="cloudLogDisableBtn">Deaktivieren</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint">API-Key ohne Zielordner-Bindung verwenden. Bei der Prüfung wird eine leere Testdatei im IP-Ordner erstellt. Die öffentliche IP wird über ipify ermittelt.</p>
|
||||
<dl class="cloud-log-status" aria-live="polite">
|
||||
<div><dt>Status</dt><dd id="cloudLogPhase">Inaktiv</dd></div>
|
||||
<div><dt>IP-Ordner</dt><dd id="cloudLogIp">—</dd></div>
|
||||
<div><dt>Zuletzt synchronisiert</dt><dd id="cloudLogLastSync">—</dd></div>
|
||||
<div><dt>Ausstehende Dateien</dt><dd id="cloudLogPending">0</dd></div>
|
||||
<div><dt>Ausstehende Log-Dateien</dt><dd id="cloudLogPending">0</dd></div>
|
||||
</dl>
|
||||
<div class="cloud-log-backfill">
|
||||
<div><strong>Vorhandene Upload-Logs</strong><p class="hint">Überträgt fehlende Einträge aus der aktuellen lokalen Log-Datei. Bereits übernommene Einträge werden übersprungen; laufende Uploads bleiben aktiv.</p></div>
|
||||
<button class="btn btn-secondary" type="button" id="cloudLogBackfillBtn" disabled>Vorhandenes Log nachsynchronisieren</button>
|
||||
<p class="hint" id="cloudLogBackfillResult" role="status" hidden></p>
|
||||
</div>
|
||||
<p class="hint" id="cloudLogError" role="status" hidden></p>
|
||||
</div>
|
||||
<div class="settings-option verbose-logging-option">
|
||||
@@ -7262,6 +7320,7 @@ function renderSettings() {
|
||||
void refreshCloudLogStatus();
|
||||
document.getElementById('cloudLogActivateBtn')?.addEventListener('click', () => configureCloudLog(true));
|
||||
document.getElementById('cloudLogDisableBtn')?.addEventListener('click', () => configureCloudLog(false));
|
||||
document.getElementById('cloudLogBackfillBtn')?.addEventListener('click', backfillCloudLog);
|
||||
const testWebhookBtn = document.getElementById('testWebhookBtn');
|
||||
if (testWebhookBtn) {
|
||||
testWebhookBtn.addEventListener('click', async () => {
|
||||
|
||||
@@ -25,6 +25,22 @@
|
||||
['IP-Ordner', 'IP folder'],
|
||||
['Zuletzt synchronisiert', 'Last synced'],
|
||||
['Ausstehende Dateien', 'Pending files'],
|
||||
['Ausstehende Log-Dateien', 'Pending log files'],
|
||||
['API-Key gespeichert', 'API key saved'],
|
||||
['Kein API-Key gespeichert', 'No API key saved'],
|
||||
['Vorhandene Upload-Logs', 'Existing upload logs'],
|
||||
['Vorhandenes Log nachsynchronisieren', 'Sync existing log entries'],
|
||||
['Vorhandenes Log wird eingelesen…', 'Reading existing log entries…'],
|
||||
['Überträgt fehlende Einträge aus der aktuellen lokalen Log-Datei. Bereits übernommene Einträge werden übersprungen; laufende Uploads bleiben aktiv.', 'Transfers missing entries from the current local log file. Previously imported entries are skipped; running uploads remain active.'],
|
||||
['Neu übernommen', 'Newly imported'],
|
||||
['Bereits vorhanden', 'Already present'],
|
||||
['Vorhandene Log-Einträge wurden zur Synchronisierung übernommen.', 'Existing log entries have been queued for synchronization.'],
|
||||
['Keine fehlenden Log-Einträge gefunden.', 'No missing log entries found.'],
|
||||
['Bitte die CloudDrop-Verbindung zuerst prüfen und aktivieren.', 'Please verify and enable the CloudDrop connection first.'],
|
||||
['Die aktuelle lokale Upload-Log-Datei wurde noch nicht angelegt.', 'The current local upload log file has not been created yet.'],
|
||||
['Die aktuelle lokale Upload-Log-Datei konnte nicht vollständig gelesen werden. Bereits übernommene Einträge bleiben gespeichert.', 'The current local upload log file could not be read completely. Previously imported entries remain saved.'],
|
||||
['Die Upload-Log-Datei überschreitet das sichere Leselimit.', 'The upload log file exceeds the safe reading limit.'],
|
||||
['Die Nachsynchronisierung wurde beendet. Bereits übernommene Einträge bleiben gespeichert.', 'Backfill has stopped. Previously imported entries remain saved.'],
|
||||
['Noch nicht synchronisiert', 'Not synced yet'],
|
||||
['Verbindung wird geprüft…', 'Checking connection…'],
|
||||
['Wird synchronisiert…', 'Syncing…'],
|
||||
|
||||
+26
-6
@@ -5532,16 +5532,36 @@ input[type="checkbox"] {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.cloud-log-settings > .hint { margin: 0 0 12px; line-height: 1.5; }
|
||||
.cloud-log-key-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
|
||||
.cloud-log-key-row label { flex: 0 0 160px; font-size: 12px; }
|
||||
.cloud-log-key-row input { flex: 1 1 220px; min-width: 150px; }
|
||||
.cloud-log-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
|
||||
.cloud-log-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
|
||||
.cloud-log-heading > div { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
|
||||
.cloud-log-heading-label { font-size: 13px; color: var(--text-muted); }
|
||||
.cloud-log-phase { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
|
||||
.cloud-log-phase::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
|
||||
.cloud-log-phase[data-phase="ready"] { color: #a6e8c2; background: #23382e; border-color: #3e6650; }
|
||||
.cloud-log-phase[data-phase="syncing"], .cloud-log-phase[data-phase="checking"] { color: #c6d8ff; background: #29354a; border-color: #51668a; }
|
||||
.cloud-log-phase[data-phase="error"] { color: #ffb1b1; background: #432b2b; border-color: #754747; }
|
||||
.cloud-log-key-state { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; line-height: 1.4; }
|
||||
.cloud-log-key-state[data-saved="true"] { color: #a6e8c2; }
|
||||
.cloud-log-key-state[data-saved="true"]::before { content: '✓'; font-weight: 700; }
|
||||
.cloud-log-key-state[data-saved="false"] { color: var(--text-muted); }
|
||||
.cloud-log-key-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 12px; }
|
||||
.cloud-log-key-row label { font-size: 13px; }
|
||||
.cloud-log-key-row input { width: 100%; min-width: 0; }
|
||||
.cloud-log-key-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.cloud-log-status { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; margin: 18px 0 0; }
|
||||
.cloud-log-status > div { min-width: 0; }
|
||||
.cloud-log-status dt { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
|
||||
.cloud-log-status dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
|
||||
.cloud-log-status dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
|
||||
.cloud-log-backfill { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
|
||||
.cloud-log-backfill > div { flex: 1 1 260px; min-width: 0; }
|
||||
.cloud-log-backfill strong { font-size: 14px; }
|
||||
.cloud-log-backfill .hint { margin: 6px 0 0; font-size: 12px; line-height: 1.6; }
|
||||
.cloud-log-backfill > button { max-width: 100%; white-space: normal; min-height: 38px; }
|
||||
.cloud-log-backfill > p { flex: 0 0 100%; }
|
||||
.cloud-log-settings #cloudLogError:not([hidden]) { margin: 12px 0 0; padding: 10px; border: 1px solid var(--border); border-radius: 5px; }
|
||||
@media (max-width: 900px) {
|
||||
.cloud-log-key-row label { flex-basis: 100%; }
|
||||
.cloud-log-key-row { grid-template-columns: minmax(0, 1fr); }
|
||||
.cloud-log-key-actions { grid-column: 1; }
|
||||
.cloud-log-status { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user