mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
refactor(docker/events): migrate list view to react [EE-2228] (#11581)
This commit is contained in:
parent
9797201c2a
commit
33ce841040
11 changed files with 71 additions and 69 deletions
|
@ -1,4 +1,5 @@
|
|||
import { EventMessage } from 'docker-types/generated/1.41';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import axios, {
|
||||
jsonObjectsToArrayHandler,
|
||||
|
@ -7,16 +8,26 @@ import axios, {
|
|||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildDockerProxyUrl } from './buildDockerProxyUrl';
|
||||
import { queryKeys } from './query-keys';
|
||||
|
||||
type Params = { since?: number; until?: number };
|
||||
|
||||
export function useEvents(
|
||||
environmentId: EnvironmentId,
|
||||
{ params }: { params?: Params } = {}
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [...queryKeys.events(environmentId, params)],
|
||||
queryFn: () => getEvents(environmentId, params),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param param1
|
||||
* @returns
|
||||
*/
|
||||
export async function getEvents(
|
||||
environmentId: EnvironmentId,
|
||||
{ since, until }: { since: string; until: string }
|
||||
{ since, until }: Params = {}
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<EventMessage[]>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue