fix: list local date
This commit is contained in:
@@ -4,7 +4,7 @@ import { DownOutlined, RightOutlined } from '@ant-design/icons';
|
||||
import { Button, Checkbox, Col, Empty, Row, Spin } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import RowContext from '../row-context';
|
||||
import { RowContextProps, SealTableProps } from '../types';
|
||||
|
||||
@@ -38,13 +38,12 @@ const TableRow: React.FC<
|
||||
const childrenDataRef = useRef<any[]>([]);
|
||||
childrenDataRef.current = childrenData;
|
||||
|
||||
console.log('table row====', record.name, firstLoad, expanded);
|
||||
console.log('table row====', childrenData, record.name, firstLoad, expanded);
|
||||
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
||||
dataList: childrenData,
|
||||
setDataList: setChildrenData
|
||||
// callback: (list) => renderChildren?.(list)
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (rowSelection) {
|
||||
const { selectedRowKeys } = rowSelection;
|
||||
@@ -70,13 +69,12 @@ const TableRow: React.FC<
|
||||
clearInterval(pollTimer.current);
|
||||
}
|
||||
chunkRequestRef.current?.current?.cancel?.();
|
||||
cacheDataListRef.current = [];
|
||||
};
|
||||
}, []);
|
||||
|
||||
const renderChildrenData = useCallback(() => {
|
||||
const renderChildrenData = () => {
|
||||
return renderChildren?.(childrenData);
|
||||
}, [childrenData]);
|
||||
};
|
||||
|
||||
const handlePolling = async () => {
|
||||
if (pollingChildren) {
|
||||
@@ -93,8 +91,8 @@ const TableRow: React.FC<
|
||||
console.log('first load=====', firstLoad);
|
||||
try {
|
||||
setLoading(true);
|
||||
// const data = await loadChildren?.(record);
|
||||
// setChildrenData(data || []);
|
||||
const data = await loadChildren?.(record);
|
||||
setChildrenData(data || []);
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
setChildrenData([]);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// 应用前置、全局运行的逻辑时 会在这里执行
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
@@ -17,7 +17,7 @@ export function useUpdateChunkedList(options: {
|
||||
mapFun?: (args: any) => any;
|
||||
computedID?: (d: object) => string;
|
||||
}) {
|
||||
const cacheDataListRef = useRef<any[]>([]);
|
||||
const cacheDataListRef = useRef<any[]>(options.dataList || []);
|
||||
const updateChunkedList = (
|
||||
data: ChunkedCollection,
|
||||
dataList: { id: string | number }[]
|
||||
@@ -57,7 +57,7 @@ export function useUpdateChunkedList(options: {
|
||||
console.log('create=========', updateIndex, dataList, collections);
|
||||
});
|
||||
cacheDataListRef.current = [...newDataList, ...cacheDataListRef.current];
|
||||
options.setDataList?.(cacheDataListRef.current);
|
||||
options.setDataList?.([...cacheDataListRef.current]);
|
||||
}
|
||||
// DELETE
|
||||
if (data?.type === WatchEventType.DELETE) {
|
||||
@@ -69,7 +69,7 @@ export function useUpdateChunkedList(options: {
|
||||
);
|
||||
// console.log('updateChunkedList=====delete', updatedList);
|
||||
// return updatedList;
|
||||
options.setDataList?.(() => cacheDataListRef.current);
|
||||
options.setDataList?.([...cacheDataListRef.current]);
|
||||
}
|
||||
// UPDATE
|
||||
if (data?.type === WatchEventType.UPDATE) {
|
||||
@@ -87,7 +87,8 @@ export function useUpdateChunkedList(options: {
|
||||
cacheDataListRef.current.push(updateItem);
|
||||
}
|
||||
});
|
||||
options.setDataList?.(() => cacheDataListRef.current);
|
||||
console.log('updateChunkedList=====update', cacheDataListRef.current);
|
||||
options.setDataList?.([...cacheDataListRef.current]);
|
||||
}
|
||||
if (options?.callback) {
|
||||
options?.callback(cacheDataListRef.current);
|
||||
|
||||
@@ -121,7 +121,9 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
</Col>
|
||||
<Col span={5}>
|
||||
<span style={{ paddingLeft: 38 }}>
|
||||
{dayjs.utc(item.created_at).format('YYYY-MM-DD HH:mm:ss')}
|
||||
{dayjs(item.created_at)
|
||||
.local()
|
||||
.format('YYYY-MM-DD HH:mm:ss')}
|
||||
</span>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
|
||||
@@ -360,18 +360,26 @@ const Models: React.FC<ModelsProps> = ({
|
||||
key="replicas"
|
||||
align="center"
|
||||
span={4}
|
||||
render={(text, record: ListItem) => {
|
||||
return (
|
||||
<span>
|
||||
{record.ready_replicas} / {record.replicas}
|
||||
</span>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<SealColumn
|
||||
span={5}
|
||||
title={intl.formatMessage({ id: 'common.table.createTime' })}
|
||||
dataIndex="created_at"
|
||||
key="createTime"
|
||||
key="created_at"
|
||||
defaultSortOrder="descend"
|
||||
sortOrder={sortOrder}
|
||||
showSorterTooltip={false}
|
||||
sorter={true}
|
||||
render={(val, row) => {
|
||||
return dayjs.utc(val).format('YYYY-MM-DD HH:mm:ss');
|
||||
render={(text, row) => {
|
||||
console.log('val=time===', text, row.name, row, row.created_at);
|
||||
return dayjs(text).local().format('YYYY-MM-DD HH:mm:ss');
|
||||
}}
|
||||
/>
|
||||
<SealColumn
|
||||
|
||||
@@ -4,6 +4,8 @@ export interface ListItem {
|
||||
huggingface_file_name: string;
|
||||
huggingface_filename: string;
|
||||
ollama_library_model_name: string;
|
||||
ready_replicas: number;
|
||||
replicas: number;
|
||||
s3Address: string;
|
||||
name: string;
|
||||
description: string;
|
||||
|
||||
@@ -47,9 +47,10 @@ const Models: React.FC = () => {
|
||||
cancelToken: axiosToken.token
|
||||
});
|
||||
console.log('res=======', res);
|
||||
if (!firstLoad) {
|
||||
setDataSource(res.items);
|
||||
}
|
||||
// if (!firstLoad) {
|
||||
// setDataSource(res.items);
|
||||
// }
|
||||
setDataSource(res.items);
|
||||
setTotal(res.pagination.total);
|
||||
} catch (error) {
|
||||
setDataSource([]);
|
||||
|
||||
Reference in New Issue
Block a user