Тест без кодекаса
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');
|
||||
|
||||
@@ -330,7 +330,11 @@ SELECT * FROM users LIMIT 10;"></textarea>
|
||||
<h3 class="text-2xl font-bold text-slate-800">Backups</h3>
|
||||
<p class="text-sm text-slate-500 mt-1">Archives contain the SQL dump and, if enabled, the application snapshot.</p>
|
||||
</div>
|
||||
<button onclick="app.createBackup()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">Create archive</button>
|
||||
<div class="flex items-center gap-2">
|
||||
<button onclick="app.createBackup()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">Create archive</button>
|
||||
<button onclick="document.getElementById('backupFileInput').click()" class="px-4 py-2 bg-amber-600 hover:bg-amber-700 text-white rounded-lg">Upload archive</button>
|
||||
<input id="backupFileInput" type="file" accept=".tar.gz" style="display: none;" onchange="app.uploadBackup()">
|
||||
</div>
|
||||
</div>
|
||||
<label class="flex items-center gap-2 text-sm text-slate-700">
|
||||
<input type="checkbox" id="managementRestoreAppSnapshot" class="w-4 h-4" checked>
|
||||
|
||||
Reference in New Issue
Block a user