APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
ed08f9c8d4
commit
6f048ad433
6 files changed
+937
-6
No files matched your search
+369
@@ -4858,6 +4858,150 @@
|
||||
<div id="backupScheduleMsg" style="margin-top:10px;font-size:12px;display:none;padding:8px 12px;border-radius:6px"></div>
|
||||
</div>
|
||||
|
||||
<!-- Stockage distant (FTP, SFTP, Google Drive, Dropbox, WebDAV, S3, Webhook) -->
|
||||
<div style="background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:18px;margin-top:16px">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:12px">
|
||||
<div>
|
||||
<strong style="font-size:15px;display:flex;align-items:center;gap:8px" data-i18n="backup_remote_title">
|
||||
☁️ Stockage distant (FTP, SFTP, Cloud)
|
||||
</strong>
|
||||
<p class="muted" style="margin:4px 0 0;font-size:13px" data-i18n="backup_remote_desc">
|
||||
Exportez automatiquement ou manuellement vos sauvegardes vers un serveur FTP/SFTP, Google Drive, Dropbox, WebDAV (Nextcloud/NAS), S3/MinIO ou Webhook.
|
||||
</p>
|
||||
</div>
|
||||
<label style="display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-weight:600;user-select:none">
|
||||
<input type="checkbox" id="backupRemoteEnabled" style="width:auto;margin:0" onchange="onBackupRemoteProviderChange()">
|
||||
<span data-i18n="backup_remote_enable">Activer le stockage distant</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="backupRemoteBody">
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;align-items:end;margin-bottom:14px">
|
||||
<div>
|
||||
<label class="label" for="backupRemoteProvider" data-i18n="backup_remote_provider_label">Destination distante</label>
|
||||
<select id="backupRemoteProvider" onchange="onBackupRemoteProviderChange()" style="margin-bottom:0">
|
||||
<option value="ftp">📡 Serveur FTP / FTPS</option>
|
||||
<option value="sftp">🔐 Serveur SFTP (SSH)</option>
|
||||
<option value="gdrive">☁️ Google Drive (API v3)</option>
|
||||
<option value="dropbox">📦 Dropbox (API v2)</option>
|
||||
<option value="webdav">🌐 WebDAV (Nextcloud / ownCloud / NAS)</option>
|
||||
<option value="s3">🪣 S3 / MinIO / Compatible S3</option>
|
||||
<option value="webhook">🔗 Webhook HTTP (POST / PUT)</option>
|
||||
</select>
|
||||
</div>
|
||||
<label style="display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;padding:8px 0;user-select:none">
|
||||
<input type="checkbox" id="backupRemoteAutoUpload" checked style="width:auto;margin:0">
|
||||
<span data-i18n="backup_remote_autoupload">Transférer automatiquement à chaque sauvegarde (Cron & manuelle)</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- FTP / FTPS -->
|
||||
<div id="remoteFields_ftp" class="remote-provider-fields" style="background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2fr 1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteFtpHost" data-i18n="backup_remote_host">Hôte / IP</label><input id="remoteFtpHost" type="text" placeholder="ftp.exemple.fr ou 192.168.1.10"></div>
|
||||
<div><label class="label" for="remoteFtpPort" data-i18n="backup_remote_port">Port</label><input id="remoteFtpPort" type="number" value="21" min="1" max="65535"></div>
|
||||
<div>
|
||||
<label class="label" for="remoteFtpTls" data-i18n="backup_remote_security">Sécurité</label>
|
||||
<select id="remoteFtpTls">
|
||||
<option value="none">FTP Standard</option>
|
||||
<option value="explicit">FTPS (TLS explicite)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteFtpUser" data-i18n="backup_remote_user">Utilisateur</label><input id="remoteFtpUser" type="text" placeholder="backup_user"></div>
|
||||
<div><label class="label" for="remoteFtpPass" data-i18n="backup_remote_pass">Mot de passe</label><input id="remoteFtpPass" type="password" placeholder="••••••••"></div>
|
||||
<div><label class="label" for="remoteFtpPath" data-i18n="backup_remote_path">Dossier distant</label><input id="remoteFtpPath" type="text" value="/backups/" placeholder="/backups/ap-manageur/"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SFTP (SSH) -->
|
||||
<div id="remoteFields_sftp" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2fr 1fr 1.5fr;gap:10px">
|
||||
<div><label class="label" for="remoteSftpHost" data-i18n="backup_remote_host">Hôte / IP</label><input id="remoteSftpHost" type="text" placeholder="nas.exemple.fr ou 192.168.1.10"></div>
|
||||
<div><label class="label" for="remoteSftpPort" data-i18n="backup_remote_port">Port</label><input id="remoteSftpPort" type="number" value="22" min="1" max="65535"></div>
|
||||
<div><label class="label" for="remoteSftpPath" data-i18n="backup_remote_path">Dossier distant</label><input id="remoteSftpPath" type="text" value="/backups/" placeholder="/home/user/backups/"></div>
|
||||
</div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteSftpUser" data-i18n="backup_remote_user">Utilisateur</label><input id="remoteSftpUser" type="text" placeholder="root ou backup"></div>
|
||||
<div><label class="label" for="remoteSftpPass" data-i18n="backup_remote_pass">Mot de passe (si pas de clé SSH)</label><input id="remoteSftpPass" type="password" placeholder="••••••••"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label" for="remoteSftpKey" data-i18n="backup_remote_ssh_key">Clé privée SSH (facultative — format PEM / OpenSSH)</label>
|
||||
<textarea id="remoteSftpKey" rows="3" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" style="font-family:monospace;font-size:11px"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Google Drive -->
|
||||
<div id="remoteFields_gdrive" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteGdriveToken" data-i18n="backup_remote_token">Jeton d’accès OAuth2 (Access Token)</label><input id="remoteGdriveToken" type="password" placeholder="ya29.a0..."></div>
|
||||
<div><label class="label" for="remoteGdriveFolder" data-i18n="backup_remote_gdrive_folder">ID du dossier Drive (facultatif)</label><input id="remoteGdriveFolder" type="text" placeholder="1AbCdEfGhIjKlMnOp..."></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dropbox -->
|
||||
<div id="remoteFields_dropbox" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteDropboxToken" data-i18n="backup_remote_token">Jeton d’accès (Access Token Dropbox)</label><input id="remoteDropboxToken" type="password" placeholder="sl.B..."></div>
|
||||
<div><label class="label" for="remoteDropboxPath" data-i18n="backup_remote_path">Dossier distant</label><input id="remoteDropboxPath" type="text" value="/AP-Manageur-Backups/" placeholder="/AP-Manageur-Backups/"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- WebDAV -->
|
||||
<div id="remoteFields_webdav" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div><label class="label" for="remoteWebdavUrl" data-i18n="backup_remote_webdav_url">URL WebDAV (Nextcloud / ownCloud / Synology / kDrive)</label><input id="remoteWebdavUrl" type="url" placeholder="https://cloud.exemple.fr/remote.php/dav/files/user/Backups/"></div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteWebdavUser" data-i18n="backup_remote_user">Utilisateur</label><input id="remoteWebdavUser" type="text" placeholder="utilisateur"></div>
|
||||
<div><label class="label" for="remoteWebdavPass" data-i18n="backup_remote_pass">Mot de passe / Mot de passe d’application</label><input id="remoteWebdavPass" type="password" placeholder="••••••••"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- S3 / MinIO -->
|
||||
<div id="remoteFields_s3" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2fr 1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteS3Endpoint" data-i18n="backup_remote_s3_endpoint">Endpoint S3 / MinIO</label><input id="remoteS3Endpoint" type="url" value="https://s3.amazonaws.com" placeholder="https://s3.fr-par.scw.cloud"></div>
|
||||
<div><label class="label" for="remoteS3Region" data-i18n="backup_remote_s3_region">Région</label><input id="remoteS3Region" type="text" value="us-east-1" placeholder="fr-par"></div>
|
||||
<div><label class="label" for="remoteS3Bucket" data-i18n="backup_remote_s3_bucket">Bucket</label><input id="remoteS3Bucket" type="text" placeholder="ap-backups"></div>
|
||||
</div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteS3AccessKey">Access Key</label><input id="remoteS3AccessKey" type="text" placeholder="AKIA..."></div>
|
||||
<div><label class="label" for="remoteS3SecretKey">Secret Key</label><input id="remoteS3SecretKey" type="password" placeholder="••••••••"></div>
|
||||
<div><label class="label" for="remoteS3Path" data-i18n="backup_remote_path">Préfixe / Dossier</label><input id="remoteS3Path" type="text" value="backups/" placeholder="backups/"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Webhook HTTP -->
|
||||
<div id="remoteFields_webhook" class="remote-provider-fields" style="display:none;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px">
|
||||
<div style="display:grid;grid-template-columns:2.5fr 1fr 1fr;gap:10px">
|
||||
<div><label class="label" for="remoteWebhookUrl">URL Webhook</label><input id="remoteWebhookUrl" type="url" placeholder="https://serveur.exemple.fr/upload"></div>
|
||||
<div>
|
||||
<label class="label" for="remoteWebhookMethod">Méthode</label>
|
||||
<select id="remoteWebhookMethod"><option value="POST">POST (multipart)</option><option value="PUT">PUT (binaire)</option></select>
|
||||
</div>
|
||||
<div><label class="label" for="remoteWebhookField">Champ fichier</label><input id="remoteWebhookField" type="text" value="backup" placeholder="backup"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label" for="remoteWebhookHeaders" data-i18n="backup_remote_headers">En-têtes HTTP personnalisés (1 par ligne : Clé: Valeur)</label>
|
||||
<textarea id="remoteWebhookHeaders" rows="2" placeholder="Authorization: Bearer mon_token" style="font-family:monospace;font-size:12px"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-top:12px">
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
|
||||
<button id="btnTestBackupRemote" type="button" class="secondary" onclick="testBackupRemote()" data-i18n="backup_remote_test_btn">
|
||||
🧪 Tester la connexion
|
||||
</button>
|
||||
<button id="btnSaveBackupRemote" type="button" onclick="saveBackupRemoteConfig()" data-i18n="backup_remote_save_btn">
|
||||
💾 Enregistrer le stockage distant
|
||||
</button>
|
||||
</div>
|
||||
<span id="backupRemoteLastStatus" class="muted" style="font-size:12px"></span>
|
||||
</div>
|
||||
<div id="backupRemoteMsg" style="margin-top:10px;font-size:12px;display:none;padding:8px 12px;border-radius:6px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Liste des sauvegardes enregistrées -->
|
||||
<div style="margin-top:20px">
|
||||
<div class="topline" style="flex-wrap:wrap;gap:10px;margin-bottom:12px">
|
||||
@@ -10629,6 +10773,7 @@ ${vpnBadgeTopo}
|
||||
<td style="text-align:right;white-space:nowrap">
|
||||
<div style="display:inline-flex;gap:6px;flex-wrap:wrap;justify-content:flex-end">
|
||||
<button type="button" class="secondary" style="padding:5px 10px;font-size:12px" onclick="downloadServerBackup('${safeArg}')" title="${escapeHtml(t('backup_btn_export', 'Exporter'))}">⬇️ ${escapeHtml(t('backup_btn_export', 'Exporter'))}</button>
|
||||
<button type="button" class="secondary" style="padding:5px 10px;font-size:12px;border-color:var(--green);color:var(--green)" onclick="uploadServerBackupToRemote('${safeArg}')" title="${escapeHtml(t('backup_btn_remote_push', 'Envoyer vers le stockage distant'))}">☁️ ${escapeHtml(t('backup_btn_remote_short', 'Distant'))}</button>
|
||||
<button type="button" class="secondary" style="padding:5px 10px;font-size:12px;border-color:var(--blue);color:var(--blue)" onclick="restoreServerBackup('${safeArg}')" title="${escapeHtml(t('backup_btn_restore', 'Restaurer'))}">♻️ ${escapeHtml(t('backup_btn_restore', 'Restaurer'))}</button>
|
||||
<button type="button" class="secondary danger" style="padding:5px 10px;font-size:12px;border-color:rgba(239,68,68,0.45);color:var(--red)" onclick="deleteServerBackup('${safeArg}')" title="${escapeHtml(t('btn_delete', 'Supprimer'))}">🗑️</button>
|
||||
</div>
|
||||
@@ -10662,6 +10807,7 @@ ${vpnBadgeTopo}
|
||||
if (!res.ok) throw new Error(d.error || 'Erreur chargement sauvegardes');
|
||||
if ($('backupDirBadge') && d.backup_dir) $('backupDirBadge').textContent = '📁 ' + d.backup_dir;
|
||||
applyBackupScheduleToUI(d.schedule);
|
||||
if (d.remote) applyBackupRemoteToUI(d.remote);
|
||||
renderServerBackupsTable(d.backups || [], d.total_size_str || '0 o');
|
||||
} catch (e) {
|
||||
const tbody = $('backupsTableBody');
|
||||
@@ -10838,6 +10984,229 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
}
|
||||
|
||||
function onBackupRemoteProviderChange() {
|
||||
const prov = $('backupRemoteProvider')?.value || 'ftp';
|
||||
const en = !!($('backupRemoteEnabled') && $('backupRemoteEnabled').checked);
|
||||
const body = $('backupRemoteBody');
|
||||
if (body) body.style.opacity = en ? '1' : '0.72';
|
||||
['ftp', 'sftp', 'gdrive', 'dropbox', 'webdav', 's3', 'webhook'].forEach(k => {
|
||||
const el = $('remoteFields_' + k);
|
||||
if (el) el.style.display = (k === prov) ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function getBackupRemotePayload() {
|
||||
return {
|
||||
enabled: !!($('backupRemoteEnabled') && $('backupRemoteEnabled').checked),
|
||||
auto_upload: !!($('backupRemoteAutoUpload') && $('backupRemoteAutoUpload').checked),
|
||||
provider: $('backupRemoteProvider')?.value || 'ftp',
|
||||
ftp: {
|
||||
host: $('remoteFtpHost')?.value?.trim() || '',
|
||||
port: parseInt($('remoteFtpPort')?.value || '21', 10) || 21,
|
||||
tls: $('remoteFtpTls')?.value || 'none',
|
||||
user: $('remoteFtpUser')?.value?.trim() || '',
|
||||
password: $('remoteFtpPass')?.value || '',
|
||||
path: $('remoteFtpPath')?.value?.trim() || '/backups/'
|
||||
},
|
||||
sftp: {
|
||||
host: $('remoteSftpHost')?.value?.trim() || '',
|
||||
port: parseInt($('remoteSftpPort')?.value || '22', 10) || 22,
|
||||
user: $('remoteSftpUser')?.value?.trim() || '',
|
||||
password: $('remoteSftpPass')?.value || '',
|
||||
key: $('remoteSftpKey')?.value?.trim() || '',
|
||||
path: $('remoteSftpPath')?.value?.trim() || '/backups/'
|
||||
},
|
||||
gdrive: {
|
||||
token: $('remoteGdriveToken')?.value?.trim() || '',
|
||||
folder_id: $('remoteGdriveFolder')?.value?.trim() || ''
|
||||
},
|
||||
dropbox: {
|
||||
token: $('remoteDropboxToken')?.value?.trim() || '',
|
||||
path: $('remoteDropboxPath')?.value?.trim() || '/AP-Manageur-Backups/'
|
||||
},
|
||||
webdav: {
|
||||
url: $('remoteWebdavUrl')?.value?.trim() || '',
|
||||
user: $('remoteWebdavUser')?.value?.trim() || '',
|
||||
password: $('remoteWebdavPass')?.value || ''
|
||||
},
|
||||
s3: {
|
||||
endpoint: $('remoteS3Endpoint')?.value?.trim() || 'https://s3.amazonaws.com',
|
||||
region: $('remoteS3Region')?.value?.trim() || 'us-east-1',
|
||||
bucket: $('remoteS3Bucket')?.value?.trim() || '',
|
||||
access_key: $('remoteS3AccessKey')?.value?.trim() || '',
|
||||
secret_key: $('remoteS3SecretKey')?.value || '',
|
||||
path: $('remoteS3Path')?.value?.trim() || 'backups/'
|
||||
},
|
||||
webhook: {
|
||||
url: $('remoteWebhookUrl')?.value?.trim() || '',
|
||||
method: $('remoteWebhookMethod')?.value || 'POST',
|
||||
field_name: $('remoteWebhookField')?.value?.trim() || 'backup',
|
||||
headers: $('remoteWebhookHeaders')?.value || ''
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function applyBackupRemoteToUI(rcfg) {
|
||||
if (!rcfg) return;
|
||||
if ($('backupRemoteEnabled')) $('backupRemoteEnabled').checked = !!rcfg.enabled;
|
||||
if ($('backupRemoteAutoUpload')) $('backupRemoteAutoUpload').checked = rcfg.auto_upload !== false;
|
||||
if ($('backupRemoteProvider') && rcfg.provider) $('backupRemoteProvider').value = rcfg.provider;
|
||||
|
||||
const f = rcfg.ftp || {};
|
||||
if ($('remoteFtpHost')) $('remoteFtpHost').value = f.host || '';
|
||||
if ($('remoteFtpPort')) $('remoteFtpPort').value = f.port || 21;
|
||||
if ($('remoteFtpTls')) $('remoteFtpTls').value = f.tls || 'none';
|
||||
if ($('remoteFtpUser')) $('remoteFtpUser').value = f.user || '';
|
||||
if ($('remoteFtpPass')) $('remoteFtpPass').value = f.password || '';
|
||||
if ($('remoteFtpPath')) $('remoteFtpPath').value = f.path || '/backups/';
|
||||
|
||||
const s = rcfg.sftp || {};
|
||||
if ($('remoteSftpHost')) $('remoteSftpHost').value = s.host || '';
|
||||
if ($('remoteSftpPort')) $('remoteSftpPort').value = s.port || 22;
|
||||
if ($('remoteSftpUser')) $('remoteSftpUser').value = s.user || '';
|
||||
if ($('remoteSftpPass')) $('remoteSftpPass').value = s.password || '';
|
||||
if ($('remoteSftpKey')) $('remoteSftpKey').value = s.key || '';
|
||||
if ($('remoteSftpPath')) $('remoteSftpPath').value = s.path || '/backups/';
|
||||
|
||||
const g = rcfg.gdrive || {};
|
||||
if ($('remoteGdriveToken')) $('remoteGdriveToken').value = g.token || '';
|
||||
if ($('remoteGdriveFolder')) $('remoteGdriveFolder').value = g.folder_id || '';
|
||||
|
||||
const dbx = rcfg.dropbox || {};
|
||||
if ($('remoteDropboxToken')) $('remoteDropboxToken').value = dbx.token || '';
|
||||
if ($('remoteDropboxPath')) $('remoteDropboxPath').value = dbx.path || '/AP-Manageur-Backups/';
|
||||
|
||||
const wd = rcfg.webdav || {};
|
||||
if ($('remoteWebdavUrl')) $('remoteWebdavUrl').value = wd.url || '';
|
||||
if ($('remoteWebdavUser')) $('remoteWebdavUser').value = wd.user || '';
|
||||
if ($('remoteWebdavPass')) $('remoteWebdavPass').value = wd.password || '';
|
||||
|
||||
const s3 = rcfg.s3 || {};
|
||||
if ($('remoteS3Endpoint')) $('remoteS3Endpoint').value = s3.endpoint || 'https://s3.amazonaws.com';
|
||||
if ($('remoteS3Region')) $('remoteS3Region').value = s3.region || 'us-east-1';
|
||||
if ($('remoteS3Bucket')) $('remoteS3Bucket').value = s3.bucket || '';
|
||||
if ($('remoteS3AccessKey')) $('remoteS3AccessKey').value = s3.access_key || '';
|
||||
if ($('remoteS3SecretKey')) $('remoteS3SecretKey').value = s3.secret_key || '';
|
||||
if ($('remoteS3Path')) $('remoteS3Path').value = s3.path || 'backups/';
|
||||
|
||||
const wh = rcfg.webhook || {};
|
||||
if ($('remoteWebhookUrl')) $('remoteWebhookUrl').value = wh.url || '';
|
||||
if ($('remoteWebhookMethod')) $('remoteWebhookMethod').value = wh.method || 'POST';
|
||||
if ($('remoteWebhookField')) $('remoteWebhookField').value = wh.field_name || 'backup';
|
||||
if ($('remoteWebhookHeaders')) $('remoteWebhookHeaders').value = wh.headers || '';
|
||||
|
||||
const stEl = $('backupRemoteLastStatus');
|
||||
if (stEl) {
|
||||
if (rcfg.last_upload_time) {
|
||||
const icon = rcfg.last_upload_status === 'ok' ? '✅' : '❌';
|
||||
stEl.textContent = `${icon} ${t('backup_remote_last_upload', 'Dernier envoi :')} ${rcfg.last_upload_time} (${rcfg.last_upload_file || ''})${rcfg.last_upload_error ? ' — ' + rcfg.last_upload_error : ''}`;
|
||||
} else {
|
||||
stEl.textContent = '';
|
||||
}
|
||||
}
|
||||
onBackupRemoteProviderChange();
|
||||
}
|
||||
|
||||
async function saveBackupRemoteConfig() {
|
||||
const msg = $('backupRemoteMsg');
|
||||
const btn = $('btnSaveBackupRemote');
|
||||
if (btn) btn.disabled = true;
|
||||
try {
|
||||
const res = await apiFetch('/api/backups/remote', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(getBackupRemotePayload())
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Erreur enregistrement');
|
||||
if (d.remote) applyBackupRemoteToUI(d.remote);
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(50,213,131,0.12)';
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = '✓ ' + t('backup_remote_saved', 'Configuration du stockage distant enregistrée !');
|
||||
setTimeout(() => { if (msg) msg.style.display = 'none'; }, 5000);
|
||||
}
|
||||
} catch (e) {
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(239,68,68,0.12)';
|
||||
msg.style.color = 'var(--red)';
|
||||
msg.textContent = '❌ ' + tErr(e.message);
|
||||
}
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function testBackupRemote() {
|
||||
const msg = $('backupRemoteMsg');
|
||||
const btn = $('btnTestBackupRemote');
|
||||
if (btn) btn.disabled = true;
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(56,189,248,0.12)';
|
||||
msg.style.color = 'var(--blue)';
|
||||
msg.textContent = t('backup_remote_testing', 'Test de connexion et de transfert en cours…');
|
||||
}
|
||||
try {
|
||||
const res = await apiFetch('/api/backups/remote/test', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ config: getBackupRemotePayload() }),
|
||||
timeout: 45000
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Échec du test');
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(50,213,131,0.12)';
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = '✓ ' + (d.message || t('backup_remote_test_ok', 'Connexion et transfert réussis !'));
|
||||
}
|
||||
} catch (e) {
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(239,68,68,0.12)';
|
||||
msg.style.color = 'var(--red)';
|
||||
msg.textContent = '❌ ' + tErr(e.message);
|
||||
}
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadServerBackupToRemote(filename) {
|
||||
const msg = $('backupActionMsg');
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(56,189,248,0.12)';
|
||||
msg.style.color = 'var(--blue)';
|
||||
msg.textContent = t('backup_remote_uploading', 'Envoi de « {file} » vers le stockage distant…').replace('{file}', filename);
|
||||
}
|
||||
try {
|
||||
const res = await apiFetch('/api/backups/remote/upload', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filename }),
|
||||
timeout: 120000
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Échec du transfert distant');
|
||||
if (d.remote) applyBackupRemoteToUI(d.remote);
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(50,213,131,0.12)';
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = '✓ ' + (d.message || t('backup_remote_upload_ok', 'Sauvegarde transférée vers le stockage distant !'));
|
||||
setTimeout(() => { if (msg) msg.style.display = 'none'; }, 7000);
|
||||
}
|
||||
} catch (e) {
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(239,68,68,0.12)';
|
||||
msg.style.color = 'var(--red)';
|
||||
msg.textContent = '❌ ' + tErr(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const EYE_OPEN = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.5-8 10-8 10 8 10 8-3.5 8-10 8S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg>';
|
||||
const EYE_OFF = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 10.6a2 2 0 0 0 2.8 2.8M9.9 4.2A10.7 10.7 0 0 1 12 4c5 0 8.5 4 10 8a16.7 16.7 0 0 1-3.1 4.8M6.6 6.6C4.7 7.8 3.5 9.7 2 12c1.5 4 5 8 10 8 1 0 2-.2 2.9-.5"/></svg>';
|
||||
const REGISTERED_PASSWORD_TOGGLES = [];
|
||||
|
||||
Reference in new issue
Block a user