Тест без кодекаса
This commit is contained in:
@@ -1342,6 +1342,57 @@
|
||||
}
|
||||
}
|
||||
|
||||
async uploadBackup() {
|
||||
const fileInput = document.getElementById('backupFileInput');
|
||||
const file = fileInput.files[0];
|
||||
|
||||
if (!file) {
|
||||
this.showToast('No file selected', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.name.endsWith('.tar.gz')) {
|
||||
this.showToast('Only .tar.gz files are supported', 'error');
|
||||
fileInput.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Show loading state
|
||||
const uploadBtn = Array.from(document.querySelectorAll('button')).find(btn => btn.textContent.includes('Upload archive'));
|
||||
const originalText = uploadBtn.textContent;
|
||||
uploadBtn.disabled = true;
|
||||
uploadBtn.textContent = 'Uploading...';
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const response = await fetch('/api/backups/upload', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error || 'Failed to upload backup');
|
||||
}
|
||||
|
||||
this.showToast('Backup uploaded successfully', 'success');
|
||||
fileInput.value = '';
|
||||
await this.loadBackups();
|
||||
} catch (err) {
|
||||
this.showToast(err.message, 'error');
|
||||
fileInput.value = '';
|
||||
} finally {
|
||||
const uploadBtn = Array.from(document.querySelectorAll('button')).find(btn => btn.textContent.includes('Upload') || btn.textContent.includes('Uploading'));
|
||||
if (uploadBtn) {
|
||||
uploadBtn.disabled = false;
|
||||
uploadBtn.textContent = 'Upload archive';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
try {
|
||||
const response = await fetch('/api/settings');
|
||||
|
||||
Reference in New Issue
Block a user