Fix backup restore freezing the panel with loading feedback.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -761,6 +761,10 @@
|
||||
<button class="btn btn-secondary btn-sm" onclick="loadProtocolBackups()">{{ _('refresh') }}</button>
|
||||
</div>
|
||||
<div class="form-hint hidden" id="exportClientsHint" style="margin-bottom:var(--space-md);">{{ _('export_client_configs_hint') }}</div>
|
||||
<div id="backupBusy" class="hidden" style="display:none; align-items:center; gap:var(--space-sm); margin-bottom:var(--space-md); padding:var(--space-md); border-radius:12px; background:var(--accent-glow); border:1px solid color-mix(in srgb, var(--accent) 35%, transparent);">
|
||||
<div class="spinner" style="width:18px;height:18px;border-width:2px;"></div>
|
||||
<span id="backupBusyText">{{ _('restoring_protocol_backup') }}</span>
|
||||
</div>
|
||||
<div id="backupLoading" class="form-hint hidden">{{ _('loading') }}</div>
|
||||
<div id="backupEmpty" class="empty-state hidden" style="padding:var(--space-xl);">
|
||||
<div class="empty-icon">{{ icon('package') }}</div>
|
||||
@@ -2129,11 +2133,38 @@
|
||||
|
||||
async function restoreProtocolBackup(proto, filename) {
|
||||
if (!confirm(_('restore_protocol_backup_confirm'))) return;
|
||||
|
||||
const busy = document.getElementById('backupBusy');
|
||||
const busyText = document.getElementById('backupBusyText');
|
||||
const createBtn = document.getElementById('createBackupBtn');
|
||||
const exportBtn = document.getElementById('exportClientsBtn');
|
||||
const list = document.getElementById('backupList');
|
||||
const restoreButtons = list ? Array.from(list.querySelectorAll('button')) : [];
|
||||
|
||||
if (busyText) busyText.textContent = _('restoring_protocol_backup');
|
||||
if (busy) {
|
||||
busy.classList.remove('hidden');
|
||||
busy.style.display = 'flex';
|
||||
}
|
||||
if (createBtn) createBtn.disabled = true;
|
||||
if (exportBtn) exportBtn.disabled = true;
|
||||
restoreButtons.forEach(b => { b.disabled = true; });
|
||||
showToast(_('restoring_protocol_backup'), 'info');
|
||||
|
||||
try {
|
||||
await apiCall(`/api/servers/${SERVER_ID}/backups/restore`, 'POST', { protocol: proto, filename });
|
||||
showToast(_('restore_protocol_backup_done'), 'success');
|
||||
await loadProtocolBackups();
|
||||
} catch (err) {
|
||||
showToast(_('error') + ': ' + err.message, 'error');
|
||||
await loadProtocolBackups();
|
||||
} finally {
|
||||
if (busy) {
|
||||
busy.classList.add('hidden');
|
||||
busy.style.display = 'none';
|
||||
}
|
||||
if (createBtn) createBtn.disabled = false;
|
||||
if (exportBtn) exportBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user