@@ -11,6 +11,7 @@ import {
1111 AiOutlineLeft ,
1212 AiOutlineMessage ,
1313 AiOutlineSearch ,
14+ AiOutlineReload ,
1415} from "solid-icons/ai" ;
1516import { Spacer } from "./Spacer" ;
1617import { Portal } from "solid-js/web" ;
@@ -24,14 +25,19 @@ import { TbSparkles, TbTimelineEventText, TbTransform } from "solid-icons/tb";
2425import { createSignal } from "solid-js" ;
2526import NewDatasetModal from "../components/NewDatasetModal" ;
2627import { ImNewspaper } from "solid-icons/im" ;
28+ import { useTrieve } from "../hooks/useTrieve" ;
29+ import { createQuery } from "@tanstack/solid-query" ;
2730
28- const searchUiURL = import . meta. env . VITE_SEARCH_UI_URL as string ;
29- const chatUiURL = import . meta. env . VITE_CHAT_UI_URL as string ;
31+ const searchUiURL =
32+ ( import . meta. env . VITE_SEARCH_UI_URL as string | undefined ) ?? "" ;
33+ const chatUiURL =
34+ ( import . meta. env . VITE_CHAT_UI_URL as string | undefined ) ?? "" ;
3035
3136export const DashboardSidebar = ( ) => {
3237 const { datasetId } = useContext ( DatasetContext ) ;
3338 const userContext = useContext ( UserContext ) ;
3439 const pathname = useLocation ( ) ;
40+ const trieve = useTrieve ( ) ;
3541
3642 const [ newDatasetModalOpen , setNewDatasetModalOpen ] =
3743 createSignal < boolean > ( false ) ;
@@ -63,6 +69,91 @@ export const DashboardSidebar = () => {
6369 ) ;
6470 } ) ;
6571
72+ const uploadStatusQuery = createQuery ( ( ) => ( {
73+ queryKey : [ "upload-status" , datasetId ( ) ] ,
74+ queryFn : async ( ) => {
75+ return await trieve . fetch (
76+ "/api/dataset/get_dataset_queue_lengths" ,
77+ "get" ,
78+ {
79+ datasetId : datasetId ( ) ,
80+ } ,
81+ ) ;
82+ } ,
83+ refetchInterval : 5000 ,
84+ refetchOnMount : true ,
85+ refetchOnWindowFocus : true ,
86+ enabled : ! ! datasetId ( ) ,
87+ } ) ) ;
88+
89+ const UploadStatusBar = ( ) => {
90+ return (
91+ < div class = "space-y-2 p-2" >
92+ < div class = "flex flex-col justify-between" >
93+ < div class = "text-sm font-medium text-neutral-700" >
94+ Processing Queue
95+ </ div >
96+ < div class = "flex items-center justify-between text-xs" >
97+ < span class = "text-neutral-500" > Updates every 5 seconds</ span >
98+ < button
99+ onClick = { ( ) => {
100+ void uploadStatusQuery . refetch ( ) ;
101+ } }
102+ class = "flex items-center gap-1 text-neutral-500 hover:text-fuchsia-500"
103+ title = "Reload status"
104+ >
105+ < AiOutlineReload
106+ size = { 14 }
107+ classList = { {
108+ "animate-spin" : uploadStatusQuery . isFetching ,
109+ } }
110+ />
111+ </ button >
112+ </ div >
113+ </ div >
114+
115+ < div class = "space-y-1" >
116+ < div class = "flex justify-between text-xs text-neutral-600" >
117+ < span > Files</ span >
118+ < span > { uploadStatusQuery . data ?. file_queue_length ?? 0 } files</ span >
119+ </ div >
120+ < div class = "h-2 w-full rounded-full bg-neutral-200" >
121+ < div
122+ class = "h-2 rounded-full bg-blue-500 transition-all duration-300"
123+ style = { {
124+ width : `${ Math . min (
125+ ( ( uploadStatusQuery . data ?. file_queue_length ?? 0 ) / 20 ) * 100 ,
126+ 100 ,
127+ ) } %`,
128+ } }
129+ />
130+ </ div >
131+ </ div >
132+
133+ < div class = "space-y-1" >
134+ < div class = "flex justify-between text-xs text-neutral-600" >
135+ < span > Chunk Batches</ span >
136+ < span >
137+ { uploadStatusQuery . data ?. chunk_queue_length ?? 0 } batches
138+ </ span >
139+ </ div >
140+ < div class = "h-2 w-full rounded-full bg-neutral-200" >
141+ < div
142+ class = "h-2 rounded-full bg-orange-500 transition-all duration-300"
143+ style = { {
144+ width : `${ Math . min (
145+ ( ( uploadStatusQuery . data ?. chunk_queue_length ?? 0 ) / 1000 ) *
146+ 100 ,
147+ 100 ,
148+ ) } %`,
149+ } }
150+ />
151+ </ div >
152+ </ div >
153+ </ div >
154+ ) ;
155+ } ;
156+
66157 const Link = ( props : {
67158 href : string ;
68159 label : JSX . Element ;
@@ -239,6 +330,10 @@ export const DashboardSidebar = () => {
239330 />
240331 </ Show >
241332 </ div >
333+ < div class = "gap flex flex-col pt-4" >
334+ < SectionLabel > Upload Status</ SectionLabel >
335+ < UploadStatusBar />
336+ </ div >
242337 </ div >
243338 </ div >
244339 </ >
0 commit comments