Skip to content

Commit

Permalink
fix: auto refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Sep 23, 2024
1 parent 43de12d commit e5aadf0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function AppBaseInfo({
}) {
const { t } = useTranslation();
const [active, setActive] = useState(0);
const [logs, setLogs] = useState('');
const ActivePod = useMemo(() => joblist?.history[active], [active, joblist]);
useQuery(
['getPodLogs', ActivePod?.podName],
Expand All @@ -23,14 +24,15 @@ export default function AppBaseInfo({
enabled: !!ActivePod?.podName,
onSuccess(data) {
if (ActivePod) {
ActivePod['logs'] = data || '';
setLogs(data || '');
}
},
onError(err) {
if (ActivePod) {
ActivePod['logs'] = typeof err === 'string' ? err : '';
setLogs(typeof err === 'string' ? err : '');
}
}
},
refetchInterval: !ActivePod?.status ? 1000 : false
}
);

Expand Down Expand Up @@ -120,7 +122,7 @@ export default function AppBaseInfo({
<Text>
{t('Log')} (pod: {ActivePod?.podName})
</Text>
<Text mt="12px">{ActivePod?.logs}</Text>
<Text mt="12px">{logs}</Text>
</Flex>
) : (
<Flex
Expand Down
3 changes: 2 additions & 1 deletion frontend/providers/cronjob/src/pages/job/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default function DetailPage({ appName }: { appName: string }) {
} = useQuery(['getJobListEventsAndLogs', appName], () => getJobListEventsAndLogs(appName), {
onError(err) {
console.log(err);
}
},
refetchInterval: 3000
});

const { refetch: refetchJobDetail } = useQuery(
Expand Down
1 change: 0 additions & 1 deletion frontend/providers/cronjob/src/types/job.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export type JobList = {
uid: string | undefined;
name: string | undefined;
events: JobEvent[];
logs: string;
podName: string;
startTimeTimestamp: number;
}[];
Expand Down

0 comments on commit e5aadf0

Please sign in to comment.