[WIFI-13446] Port tables not showing all ports

Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
Charles
2024-02-27 16:42:32 +01:00
parent 22b223f82f
commit 0781e3ad8e
5 changed files with 14 additions and 7 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ucentral-client",
"version": "3.0.2(1)",
"version": "3.0.2(5)",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ucentral-client",
"version": "3.0.2(1)",
"version": "3.0.2(5)",
"license": "ISC",
"dependencies": {
"@chakra-ui/anatomy": "^2.1.1",

View File

@@ -1,6 +1,6 @@
{
"name": "ucentral-client",
"version": "3.0.2(1)",
"version": "3.0.2(5)",
"description": "",
"private": true,
"main": "index.tsx",

View File

@@ -2,7 +2,8 @@ import * as React from 'react';
import { ColumnDef, PaginationState, SortingColumnDef, SortingState, VisibilityState } from '@tanstack/react-table';
import { useAuth } from 'contexts/AuthProvider';
const getDefaultSettings = (settings?: string) => {
const getDefaultSettings = ({ settings, showAllRows }: { settings?: string; showAllRows?: boolean }) => {
if (showAllRows) return { pageSize: 1000, pageIndex: 0 };
let limit = 10;
let index = 0;
@@ -54,9 +55,10 @@ export type UseDataGridProps = {
tableSettingsId: string;
defaultOrder: string[];
defaultSortBy?: SortingState;
showAllRows?: boolean;
};
export const useDataGrid = ({ tableSettingsId, defaultSortBy, defaultOrder }: UseDataGridProps) => {
export const useDataGrid = ({ tableSettingsId, defaultSortBy, defaultOrder, showAllRows }: UseDataGridProps) => {
const orderSetting = `${tableSettingsId}.order`;
const hiddenColumnSetting = `${tableSettingsId}.hiddenColumns`;
const pageSetting = `${tableSettingsId}.page`;
@@ -66,8 +68,9 @@ export const useDataGrid = ({ tableSettingsId, defaultSortBy, defaultOrder }: Us
const [columnOrder, setColumnOrder] = React.useState<string[]>(
getSavedColumnOrder(defaultOrder ?? [], tableSettingsId),
);
const [pageInfo, setPageInfo] = React.useState<PaginationState>(getDefaultSettings(tableSettingsId));
const [pageInfo, setPageInfo] = React.useState<PaginationState>(
getDefaultSettings({ settings: tableSettingsId, showAllRows }),
);
const setNewColumnOrder = React.useCallback(
(newOrder: string[]) => {
setColumnOrder(newOrder);

View File

@@ -40,6 +40,7 @@ const LinkStateTable = ({ statistics, refetch, isFetching, type, serialNumber }:
'actions',
],
defaultSortBy: [{ id: 'name', desc: false }],
showAllRows: true,
});
const columns: DataGridColumn<Row>[] = React.useMemo(
@@ -48,6 +49,7 @@ const LinkStateTable = ({ statistics, refetch, isFetching, type, serialNumber }:
id: 'carrier',
header: '',
accessorKey: '',
sortingFn: 'alphanumericCaseSensitive',
cell: ({ cell }) => (cell.row.original.carrier ? '🟢' : '🔴'),
meta: {
customWidth: '35px',

View File

@@ -30,6 +30,7 @@ const SwitchInterfaceTable = ({ statistics, refetch, isFetching }: Props) => {
'tx_error',
],
defaultSortBy: [{ id: 'name', desc: false }],
showAllRows: true,
});
const columns: DataGridColumn<DeviceInterfaceStatistics>[] = React.useMemo(
@@ -38,6 +39,7 @@ const SwitchInterfaceTable = ({ statistics, refetch, isFetching }: Props) => {
id: 'name',
header: 'Name',
accessorKey: 'name',
sortingFn: 'alphanumericCaseSensitive',
meta: {
customWidth: '35px',
},