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