a1a3bd1b2b
- Fix recursive CTE: add missing RECURSIVE keyword in move_to_trash and restore_from_trash SQL queries (relation 'descendants' does not exist) - Fix folder deletion: delete descendant files before folder to avoid 'duplicate key violates unique constraint idx_files_unique_name_at_root' - Simplify trash model: only mark the folder as trashed, not child files (implicit trash via parent) - Update trash_items view: filter to show only top-level trashed items - Update schema.sql: change files.folder_id FK from ON DELETE SET NULL to ON DELETE CASCADE - Fix trash view icons: folders and files now show correct visual icons (folder-icon, pdf-icon, etc.) in trash view - Frontend refactoring: extract inline CSS/JS from admin.html and profile.html into dedicated external files - Frontend cleanup: replace all inline style attributes with CSS classes - Frontend cleanup: replace style.display JS - Fix recursive CTE: add missing RECURSIVE keyword in move_to_trash and restore_from_trash SQL queries (relation 'descendants' d
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
/**
|
|
* Search view orchestration logic
|
|
*/
|
|
|
|
async function performSearch(query, sortBy) {
|
|
const app = window.app;
|
|
|
|
console.log(`Performing search for: "${query}" (sort: ${sortBy || 'relevance'})`);
|
|
|
|
try {
|
|
app.isSearchMode = true;
|
|
window.ui.updateBreadcrumb(`Search: "${query}"`);
|
|
|
|
const filesGrid = document.getElementById('files-grid');
|
|
if (filesGrid) {
|
|
filesGrid.innerHTML = `
|
|
<div class="search-results-header">
|
|
<h3><i class="fas fa-spinner fa-spin" style="margin-right:8px;"></i> Searching for "${query}"...</h3>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
const options = {
|
|
recursive: true,
|
|
limit: 100,
|
|
sort_by: sortBy || 'relevance'
|
|
};
|
|
|
|
if (!app.isTrashView) {
|
|
options.folder_id = app.currentPath;
|
|
|
|
if (!options.folder_id || options.folder_id === '') {
|
|
await window.resolveHomeFolder();
|
|
options.folder_id = app.currentPath;
|
|
}
|
|
}
|
|
|
|
const searchResults = await window.search.searchFiles(query, options);
|
|
window.search.displaySearchResults(searchResults);
|
|
|
|
} catch (error) {
|
|
console.error('Search error:', error);
|
|
window.ui.showNotification('Error', 'Error performing search');
|
|
}
|
|
}
|
|
|
|
document.addEventListener('search-resort', (e) => {
|
|
const searchInput = document.querySelector('.search-container input');
|
|
if (searchInput && searchInput.value.trim()) {
|
|
performSearch(searchInput.value.trim(), e.detail.sort_by);
|
|
}
|
|
});
|
|
|
|
window.performSearch = performSearch;
|