@@ -58,12 +58,26 @@ export function SystemTableContent({
58
58
taskCategories,
59
59
} : Props ) {
60
60
const { userInfo } = useUser ( ) ;
61
+ if (
62
+ filterValue . sortField &&
63
+ filterValue . sortField !== "created_at" &&
64
+ ! metricNames . includes ( filterValue . sortField )
65
+ ) {
66
+ metricNames . push ( filterValue . sortField ) ;
67
+ }
61
68
const metricColumns : ColumnsType < SystemModel > = metricNames . map ( ( metric ) => ( {
62
69
dataIndex : [ "results" , ...metric . split ( "." ) ] ,
63
70
title : metric ,
64
71
width : 135 ,
65
72
ellipsis : true ,
66
73
align : "center" ,
74
+ fixed : filterValue . sortField === metric ? "left" : false ,
75
+ sorter : filterValue . sortField === metric ,
76
+ showSorterTooltip : false ,
77
+ sortOrder :
78
+ filterValue . sortField === metric && filterValue . sortDir === "asc"
79
+ ? "ascend"
80
+ : "descend" ,
67
81
} ) ) ;
68
82
69
83
function showSystemAnalysis ( systemID : string ) {
@@ -211,6 +225,7 @@ export function SystemTableContent({
211
225
] ,
212
226
filteredValue : filterValue . split ? [ filterValue . split ] : null ,
213
227
} ,
228
+ ...metricColumns ,
214
229
{
215
230
dataIndex : "source_language" ,
216
231
width : 100 ,
@@ -223,7 +238,6 @@ export function SystemTableContent({
223
238
title : "Output Lang" ,
224
239
align : "center" ,
225
240
} ,
226
- ...metricColumns ,
227
241
{
228
242
dataIndex : "preferred_username" ,
229
243
title : "Creator" ,
@@ -236,6 +250,13 @@ export function SystemTableContent({
236
250
render : ( _ , record ) => record . created_at . format ( "MM/DD/YYYY HH:mm" ) ,
237
251
width : 130 ,
238
252
align : "center" ,
253
+ fixed : filterValue . sortField === "created_at" ? "right" : false ,
254
+ sorter : filterValue . sortField === "created_at" ,
255
+ showSorterTooltip : false ,
256
+ sortOrder :
257
+ filterValue . sortField === "created_at" && filterValue . sortDir === "asc"
258
+ ? "ascend"
259
+ : "descend" ,
239
260
} ,
240
261
{
241
262
dataIndex : "system_tags" ,
@@ -245,50 +266,64 @@ export function SystemTableContent({
245
266
width : 130 ,
246
267
align : "center" ,
247
268
} ,
248
- {
249
- dataIndex : "action" ,
250
- title : "" ,
251
- fixed : "right" ,
252
- width : 90 ,
253
- render : ( _ , record ) => {
254
- const notCreator = record . creator !== userInfo ?. id ;
255
- return (
256
- < Space size = "small" direction = "vertical" >
257
- < Space size = "small" >
258
- < Button
259
- size = "small"
260
- onClick = { ( ) => showSystemAnalysis ( record . system_id ) }
261
- >
262
- Analysis
263
- </ Button >
264
- </ Space >
265
- < Space size = "small" >
269
+ ] ;
270
+ columns . sort ( function ( a , b ) {
271
+ if (
272
+ ( a . fixed === "left" && b . fixed !== "left" ) ||
273
+ ( a . fixed !== "right" && b . fixed === "right" )
274
+ ) {
275
+ return - 1 ;
276
+ } else if (
277
+ ( b . fixed === "left" && a . fixed !== "left" ) ||
278
+ ( b . fixed !== "right" && a . fixed === "right" )
279
+ ) {
280
+ return 1 ;
281
+ }
282
+ return 0 ;
283
+ } ) ;
284
+ columns . push ( {
285
+ dataIndex : "action" ,
286
+ title : "" ,
287
+ fixed : "right" ,
288
+ width : 90 ,
289
+ render : ( _ , record ) => {
290
+ const notCreator = record . creator !== userInfo ?. id ;
291
+ return (
292
+ < Space size = "small" direction = "vertical" >
293
+ < Space size = "small" >
294
+ < Button
295
+ size = "small"
296
+ onClick = { ( ) => showSystemAnalysis ( record . system_id ) }
297
+ >
298
+ Analysis
299
+ </ Button >
300
+ </ Space >
301
+ < Space size = "small" >
302
+ < Button
303
+ size = "small"
304
+ disabled = { notCreator }
305
+ icon = { < EditOutlined /> }
306
+ onClick = { ( ) => {
307
+ showEditDrawer ( record . system_id ) ;
308
+ } }
309
+ />
310
+ < Popconfirm
311
+ disabled = { notCreator }
312
+ title = "Are you sure?"
313
+ onConfirm = { ( ) => deleteSystem ( record . system_id ) }
314
+ >
266
315
< Button
267
- size = "small"
316
+ danger
268
317
disabled = { notCreator }
269
- icon = { < EditOutlined /> }
270
- onClick = { ( ) => {
271
- showEditDrawer ( record . system_id ) ;
272
- } }
318
+ size = "small"
319
+ icon = { < DeleteOutlined /> }
273
320
/>
274
- < Popconfirm
275
- disabled = { notCreator }
276
- title = "Are you sure?"
277
- onConfirm = { ( ) => deleteSystem ( record . system_id ) }
278
- >
279
- < Button
280
- danger
281
- disabled = { notCreator }
282
- size = "small"
283
- icon = { < DeleteOutlined /> }
284
- />
285
- </ Popconfirm >
286
- </ Space >
321
+ </ Popconfirm >
287
322
</ Space >
288
- ) ;
289
- } ,
323
+ </ Space >
324
+ ) ;
290
325
} ,
291
- ] ;
326
+ } ) ;
292
327
293
328
// rowSelection object indicates the need for row selection
294
329
const rowSelection = {
0 commit comments