mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +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
33
app/react/docker/events/ListView.tsx
Normal file
33
app/react/docker/events/ListView.tsx
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { useState } from 'react';
|
||||
import moment from 'moment';
|
||||
|
||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||
|
||||
import { PageHeader } from '@@/PageHeader';
|
||||
|
||||
import { useEvents } from '../proxy/queries/useEvents';
|
||||
|
||||
import { EventsDatatable } from './EventsDatatables';
|
||||
|
||||
export function ListView() {
|
||||
const { since, until } = useDateRange();
|
||||
const envId = useEnvironmentId();
|
||||
const eventsQuery = useEvents(envId, { params: { since, until } });
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title="Event list" breadcrumbs="Events" reload />
|
||||
|
||||
<EventsDatatable dataset={eventsQuery.data} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function useDateRange() {
|
||||
return useState(() => {
|
||||
const since = moment().subtract(24, 'hour').unix();
|
||||
const until = moment().unix();
|
||||
|
||||
return { since, until };
|
||||
})[0];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue