mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 13:59:40 +02:00
refactor(cluster): migrate nodes datatable to react [EE-4962] (#10459)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
b346fd7f39
commit
0e47f22c0a
25 changed files with 448 additions and 219 deletions
29
app/react/kubernetes/cluster/kubernetesEndpoint.service.ts
Normal file
29
app/react/kubernetes/cluster/kubernetesEndpoint.service.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { EndpointsList } from 'kubernetes-types/core/v1';
|
||||
import { useQuery } from 'react-query';
|
||||
|
||||
import axios from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
async function getKubernetesEndpoints(environmentId: EnvironmentId) {
|
||||
const { data: endpointsList } = await axios.get<EndpointsList>(
|
||||
`/endpoints/${environmentId}/kubernetes/api/v1/endpoints`
|
||||
);
|
||||
return endpointsList.items;
|
||||
}
|
||||
|
||||
export function useKubernetesEndpointsQuery(
|
||||
environmentId: EnvironmentId,
|
||||
options?: { autoRefreshRate?: number }
|
||||
) {
|
||||
return useQuery(
|
||||
['environments', environmentId, 'kubernetes', 'endpoints'],
|
||||
() => getKubernetesEndpoints(environmentId),
|
||||
{
|
||||
...withError('Unable to retrieve Kubernetes endpoints'),
|
||||
refetchInterval() {
|
||||
return options?.autoRefreshRate ?? false;
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue