feat: add events, log api

This commit is contained in:
jialin
2026-05-15 16:22:07 +08:00
committed by jialin
parent 1bef1637e0
commit 9dfaf990fd
8 changed files with 400 additions and 2 deletions
@@ -0,0 +1,45 @@
import { currentClusterAtom } from '@/atoms/gpuservice';
import { getCurrentOrganizationId } from '@/atoms/user';
import { useQueryData } from '@gpustack/core-ui';
import { useAtomValue } from 'jotai';
import { useCallback } from 'react';
import { queryGPUServiceInstanceLog } from '../apis';
import { InstanceLog, InstanceLogQueryParams } from '../config/types';
interface QueryInstanceLogParams extends InstanceLogQueryParams {
name: string;
}
export default function useQueryInstanceLog() {
const namespace = getCurrentOrganizationId();
const currentCluster = useAtomValue(currentClusterAtom);
const clusterID = currentCluster?.id;
const fetchDetail = useCallback(
(params: QueryInstanceLogParams, options?: any) =>
queryGPUServiceInstanceLog(
{
...params,
namespace,
clusterID
},
options
),
[namespace, clusterID]
);
const { detailData, loading, cancelRequest, fetchData } = useQueryData<
InstanceLog,
QueryInstanceLogParams
>({
fetchDetail,
key: 'instanceLog'
});
return {
detailData,
loading,
cancelRequest,
fetchData
};
}