style: keep the logs pagination visible

This commit is contained in:
jialin
2025-06-27 10:15:11 +08:00
parent e2d79a6802
commit cbeea23295
14 changed files with 116 additions and 132 deletions
+85 -85
View File
@@ -10,7 +10,7 @@ import {
type ModalFuncProps type ModalFuncProps
} from 'antd'; } from 'antd';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import { useState } from 'react'; import { forwardRef, useImperativeHandle, useState } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
const useStyles = createStyles(({ css }) => ({ const useStyles = createStyles(({ css }) => ({
@@ -71,7 +71,7 @@ interface Configuration {
checked: boolean; checked: boolean;
} }
export default function useDeleteModel() { const DeleteModal = forwardRef((props, ref) => {
const intl = useIntl(); const intl = useIntl();
const { styles } = useStyles(); const { styles } = useStyles();
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll(); const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
@@ -123,89 +123,89 @@ export default function useDeleteModel() {
} }
}; };
const DeleteModal = () => { useImperativeHandle(ref, () => ({
return (
<Modal
style={{
top: '20%'
}}
open={visible}
onOk={handleOk}
onCancel={handleCancel}
destroyOnClose={false}
closeIcon={false}
maskClosable={false}
keyboard={false}
width={460}
styles={{
footer: {
marginTop: '20px'
}
}}
footer={
<Space size={20}>
<Button onClick={handleCancel} size="middle">
{config.cancelText
? intl.formatMessage({ id: config.cancelText })
: intl.formatMessage({ id: 'common.button.cancel' })}
</Button>
<Button type="primary" onClick={handleOk} size="middle">
{config.okText
? intl.formatMessage({ id: config.okText })
: intl.formatMessage({ id: 'common.button.delete' })}
</Button>
</Space>
}
>
<div className={styles['delete-modal-content']}>
<span className="title">
<ExclamationCircleFilled />
<span>
{config.title
? intl.formatMessage({ id: config.title })
: intl.formatMessage({ id: 'common.title.delete.confirm' })}
</span>
</span>
</div>
<div
className={styles['content']}
dangerouslySetInnerHTML={{
__html: config.content
? intl.formatMessage(
{
id: config.operation || ''
},
{
type: intl.formatMessage({ id: config.content }),
name: config.name
}
)
: ''
}}
></div>
{config.checkConfig && (
<CheckboxWrapper>
<Checkbox
checked={configuration.checked}
onChange={(e) =>
setConfiguration({
checked: e.target.checked
})
}
>
<span className="check-text">
{intl.formatMessage({ id: config.checkConfig?.checkText })}
</span>
</Checkbox>
</CheckboxWrapper>
)}
</Modal>
);
};
return {
DeleteModal,
show, show,
hide, hide,
configuration configuration
}; }));
}
return (
<Modal
style={{
top: '20%'
}}
open={visible}
onOk={handleOk}
onCancel={handleCancel}
destroyOnClose={false}
closeIcon={false}
maskClosable={false}
keyboard={false}
width={460}
styles={{
footer: {
marginTop: '20px'
}
}}
footer={
<Space size={20}>
<Button onClick={handleCancel} size="middle">
{config.cancelText
? intl.formatMessage({ id: config.cancelText })
: intl.formatMessage({ id: 'common.button.cancel' })}
</Button>
<Button type="primary" onClick={handleOk} size="middle">
{config.okText
? intl.formatMessage({ id: config.okText })
: intl.formatMessage({ id: 'common.button.delete' })}
</Button>
</Space>
}
>
<div className={styles['delete-modal-content']}>
<span className="title">
<ExclamationCircleFilled />
<span>
{config.title
? intl.formatMessage({ id: config.title })
: intl.formatMessage({ id: 'common.title.delete.confirm' })}
</span>
</span>
</div>
<div
className={styles['content']}
dangerouslySetInnerHTML={{
__html: config.content
? intl.formatMessage(
{
id: config.operation || ''
},
{
type: intl.formatMessage({ id: config.content }),
name: config.name
}
)
: ''
}}
></div>
{config.checkConfig && (
<CheckboxWrapper>
<Checkbox
checked={configuration.checked}
onChange={(e) =>
setConfiguration({
checked: e.target.checked
})
}
>
<span className="check-text">
{intl.formatMessage({ id: config.checkConfig?.checkText })}
</span>
</Checkbox>
</CheckboxWrapper>
)}
</Modal>
);
});
export default DeleteModal;
+1 -1
View File
@@ -1,7 +1,7 @@
export const controlSeqRegex = /\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g; export const controlSeqRegex = /\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g;
export const replaceLineRegex = /\r\n/g; export const replaceLineRegex = /\r\n/g;
export const PageSize = 500; export const PageSize = 1000;
export const throttle = <T extends (...args: any[]) => void>( export const throttle = <T extends (...args: any[]) => void>(
func: T, func: T,
@@ -106,4 +106,4 @@ const LogsPagination: React.FC<LogsPaginationProps> = (props) => {
); );
}; };
export default React.memo(LogsPagination); export default LogsPagination;
+1 -1
View File
@@ -17,7 +17,7 @@
top: 0; top: 0;
bottom: 0; bottom: 0;
right: -18px; right: -18px;
width: 80px; // width: 80px;
height: 185px; height: 185px;
&:hover { &:hover {
@@ -15,6 +15,7 @@
.text { .text {
min-height: 22px; min-height: 22px;
padding-inline-end: 80px;
&.numable { &.numable {
position: relative; position: relative;
@@ -12,7 +12,7 @@
} }
.ant-btn { .ant-btn {
background-color: rgba(71, 71, 71, 100%) !important; background-color: rgba(71, 71, 71, 70%) !important;
} }
.pages { .pages {
@@ -11,7 +11,6 @@ import React, {
useRef, useRef,
useState useState
} from 'react'; } from 'react';
import styled from 'styled-components';
import LogsList from './logs-list'; import LogsList from './logs-list';
import LogsPagination from './logs-pagination'; import LogsPagination from './logs-pagination';
import './styles/index.less'; import './styles/index.less';
@@ -28,12 +27,6 @@ interface LogsViewerProps {
diffHeight?: number; diffHeight?: number;
} }
const PaginationWrapper = styled.div`
position: absolute;
right: 50px;
top: 30px;
`;
const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => { const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const { diffHeight, url, tail: defaultTail, enableScorllLoad = true } = props; const { diffHeight, url, tail: defaultTail, enableScorllLoad = true } = props;
const { pageSize, page, setPage, setTotalPage, totalPage } = const { pageSize, page, setPage, setTotalPage, totalPage } =
@@ -302,16 +295,6 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
return ( return (
<div className="logs-viewer-wrap-w2"> <div className="logs-viewer-wrap-w2">
{/* <PaginationWrapper>
<Pagination
simple={{ readOnly: true }}
total={totalPage}
current={page}
pageSize={pageSize}
showSizeChanger={false}
hideOnSinglePage={false}
></Pagination>
</PaginationWrapper> */}
<div className="wrap"> <div className="wrap">
<div> <div>
<LogsList <LogsList
@@ -331,7 +314,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
<div className="pg"> <div className="pg">
<div <div
className={classNames('pg-inner', { className={classNames('pg-inner', {
'at-top': isAtTop 'at-top': true
})} })}
> >
<LogsPagination <LogsPagination
+4 -7
View File
@@ -1,4 +1,3 @@
import useDeleteModel from '@/components/delete-modal';
import useSetChunkRequest from '@/hooks/use-chunk-request'; import useSetChunkRequest from '@/hooks/use-chunk-request';
import useTableRowSelection from '@/hooks/use-table-row-selection'; import useTableRowSelection from '@/hooks/use-table-row-selection';
import useTableSort from '@/hooks/use-table-sort'; import useTableSort from '@/hooks/use-table-sort';
@@ -56,7 +55,6 @@ export default function useTableFetch<ListItem>(
perPage: 10, perPage: 10,
search: '' search: ''
}); });
const { DeleteModal, show, hide, configuration } = useDeleteModel();
const { setChunkRequest } = useSetChunkRequest(); const { setChunkRequest } = useSetChunkRequest();
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({ const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
events: ['UPDATE', 'DELETE', 'INSERT'], events: ['UPDATE', 'DELETE', 'INSERT'],
@@ -204,7 +202,7 @@ export default function useTableFetch<ListItem>(
row: ListItem & { name: string; id: number }, row: ListItem & { name: string; id: number },
options?: any options?: any
) => { ) => {
show({ modalRef.current?.show({
content: contentForDelete, content: contentForDelete,
operation: 'common.delete.single.confirm', operation: 'common.delete.single.confirm',
name: row.name, name: row.name,
@@ -212,7 +210,7 @@ export default function useTableFetch<ListItem>(
async onOk() { async onOk() {
console.log('OK'); console.log('OK');
await deleteAPI?.(row.id, { await deleteAPI?.(row.id, {
...configuration ...modalRef.current?.configuration
}); });
fetchData(); fetchData();
} }
@@ -220,7 +218,7 @@ export default function useTableFetch<ListItem>(
}; };
const handleDeleteBatch = (options = {}) => { const handleDeleteBatch = (options = {}) => {
show({ modalRef.current?.show({
content: contentForDelete, content: contentForDelete,
operation: 'common.delete.confirm', operation: 'common.delete.confirm',
selection: true, selection: true,
@@ -232,7 +230,7 @@ export default function useTableFetch<ListItem>(
rowSelection.selectedRowKeys, rowSelection.selectedRowKeys,
async (id: any) => { async (id: any) => {
await deleteAPI(id, { await deleteAPI(id, {
configuration ...modalRef.current?.configuration
}); });
successIds.push(id); successIds.push(id);
} }
@@ -275,7 +273,6 @@ export default function useTableFetch<ListItem>(
sortOrder, sortOrder,
queryParams, queryParams,
modalRef, modalRef,
DeleteModal,
setQueryParams, setQueryParams,
handleDelete, handleDelete,
handleDeleteBatch, handleDeleteBatch,
+1 -1
View File
@@ -210,7 +210,7 @@ export default {
'common.button.feedback': 'Feedback', 'common.button.feedback': 'Feedback',
'common.button.docs': 'Documentation', 'common.button.docs': 'Documentation',
'common.button.version': 'Version', 'common.button.version': 'Version',
'common.title.delete.confirm': 'Confirm delete', 'common.title.delete.confirm': 'Confirm deletion',
'common.title.stop.confirm': 'Confirm stop', 'common.title.stop.confirm': 'Confirm stop',
'common.title.start.confirm': 'Confirm start', 'common.title.start.confirm': 'Confirm start',
'common.title.recreate.confirm': 'Confirm recreate', 'common.title.recreate.confirm': 'Confirm recreate',
+3 -2
View File
@@ -1,4 +1,5 @@
import AutoTooltip from '@/components/auto-tooltip'; import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import PageTools from '@/components/page-tools'; import PageTools from '@/components/page-tools';
import { PageAction } from '@/config'; import { PageAction } from '@/config';
import HotKeys from '@/config/hotkeys'; import HotKeys from '@/config/hotkeys';
@@ -31,7 +32,7 @@ const APIKeys: React.FC = () => {
rowSelection, rowSelection,
queryParams, queryParams,
sortOrder, sortOrder,
DeleteModal, modalRef,
handleDelete, handleDelete,
handleDeleteBatch, handleDeleteBatch,
fetchData, fetchData,
@@ -260,7 +261,7 @@ const APIKeys: React.FC = () => {
onCancel={handleModalCancel} onCancel={handleModalCancel}
onOk={handleModalOk} onOk={handleModalOk}
></AddAPIKeyModal> ></AddAPIKeyModal>
<DeleteModal></DeleteModal> <DeleteModal ref={modalRef}></DeleteModal>
</> </>
); );
}; };
+8 -9
View File
@@ -1,6 +1,6 @@
import { modelsExpandKeysAtom } from '@/atoms/models'; import { modelsExpandKeysAtom } from '@/atoms/models';
import AutoTooltip from '@/components/auto-tooltip'; import AutoTooltip from '@/components/auto-tooltip';
import useDeleteModel from '@/components/delete-modal'; import DeleteModal from '@/components/delete-modal';
import DropDownActions from '@/components/drop-down-actions'; import DropDownActions from '@/components/drop-down-actions';
import DropdownButtons from '@/components/drop-down-buttons'; import DropdownButtons from '@/components/drop-down-buttons';
import { PageSize } from '@/components/logs-viewer/config'; import { PageSize } from '@/components/logs-viewer/config';
@@ -146,7 +146,6 @@ const Models: React.FC<ModelsProps> = ({
loadend, loadend,
total total
}) => { }) => {
const { DeleteModal, show } = useDeleteModel();
const { getGPUList, generateFormValues, gpuDeviceList } = const { getGPUList, generateFormValues, gpuDeviceList } =
useGenerateFormEditInitialValues(); useGenerateFormEditInitialValues();
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll(); const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
@@ -328,7 +327,7 @@ const Models: React.FC<ModelsProps> = ({
}, [onCancelViewLogs]); }, [onCancelViewLogs]);
const handleDelete = async (row: any) => { const handleDelete = async (row: any) => {
show({ modalRef.current?.show({
content: 'models.table.models', content: 'models.table.models',
operation: 'common.delete.single.confirm', operation: 'common.delete.single.confirm',
name: row.name, name: row.name,
@@ -343,7 +342,7 @@ const Models: React.FC<ModelsProps> = ({
}; };
const handleDeleteBatch = () => { const handleDeleteBatch = () => {
show({ modalRef.current?.show({
content: 'models.table.models', content: 'models.table.models',
operation: 'common.delete.confirm', operation: 'common.delete.confirm',
selection: true, selection: true,
@@ -407,7 +406,7 @@ const Models: React.FC<ModelsProps> = ({
); );
const handleDeleteInstace = useCallback( const handleDeleteInstace = useCallback(
(row: any) => { (row: any) => {
show({ modalRef.current?.show({
content: 'models.instances', content: 'models.instances',
okText: 'common.button.delrecreate', okText: 'common.button.delrecreate',
operation: 'common.delete.single.confirm', operation: 'common.delete.single.confirm',
@@ -488,7 +487,7 @@ const Models: React.FC<ModelsProps> = ({
} }
if (val === 'stop') { if (val === 'stop') {
show({ modalRef.current?.show({
content: 'models.instances', content: 'models.instances',
title: 'common.title.stop.confirm', title: 'common.title.stop.confirm',
okText: 'common.button.stop', okText: 'common.button.stop',
@@ -563,7 +562,7 @@ const Models: React.FC<ModelsProps> = ({
}; };
const handleStartBatch = async () => { const handleStartBatch = async () => {
show({ modalRef.current?.show({
content: 'models.table.models', content: 'models.table.models',
title: 'common.title.start.confirm', title: 'common.title.start.confirm',
okText: 'common.button.start', okText: 'common.button.start',
@@ -576,7 +575,7 @@ const Models: React.FC<ModelsProps> = ({
}; };
const handleStopBatch = async () => { const handleStopBatch = async () => {
show({ modalRef.current?.show({
content: 'models.table.models', content: 'models.table.models',
title: 'common.title.stop.confirm', title: 'common.title.stop.confirm',
okText: 'common.button.stop', okText: 'common.button.stop',
@@ -885,7 +884,7 @@ const Models: React.FC<ModelsProps> = ({
open={openLogModal} open={openLogModal}
onCancel={handleLogModalCancel} onCancel={handleLogModalCancel}
></ViewLogsModal> ></ViewLogsModal>
<DeleteModal></DeleteModal> <DeleteModal ref={modalRef}></DeleteModal>
<APIAccessInfoModal <APIAccessInfoModal
open={apiAccessInfo.show} open={apiAccessInfo.show}
data={apiAccessInfo.data} data={apiAccessInfo.data}
@@ -1,5 +1,6 @@
import { modelsExpandKeysAtom } from '@/atoms/models'; import { modelsExpandKeysAtom } from '@/atoms/models';
import AutoTooltip from '@/components/auto-tooltip'; import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import DropdownButtons from '@/components/drop-down-buttons'; import DropdownButtons from '@/components/drop-down-buttons';
import { TooltipOverlayScroller } from '@/components/overlay-scroller'; import { TooltipOverlayScroller } from '@/components/overlay-scroller';
import { FilterBar } from '@/components/page-tools'; import { FilterBar } from '@/components/page-tools';
@@ -293,7 +294,7 @@ const ModelFiles = () => {
dataSource, dataSource,
rowSelection, rowSelection,
queryParams, queryParams,
DeleteModal, modalRef,
fetchData, fetchData,
handleDelete, handleDelete,
handleDeleteBatch, handleDeleteBatch,
@@ -682,7 +683,7 @@ const ModelFiles = () => {
}} }}
></Table> ></Table>
</ConfigProvider> </ConfigProvider>
<DeleteModal></DeleteModal> <DeleteModal ref={modalRef}></DeleteModal>
<DownloadModal <DownloadModal
onCancel={handleDownloadCancel} onCancel={handleDownloadCancel}
onOk={handleDownload} onOk={handleDownload}
+3 -2
View File
@@ -1,4 +1,5 @@
import AutoTooltip from '@/components/auto-tooltip'; import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import DropdownButtons from '@/components/drop-down-buttons'; import DropdownButtons from '@/components/drop-down-buttons';
import { FilterBar } from '@/components/page-tools'; import { FilterBar } from '@/components/page-tools';
import ProgressBar from '@/components/progress-bar'; import ProgressBar from '@/components/progress-bar';
@@ -93,7 +94,7 @@ const Workers: React.FC = () => {
dataSource, dataSource,
rowSelection, rowSelection,
queryParams, queryParams,
DeleteModal, modalRef,
handleDelete, handleDelete,
handleDeleteBatch, handleDeleteBatch,
fetchData, fetchData,
@@ -446,7 +447,7 @@ const Workers: React.FC = () => {
/> />
</Table> </Table>
</ConfigProvider> </ConfigProvider>
<DeleteModal></DeleteModal> <DeleteModal ref={modalRef}></DeleteModal>
<AddWorker open={open} onCancel={() => setOpen(false)}></AddWorker> <AddWorker open={open} onCancel={() => setOpen(false)}></AddWorker>
<UpdateLabels <UpdateLabels
open={updateLabelsData.open} open={updateLabelsData.open}
+3 -2
View File
@@ -1,4 +1,5 @@
import AutoTooltip from '@/components/auto-tooltip'; import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import DropdownButtons from '@/components/drop-down-buttons'; import DropdownButtons from '@/components/drop-down-buttons';
import PageTools from '@/components/page-tools'; import PageTools from '@/components/page-tools';
import { PageAction } from '@/config'; import { PageAction } from '@/config';
@@ -54,7 +55,7 @@ const Users: React.FC = () => {
rowSelection, rowSelection,
queryParams, queryParams,
sortOrder, sortOrder,
DeleteModal, modalRef,
handleDelete, handleDelete,
handleDeleteBatch, handleDeleteBatch,
fetchData, fetchData,
@@ -320,7 +321,7 @@ const Users: React.FC = () => {
onCancel={handleModalCancel} onCancel={handleModalCancel}
onOk={handleModalOk} onOk={handleModalOk}
></AddModal> ></AddModal>
<DeleteModal></DeleteModal> <DeleteModal ref={modalRef}></DeleteModal>
</> </>
); );
}; };