Add persistent Clouddrop synchronization for successful upload logs
CI / verify (push) Canceled after 0s
CI / verify (push) Canceled after 0s
This commit is contained in:
1 parent
be57ce13e2
commit
6182aa2262
13 files changed
+650
-2
No files matched your search
@@ -40,6 +40,7 @@ function refreshLocalizedRuntimeUi() {
|
||||
updateStatusBar();
|
||||
refreshAutomationControlCenter();
|
||||
refreshAutomationTestOverlay();
|
||||
renderCloudLogStatus(cloudLogLastStatus);
|
||||
const activeRecentTab = document.querySelector('.recent-tab.active');
|
||||
const hint = document.getElementById('recentFilesHint');
|
||||
if (hint && activeRecentTab) hint.textContent = localizeUiText(activeRecentTab.dataset.panel === 'statsTab' ? 'Upload-Statistiken' : 'Zuletzt erzeugte Upload-Links');
|
||||
@@ -6384,6 +6385,69 @@ async function runHealthCheck(mode = 'manual', requestedHosters = null) {
|
||||
}
|
||||
|
||||
// --- Settings ---
|
||||
let cloudLogBusy = false;
|
||||
let cloudLogLastStatus = null;
|
||||
const cloudLogErrors = {
|
||||
KEY_STORAGE_UNAVAILABLE: 'Der API-Key konnte nicht im sicheren Zugangsdaten-Speicher gesichert werden.',
|
||||
INVALID_KEY: 'Der Clouddrop-API-Key ist ungültig oder wurde widerrufen.',
|
||||
ACCESS_DENIED: 'Der API-Key hat keine Berechtigung für diese Aktion.',
|
||||
UNRESTRICTED_KEY_REQUIRED: 'Für die Synchronisierung wird ein API-Key ohne Zielordner-Bindung benötigt.',
|
||||
IP_UNAVAILABLE: 'Die öffentliche IP-Adresse konnte nicht ermittelt werden.',
|
||||
CONNECTION_FAILED: 'Clouddrop ist nicht erreichbar. Ausstehende Einträge bleiben lokal gespeichert.',
|
||||
RATE_LIMIT: 'Clouddrop begrenzt die Anfragen. Die Synchronisierung wird automatisch erneut versucht.',
|
||||
LOCAL_WRITE_FAILED: 'Die lokale Synchronisierungsdatei konnte nicht gespeichert werden. Bitte Speicherplatz und Zugriffsrechte prüfen.',
|
||||
LOCAL_STATE_INVALID: 'Die lokale Synchronisierungsdatei konnte nicht gelesen werden.',
|
||||
REMOTE_ERROR: 'Clouddrop hat die Aktualisierung abgelehnt. Ausstehende Einträge bleiben lokal gespeichert.',
|
||||
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.'
|
||||
};
|
||||
|
||||
function renderCloudLogStatus(status) {
|
||||
if (status) cloudLogLastStatus = 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('cloudLogIp').textContent = status.ip ? status.ip.replaceAll(':', '_') : '—';
|
||||
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 error = document.getElementById('cloudLogError');
|
||||
error.hidden = !status.errorCode;
|
||||
error.textContent = status.errorCode ? localizeUiText(cloudLogErrors[status.errorCode] || cloudLogErrors.CONNECTION_FAILED) : '';
|
||||
}
|
||||
|
||||
async function refreshCloudLogStatus() {
|
||||
try { renderCloudLogStatus(await window.api.getCloudLogStatus?.()); } catch {}
|
||||
}
|
||||
|
||||
async function configureCloudLog(enabled) {
|
||||
if (cloudLogBusy) return;
|
||||
cloudLogBusy = true;
|
||||
const key = document.getElementById('cloudLogKeyInput');
|
||||
document.getElementById('cloudLogActivateBtn').disabled = true;
|
||||
document.getElementById('cloudLogDisableBtn').disabled = true;
|
||||
try {
|
||||
const result = await window.api.configureCloudLog({ enabled, apiKey: key?.value.trim() || '' });
|
||||
if (result?.ok) {
|
||||
if (key) key.value = '';
|
||||
showCopyToast(enabled ? 'Clouddrop-Log-Synchronisierung ist aktiv.' : 'Clouddrop-Log-Synchronisierung ist deaktiviert.');
|
||||
} else {
|
||||
showCopyToast(cloudLogErrors[result?.errorCode] || cloudLogErrors.CONNECTION_FAILED, 6500, 'error');
|
||||
}
|
||||
} catch {
|
||||
showCopyToast(cloudLogErrors.CONNECTION_FAILED, 6500, 'error');
|
||||
} finally {
|
||||
cloudLogBusy = false;
|
||||
await refreshCloudLogStatus();
|
||||
}
|
||||
}
|
||||
|
||||
async function _renderLogPathsList(el) {
|
||||
if (!el || !window.api || !window.api.getLogPaths) return;
|
||||
try {
|
||||
@@ -6754,6 +6818,24 @@ function renderSettings() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-section-label">Clouddrop-Log-Synchronisierung</div>
|
||||
<div class="cloud-log-settings">
|
||||
<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">
|
||||
<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>
|
||||
<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>
|
||||
</dl>
|
||||
<p class="hint" id="cloudLogError" role="status" hidden></p>
|
||||
</div>
|
||||
<div class="settings-option verbose-logging-option">
|
||||
<div class="settings-option-copy">
|
||||
<label for="logVerboseInput">Verbose Logging</label>
|
||||
@@ -7146,6 +7228,9 @@ function renderSettings() {
|
||||
});
|
||||
|
||||
_renderLogPathsList(document.getElementById('logPathsList'));
|
||||
void refreshCloudLogStatus();
|
||||
document.getElementById('cloudLogActivateBtn')?.addEventListener('click', () => configureCloudLog(true));
|
||||
document.getElementById('cloudLogDisableBtn')?.addEventListener('click', () => configureCloudLog(false));
|
||||
const testWebhookBtn = document.getElementById('testWebhookBtn');
|
||||
if (testWebhookBtn) {
|
||||
testWebhookBtn.addEventListener('click', async () => {
|
||||
@@ -10631,6 +10716,7 @@ function updateStatsPanel() {
|
||||
|
||||
// --- Start ---
|
||||
window.api.onUpdateAvailable(showUpdateBanner);
|
||||
window.api.onCloudLogStatus?.(renderCloudLogStatus);
|
||||
window.api.onUpdateProgress(handleUpdateProgress);
|
||||
window.api.onPrepareClose(prepareForWindowClose);
|
||||
initializeStaticHeader();
|
||||
|
||||
@@ -4,6 +4,37 @@
|
||||
if (root) root.I18n = api;
|
||||
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
||||
const pairs = [
|
||||
['Clouddrop-Log-Synchronisierung', 'Clouddrop log sync'],
|
||||
['Der API-Key konnte nicht im sicheren Zugangsdaten-Speicher gesichert werden.', 'The API key could not be saved in secure credential storage.'],
|
||||
['Clouddrop-API-Key', 'Clouddrop API key'],
|
||||
['Prüfen und aktivieren', 'Verify and enable'],
|
||||
['Deaktivieren', 'Disable'],
|
||||
['API-Key eingeben', 'Enter API key'],
|
||||
['Gespeicherten API-Key verwenden', 'Use saved API key'],
|
||||
['IP-Ordner', 'IP folder'],
|
||||
['Zuletzt synchronisiert', 'Last synced'],
|
||||
['Ausstehende Dateien', 'Pending files'],
|
||||
['Noch nicht synchronisiert', 'Not synced yet'],
|
||||
['Verbindung wird geprüft…', 'Checking connection…'],
|
||||
['Wird synchronisiert…', 'Syncing…'],
|
||||
['Synchronisierung fehlgeschlagen', 'Sync failed'],
|
||||
['Clouddrop-Log-Synchronisierung ist aktiv.', 'Clouddrop log sync is enabled.'],
|
||||
['Clouddrop-Log-Synchronisierung ist deaktiviert.', 'Clouddrop log sync is disabled.'],
|
||||
['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.', 'Automatically save successful uploads as TXT files in a Clouddrop folder named after this device’s public IP address. Sync starts when enabled and follows the selected log file mode.'],
|
||||
['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.', 'Use an API key without a target folder restriction. Verification creates an empty test file in the IP folder. The public IP is obtained through ipify.'],
|
||||
['Der Clouddrop-API-Key ist ungültig oder wurde widerrufen.', 'The Clouddrop API key is invalid or has been revoked.'],
|
||||
['Der API-Key hat keine Berechtigung für diese Aktion.', 'The API key does not have permission for this action.'],
|
||||
['Für die Synchronisierung wird ein API-Key ohne Zielordner-Bindung benötigt.', 'Sync requires an API key without a target folder restriction.'],
|
||||
['Die öffentliche IP-Adresse konnte nicht ermittelt werden.', 'The public IP address could not be determined.'],
|
||||
['Clouddrop ist nicht erreichbar. Ausstehende Einträge bleiben lokal gespeichert.', 'Clouddrop could not be reached. Pending entries remain saved locally.'],
|
||||
['Clouddrop begrenzt die Anfragen. Die Synchronisierung wird automatisch erneut versucht.', 'Clouddrop is rate limiting requests. Sync will retry automatically.'],
|
||||
['Die lokale Synchronisierungsdatei konnte nicht gespeichert werden. Bitte Speicherplatz und Zugriffsrechte prüfen.', 'The local sync file could not be saved. Check disk space and access permissions.'],
|
||||
['Die lokale Synchronisierungsdatei konnte nicht gelesen werden.', 'The local sync file could not be read.'],
|
||||
['Clouddrop hat die Aktualisierung abgelehnt. Ausstehende Einträge bleiben lokal gespeichert.', 'Clouddrop rejected the update. Pending entries remain saved locally.'],
|
||||
['Clouddrop hat eine unerwartete Antwort geliefert.', 'Clouddrop returned an unexpected response.'],
|
||||
['Die Testdatei konnte nicht verifiziert werden.', 'The test file could not be verified.'],
|
||||
['Die Clouddrop-Antwort überschreitet die zulässige Größe.', 'The Clouddrop response exceeds the allowed size.'],
|
||||
['Ein Log-Eintrag überschreitet die zulässige Größe.', 'A log entry exceeds the allowed size.'],
|
||||
['Speicher', 'Storage'],
|
||||
['Alternative', 'Alternate'],
|
||||
['Arbeitsbereich', 'Workspace'],
|
||||
|
||||
@@ -5335,3 +5335,22 @@ input[type="checkbox"] {
|
||||
grid-template-columns: 280px minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
.cloud-log-settings {
|
||||
padding: 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
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-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-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-status { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
Reference in new issue
Block a user