feat: instance pv events

This commit is contained in:
jialin
2026-05-25 22:42:02 +08:00
committed by jialin
parent 2ebb8f44b7
commit 27d57d7563
8 changed files with 243 additions and 121 deletions
@@ -0,0 +1,46 @@
import { currentClusterAtom } from '@/atoms/gpuservice';
import { getCurrentOrgNamespace } from '@/atoms/user';
import { useQueryData } from '@gpustack/core-ui';
import { useAtomValue } from 'jotai';
import { useCallback } from 'react';
import { queryGPUServiceInstancePVEvents } from '../apis';
import { InstanceEvents } from '../config/types';
interface QueryVolumeEventsParams {
name: string;
pretty?: string;
}
export default function useQueryVolumeEvents() {
const currentCluster = useAtomValue(currentClusterAtom);
const clusterID = currentCluster?.id;
const namespace = getCurrentOrgNamespace(currentCluster?.owner_principal_id);
const fetchDetail = useCallback(
(params: QueryVolumeEventsParams, options?: any) =>
queryGPUServiceInstancePVEvents(
{
namespace,
clusterID,
name: params.name
},
options
),
[namespace, clusterID]
);
const { detailData, loading, cancelRequest, fetchData } = useQueryData<
InstanceEvents,
QueryVolumeEventsParams
>({
fetchDetail,
key: 'volumeEvents'
});
return {
detailData,
loading,
cancelRequest,
fetchData
};
}