@ -1,4 +1,4 @@
import { type Component , create Signal, onMount , For , Show } from 'solid-js' ;
import { type Component , create Resource , For , Show } from 'solid-js' ;
import { useParams , A } from '@solidjs/router' ;
import { useParams , A } from '@solidjs/router' ;
import { useI18n } from '~/i18n' ;
import { useI18n } from '~/i18n' ;
import { llmLogsApi } from '~/api/llmLogs' ;
import { llmLogsApi } from '~/api/llmLogs' ;
@ -36,20 +36,7 @@ const LlmLogs: Component = () => {
const { t } = useI18n ( ) ;
const { t } = useI18n ( ) ;
const params = useParams < { jobId : string } > ( ) ;
const params = useParams < { jobId : string } > ( ) ;
const [ logs , setLogs ] = createSignal < LlmCallLogEntry [ ] > ( [ ] ) ;
const [ logs ] = createResource ( ( ) = > params . jobId , llmLogsApi . getByJobId ) ;
const [ loading , setLoading ] = createSignal ( true ) ;
const [ error , setError ] = createSignal < string | null > ( null ) ;
onMount ( async ( ) = > {
try {
const data = await llmLogsApi . getByJobId ( params . jobId ) ;
setLogs ( data ) ;
} catch {
setError ( t ( 'common.error' ) ) ;
} finally {
setLoading ( false ) ;
}
} ) ;
return (
return (
< div class = "max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8" >
< div class = "max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8" >
@ -64,23 +51,23 @@ const LlmLogs: Component = () => {
< h1 class = "text-2xl font-bold text-gray-900 mb-6" > { t ( 'llmLogs.title' ) } < / h1 >
< h1 class = "text-2xl font-bold text-gray-900 mb-6" > { t ( 'llmLogs.title' ) } < / h1 >
< Show when = { ! lo ading( ) } fallback = { < LoadingSpinner / > } >
< Show when = { ! lo gs. lo ading} fallback = { < LoadingSpinner / > } >
< Show when = { error( ) } >
< Show when = { logs. error} >
< div class = "bg-red-50 border border-red-200 rounded-md p-4 text-sm text-red-800" >
< div class = "bg-red-50 border border-red-200 rounded-md p-4 text-sm text-red-800" >
{ error( ) }
{ t( 'common.error' ) }
< / div >
< / div >
< / Show >
< / Show >
< Show
< Show
when = { logs ( ) . length > 0 }
when = { ( logs ( ) ? ? [ ] ) . length > 0 }
fallback = {
fallback = {
< Show when = { ! error( ) } >
< Show when = { ! logs. error} >
< p class = "text-gray-500 text-sm" > { t ( 'llmLogs.empty' ) } < / p >
< p class = "text-gray-500 text-sm" > { t ( 'llmLogs.empty' ) } < / p >
< / Show >
< / Show >
}
}
>
>
< div class = "space-y-4" >
< div class = "space-y-4" >
< For each = { logs ( ) } >
< For each = { logs ( ) ? ? [ ] } >
{ ( entry ) = > (
{ ( entry ) = > (
< div class = "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden" >
< div class = "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden" >
< div class = "flex items-center gap-3 px-5 py-3 border-b border-gray-100 bg-gray-50" >
< div class = "flex items-center gap-3 px-5 py-3 border-b border-gray-100 bg-gray-50" >