working now
This commit is contained in:
@@ -1643,8 +1643,48 @@ async function createBackup() {
|
||||
}
|
||||
}
|
||||
|
||||
function downloadBackup(filename) {
|
||||
window.open('/api/admin/backup/download', '_blank');
|
||||
async function downloadBackup(filename) {
|
||||
try {
|
||||
const response = await fetch('/api/admin/backup/download', {
|
||||
method: 'GET',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
let errorMsg = 'Failed to download backup';
|
||||
try {
|
||||
const err = await response.json();
|
||||
errorMsg = err.detail || errorMsg;
|
||||
} catch (_) {}
|
||||
showAlert(errorMsg, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
|
||||
// Try to extract filename from headers if provided
|
||||
let suggestedName = filename || 'database_backup.db';
|
||||
const disp = response.headers.get('Content-Disposition') || response.headers.get('content-disposition');
|
||||
if (disp) {
|
||||
const match = /filename\*=UTF-8''([^;]+)|filename="?([^";]+)"?/i.exec(disp);
|
||||
const extracted = match && (match[1] || match[2]);
|
||||
if (extracted) {
|
||||
try { suggestedName = decodeURIComponent(extracted); } catch (_) { suggestedName = extracted; }
|
||||
}
|
||||
}
|
||||
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = suggestedName;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
} catch (error) {
|
||||
console.error('Backup download failed:', error);
|
||||
showAlert('Failed to download backup', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Utility Functions
|
||||
|
||||
@@ -407,7 +407,7 @@
|
||||
// Advanced Search JavaScript
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize search components
|
||||
initializeSearch();
|
||||
initializeAdvancedSearch();
|
||||
loadSearchFacets();
|
||||
setupEventHandlers();
|
||||
setupKeyboardShortcuts();
|
||||
@@ -424,7 +424,7 @@ let currentSearchCriteria = {};
|
||||
let searchTimeout;
|
||||
let facetsData = {};
|
||||
|
||||
function initializeSearch() {
|
||||
function initializeAdvancedSearch() {
|
||||
// Set default date for today
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user