From 06a2b00e2f3b4d15fdf36375b821fe99504babaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20ERG=C3=9CN?= Date: Thu, 27 Feb 2025 17:38:18 +0300 Subject: [PATCH] feat(VectorSearch, QueryInput): redesign UI layout --- crossbar_llm/frontend/src/App.js | 8 + .../frontend/src/components/QueryInput.js | 40 +++-- .../frontend/src/components/ResultsDisplay.js | 161 ++++++++++++++---- .../frontend/src/components/VectorSearch.js | 38 +++-- 4 files changed, 176 insertions(+), 71 deletions(-) diff --git a/crossbar_llm/frontend/src/App.js b/crossbar_llm/frontend/src/App.js index bc13fde..2e9dd32 100644 --- a/crossbar_llm/frontend/src/App.js +++ b/crossbar_llm/frontend/src/App.js @@ -15,6 +15,7 @@ function App() { const [tabValue, setTabValue] = useState('query'); const [queryResult, setQueryResult] = useState(null); const [executionResult, setExecutionResult] = useState(null); + const [realtimeLogs, setRealtimeLogs] = useState(''); const [showAboutModal, setShowAboutModal] = useState(false); const [latestQueries, setLatestQueries] = useState([]); const [selectedQuery, setSelectedQuery] = useState(null); @@ -64,6 +65,9 @@ function App() { const handleTabChange = (event, newValue) => { setTabValue(newValue); + setQueryResult(null); + setExecutionResult(null); + setRealtimeLogs(''); }; const handleCloseModal = () => { @@ -146,6 +150,7 @@ function App() { )} + + {/* Generated Query TextArea */} + {generatedQuery && !runnedQuery && ( + setGeneratedQuery(e.target.value)} + fullWidth + multiline + rows={4} + margin="normal" + /> + )} + + {/* Error message display */} + {error && ( + + {error} + + )} + + {/* Log sections moved below outputs */} {/* Real-time logs from EventSource */} {verbose && ( )} - - {error && ( - - {error} - - )} - {/* Generated Query TextArea */} - {generatedQuery && !runnedQuery && ( - setGeneratedQuery(e.target.value)} - fullWidth - multiline - rows={4} - margin="normal" - /> - )} ); } diff --git a/crossbar_llm/frontend/src/components/ResultsDisplay.js b/crossbar_llm/frontend/src/components/ResultsDisplay.js index fb3425d..6e67f04 100644 --- a/crossbar_llm/frontend/src/components/ResultsDisplay.js +++ b/crossbar_llm/frontend/src/components/ResultsDisplay.js @@ -1,72 +1,163 @@ -import React from 'react'; -import { Typography, Card, CardContent, Box, useTheme } from '@mui/material'; +import React, { useState } from 'react'; +import { Typography, Card, CardContent, Box, useTheme, IconButton, Dialog, DialogContent, Snackbar } from '@mui/material'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { docco, dracula } from 'react-syntax-highlighter/dist/esm/styles/hljs'; +import ContentCopyIcon from '@mui/icons-material/ContentCopy'; +import FullscreenIcon from '@mui/icons-material/Fullscreen'; function ResultsDisplay({ queryResult, executionResult, realtimeLogs }) { const theme = useTheme(); const syntaxTheme = theme.palette.mode === 'dark' ? dracula : docco; + const [isFullscreen, setIsFullscreen] = useState(false); + const [copySnackbar, setCopySnackbar] = useState(false); if (!queryResult && !executionResult) { return null; } + const handleCopy = (text) => { + navigator.clipboard.writeText(text); + setCopySnackbar(true); + }; + return ( - {queryResult && executionResult && ( + {executionResult && ( - Generated Cypher Query: - - {queryResult} - + + Natural Language Response: + + + {executionResult.response} + )} - {executionResult && ( - + + {(queryResult || executionResult?.result) && ( + - Results: - {realtimeLogs && ( - - - Real-time Logs: + {queryResult && ( + <> + Generated Cypher Query: + + {queryResult} + + + )} + + {executionResult?.result && ( + <> + + + Raw Query Output: + + + handleCopy(JSON.stringify(executionResult.result, null, 2))} + title="Copy to clipboard" + > + + + setIsFullscreen(true)} + title="View fullscreen" + > + + + + + - {realtimeLogs} + {JSON.stringify(executionResult.result, null, 2)} - - + + )} - - Natural Language Response: - - - {executionResult.response} - - - - Raw Query Output: - + + + )} + + setIsFullscreen(false)} + > + + + handleCopy(JSON.stringify(executionResult?.result, null, 2))} + sx={{ position: 'absolute', right: 48, top: 0 }} + title="Copy to clipboard" + > + + + setIsFullscreen(false)} + sx={{ position: 'absolute', right: 0, top: 0 }} + title="Exit fullscreen" + > + + + {JSON.stringify(executionResult?.result, null, 2)} + + + + + + setCopySnackbar(false)} + message="Copied to clipboard" + anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} + sx={{ + '& .MuiSnackbarContent-root': { + bgcolor: theme.palette.mode === 'dark' ? '#333' : '#fff', + color: theme.palette.mode === 'dark' ? '#fff' : '#333', + boxShadow: theme.shadows[3] + } + }} + /> + + {/* Log sections moved below */} + {realtimeLogs && ( + + + Verbose Output: + - {JSON.stringify(executionResult.result, null, 2)} + {realtimeLogs} diff --git a/crossbar_llm/frontend/src/components/VectorSearch.js b/crossbar_llm/frontend/src/components/VectorSearch.js index 131e107..8e507a6 100644 --- a/crossbar_llm/frontend/src/components/VectorSearch.js +++ b/crossbar_llm/frontend/src/components/VectorSearch.js @@ -642,6 +642,26 @@ function VectorSearch({ )} + {/* Generated Query TextArea */} + {generatedQuery && !runnedQuery && ( + setGeneratedQuery(e.target.value)} + fullWidth + multiline + rows={4} + margin="normal" + /> + )} + + {error && ( + + {error} + + )} + + {/* Log sections moved to bottom */} {/* Real-time logs from EventSource */} {verbose && ( )} - - {error && ( - - {error} - - )} - {/* Generated Query TextArea */} - {generatedQuery && !runnedQuery && ( - setGeneratedQuery(e.target.value)} - fullWidth - multiline - rows={4} - margin="normal" - /> - )} ); }