Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: resolve file upload and indexing functionality issues

LearningCircuit8709688e3d61
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index 67b1f4ec29..7fb9fd85ce 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -81,6 +81,27 @@ def collection_details_page(collection_id):
)
+@rag_bp.route("/collections/<string:collection_id>/upload")
+@login_required
+def collection_upload_page(collection_id):
+ """Render the Collection Upload page."""
+ return render_template(
+ "pages/collection_upload.html",
+ active_page="collections",
+ collection_id=collection_id,
+ collection_name=None, # Could fetch from DB if needed
+ )
+
+
+@rag_bp.route("/collections/create")
+@login_required
+def collection_create_page():
+ """Render the Create Collection page."""
+ return render_template(
+ "pages/collection_create.html", active_page="collections"
+ )
+
+
# API Routes
diff --git a/src/local_deep_research/web/static/css/collection_details.css b/src/local_deep_research/web/static/css/collection_details.css
index 4ca249e6bd..646fd5475b 100644
--- a/src/local_deep_research/web/static/css/collection_details.css
+++ b/src/local_deep_research/web/static/css/collection_details.css
@@ -2,17 +2,13 @@
.ldr-rag-manager-container {
max-width: 1200px;
margin: 0 auto;
- padding: 20px;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- min-height: 100vh;
- border-radius: 20px;
- box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
+ padding: 2rem;
+ animation: fadeInUp 0.6s ease;
}
/* Header Section */
.ldr-rag-header {
- background: rgba(255, 255, 255, 0.95);
- backdrop-filter: blur(10px);
+ background: transparent;
border-radius: 16px;
padding: 30px;
margin-bottom: 25px;
@@ -29,17 +25,10 @@
display: flex;
align-items: center;
gap: 15px;
- background: linear-gradient(135deg, #667eea, #764ba2);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- background-clip: text;
}
.ldr-rag-header h1 i {
- background: linear-gradient(135deg, #667eea, #764ba2);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- background-clip: text;
+ color: #667eea;
}
.ldr-subtitle {
@@ -51,8 +40,7 @@
/* Section Styling */
.ldr-rag-section {
- background: rgba(255, 255, 255, 0.95);
- backdrop-filter: blur(10px);
+ background: transparent;
border-radius: 16px;
padding: 25px;
margin-bottom: 25px;
@@ -259,7 +247,7 @@
font-size: 0.9rem;
font-weight: 500;
border: 2px solid #e2e8f0;
- background: white;
+ background: rgba(255, 255, 255, 0.1);
color: #4a5568;
transition: all 0.3s ease;
}
@@ -402,7 +390,7 @@
/* Document Items */
.ldr-document-item {
- background: white;
+ background: rgba(255, 255, 255, 0.8);
border-radius: 12px;
padding: 20px;
margin-bottom: 15px;
@@ -677,3 +665,335 @@
border-color: #4a5568;
}
}
+
+/* Drop Zone Styles */
+.ldr-drop-zone {
+ border: 2px dashed #ccc;
+ border-radius: 8px;
+ padding: 40px 20px;
+ text-align: center;
+ background-color: rgba(248, 249, 250, 0.5);
+ transition: all 0.3s ease;
+ cursor: pointer;
+}
+
+.ldr-drop-zone:hover {
+ border-color: #007bff;
+ background-color: #e9ecef;
+}
+
+.ldr-drop-zone.ldr-drag-over {
+ border-color: #28a745;
+ background-color: #d4edda;
+ border-style: solid;
+}
+
+.ldr-drop-zone-text {
+ margin: 15px 0 5px;
+ font-size: 18px;
+ font-weight: 500;
+}
+
+.ldr-drop-zone-subtext {
+ margin: 5px 0 15px;
+ color: #6c757d;
+}
+
+.ldr-selected-files {
+ margin-top: 15px;
+ padding: 15px;
+ background-color: rgba(248, 249, 250, 0.5);
+ border-radius: 6px;
+}
+
+.ldr-selected-files ul {
+ list-style: none;
+ padding: 0;
+ margin: 10px 0 0;
+}
+
+.ldr-selected-files li {
+ padding: 8px 12px;
+ margin: 5px 0;
+ background-color: rgba(255, 255, 255, 0.6);
+ border: 1px solid #dee2e6;
+ border-radius: 4px;
+ display: flex;
+ align-items: center;
+ gap: 10px;
+}
+
+.ldr-selected-files li i {
+ color: #007bff;
+}
+
+/* Modal Styles */
+.ldr-modal {
+ display: none;
+ position: fixed;
+ z-index: 1000;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.7);
+ backdrop-filter: blur(5px);
+ animation: fadeIn 0.3s ease;
+}
+
+.ldr-modal-content {
+ background: rgba(255, 255, 255, 0.1);
+ margin: 5% auto;
+ border: 1px solid rgba(255, 255, 255, 0.2);
+ border-radius: 16px;
+ width: 90%;
+ max-width: 500px;
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
+ animation: slideInDown 0.3s ease;
+ overflow: hidden;
+}
+
+@keyframes slideInDown {
+ from {
+ opacity: 0;
+ transform: translateY(-50px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+.ldr-modal-header {
+ background: rgba(102, 126, 234, 0.1);
+ color: #2d3748;
+ padding: 1.5rem;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.ldr-modal-header h3 {
+ margin: 0;
+ font-size: 1.4rem;
+ font-weight: 600;
+}
+
+.ldr-close {
+ color: #2d3748;
+ font-size: 1.5rem;
+ font-weight: bold;
+ cursor: pointer;
+ line-height: 1;
+ opacity: 0.8;
+ transition: opacity 0.2s ease;
+ background: none;
+ border: none;
+ padding: 0.25rem;
+ border-radius: 4px;
+}
+
+.ldr-close:hover {
+ opacity: 1;
+ background: rgba(255, 255, 255, 0.1);
+}
+
+.ldr-modal-body {
+ padding: 2rem;
+}
+
+/* Form Styles */
+.ldr-form-group {
+ margin-bottom: 1.5rem;
+}
+
+.ldr-form-group label {
+ display: block;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ color: #718096;
+ font-size: 0.95rem;
+}
+
+.ldr-form-group input[type="text"],
+.ldr-form-group textarea {
+ width: 100%;
+ padding: 0.75rem 1rem;
+ border: 2px solid #e2e8f0;
+ border-radius: 10px;
+ background-color: rgba(255, 255, 255, 0.1);
+ color: #2d3748;
+ font-family: inherit;
+ font-size: 1rem;
+ transition: all 0.3s ease;
+}
+
+.ldr-form-group input[type="text"]:focus,
+.ldr-form-group textarea:focus {
+ outline: none;
+ border-color: #667eea;
+ box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
+ transform: translateY(-2px);
+}
+
+.ldr-form-group textarea {
+ resize: vertical;
+ min-height: 100px;
+}
+
+.ldr-form-actions {
+ display: flex;
+ gap: 1rem;
+ justify-content: flex-end;
+ margin-top: 2rem;
+ padding-top: 1.5rem;
+ border-top: 1px solid #e2e8f0;
+}
+
+.ldr-form-help {
+ color: #718096;
+ font-size: 0.9rem;
+ margin-top: 0.5rem;
+ font-style: italic;
+}
+
+/* Button Styles - Essential for upload functionality */
+.ldr-btn-collections {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.5rem;
+ padding: 0.75rem 1.5rem;
+ border-radius: 10px;
+ font-weight: 500;
+ font-size: 0.95rem;
+ cursor: pointer;
+ transition: all 0.3s ease;
+ border: none;
+ position: relative;
+ overflow: hidden;
+ text-decoration: none;
+}
+
+.ldr-btn-collections-primary {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ color: white;
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
+ border: 3px solid #667eea;
+}
+
+/* Special styling for upload button to make it stand out */
+#upload-files-btn.ldr-btn-collections-primary {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ color: white;
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
+ border: 3px solid #667eea;
+ animation: pulse 2s infinite;
+}
+
+@keyframes pulse {
+ 0% {
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
+ }
+ 50% {
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
+ }
+ 100% {
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
+ }
+}
+
+.ldr-btn-collections-primary:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
+}
+
+.ldr-btn-collections-secondary {
+ background-color: rgba(255, 255, 255, 0.1);
+ color: #718096;
+ border: 2px solid #e2e8f0;
+}
+
+.ldr-btn-collections-secondary:hover {
+ background-color: rgba(255, 255, 255, 0.2);
+ border-color: #667eea;
+ color: #667eea;
+ transform: translateY(-2px);
+}
+
+.ldr-btn-collections-success {
+ background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
+ color: white;
+ box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
+}
+
+.ldr-btn-collections-success:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
+}
+
+.ldr-btn-collections-warning {
+ background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
+ color: white;
+ box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
+}
+
+.ldr-btn-collections-warning:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
+}
+
+.ldr-btn-collections-danger {
+ background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
+ color: white;
+ box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
+}
+
+.ldr-btn-collections-danger:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
+}
+
+.ldr-btn-lg {
+ padding: 1.25rem 2.5rem;
+ font-size: 1.2rem;
+ min-width: 200px;
+}
+
+.ldr-btn-outline-primary {
+ background: transparent;
+ color: #667eea;
+ border: 2px solid #667eea;
+}
+
+.ldr-btn-outline-primary:hover {
+ background: #667eea;
+ color: white;
+}
+
+.ldr-btn-outline-success {
+ background: transparent;
+ color: #28a745;
+ border: 2px solid #28a745;
+}
+
+.ldr-btn-outline-success:hover {
+ background: #28a745;
+ color: white;
+}
+
+.ldr-btn-outline-warning {
+ background: transparent;
+ color: #ffc107;
+ border: 2px solid #ffc107;
+}
+
+.ldr-btn-outline-warning:hover {
+ background: #ffc107;
+ color: white;
+}
+
+.ldr-active {
+ background: #667eea !important;
+ color: white !important;
+}
diff --git a/src/local_deep_research/web/static/js/collection_create.js b/src/local_deep_research/web/static/js/collection_create.js
new file mode 100644
index 0000000000..9ebed1b1ec
--- /dev/null
+++ b/src/local_deep_research/web/static/js/collection_create.js
@@ -0,0 +1,170 @@
+/**
+ * Collection Create Page JavaScript
+ * Handles creation of new collections
+ */
+
+// Use existing URLS configuration from config/urls.js
+// Collection create endpoint is now available as URLS.LIBRARY_API.COLLECTION_CREATE
+
+// Safe fetch wrapper with URL validation
+async function safeFetch(url, options = {}) {
+ // Internal URLs starting with '/' are safe
+ if (!url.startsWith('/')) {
+ if (!URLValidator.isSafeUrl(url)) {
+ throw new Error(`Blocked unsafe URL: ${url}`);
+ }
+ }
+ return fetch(url, options);
+}
+
+/**
+ * Initialize the create page
+ */
+document.addEventListener('DOMContentLoaded', function() {
+ // Setup form submission
+ document.getElementById('create-collection-form').addEventListener('submit', handleCreateCollection);
+
+ // Setup name input character counter
+ const nameInput = document.getElementById('collection-name');
+ nameInput.addEventListener('input', function(e) {
+ const maxLength = 100;
+ const currentLength = e.target.value.length;
+ const remaining = maxLength - currentLength;
+ const counter = document.getElementById('name-counter');
+ if (counter) {
+ counter.textContent = `${remaining} characters remaining`;
+ }
+ });
+});
+
+/**
+ * Handle collection creation
+ */
+async function handleCreateCollection(e) {
+ e.preventDefault();
+
+ // Get form data
+ const formData = new FormData(e.target);
+
+ // Validate required fields
+ const name = formData.get('name');
+ const description = formData.get('description');
+
+ if (!name || name.trim().length === 0) {
+ showError('Collection name is required');
+ return;
+ }
+
+ const submitBtn = e.target.querySelector('button[type="submit"]');
+ const createBtn = document.getElementById('create-collection-btn');
+
+ try {
+ submitBtn.disabled = true;
+ submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Creating Collection...';
+ createBtn.disabled = true;
+ createBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Creating Collection...';
+
+ const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
+
+ // Prepare JSON data
+ const jsonData = {
+ name: name.trim(),
+ description: description ? description.trim() : '',
+ type: 'user_uploads'
+ };
+
+ const response = await safeFetch(URLS.LIBRARY_API.COLLECTION_CREATE, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify(jsonData)
+ });
+
+ const data = await response.json();
+
+ if (data.success) {
+ showCreateResults(data);
+ // Reset form
+ document.getElementById('create-collection-form').reset();
+
+ // Redirect to the new collection after a short delay
+ setTimeout(() => {
+ if (data.collection && data.collection.id) {
+ window.location.href = `/library/collections/${data.collection.id}`;
+ } else {
+ window.location.href = '/library/collections';
+ }
+ }, 1500);
+ } else {
+ showError(data.error || 'Failed to create collection');
+ }
+ } catch (error) {
+ console.error('Error creating collection:', error);
+ showError('Failed to create collection: ' + error.message);
+ } finally {
+ submitBtn.disabled = false;
+ submitBtn.innerHTML = '<i class="fas fa-folder-plus"></i> 🚀 Create Collection';
+ createBtn.disabled = false;
+ }
+}
+
+/**
+ * Show creation results
+ */
+function showCreateResults(data) {
+ const resultsDiv = document.getElementById('create-results');
+
+ let html = '<div class="alert" style="background: #d4edda; color: #155724; border: 1px solid #c3e6cb; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;">';
+ html += '<h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-check-circle"></i> Collection Created!</h4>';
+
+ if (data.collection && data.collection.id) {
+ html += `<p><strong>Collection created successfully!</strong></p>`;
+ html += '<p>Your collection ID is: <strong>' + data.collection.id + '</strong></p>';
+ html += '<div style="margin-top: 1rem;">';
+ html += `<a href="/library/collections/${data.collection.id}" class="ldr-btn-collections ldr-btn-collections-primary">`;
+ html += '<i class="fas fa-folder-open"></i> View Collection';
+ html += '</a>';
+ html += `<a href="/library/collections/${data.collection.id}/upload" class="ldr-btn-collections ldr-btn-collections-secondary" style="margin-left: 1rem;">`;
+ html += '<i class="fas fa-plus"></i> Upload Files';
+ html += '</a>';
+ html += '</div>';
+ html += '</div>';
+ } else {
+ html += '<p><strong>Collection created!</strong></p>';
+ html += '<p>You can now start uploading files to organize your documents.</p>';
+ html += '<div style="margin-top: 1rem;">';
+ html += '<a href="/library/collections" class="ldr-btn-collections ldr-btn-collections-primary">';
+ html += '<i class="fas fa-folder-open"></i> View All Collections';
+ html += '</a>';
+ html += '<button onclick="window.location.href=\'/library/collections/create\'" class="ldr-btn-collections ldr-btn-collections-secondary" style="margin-left: 1rem;">';
+ html += '<i class="fas fa-plus"></i> Create Another Collection';
+ html += '</button>';
+ html += '</div>';
+ }
+
+ html += '</div>';
+
+ resultsDiv.innerHTML = html;
+ resultsDiv.style.display = 'block';
+}
+
+/**
+ * Show error message
+ */
+function showError(message) {
+ const resultsDiv = document.getElementById('create-results');
+ const html = `
+ <div class="alert" style="background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;">
+ <h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-exclamation-triangle"></i> Creation Error</h4>
+ <p>${message}</p>
+ <div style="margin-top: 1rem;">
+ <a href="/library/collections" class="ldr-btn-collections ldr-btn-collections-primary">Back to Collections</a>
+ </div>
+ </div>
+ `;
+
+ resultsDiv.innerHTML = html;
+ resultsDiv.style.display = 'block';
+}
diff --git a/src/local_deep_research/web/static/js/collection_details.js b/src/local_deep_research/web/static/js/collection_details.js
index f3a8f5d76a..4c289d130b 100644
--- a/src/local_deep_research/web/static/js/collection_details.js
+++ b/src/local_deep_research/web/static/js/collection_details.js
@@ -335,14 +335,30 @@ async function handleUploadFiles(event) {
* Index collection documents
*/
async function indexCollection(forceReindex) {
+ console.log('🚀 Index Collection button clicked!');
+ console.log('📋 Force reindex:', forceReindex);
+ console.log('🆔 Collection ID:', COLLECTION_ID);
+
const action = forceReindex ? 're-index' : 'index';
- if (!confirm(`${action.charAt(0).toUpperCase() + action.slice(1)} all documents in this collection?`)) return;
+ if (!confirm(`${action.charAt(0).toUpperCase() + action.slice(1)} all documents in this collection?`)) {
+ console.log('❌ User cancelled indexing');
+ return;
+ }
+
+ console.log('✅ User confirmed indexing');
const progressSection = document.getElementById('indexing-progress');
const progressFill = document.getElementById('progress-fill');
const progressText = document.getElementById('progress-text');
const progressLog = document.getElementById('progress-log');
+ console.log('🎯 UI elements found:', {
+ progressSection: !!progressSection,
+ progressFill: !!progressFill,
+ progressText: !!progressText,
+ progressLog: !!progressLog
+ });
+
try {
// Show progress section
progressSection.style.display = 'block';
@@ -352,20 +368,29 @@ async function indexCollection(forceReindex) {
// Use Server-Sent Events for progress updates
const url = URLBuilder.build(URLS.LIBRARY_API.COLLECTION_INDEX, COLLECTION_ID) + `?force_reindex=${forceReindex}`;
+ console.log('🌐 Indexing URL:', url);
+
+ console.log('📡 Creating EventSource...');
const eventSource = new EventSource(url);
+ console.log('📡 EventSource created:', eventSource);
eventSource.onmessage = function(event) {
+ console.log('📨 EventSource message received:', event.data);
const data = JSON.parse(event.data);
+ console.log('📨 Parsed data:', data);
if (data.type === 'start') {
+ console.log('▶️ Indexing started:', data.message);
progressText.textContent = data.message;
addLogEntry(data.message, 'info');
} else if (data.type === 'progress') {
+ console.log('📊 Indexing progress:', data);
const percent = data.percent || 0;
progressFill.style.width = percent + '%';
progressText.textContent = `Processing ${data.current}/${data.total}: ${data.filename}`;
addLogEntry(`[${data.current}/${data.total}] ${data.filename}`, 'info');
} else if (data.type === 'complete') {
+ console.log('✅ Indexing complete:', data.results);
const results = data.results;
progressFill.style.width = '100%';
progressText.textContent = `Complete! ${results.successful} indexed, ${results.failed} failed.`;
@@ -379,6 +404,7 @@ async function indexCollection(forceReindex) {
progressSection.style.display = 'none';
}, 3000);
} else if (data.type === 'error') {
+ console.log('❌ Indexing error:', data.error);
addLogEntry(`Error: ${data.error}`, 'error');
progressText.textContent = 'Indexing failed';
eventSource.close();
@@ -386,7 +412,8 @@ async function indexCollection(forceReindex) {
};
eventSource.onerror = function(error) {
- console.error('EventSource error:', error);
+ console.error('❌ EventSource error:', error);
+ console.error('❌ EventSource readyState:', eventSource.readyState);
addLogEntry('Connection error during indexing', 'error');
progressText.textContent = 'Indexing failed';
eventSource.close();
diff --git a/src/local_deep_research/web/static/js/collection_upload.js b/src/local_deep_research/web/static/js/collection_upload.js
new file mode 100644
index 0000000000..c350acf0a1
--- /dev/null
+++ b/src/local_deep_research/web/static/js/collection_upload.js
@@ -0,0 +1,300 @@
+/**
+ * Collection Upload Page JavaScript
+ * Handles file uploads for a specific collection
+ */
+
+// Use existing URLS configuration from config/urls.js
+// Collection upload endpoint is now available as URLS.LIBRARY_API.COLLECTION_UPLOAD
+
+// Safe fetch wrapper with URL validation
+async function safeFetch(url, options = {}) {
+ // Internal URLs starting with '/' are safe
+ if (!url.startsWith('/')) {
+ if (!URLValidator.isSafeUrl(url)) {
+ throw new Error(`Blocked unsafe URL: ${url}`);
+ }
+ }
+ return fetch(url, options);
+}
+
+// Store selected files globally to avoid losing them
+let selectedFiles = [];
+
+/**
+ * Initialize the upload page
+ */
+document.addEventListener('DOMContentLoaded', function() {
+ // Setup form submission
+ document.getElementById('upload-files-form').addEventListener('submit', function(e) {
+ console.log('📋 Form submit event triggered');
+ console.log('📋 File input state before submit:');
+ const fileInput = document.getElementById('files-input');
+ console.log('📋 - files:', fileInput.files);
+ console.log('📋 - value:', fileInput.value);
+ console.log('📋 - length:', fileInput.files.length);
+ handleUploadFiles(e);
+ });
+
+ // Setup file input change handler
+ document.getElementById('files-input').addEventListener('change', handleFileSelect);
+
+ // Setup drag and drop
+ const dropZone = document.getElementById('drop-zone');
+ const fileInput = document.getElementById('files-input');
+
+ if (dropZone && fileInput) {
+ dropZone.addEventListener('click', (e) => {
+ if (e.target.tagName !== 'BUTTON') {
+ fileInput.click();
+ }
+ });
+
+ dropZone.addEventListener('dragover', handleDragOver);
+ dropZone.addEventListener('dragleave', handleDragLeave);
+ dropZone.addEventListener('drop', handleDrop);
+ }
+});
+
+/**
+ * Handle drag over event
+ */
+function handleDragOver(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ e.currentTarget.classList.add('ldr-drag-over');
+}
+
+/**
+ * Handle drag leave event
+ */
+function handleDragLeave(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ e.currentTarget.classList.remove('ldr-drag-over');
+}
+
+/**
+ * Handle drop event
+ */
+function handleDrop(e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ const dropZone = e.currentTarget;
+ dropZone.classList.remove('ldr-drag-over');
+
+ const files = e.dataTransfer.files;
+ handleFiles(files);
+}
+
+/**
+ * Handle file selection
+ */
+function handleFileSelect(e) {
+ console.log('📂 File selection triggered');
+ console.log('📂 Event target:', e.target);
+ console.log('📂 Files from event:', e.target.files);
+ const files = e.target.files;
+ console.log('📂 Calling handleFiles with:', files.length, 'files');
+ handleFiles(files);
+}
+
+/**
+ * Handle selected files
+ */
+function handleFiles(files) {
+ console.log('📦 handleFiles called with:', files.length, 'files');
+
+ // Store files globally
+ selectedFiles = Array.from(files);
+ console.log('📦 Stored files globally:', selectedFiles.length, 'files');
+
+ if (files.length === 0) {
+ hideSelectedFiles();
+ return;
+ }
+
+ showSelectedFiles(files);
+}
+
+/**
+ * Show selected files preview
+ */
+function showSelectedFiles(files) {
+ console.log('👀 showSelectedFiles called with:', files.length, 'files');
+ const selectedFilesDiv = document.getElementById('selected-files');
+ const fileList = document.getElementById('file-list');
+ console.log('👀 UI elements found:', {
+ selectedFilesDiv: !!selectedFilesDiv,
+ fileList: !!fileList
+ });
+
+ // Clear existing file list
+ fileList.innerHTML = '';
+
+ // Add each file to list
+ Array.from(files).forEach((file, index) => {
+ console.log(`👀 Processing file ${index + 1}:`, file.name, file.size);
+ const li = document.createElement('li');
+ const fileSize = (file.size / 1024 / 1024).toFixed(2) + ' MB';
+ li.innerHTML = `
+ <i class="fas fa-file"></i>
+ <span>${file.name} (${fileSize})</span>
+ `;
+ fileList.appendChild(li);
+ });
+
+ selectedFilesDiv.style.display = 'block';
+ console.log('👀 Selected files preview shown');
+}
+
+/**
+ * Hide selected files preview
+ */
+function hideSelectedFiles() {
+ const selectedFilesDiv = document.getElementById('selected-files');
+ selectedFilesDiv.style.display = 'none';
+}
+
+/**
+ * Handle file upload
+ */
+async function handleUploadFiles(e) {
+ console.log('🚀 UPLOAD BUTTON CLICKED - handleUploadFiles called');
+ e.preventDefault();
+ console.log('✅ Form submission prevented');
+
+ // Use globally stored files instead of file input
+ console.log('📁 Using stored files:', selectedFiles.length, 'files');
+ console.log('📁 Stored file names:', selectedFiles.map(f => f.name));
+
+ // Also check file input state for debugging
+ const fileInput = document.getElementById('files-input');
+ console.log('🔍 File input state for comparison:', {
+ inputFiles: fileInput.files.length,
+ storedFiles: selectedFiles.length,
+ inputValue: fileInput.value
+ });
+
+ if (selectedFiles.length === 0) {
+ console.log('❌ No files selected - showing error');
+ showError('Please select at least one file to upload.');
+ return;
+ }
+
+ console.log('🔧 Building FormData...');
+ const formData = new FormData();
+ for (let file of selectedFiles) {
+ console.log(`📎 Adding file: ${file.name} (${file.size} bytes)`);
+ formData.append('files', file);
+ }
+
+ const progressDiv = document.getElementById('upload-progress');
+ const resultsDiv = document.getElementById('upload-results');
+ const submitBtn = e.target.querySelector('button[type="submit"]');
+ console.log('🎯 UI elements found:', {
+ progressDiv: !!progressDiv,
+ resultsDiv: !!resultsDiv,
+ submitBtn: !!submitBtn
+ });
+
+ try {
+ console.log('⏳ Showing progress UI...');
+ progressDiv.style.display = 'block';
+ submitBtn.disabled = true;
+ submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Uploading...';
+
+ console.log('🔐 Getting CSRF token...');
+ const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
+ console.log('🔑 CSRF token found:', !!csrfToken);
+
+ console.log('🌐 Building upload URL...');
+ const uploadUrl = URLBuilder.build(URLS.LIBRARY_API.COLLECTION_UPLOAD, COLLECTION_ID);
+ console.log('📡 Upload URL:', uploadUrl);
+ console.log('🆔 COLLECTION_ID:', COLLECTION_ID);
+
+ console.log('🚀 Starting fetch request...');
+ const response = await safeFetch(uploadUrl, {
+ method: 'POST',
+ headers: {
+ 'X-CSRFToken': csrfToken
+ },
+ body: formData
+ });
+
+ const data = await response.json();
+
+ if (data.success) {
+ showUploadResults(data);
+ // Reset form and clear stored files
+ document.getElementById('upload-files-form').reset();
+ selectedFiles = []; // Clear stored files
+ hideSelectedFiles();
+ } else {
+ showError(data.error || 'Upload failed');
+ }
+ } catch (error) {
+ console.error('Error uploading files:', error);
+ showError('Upload failed: ' + error.message);
+ } finally {
+ progressDiv.style.display = 'none';
+ submitBtn.disabled = false;
+ submitBtn.innerHTML = '<i class="fas fa-upload"></i> 🚀 Upload Files';
+ }
+}
+
+/**
+ * Show upload results
+ */
+function showUploadResults(data) {
+ const resultsDiv = document.getElementById('upload-results');
+
+ let html = '<div class="alert" style="background: #d4edda; color: #155724; border: 1px solid #c3e6cb; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;">';
+ html += '<h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-check-circle"></i> Upload Complete!</h4>';
+
+ if (data.uploaded_files && data.uploaded_files.length > 0) {
+ html += '<p><strong>Successfully uploaded:</strong></p><ul>';
+ data.uploaded_files.forEach(file => {
+ html += `<li>✅ ${file.name} (${(file.size / 1024 / 1024).toFixed(2)} MB)</li>`;
+ });
+ html += '</ul>';
+ }
+
+ if (data.failed_files && data.failed_files.length > 0) {
+ html += '<p><strong>Failed to upload:</strong></p><ul>';
+ data.failed_files.forEach(file => {
+ html += `<li>❌ ${file.name}: ${file.error}</li>`;
+ });
+ html += '</ul>';
+ }
+
+ html += '<div style="margin-top: 1rem;">';
+ html += `<a href="/library/collections/${COLLECTION_ID}" class="ldr-btn-collections ldr-btn-collections-primary">`;
+ html += '<i class="fas fa-folder-open"></i> View Collection';
+ html += '</a>';
+ html += '<button onclick="location.reload()" class="ldr-btn-collections ldr-btn-collections-secondary" style="margin-left: 1rem;">';
+ html += '<i class="fas fa-plus"></i> Upload More Files';
+ html += '</button>';
+ html += '</div>';
+
+ html += '</div>';
+
+ resultsDiv.innerHTML = html;
+ resultsDiv.style.display = 'block';
+}
+
+/**
+ * Show error message
+ */
+function showError(message) {
+ const resultsDiv = document.getElementById('upload-results');
+ const html = `
+ <div class="alert" style="background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;">
+ <h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-exclamation-triangle"></i> Upload Error</h4>
+ <p>${message}</p>
+ </div>
+ `;
+
+ resultsDiv.innerHTML = html;
+ resultsDiv.style.display = 'block';
+}
diff --git a/src/local_deep_research/web/static/js/collections_manager.js b/src/local_deep_research/web/static/js/collections_manager.js
index cc1d97b703..d3abd0481e 100644
--- a/src/local_deep_research/web/static/js/collections_manager.js
+++ b/src/local_deep_research/web/static/js/collections_manager.js
@@ -7,9 +7,7 @@
let collections = [];
let currentCollectionId = null;
-/**
- * Safe fetch wrapper with URL validation
- */
+// Safe fetch wrapper with URL validation
async function safeFetch(url, options = {}) {
// Internal URLs starting with '/' are safe
if (!url.startsWith('/')) {
@@ -28,7 +26,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Setup modal handlers
document.getElementById('create-collection-btn').addEventListener('click', showCreateCollectionModal);
- document.getElementById('create-collection-form').addEventListener('submit', handleCreateCollection);
+ document.getElementById('create-collection-modal-form').addEventListener('submit', handleCreateCollection);
document.getElementById('cancel-create-btn').addEventListener('click', hideCreateCollectionModal);
// Setup close buttons
@@ -128,7 +126,7 @@ function renderCollections() {
*/
function showCreateCollectionModal() {
document.getElementById('create-collection-modal').style.display = 'flex';
- document.getElementById('collection-name').focus();
+ document.getElementById('modal-collection-name').focus();
}
/**
@@ -136,7 +134,7 @@ function showCreateCollectionModal() {
*/
function hideCreateCollectionModal() {
document.getElementById('create-collection-modal').style.display = 'none';
- document.getElementById('create-collection-form').reset();
+ document.getElementById('create-collection-modal-form').reset();
}
/**
@@ -145,8 +143,8 @@ function hideCreateCollectionModal() {
async function handleCreateCollection(event) {
event.preventDefault();
- const name = document.getElementById('collection-name').value.trim();
- const description = document.getElementById('collection-description').value.trim();
+ const name = document.getElementById('modal-collection-name').value.trim();
+ const description = document.getElementById('modal-collection-description').value.trim();
if (!name) {
showError('Collection name is required');
diff --git a/src/local_deep_research/web/static/js/config/urls.js b/src/local_deep_research/web/static/js/config/urls.js
index 3a7bb41583..1ca1204355 100644
--- a/src/local_deep_research/web/static/js/config/urls.js
+++ b/src/local_deep_research/web/static/js/config/urls.js
@@ -3,7 +3,11 @@
* This prevents hardcoded URLs scattered throughout the codebase
*/
-const URLS = {
+// Prevent redeclaration if URLS already exists
+if (typeof URLS !== 'undefined') {
+ console.warn('URLS already defined, skipping redeclaration');
+} else {
+ const URLS = {
// API endpoints
API: {
START_RESEARCH: '/api/start_research',
@@ -93,6 +97,7 @@ const URLS = {
LIBRARY_API: {
// Collections management
COLLECTIONS: '/library/api/collections',
+ COLLECTION_CREATE: '/library/api/collections',
COLLECTION_DETAILS: '/library/api/collections/{id}',
COLLECTION_DOCUMENTS: '/library/api/collections/{id}/documents',
COLLECTION_UPLOAD: '/library/api/collections/{id}/upload',
@@ -305,3 +310,5 @@ if (typeof window !== 'undefined') {
window.URLS = URLS;
window.URLBuilder = URLBuilder;
}
+
+} // Close the if (typeof URLS !== 'undefined') else block
diff --git a/src/local_deep_research/web/templates/pages/collection_create.html b/src/local_deep_research/web/templates/pages/collection_create.html
new file mode 100644
index 0000000000..bc741fdefa
--- /dev/null
+++ b/src/local_deep_research/web/templates/pages/collection_create.html
@@ -0,0 +1,106 @@
+{% extends "base.html" %}
+
+{% block title %}Create New Collection{% endblock %}
+
+{% block extra_head %}
+<link rel="stylesheet" href="/static/css/collection_details.css">
+{% endblock %}
+
+{% block content %}
+<div class="ldr-rag-manager-container">
+ <!-- Header -->
+ <div class="ldr-rag-header">
+ <div style="display: flex; align-items: center; gap: 15px; margin-bottom: 10px;">
+ <a href="/library/collections" class="ldr-btn-collections ldr-btn-collections-secondary">
+ <i class="fas fa-arrow-left"></i> Back to Collections
+ </a>
+ </div>
+ <h1><i class="fas fa-plus-circle"></i> Create New Collection</h1>
+ <p class="ldr-subtitle">Set up a new collection to organize and index your documents</p>
+ </div>
+
+ <!-- Create Collection Form -->
+ <div class="ldr-rag-section" style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border: 2px solid #667eea;">
+ <div class="ldr-section-header">
+ <h2><i class="fas fa-plus-circle"></i> Collection Details</h2>
+ </div>
+
+ <form id="create-collection-form">
+ <div class="ldr-form-group">
+ <label for="collection-name">Collection Name *</label>
+ <input type="text" id="collection-name" name="name" required
+ placeholder="Enter a descriptive name for your collection"
+ maxlength="100">
+ <div class="ldr-form-help">Choose a name that clearly describes what documents will be in this collection (e.g., "Research Papers on AI Ethics", "Product Documentation 2025")</div>
+ <div id="name-counter" style="font-size: 0.875rem; color: #718096; margin-top: 0.25rem;">100 characters remaining</div>
+ </div>
+
+ <div class="ldr-form-group">
+ <label for="collection-description">Description</label>
+ <textarea id="collection-description" name="description" rows="4"
+ placeholder="Optional: Add a brief description of what this collection contains..."></textarea>
+ <div class="ldr-form-help">Optional: Provide context about the collection contents and purpose</div>
+ </div>
+
+ <div class="ldr-form-actions">
+ <button type="button" class="ldr-btn-collections ldr-btn-collections-secondary" onclick="window.location.href='/library/collections'">
+ <i class="fas fa-times"></i> Cancel
+ </button>
+ <button type="submit" class="ldr-btn-collections ldr-btn-collections-primary ldr-btn-lg" id="create-collection-btn" style="font-size: 1.2rem; padding: 1rem 2rem; min-width: 200px;">
+ <i class="fas fa-folder-plus"></i> 🚀 Create Collection
+ </button>
+ </div>
+ </form>
+
+ <!-- Results display area -->
+ <div id="create-results" style="display: none;"></div>
+ </div>
+
+ <!-- Instructions Section -->
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
+ <h2><i class="fas fa-info-circle"></i> Collection Guidelines</h2>
+ </div>
+
+ <div style="padding: 1rem;">
+ <h3>📝 Naming Your Collection</h3>
+ <ul>
+ <li><strong>Be Specific</strong> - Use descriptive names like "Q4 2024 Marketing Research" instead of generic names</li>
+ <li><strong>Include Time Period</strong> - Add years or quarters to help with organization (e.g., "Customer Feedback 2024", "Technical Documentation v2.1")</li>
+ <li><strong>Consider Purpose</strong> - Think about how you'll use the collection (research, reference, documentation, etc.)</li>
+ <li><strong>Use Descriptive Keywords</strong> - Include terms that will help you find content later</li>
+ </ul>
+
+ <h3>💡 Upload Strategy</h3>
+ <ul>
+ <li><strong>Start Small</strong> - Create focused collections rather than dumping everything into one large collection</li>
+ <li><strong>Group by Topic</strong> - Related documents work better together (e.g., separate collections for different projects)</li>
+ <li><strong>Plan for Growth</strong> - Leave room to add more documents as your needs evolve</li>
+ </ul>
+
+ <h3>📋 Best Practices</h3>
+ <ul>
+ <li><strong>Regular Organization</strong> - Keep collections manageable and well-organized</li>
+ <li><strong>Clear Descriptions</strong> - Always include clear descriptions for better searchability</li>
+ <li><strong>Consistent Naming</strong> - Use a standard naming convention across collections</li>
+ <li><strong>Backup Important</strong> - Create separate collections for critical or frequently accessed documents</li>
+ </ul>
+
+ <div style="margin-top: 2rem;">
+ <p style="text-align: center; color: #718096; font-style: italic; margin-bottom: 1rem;">
+ After creating your collection, you can immediately start uploading documents using the dedicated upload interface.
+ </p>
+ <a href="/library/collections" class="ldr-btn-collections ldr-btn-collections-primary" style="display: inline-flex; align-items: center; justify-content: center; text-decoration: none; padding: 1rem 2rem;">
+ <i class="fas fa-folder-open"></i> 📁 View All Collections
+ </a>
+ </div>
+ </div>
+ </div>
+</div>
+
+<!-- Pass collection_id placeholder (not used) to JavaScript -->
+<script>
+ const COLLECTION_ID = null; // Not needed for create page
+</script>
+<script src="/static/js/collection_create.js"></script>
+{% endblock %}
diff --git a/src/local_deep_research/web/templates/pages/collection_details.html b/src/local_deep_research/web/templates/pages/collection_details.html
index f8b7175cf0..65451a474c 100644
--- a/src/local_deep_research/web/templates/pages/collection_details.html
+++ b/src/local_deep_research/web/templates/pages/collection_details.html
@@ -1,68 +1,9 @@
{% extends "base.html" %}
+{% block title %}Collection Details{% endblock %}
+
{% block extra_head %}
<link rel="stylesheet" href="/static/css/collection_details.css">
-<style>
-.ldr-drop-zone {
- border: 2px dashed var(--ldr-border-color, #ccc);
- border-radius: 8px;
- padding: 40px 20px;
- text-align: center;
- background-color: var(--ldr-card-bg, #f8f9fa);
- transition: all 0.3s ease;
- cursor: pointer;
-}
-
-.ldr-drop-zone:hover {
- border-color: var(--ldr-primary-color, #007bff);
- background-color: var(--ldr-hover-bg, #e9ecef);
-}
-
-.ldr-drop-zone.ldr-drag-over {
- border-color: var(--ldr-success-color, #28a745);
- background-color: var(--ldr-success-bg, #d4edda);
- border-style: solid;
-}
-
-.ldr-drop-zone-text {
- margin: 15px 0 5px;
- font-size: 18px;
- font-weight: 500;
-}
-
-.ldr-drop-zone-subtext {
- margin: 5px 0 15px;
- color: var(--ldr-text-secondary, #6c757d);
-}
-
-.ldr-selected-files {
- margin-top: 15px;
- padding: 15px;
- background-color: var(--ldr-card-bg, #f8f9fa);
- border-radius: 6px;
-}
-
-.ldr-selected-files ul {
- list-style: none;
- padding: 0;
- margin: 10px 0 0;
-}
-
-.ldr-selected-files li {
- padding: 8px 12px;
- margin: 5px 0;
- background-color: var(--ldr-bg, white);
- border: 1px solid var(--ldr-border-color, #dee2e6);
- border-radius: 4px;
- display: flex;
- align-items: center;
- gap: 10px;
-}
-
-.ldr-selected-files li i {
- color: var(--ldr-primary-color, #007bff);
-}
-</style>
{% endblock %}
{% block content %}
@@ -85,9 +26,9 @@
</div>
<div class="ldr-collection-actions-grid">
- <button id="upload-files-btn" class="ldr-btn-collections ldr-btn-collections-primary ldr-btn-lg">
- <i class="fas fa-upload"></i> Upload Files
- </button>
+ <a href="/library/collections/{{ collection_id }}/upload" class="ldr-btn-collections ldr-btn-collections-primary ldr-btn-lg" style="text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; padding: 1.25rem 2.5rem; min-width: 250px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: 3px solid #667eea; box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5); animation: pulse 2s infinite;">
+ <i class="fas fa-upload"></i> 🚀 Upload Files
+ </a>
<button id="index-collection-btn" class="ldr-btn-collections ldr-btn-collections-success ldr-btn-lg">
<i class="fas fa-sync"></i> Index All Documents
</button>
@@ -162,9 +103,9 @@
<div id="no-documents-message" class="ldr-empty-state" style="display: none;">
<i class="fas fa-file fa-3x"></i>
<p>No documents in this collection yet</p>
- <button class="ldr-btn-collections ldr-btn-collections-primary" onclick="document.getElementById('upload-files-btn').click()">
+ <a href="/library/collections/{{ collection_id }}/upload" class="ldr-btn-collections ldr-btn-collections-primary">
<i class="fas fa-upload"></i> Upload Files
- </button>
+ </a>
</div>
</div>
</div>
@@ -218,7 +159,7 @@
<!-- Pass collection_id to JavaScript -->
<script>
- const COLLECTION_ID = {{ collection_id }};
+ const COLLECTION_ID = "{{ collection_id }}";
</script>
<script src="/static/js/collection_details.js"></script>
{% endblock %}
diff --git a/src/local_deep_research/web/templates/pages/collection_upload.html b/src/local_deep_research/web/templates/pages/collection_upload.html
new file mode 100644
index 0000000000..fa2ca5c1a0
--- /dev/null
+++ b/src/local_deep_research/web/templates/pages/collection_upload.html
@@ -0,0 +1,104 @@
+{% extends "base.html" %}
+
+{% block title %}Upload Files - {{ collection_name or 'Collection' }}{% endblock %}
+
+{% block extra_head %}
+<link rel="stylesheet" href="/static/css/collection_details.css">
+{% endblock %}
+
+{% block content %}
+<div class="ldr-rag-manager-container">
+ <!-- Header -->
+ <div class="ldr-rag-header">
+ <div style="display: flex; align-items: center; gap: 15px; margin-bottom: 10px;">
+ <a href="/library/collections/{{ collection_id }}" class="ldr-btn-collections ldr-btn-collections-secondary">
+ <i class="fas fa-arrow-left"></i> Back to Collection
+ </a>
+ </div>
+ <h1><i class="fas fa-cloud-upload-alt"></i> <span>Upload Files to {{ collection_name or 'Collection' }}</span></h1>
+ <p class="ldr-subtitle">Add documents to your collection for indexing and search</p>
+ </div>
+
+ <!-- Upload Section -->
+ <div class="ldr-rag-section" style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border: 2px solid #667eea;">
+ <div class="ldr-section-header">
+ <h2><i class="fas fa-upload"></i> 📁 Upload Documents</h2>
+ </div>
+
+ <form id="upload-files-form" enctype="multipart/form-data">
+ <div class="ldr-form-group">
+ <label><strong>Select Files to Upload</strong></label>
+
+ <!-- Drag and drop zone -->
+ <div id="drop-zone" class="ldr-drop-zone">
+ <i class="fas fa-cloud-upload-alt fa-4x"></i>
+ <p class="ldr-drop-zone-text">🚀 Drag and drop files here</p>
+ <p class="ldr-drop-zone-subtext">or</p>
+ <button type="button" class="ldr-btn-collections ldr-btn-collections-primary" onclick="document.getElementById('files-input').click()">
+ <i class="fas fa-folder-open"></i> Browse Files
+ </button>
+ <input type="file" id="files-input" name="files" multiple accept=".pdf,.txt,.md,.html,.htm" style="display: none;">
+ </div>
+
+ <!-- Selected files preview -->
+ <div id="selected-files" class="ldr-selected-files" style="display: none;">
+ <p><strong>Selected files:</strong></p>
+ <ul id="file-list"></ul>
+ </div>
+
+ <p class="ldr-form-help">💡 Accepted formats: PDF, TXT, MD, HTML. Text will be extracted and stored securely.</p>
+ </div>
+
+ <div id="upload-progress" class="ldr-upload-progress" style="display: none;">
+ <div class="ldr-progress-bar">
+ <div class="ldr-progress-fill"></div>
+ </div>
+ <p class="ldr-progress-text"></p>
+ </div>
+
+ <div id="upload-results" class="ldr-upload-results" style="display: none;"></div>
+
+ <div class="ldr-form-actions">
+ <button type="button" class="ldr-btn-collections ldr-btn-collections-secondary" onclick="window.location.href='/library/collections/{{ collection_id }}'">
+ <i class="fas fa-times"></i> Cancel
+ </button>
+ <button type="submit" class="ldr-btn-collections ldr-btn-collections-primary" style="font-size: 1.2rem; padding: 1rem 2rem; min-width: 200px;">
+ <i class="fas fa-upload"></i> 🚀 Upload Files
+ </button>
+ </div>
+ </form>
+ </div>
+
+ <!-- Instructions Section -->
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
+ <h2><i class="fas fa-info-circle"></i> Upload Instructions</h2>
+ </div>
+
+ <div style="padding: 1rem;">
+ <h3>📋 Supported File Types</h3>
+ <ul>
+ <li><strong>PDF</strong> - Documents and reports</li>
+ <li><strong>TXT</strong> - Plain text files</li>
+ <li><strong>MD</strong> - Markdown documents</li>
+ <li><strong>HTML</strong> - Web pages and HTML documents</li>
+ </ul>
+
+ <h3>💡 Tips</h3>
+ <ul>
+ <li>Upload multiple files at once using drag & drop</li>
+ <li>Files will be automatically processed and indexed</li>
+ <li>You can track processing progress on the collection details page</li>
+ </ul>
+ </div>
+ </div>
+</div>
+
+<!-- All JavaScript dependencies are already loaded in base template -->
+
+<!-- Pass collection_id to JavaScript -->
+<script>
+ const COLLECTION_ID = "{{ collection_id }}";
+</script>
+<script src="/static/js/collection_upload.js"></script>
+{% endblock %}
diff --git a/src/local_deep_research/web/templates/pages/collections.html b/src/local_deep_research/web/templates/pages/collections.html
index 278a497dda..417ca0dfef 100644
--- a/src/local_deep_research/web/templates/pages/collections.html
+++ b/src/local_deep_research/web/templates/pages/collections.html
@@ -15,9 +15,9 @@
<div class="ldr-rag-section">
<div class="ldr-section-header">
<h2><i class="fas fa-folder"></i> My Collections</h2>
- <button id="create-collection-btn" class="ldr-btn-collections ldr-btn-collections-primary">
+ <a href="/library/collections/create" id="create-collection-btn" class="ldr-btn-collections ldr-btn-collections-primary">
<i class="fas fa-plus"></i> Create Collection
- </button>
+ </a>
</div>
<div id="collections-container" class="ldr-collections-grid">
@@ -40,14 +40,14 @@
<span class="ldr-close">&times;</span>
</div>
<div class="ldr-modal-body">
- <form id="create-collection-form">
+ <form id="create-collection-modal-form">
<div class="ldr-form-group">
- <label for="collection-name">Collection Name *</label>
- <input type="text" id="collection-name" name="name" required placeholder="e.g., Research Papers, Work Documents">
+ <label for="modal-collection-name">Collection Name *</label>
+ <input type="text" id="modal-collection-name" name="name" required placeholder="e.g., Research Papers, Work Documents">
</div>
<div class="ldr-form-group">
- <label for="collection-description">Description</label>
- <textarea id="collection-description" name="description" rows="3" placeholder="Describe what this collection is for..."></textarea>
+ <label for="modal-collection-description">Description</label>
+ <textarea id="modal-collection-description" name="description" rows="3" placeholder="Describe what this collection is for..."></textarea>
</div>
<div class="ldr-form-actions">
<button type="button" class="ldr-btn-collections ldr-btn-collections-secondary" id="cancel-create-btn">Cancel</button>