pull/1479/head
yikai 2 years ago
parent d645c49450
commit 6a8bef846f

@ -0,0 +1,3 @@
// .custom-icon {
// color: red !important;
// }

@ -1,15 +1,15 @@
import { createFromIconfontCN } from '@ant-design/icons';
interface Props {
type: string;
}
import React from 'react';
import style from './index.module.less';
const MyIcon = createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/c/font_4254722_3l4m6by7h34.js', // 在 iconfont.cn 上生成
scriptUrl: '//at.alicdn.com/t/c/font_4254722_vw34zn7su2.js', // 在 iconfont.cn 上生成
});
const IconFont = (props: Props) => {
return <MyIcon {...props}></MyIcon>;
type MyComponentProps = React.HTMLProps<HTMLDivElement> & { type: string };
const IconFont: React.FC<MyComponentProps> = props => {
return <MyIcon className={style['custom-icon']} {...props}></MyIcon>;
};
export default IconFont;

@ -0,0 +1,27 @@
import { Button, ButtonProps } from 'antd';
import React from 'react';
import { SearchOutlined, PlusOutlined, RedoOutlined } from '@ant-design/icons';
function withSearchIconButton<P extends ButtonProps>(WrappedComponent: React.ComponentType<P>) {
return function EnhancedComponent(props: P) {
return <WrappedComponent icon={<SearchOutlined></SearchOutlined>} {...props} />;
};
}
function withAddIconButton<P extends ButtonProps>(WrappedComponent: React.ComponentType<P>) {
return function EnhancedComponent(props: P) {
return <WrappedComponent icon={<PlusOutlined />} {...props}></WrappedComponent>;
};
}
function withResetIconButton<P extends ButtonProps>(WrappedComponent: React.ComponentType<P>) {
return function EnhancedComponent(props: P) {
return <WrappedComponent {...props} icon={<RedoOutlined />}></WrappedComponent>;
};
}
export const SearchButton = withSearchIconButton(Button);
export const AddButton = withAddIconButton(Button);
export const ResetButton = withResetIconButton(Button);

@ -1,14 +1,18 @@
import { Button, Form, Select, Space, Table, Typography } from 'antd';
import { Form, Select, Space, Table, Typography } from 'antd';
import { useFormStateToUrl, useTran } from '@/hooks';
import { STR_MAP } from '@/config/i18n/locales/constants';
import { ColumnProps } from 'antd/es/table';
import { SearchButton, AddButton } from '@/components/with-button';
import { useAntdTable } from 'ahooks';
import service, { Result, ThreadPoolTableBody } from './service';
const { Title } = Typography;
const { Item } = Form;
const paramsType = { project: 0, thpool: 0 };
const params = { project: 0, thpool: 0 };
const ThreadPoll = () => {
const [form] = Form.useForm();
const { handleSetUrlState } = useFormStateToUrl<{ project: number; thpool: number }>(form, params);
const { handleSetUrlState } = useFormStateToUrl<{ project: number; thpool: number }>(form, paramsType);
const columns: ColumnProps<any>[] = [
{
title: useTran(STR_MAP.SERIAL_NUMBER),
@ -44,7 +48,7 @@ const ThreadPoll = () => {
},
{
title: useTran(STR_MAP.ALARM_OR_NOT),
dataIndex: 'tenantry',
dataIndex: 'allowCoreThreadTimeOut',
},
{
title: useTran(STR_MAP.CREATION_TIME),
@ -60,14 +64,29 @@ const ThreadPoll = () => {
},
];
const handleSubmit = () => {
handleSetUrlState();
const getTableData = (): Promise<Result> => {
return service.fetchThreadPoolTable({
current: 1,
size: 10,
tpId: '',
itemId: '',
});
};
const { tableProps, search } = useAntdTable<Result, ThreadPoolTableBody>(getTableData, {
defaultPageSize: 5,
form: form,
});
const { submit } = search;
return (
<Space direction="vertical" style={{ width: '100%' }} size="large">
<Title>{useTran(STR_MAP.THREAD_POOL)}</Title>
<Form form={form} layout="inline">
<Item name="tenatIds" style={{ flex: 1 }}>
<Select options={[{ label: '哈哈哈', value: 1 }]} placeholder={useTran(STR_MAP.PROJECT)}></Select>
</Item>
<Item name="project" style={{ flex: 1 }}>
<Select options={[{ label: '哈哈哈', value: 1 }]} placeholder={useTran(STR_MAP.PROJECT)}></Select>
</Item>
@ -76,14 +95,21 @@ const ThreadPoll = () => {
</Item>
<Item style={{ flex: 4 }}>
<Space>
<Button type="primary" htmlType="submit" onClick={handleSubmit}>
<SearchButton
type="primary"
htmlType="submit"
onClick={() => {
submit();
handleSetUrlState();
}}
>
{useTran(STR_MAP.SEARCH)}
</Button>
<Button type="primary">{useTran(STR_MAP.ADD)}</Button>
</SearchButton>
<AddButton type="primary">{useTran(STR_MAP.ADD)}</AddButton>
</Space>
</Item>
</Form>
<Table columns={columns}></Table>
<Table columns={columns} {...tableProps}></Table>
</Space>
);
};

@ -0,0 +1,16 @@
import request from '@/utils';
const fetchThreadPoolTable = async (body: ThreadPoolTableBody): Promise<Result> => {
const { data } = await request<ThreadPoolTableRes>('/hippo4j/v1/cs/thread/pool/query/page', {
method: 'POST',
body,
});
return {
total: data?.total,
list: data?.records,
};
};
export default {
fetchThreadPoolTable,
};

@ -0,0 +1,123 @@
import { Params } from 'ahooks/lib/useAntdTable/types';
// body
export interface ThreadPoolTableBody extends Params {
/**
* current page
*/
current: number;
/**
* project id
*/
itemId?: string;
/**
* page size
*/
size: number;
/**
*tenant Id
*/
tenantId?: string;
/**
* thread pool ID
*/
tpId?: string;
}
export interface Record {
/**
*
*/
allowCoreThreadTimeOut?: number;
/**
*
*/
capacity?: number;
/**
*
*/
capacityAlarm?: number;
/**
* 线
*/
coreSize?: number;
/**
*
*/
executeTimeOut?: number;
/**
*
*/
gmtCreate?: string;
/**
*
*/
gmtModified?: string;
/**
* ID
*/
id?: string;
/**
*
*/
isAlarm?: number;
/**
* ID
*/
itemId?: string;
/**
*
*/
keepAliveTime?: number;
/**
*
*/
livenessAlarm?: number;
/**
* 线
*/
maxSize?: number;
/**
*
*/
queueName?: null;
/**
*
*/
queueType?: number;
/**
*
*/
rejectedType?: number;
/**
* ID
*/
tenantId?: string;
/**
* 线ID
*/
tpId?: string;
}
export interface ThreadPoolTableRes {
countId: null;
current: number;
desc: boolean;
hitCount: boolean;
itemId: string;
maxLimit: null;
optimizeCountSql: boolean;
orders: string[];
pages: number;
records: Record[];
searchCount: boolean;
size: number;
tenantId: string;
total: number;
tpId: string;
}
export interface Result {
total: number;
list: Record[];
}

@ -24,7 +24,7 @@ interface RequestOptions {
type Response<T = any> = {
success: boolean;
data?: T;
data: T;
module?: T;
msg?: string;
status?: number;
@ -41,8 +41,11 @@ const inital: RequestOptions = {
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMCxiYW94aW55aV91c2VyIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTU3MzAwNzYsImlhdCI6MTY5NTEyNTI3Niwicm9sIjoiUk9MRV9VU0VSIn0.4cWyhllP7u-aoRAIHs3nMggsgl4-LUCVBas8WE0FJYIe-YNS0wGf1_0RJq3TUGw00KmSaSRPKdoPgRTFqEphZA',
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMCxiYW94aW55aV91c2VyIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTU4MjY1ODQsImlhdCI6MTY5NTIyMTc4NCwicm9sIjoiUk9MRV9VU0VSIn0.HQx33P1hlZK2-0omlUt58kpa77OxiGdW-jLV4GWbbLIFf86y8-0IOdeu8gzMwMWUTRtrwp2_YWMl_05TVlDJbA',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
// headers,
credentials: true,
responseType: 'JSON',
cache: 'no-cache',
@ -85,7 +88,10 @@ function request<T>(url: string, config: RequestOptions): Promise<Response<T>> {
}
if (config.headers && isPlainObject(config.headers)) {
config.headers = Object.assign({}, inital.headers, config.headers);
} else {
config.headers = inital.headers;
}
let { method, params, body, headers, credentials, responseType } = Object.assign({}, inital, config) as any;
if (typeof url !== 'string') throw new TypeError('url is not an string');
if (!/^http(s?):\/\//i.test(url)) url = baseURL + url;

Loading…
Cancel
Save