@@ -63,13 +63,16 @@ <h5 class="card-title">Projects</h5>
6363 < div class ="flex-grow-1 ">
6464 < div class ="fw-bold "> {{ p.name or p.path.split('/')[-1] }}</ div >
6565 < small class ="text-muted "> {{ p.path }}</ small > < br >
66- < small class ="text-muted "> Status: < span class ="badge bg-{{ 'success' if p.status=='ready' else 'warning' }} "> {{ p.status }}</ span > </ small >
66+ < small class ="text-muted ">
67+ Status: < span class ="badge bg-{{ 'success' if p.status=='ready' else ('warning' if p.status=='indexing' else 'secondary') }} " data-status ="{{ p.status }} "> {{ p.status }}</ span >
68+ </ small >
69+ < br >
70+ < small class ="text-muted indexing-info " style ="display:none; ">
71+ Files: < span class ="file-count "> 0</ span > | Embeddings: < span class ="embedding-count "> 0</ span >
72+ </ small >
6773 </ div >
6874 < div >
69- < form action ="/projects/{{ p.id }} " method ="post " style ="display:inline; " onsubmit ="return confirm('Delete this project and its database?'); ">
70- < input type ="hidden " name ="_method " value ="DELETE ">
71- < button type ="submit " class ="btn btn-sm btn-outline-danger "> ×</ button >
72- </ form >
75+ < button type ="button " class ="btn btn-sm btn-outline-danger delete-project-btn " data-project-id ="{{ p.id }} " title ="Delete project "> ×</ button >
7376 </ div >
7477 </ li >
7578 {% endfor %}
@@ -262,28 +265,81 @@ <h5 class="card-title">Chat</h5>
262265 firstProject . classList . add ( "active" ) ;
263266 }
264267
265- // Poll for project status updates
268+ // Poll for project status updates with detailed stats
266269 setInterval ( async ( ) => {
267270 try {
268271 const response = await fetch ( "/projects/status" ) ;
269272 const projects = await response . json ( ) ;
270273
271- // Update project status badges
272- projects . forEach ( p => {
274+ // Update project status badges and stats
275+ for ( const p of projects ) {
273276 const item = document . querySelector ( `[data-project-id="${ p . id } "]` ) ;
274277 if ( item ) {
275278 const badge = item . querySelector ( '.badge' ) ;
276279 if ( badge ) {
277280 badge . className = `badge bg-${ p . status === 'ready' ? 'success' : p . status === 'indexing' ? 'warning' : 'secondary' } ` ;
278281 badge . textContent = p . status ;
279282 }
283+
284+ // Fetch detailed stats for this project
285+ try {
286+ const detailResponse = await fetch ( `/api/projects/${ p . id } ` ) ;
287+ const details = await detailResponse . json ( ) ;
288+
289+ if ( details . indexing_stats ) {
290+ const indexingInfo = item . querySelector ( '.indexing-info' ) ;
291+ const fileCount = item . querySelector ( '.file-count' ) ;
292+ const embeddingCount = item . querySelector ( '.embedding-count' ) ;
293+
294+ if ( indexingInfo && fileCount && embeddingCount ) {
295+ fileCount . textContent = details . indexing_stats . file_count || 0 ;
296+ embeddingCount . textContent = details . indexing_stats . embedding_count || 0 ;
297+
298+ // Show stats if project has been indexed
299+ if ( details . indexing_stats . file_count > 0 ) {
300+ indexingInfo . style . display = 'block' ;
301+ } else {
302+ indexingInfo . style . display = 'none' ;
303+ }
304+ }
305+ }
306+ } catch ( detailErr ) {
307+ // Ignore errors fetching individual project details
308+ }
280309 }
281- } ) ;
310+ }
282311 } catch ( err ) {
283312 console . error ( "Error polling status:" , err ) ;
284313 }
285314 } , 3000 ) ;
286315
316+ // Handle project deletion
317+ document . addEventListener ( 'click' , async ( e ) => {
318+ if ( e . target . classList . contains ( 'delete-project-btn' ) ) {
319+ const projectId = e . target . getAttribute ( 'data-project-id' ) ;
320+
321+ if ( ! confirm ( 'Delete this project and its database?' ) ) {
322+ return ;
323+ }
324+
325+ try {
326+ const response = await fetch ( `/projects/${ projectId } ` , {
327+ method : 'DELETE'
328+ } ) ;
329+
330+ if ( response . ok ) {
331+ // Reload page to show updated project list
332+ window . location . reload ( ) ;
333+ } else {
334+ const data = await response . json ( ) ;
335+ alert ( `Failed to delete project: ${ data . error || 'Unknown error' } ` ) ;
336+ }
337+ } catch ( err ) {
338+ alert ( `Error deleting project: ${ err . message } ` ) ;
339+ }
340+ }
341+ } ) ;
342+
287343 // Initial render
288344 renderChat ( ) ;
289345 </ script >
0 commit comments