mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(edge): sort waiting room table [EE-6259] (#10577)
This commit is contained in:
parent
32d8dc311b
commit
25741e8c4c
10 changed files with 306 additions and 106 deletions
|
@ -22,6 +22,7 @@ export function Datatable() {
|
|||
} = useEnvironments({
|
||||
pageLimit: tableState.pageSize,
|
||||
search: tableState.search,
|
||||
sortBy: tableState.sortBy,
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
@ -8,27 +8,32 @@ const columnHelper = createColumnHelper<WaitingRoomEnvironment>();
|
|||
export const columns = [
|
||||
columnHelper.accessor('Name', {
|
||||
header: 'Name',
|
||||
id: 'name',
|
||||
id: 'Name',
|
||||
}),
|
||||
columnHelper.accessor('EdgeID', {
|
||||
header: 'Edge ID',
|
||||
id: 'edge-id',
|
||||
id: 'EdgeID',
|
||||
}),
|
||||
columnHelper.accessor((row) => row.EdgeGroups.join(', ') || '-', {
|
||||
columnHelper.accessor((row) => row.EdgeGroups.join(', '), {
|
||||
header: 'Edge Groups',
|
||||
id: 'edge-groups',
|
||||
enableSorting: false,
|
||||
cell: ({ getValue }) => getValue() || '-',
|
||||
}),
|
||||
columnHelper.accessor((row) => row.Group || '-', {
|
||||
columnHelper.accessor((row) => row.Group, {
|
||||
header: 'Group',
|
||||
id: 'group',
|
||||
id: 'Group',
|
||||
cell: ({ getValue }) => getValue() || '-',
|
||||
}),
|
||||
columnHelper.accessor((row) => row.Tags.join(', ') || '-', {
|
||||
columnHelper.accessor((row) => row.Tags.join(', '), {
|
||||
header: 'Tags',
|
||||
id: 'tags',
|
||||
enableSorting: false,
|
||||
cell: ({ getValue }) => getValue() || '-',
|
||||
}),
|
||||
columnHelper.accessor((row) => row.LastCheckInDate, {
|
||||
header: 'Last Check-in',
|
||||
id: 'last-check-in',
|
||||
id: 'LastCheckIn',
|
||||
cell: ({ getValue }) => {
|
||||
const value = getValue();
|
||||
return value ? moment(value * 1000).fromNow() : '-';
|
||||
|
|
|
@ -6,6 +6,10 @@ import { useEdgeGroups } from '@/react/edge/edge-groups/queries/useEdgeGroups';
|
|||
import { useGroups } from '@/react/portainer/environments/environment-groups/queries';
|
||||
import { useEnvironmentList } from '@/react/portainer/environments/queries';
|
||||
import { EdgeTypes } from '@/react/portainer/environments/types';
|
||||
import {
|
||||
Query,
|
||||
getSortType,
|
||||
} from '@/react/portainer/environments/queries/useEnvironmentList';
|
||||
|
||||
import { WaitingRoomEnvironment } from '../types';
|
||||
|
||||
|
@ -14,9 +18,11 @@ import { useFilterStore } from './filter-store';
|
|||
export function useEnvironments({
|
||||
pageLimit = 10,
|
||||
search,
|
||||
sortBy,
|
||||
}: {
|
||||
pageLimit: number;
|
||||
search: string;
|
||||
sortBy: { id: string; desc: boolean } | undefined;
|
||||
}) {
|
||||
const [page, setPage] = useState(0);
|
||||
const filterStore = useFilterStore();
|
||||
|
@ -35,7 +41,7 @@ export function useEnvironments({
|
|||
[edgeGroupsQuery.data, filterStore.edgeGroups]
|
||||
);
|
||||
|
||||
const query = useMemo(
|
||||
const query: Partial<Query> = useMemo(
|
||||
() => ({
|
||||
pageLimit,
|
||||
edgeDeviceUntrusted: true,
|
||||
|
@ -46,6 +52,8 @@ export function useEnvironments({
|
|||
endpointIds: filterByEnvironmentsIds,
|
||||
edgeCheckInPassedSeconds: filterStore.checkIn,
|
||||
search,
|
||||
sort: getSortType(sortBy?.id),
|
||||
order: sortBy?.desc ? 'desc' : 'asc',
|
||||
}),
|
||||
[
|
||||
filterByEnvironmentsIds,
|
||||
|
@ -54,6 +62,7 @@ export function useEnvironments({
|
|||
filterStore.tags,
|
||||
pageLimit,
|
||||
search,
|
||||
sortBy,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue