From 2b8c05e7ea6e566a3bc93f900800abf8238cabbb Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 24 Jan 2025 16:17:20 +0100 Subject: [PATCH] Update index.html --- lightrag/api/static/index.html | 143 ++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 47 deletions(-) diff --git a/lightrag/api/static/index.html b/lightrag/api/static/index.html index 16df098a..0e1e3f68 100644 --- a/lightrag/api/static/index.html +++ b/lightrag/api/static/index.html @@ -3,75 +3,87 @@ - RAG WebUI + LightRag - + + - -
+ +
- - -
-
-
- - - - + +
+

LightRag

+

Lightweight RAG System Interface

- -

RAG WebUI

- -
-

Upload Files

-
- - +
+

Document Upload

+ +
+ +
+ + +
+ + -
+
-
-

Query

-
- - +
+

Query Documents

+ + + -
+
@@ -140,6 +152,8 @@ // File Upload Handler const uploadForm = document.getElementById('uploadForm'); const fileInput = document.getElementById('fileInput'); + const selectedFiles = document.getElementById('selectedFiles'); + const uploadStatus = document.getElementById('uploadStatus'); const progressContainer = document.getElementById('progressContainer'); const progressBar = document.getElementById('progressBar').firstElementChild; @@ -230,6 +244,41 @@ queryResponse.textContent = `Error: ${err.message}`; } }); + + // File preview functionality + fileInput.addEventListener('change', () => { + selectedFiles.innerHTML = ''; + Array.from(fileInput.files).forEach((file, index) => { + const fileDiv = document.createElement('div'); + fileDiv.className = 'flex items-center justify-between p-2 bg-white rounded border'; + fileDiv.innerHTML = ` + ${file.name} (${(file.size / 1024).toFixed(1)} KB) + + `; + selectedFiles.appendChild(fileDiv); + }); + }); + + // Remove file functionality + selectedFiles.addEventListener('click', (e) => { + if (e.target.closest('button')) { + const index = e.target.closest('button').dataset.index; + const dt = new DataTransfer(); + const files = fileInput.files; + + for (let i = 0; i < files.length; i++) { + if (i != index) dt.items.add(files[i]); + } + + fileInput.files = dt.files; + e.target.closest('div').remove(); + } + }); +