From 6e4668cec897b8c7886f844c5030f1508f9df49f Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 24 Jan 2025 16:05:20 +0100 Subject: [PATCH] Update index.html --- lightrag/api/static/index.html | 83 +++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/lightrag/api/static/index.html b/lightrag/api/static/index.html index 20addf6c..16df098a 100644 --- a/lightrag/api/static/index.html +++ b/lightrag/api/static/index.html @@ -3,7 +3,7 @@ - LightRAG WebUI + RAG WebUI @@ -12,11 +12,11 @@ - + + + + + + +

RAG WebUI

@@ -73,29 +89,54 @@ settingsModal.classList.add('hidden'); }); - // Bearer Key Handling - const bearerKeyInput = document.getElementById('bearerKeyInput'); - const saveBearerKey = document.getElementById('saveBearerKey'); - const bearerKeyStatus = document.getElementById('bearerKeyStatus'); + // Health Check Modal Handling + const healthCheckButton = document.getElementById('healthCheckButton'); + const healthModal = document.getElementById('healthModal'); + const closeHealth = document.getElementById('closeHealth'); + const healthInfo = document.getElementById('healthInfo'); - // Load Bearer Key from localStorage on page load - const storedBearerKey = localStorage.getItem('bearerKey'); - if (storedBearerKey) { - bearerKeyInput.value = storedBearerKey; - bearerKeyStatus.textContent = "Bearer Key loaded from local storage."; - } + healthCheckButton.addEventListener('click', async () => { + healthModal.classList.remove('hidden'); + healthInfo.textContent = "Fetching system health..."; + try { + const response = await fetch('/health', { + method: 'GET', + headers: { + 'Authorization': `Bearer ${localStorage.getItem('bearerKey') || ''}` + } + }); - // Save Bearer Key to localStorage - saveBearerKey.addEventListener('click', () => { - const key = bearerKeyInput.value.trim(); - if (key) { - localStorage.setItem('bearerKey', key); - bearerKeyStatus.textContent = "Bearer Key saved successfully."; - } else { - bearerKeyStatus.textContent = "Please enter a valid Bearer Key."; + if (response.ok) { + const data = await response.json(); + healthInfo.innerHTML = ` +

Status: ${data.status}

+

Working Directory: ${data.working_directory}

+

Input Directory: ${data.input_directory}

+

Indexed Files: ${data.indexed_files}

+

Configuration:

+ + `; + } else { + const error = await response.json(); + healthInfo.textContent = `Error: ${error.detail}`; + } + } catch (err) { + healthInfo.textContent = `Error: ${err.message}`; } }); + closeHealth.addEventListener('click', () => { + healthModal.classList.add('hidden'); + }); + // File Upload Handler const uploadForm = document.getElementById('uploadForm'); const fileInput = document.getElementById('fileInput');