Skip to content

Commit 42f8e6a

Browse files
committed
chore: set col order
1 parent 23a7612 commit 42f8e6a

File tree

9 files changed

+52
-103
lines changed

9 files changed

+52
-103
lines changed

src/config/settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ export const GPUSTACK_API_BASE_URL = 'v2';
1111
export const OPENAI_COMPATIBLE = 'v1';
1212

1313
type SortDirection = 'ascend' | 'descend' | null;
14+
1415
export const TABLE_SORT_DIRECTIONS: SortDirection[] = [
1516
'ascend',
1617
'descend',
1718
null
1819
];
20+
21+
export const tableSorter = (order: number | boolean) => {
22+
if (typeof order === 'number') {
23+
return {
24+
multiple: order
25+
};
26+
}
27+
return order;
28+
};

src/pages/api-keys/hooks/use-keys-columns.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import AutoTooltip from '@/components/auto-tooltip';
33
import DropdownButtons from '@/components/drop-down-buttons';
44
import icons from '@/components/icon-font/icons';
5+
import { tableSorter } from '@/config/settings';
56
import { useIntl } from '@umijs/max';
67
import { ColumnsType } from 'antd/lib/table';
78
import dayjs from 'dayjs';
@@ -39,9 +40,7 @@ const useModelsColumns = ({
3940
title: intl.formatMessage({ id: 'common.table.name' }),
4041
dataIndex: 'name',
4142
key: 'name',
42-
sorter: {
43-
multiple: 1
44-
},
43+
sorter: tableSorter(1),
4544
render: (text: string, record: ListItem) => (
4645
<AutoTooltip ghost style={{ maxWidth: 400 }}>
4746
{text}
@@ -52,9 +51,7 @@ const useModelsColumns = ({
5251
title: intl.formatMessage({ id: 'apikeys.form.expiretime' }),
5352
dataIndex: 'expires_at',
5453
key: 'expires_at',
55-
sorter: {
56-
multiple: 2
57-
},
54+
sorter: tableSorter(2),
5855
render: (text: string, record: ListItem) => (
5956
<AutoTooltip ghost>
6057
{text
@@ -96,9 +93,7 @@ const useModelsColumns = ({
9693
dataIndex: 'created_at',
9794
key: 'created_at',
9895
defaultSortOrder: 'descend',
99-
sorter: {
100-
multiple: 3
101-
},
96+
sorter: tableSorter(3),
10297
ellipsis: {
10398
showTitle: false
10499
},

src/pages/cluster-management/hooks/use-cluster-columns.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import AutoTooltip from '@/components/auto-tooltip';
33
import DropdownButtons from '@/components/drop-down-buttons';
44
import { SealColumnProps } from '@/components/seal-table/types';
55
import StatusTag from '@/components/status-tag';
6+
import { tableSorter } from '@/config/settings';
67
import { useIntl } from '@umijs/max';
78
import dayjs from 'dayjs';
89
import { useMemo } from 'react';
@@ -33,9 +34,7 @@ const useClusterColumns = (
3334
{
3435
title: intl.formatMessage({ id: 'common.table.name' }),
3536
dataIndex: 'name',
36-
sorter: {
37-
multiple: 1
38-
},
37+
sorter: tableSorter(1),
3938
span: 3,
4039
render: (text: string, record: ClusterListItem) => (
4140
<AutoTooltip ghost>{text}</AutoTooltip>
@@ -44,9 +43,7 @@ const useClusterColumns = (
4443
{
4544
title: intl.formatMessage({ id: 'clusters.table.provider' }),
4645
dataIndex: 'provider',
47-
sorter: {
48-
multiple: 2
49-
},
46+
sorter: tableSorter(2),
5047
span: 4,
5148
render: (value: string) => (
5249
<AutoTooltip ghost minWidth={20}>
@@ -93,9 +90,7 @@ const useClusterColumns = (
9390
title: intl.formatMessage({ id: 'common.table.createTime' }),
9491
dataIndex: 'created_at',
9592
defaultSortOrder: 'descend',
96-
sorter: {
97-
multiple: 5
98-
},
93+
sorter: tableSorter(5),
9994
span: 4,
10095
render: (value: string) => (
10196
<AutoTooltip ghost minWidth={20}>

src/pages/cluster-management/hooks/use-credential-columns.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// columns.ts
22
import AutoTooltip from '@/components/auto-tooltip';
33
import DropdownButtons from '@/components/drop-down-buttons';
4+
import { tableSorter } from '@/config/settings';
45
import { useIntl } from '@umijs/max';
56
import { ColumnsType } from 'antd/es/table';
67
import type { SortOrder } from 'antd/es/table/interface';
@@ -23,9 +24,7 @@ const useCredentialColumns = (
2324
{
2425
title: intl.formatMessage({ id: 'common.table.name' }),
2526
dataIndex: 'name',
26-
sorter: {
27-
multiple: 1
28-
},
27+
sorter: tableSorter(1),
2928
render: (text: string) => (
3029
<AutoTooltip ghost minWidth={20}>
3130
{text}
@@ -43,9 +42,7 @@ const useCredentialColumns = (
4342
dataIndex: 'created_at',
4443
showSorterTooltip: false,
4544
defaultSortOrder: 'descend',
46-
sorter: {
47-
multiple: 3
48-
},
45+
sorter: tableSorter(3),
4946
ellipsis: {
5047
showTitle: false
5148
},

src/pages/llmodels/hooks/use-models-columns.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import AutoTooltip from '@/components/auto-tooltip';
33
import DropdownButtons from '@/components/drop-down-buttons';
44
import { SealColumnProps } from '@/components/seal-table/types';
5-
import { OPENAI_COMPATIBLE } from '@/config/settings';
5+
import { OPENAI_COMPATIBLE, tableSorter } from '@/config/settings';
66
import { QuestionCircleOutlined } from '@ant-design/icons';
77
import { useIntl } from '@umijs/max';
88
import { Tooltip } from 'antd';
@@ -53,9 +53,7 @@ const useModelsColumns = ({
5353
title: intl.formatMessage({ id: 'common.table.name' }),
5454
dataIndex: 'name',
5555
key: 'name',
56-
sorter: {
57-
multiple: 1
58-
},
56+
sorter: tableSorter(1),
5957
span: 5,
6058
render: (text: string, record: ListItem) => (
6159
<span className="flex-center" style={{ maxWidth: '100%' }}>
@@ -70,9 +68,7 @@ const useModelsColumns = ({
7068
title: intl.formatMessage({ id: 'clusters.title' }),
7169
dataIndex: 'cluster_id',
7270
key: 'cluster_id',
73-
sorter: {
74-
multiple: 2
75-
},
71+
sorter: tableSorter(2),
7672
span: 3,
7773
render: (text: string, record: ListItem) => (
7874
<span className="flex flex-column" style={{ width: '100%' }}>
@@ -87,9 +83,7 @@ const useModelsColumns = ({
8783
title: intl.formatMessage({ id: 'models.form.source' }),
8884
dataIndex: 'source',
8985
key: 'source',
90-
sorter: {
91-
multiple: 3
92-
},
86+
sorter: tableSorter(3),
9387
span: 5,
9488
render: (text: string, record: ListItem) => (
9589
<span className="flex flex-column" style={{ width: '100%' }}>
@@ -114,9 +108,7 @@ const useModelsColumns = ({
114108
dataIndex: 'ready_replicas',
115109
key: 'ready_replicas',
116110
align: 'center',
117-
sorter: {
118-
multiple: 4
119-
},
111+
sorter: tableSorter(4),
120112
span: 4,
121113
editable: {
122114
valueType: 'number',
@@ -133,9 +125,7 @@ const useModelsColumns = ({
133125
dataIndex: 'created_at',
134126
key: 'created_at',
135127
defaultSortOrder: 'descend',
136-
sorter: {
137-
multiple: 5
138-
},
128+
sorter: tableSorter(5),
139129
span: 4,
140130
render: (text: number) => (
141131
<AutoTooltip ghost>

src/pages/resources/hooks/use-files-columns.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import AutoTooltip from '@/components/auto-tooltip';
22
import DropdownButtons from '@/components/drop-down-buttons';
33
import { TooltipOverlayScroller } from '@/components/overlay-scroller';
44
import StatusTag from '@/components/status-tag';
5+
import { tableSorter } from '@/config/settings';
56
import { modelSourceMap } from '@/pages/llmodels/config';
67
import { modelFileActions } from '@/pages/llmodels/config/button-actions';
78
import { convertFileSize } from '@/utils';
@@ -265,9 +266,7 @@ const useFilesColumns = (props: {
265266
{
266267
title: intl.formatMessage({ id: 'models.form.source' }),
267268
dataIndex: 'source',
268-
sorter: {
269-
multiple: 1
270-
},
269+
sorter: tableSorter(1),
271270
ellipsis: {
272271
showTitle: false
273272
},
@@ -286,9 +285,7 @@ const useFilesColumns = (props: {
286285
{
287286
title: intl.formatMessage({ id: 'resources.worker' }),
288287
dataIndex: 'worker_id',
289-
sorter: {
290-
multiple: 2
291-
},
288+
sorter: tableSorter(2),
292289
width: '18%',
293290
ellipsis: {
294291
showTitle: false
@@ -312,9 +309,7 @@ const useFilesColumns = (props: {
312309
{
313310
title: intl.formatMessage({ id: 'resources.modelfiles.form.path' }),
314311
dataIndex: 'resolved_paths',
315-
sorter: {
316-
multiple: 3
317-
},
312+
sorter: tableSorter(3),
318313
width: '20%',
319314
ellipsis: {
320315
showTitle: false
@@ -344,9 +339,7 @@ const useFilesColumns = (props: {
344339
dataIndex: 'created_at',
345340
defaultSortOrder: 'descend',
346341
key: 'created_at',
347-
sorter: {
348-
multiple: 4
349-
},
342+
sorter: tableSorter(4),
350343
width: 180,
351344
ellipsis: {
352345
showTitle: false

src/pages/resources/hooks/use-gpu-columns.tsx

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import AutoTooltip from '@/components/auto-tooltip';
22
import ProgressBar from '@/components/progress-bar';
33
import InfoColumn from '@/components/simple-table/info-column';
4+
import { tableSorter } from '@/config/settings';
45
import { convertFileSize } from '@/utils';
56
import { useIntl } from '@umijs/max';
67
import { ColumnsType } from 'antd/lib/table';
@@ -50,9 +51,7 @@ const useGPUColumns = (props: {
5051
title: intl.formatMessage({ id: 'common.table.name' }),
5152
dataIndex: 'name',
5253
width: 240,
53-
sorter: {
54-
multiple: 1
55-
},
54+
sorter: tableSorter(1),
5655
render: (text: string, record: GPUDeviceItem) => (
5756
<AutoTooltip ghost maxWidth={240}>
5857
{text}
@@ -62,17 +61,13 @@ const useGPUColumns = (props: {
6261
{
6362
title: intl.formatMessage({ id: 'resources.table.index' }),
6463
dataIndex: 'index',
65-
sorter: {
66-
multiple: 2
67-
},
64+
sorter: tableSorter(2),
6865
render: (text: string, record: GPUDeviceItem) => <span>{text}</span>
6966
},
7067
{
7168
title: intl.formatMessage({ id: 'clusters.title' }),
7269
dataIndex: 'cluster_id',
73-
sorter: {
74-
multiple: 3
75-
},
70+
sorter: tableSorter(3),
7671
ellipsis: {
7772
showTitle: false
7873
},
@@ -85,9 +80,7 @@ const useGPUColumns = (props: {
8580
{
8681
title: intl.formatMessage({ id: 'resources.worker' }),
8782
dataIndex: 'worker_name',
88-
sorter: {
89-
multiple: 4
90-
},
83+
sorter: tableSorter(4),
9184
ellipsis: {
9285
showTitle: false
9386
},
@@ -98,9 +91,7 @@ const useGPUColumns = (props: {
9891
{
9992
title: intl.formatMessage({ id: 'resources.table.vender' }),
10093
dataIndex: 'vendor',
101-
sorter: {
102-
multiple: 5
103-
}
94+
sorter: tableSorter(5)
10495
},
10596
{
10697
title: `${intl.formatMessage({ id: 'resources.table.temperature' })} (°C)`,
@@ -113,9 +104,7 @@ const useGPUColumns = (props: {
113104
title: `${intl.formatMessage({ id: 'resources.table.utilization' })}`,
114105
dataIndex: 'core.utilization_rate',
115106
key: 'core.utilization_rate',
116-
sorter: {
117-
multiple: 6
118-
},
107+
sorter: tableSorter(6),
119108
render: (text: number, record: GPUDeviceItem) => {
120109
return (
121110
<>
@@ -134,9 +123,7 @@ const useGPUColumns = (props: {
134123
title: intl.formatMessage({ id: 'resources.table.vramutilization' }),
135124
dataIndex: 'memory.utilization_rate',
136125
key: 'memory.utilization_rate',
137-
sorter: {
138-
multiple: 7
139-
},
126+
sorter: tableSorter(7),
140127
render: (text: number, record: GPUDeviceItem, index: number) => {
141128
return (
142129
<ProgressBar

src/pages/resources/hooks/use-worker-columns.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import LabelsCell from '@/components/label-cell';
44
import ProgressBar from '@/components/progress-bar';
55
import InfoColumn from '@/components/simple-table/info-column';
66
import StatusTag from '@/components/status-tag';
7+
import { tableSorter } from '@/config/settings';
78
import { convertFileSize } from '@/utils';
89
import {
910
DeleteOutlined,
@@ -274,9 +275,7 @@ const useWorkerColumns = ({
274275
title: intl.formatMessage({ id: 'common.table.name' }),
275276
dataIndex: 'name',
276277
width: 100,
277-
sorter: {
278-
multiple: 1
279-
},
278+
sorter: tableSorter(1),
280279
render: (text: string) => (
281280
<AutoTooltip ghost maxWidth={240}>
282281
{text}
@@ -301,9 +300,7 @@ const useWorkerColumns = ({
301300
{
302301
title: intl.formatMessage({ id: 'common.table.status' }),
303302
dataIndex: 'state',
304-
sorter: {
305-
multiple: 2
306-
},
303+
sorter: tableSorter(2),
307304
render: (_, record) => (
308305
<StatusTag
309306
maxTooltipWidth={400}
@@ -319,9 +316,7 @@ const useWorkerColumns = ({
319316
{
320317
title: 'IP',
321318
dataIndex: 'ip',
322-
sorter: {
323-
multiple: 3
324-
},
319+
sorter: tableSorter(3),
325320
render: (text: string, record) => (
326321
<AutoTooltip ghost maxWidth={240}>
327322
{renderIP(text, record)}
@@ -331,9 +326,7 @@ const useWorkerColumns = ({
331326
{
332327
title: 'CPU',
333328
dataIndex: 'status.cpu.utilization_rate',
334-
sorter: {
335-
multiple: 4
336-
},
329+
sorter: tableSorter(4),
337330
render: (text: string, record) =>
338331
statusAvailable(record) ? (
339332
<ProgressBar
@@ -346,9 +339,7 @@ const useWorkerColumns = ({
346339
{
347340
title: intl.formatMessage({ id: 'resources.table.memory' }),
348341
dataIndex: 'status.memory.utilization_rate',
349-
sorter: {
350-
multiple: 5
351-
},
342+
sorter: tableSorter(5),
352343
render: (_, record) =>
353344
statusAvailable(record) ? (
354345
<ProgressBar

0 commit comments

Comments
 (0)