* 配置pageSize列表 #3439 * Service List Page Increase the number of pages switching function is the same as the configuration management page #3500
This commit is contained in:
parent
b79f048a9b
commit
e4fdc3820f
@ -38,3 +38,5 @@ export const PERMISSIONS_LIST = 'PERMISSIONS_LIST';
|
|||||||
export const GET_NAMESPACES = 'GET_NAMESPACES';
|
export const GET_NAMESPACES = 'GET_NAMESPACES';
|
||||||
|
|
||||||
export const GET_CONFIGURATION = 'GET_CONFIGURATION';
|
export const GET_CONFIGURATION = 'GET_CONFIGURATION';
|
||||||
|
|
||||||
|
export const GLOBAL_PAGE_SIZE_LIST = [10, 20, 30, 50, 100];
|
||||||
|
@ -46,7 +46,7 @@ import { connect } from 'react-redux';
|
|||||||
import { getConfigs } from '../../../reducers/configuration';
|
import { getConfigs } from '../../../reducers/configuration';
|
||||||
|
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import { LANGUAGE_KEY } from '../../../constants';
|
import { LANGUAGE_KEY, GLOBAL_PAGE_SIZE_LIST } from '../../../constants';
|
||||||
|
|
||||||
const { Panel } = Collapse;
|
const { Panel } = Collapse;
|
||||||
const configsTableSelected = new Map();
|
const configsTableSelected = new Map();
|
||||||
@ -1384,7 +1384,7 @@ class ConfigurationManagement extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
<Pagination
|
<Pagination
|
||||||
style={{ float: 'right' }}
|
style={{ float: 'right' }}
|
||||||
pageSizeList={[10, 20, 30]}
|
pageSizeList={ GLOBAL_PAGE_SIZE_LIST }
|
||||||
pageSizePosition="start"
|
pageSizePosition="start"
|
||||||
pageSizeSelector="dropdown"
|
pageSizeSelector="dropdown"
|
||||||
popupProps={{ align: 'bl tl' }}
|
popupProps={{ align: 'bl tl' }}
|
||||||
|
@ -37,6 +37,7 @@ import EditServiceDialog from '../ServiceDetail/EditServiceDialog';
|
|||||||
import ShowServiceCodeing from 'components/ShowCodeing/ShowServiceCodeing';
|
import ShowServiceCodeing from 'components/ShowCodeing/ShowServiceCodeing';
|
||||||
|
|
||||||
import './ServiceList.scss';
|
import './ServiceList.scss';
|
||||||
|
import { GLOBAL_PAGE_SIZE_LIST } from '../../../constants';
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
const { Row, Col } = Grid;
|
const { Row, Col } = Grid;
|
||||||
@ -94,12 +95,14 @@ class ServiceList extends React.Component {
|
|||||||
`serviceNameParam=${search.serviceName}`,
|
`serviceNameParam=${search.serviceName}`,
|
||||||
`groupNameParam=${search.groupName}`,
|
`groupNameParam=${search.groupName}`,
|
||||||
];
|
];
|
||||||
|
this.openLoading();
|
||||||
request({
|
request({
|
||||||
url: `v1/ns/catalog/services?${parameter.join('&')}`,
|
url: `v1/ns/catalog/services?${parameter.join('&')}`,
|
||||||
success: ({ count = 0, serviceList = [] } = {}) => {
|
success: ({ count = 0, serviceList = [] } = {}) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
dataSource: serviceList,
|
dataSource: serviceList,
|
||||||
total: count,
|
total: count,
|
||||||
|
loading: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: () =>
|
error: () =>
|
||||||
@ -107,6 +110,7 @@ class ServiceList extends React.Component {
|
|||||||
dataSource: [],
|
dataSource: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
currentPage: 0,
|
currentPage: 0,
|
||||||
|
loading: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -129,6 +133,10 @@ class ServiceList extends React.Component {
|
|||||||
this.showcode.current.getInstance().openDialog(record);
|
this.showcode.current.getInstance().openDialog(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePageSizeChange(pageSize) {
|
||||||
|
this.setState({ pageSize }, () => this.queryServiceList());
|
||||||
|
}
|
||||||
|
|
||||||
deleteService(service) {
|
deleteService(service) {
|
||||||
const { locale = {} } = this.props;
|
const { locale = {} } = this.props;
|
||||||
const { prompt, promptDelete } = locale;
|
const { prompt, promptDelete } = locale;
|
||||||
@ -187,156 +195,143 @@ class ServiceList extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-container service-management">
|
<div className="main-container service-management">
|
||||||
<Loading
|
<div style={{ marginTop: -15 }}>
|
||||||
shape="flower"
|
<RegionGroup
|
||||||
|
setNowNameSpace={this.setNowNameSpace}
|
||||||
|
namespaceCallBack={this.getQueryLater}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<h3 className="page-title">
|
||||||
|
<span className="title-item">{serviceList}</span>
|
||||||
|
<span className="title-item">|</span>
|
||||||
|
<span className="title-item">{nowNamespaceName}</span>
|
||||||
|
<span className="title-item">{nowNamespaceId}</span>
|
||||||
|
</h3>
|
||||||
|
<Row
|
||||||
|
className="demo-row"
|
||||||
style={{
|
style={{
|
||||||
position: 'relative',
|
marginBottom: 10,
|
||||||
width: '100%',
|
padding: 0,
|
||||||
}}
|
}}
|
||||||
visible={this.state.loading}
|
|
||||||
tip="Loading..."
|
|
||||||
color="#333"
|
|
||||||
>
|
>
|
||||||
<div style={{ marginTop: -15 }}>
|
<Col span="24">
|
||||||
<RegionGroup
|
<Form inline field={this.field}>
|
||||||
setNowNameSpace={this.setNowNameSpace}
|
<FormItem label={serviceName}>
|
||||||
namespaceCallBack={this.getQueryLater}
|
<Input
|
||||||
/>
|
placeholder={serviceNamePlaceholder}
|
||||||
</div>
|
style={{ width: 200 }}
|
||||||
<h3 className="page-title">
|
value={search.serviceName}
|
||||||
<span className="title-item">{serviceList}</span>
|
onChange={serviceName => this.setState({ search: { ...search, serviceName } })}
|
||||||
<span className="title-item">|</span>
|
onPressEnter={() =>
|
||||||
<span className="title-item">{nowNamespaceName}</span>
|
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
||||||
<span className="title-item">{nowNamespaceId}</span>
|
}
|
||||||
</h3>
|
|
||||||
<Row
|
|
||||||
className="demo-row"
|
|
||||||
style={{
|
|
||||||
marginBottom: 10,
|
|
||||||
padding: 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Col span="24">
|
|
||||||
<Form inline field={this.field}>
|
|
||||||
<FormItem label={serviceName}>
|
|
||||||
<Input
|
|
||||||
placeholder={serviceNamePlaceholder}
|
|
||||||
style={{ width: 200 }}
|
|
||||||
value={search.serviceName}
|
|
||||||
onChange={serviceName => this.setState({ search: { ...search, serviceName } })}
|
|
||||||
onPressEnter={() =>
|
|
||||||
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label={groupName}>
|
|
||||||
<Input
|
|
||||||
placeholder={groupNamePlaceholder}
|
|
||||||
style={{ width: 200 }}
|
|
||||||
value={search.groupName}
|
|
||||||
onChange={groupName => this.setState({ search: { ...search, groupName } })}
|
|
||||||
onPressEnter={() =>
|
|
||||||
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<Form.Item label={`${hiddenEmptyService}:`}>
|
|
||||||
<Switch
|
|
||||||
checked={hasIpCount}
|
|
||||||
onChange={hasIpCount =>
|
|
||||||
this.setState({ hasIpCount, currentPage: 1 }, () => {
|
|
||||||
localStorage.setItem('hasIpCount', hasIpCount);
|
|
||||||
this.queryServiceList();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
<FormItem label="">
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
onClick={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
|
|
||||||
style={{ marginRight: 10 }}
|
|
||||||
>
|
|
||||||
{query}
|
|
||||||
</Button>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="" style={{ float: 'right' }}>
|
|
||||||
<Button type="secondary" onClick={() => this.openEditServiceDialog()}>
|
|
||||||
{create}
|
|
||||||
</Button>
|
|
||||||
</FormItem>
|
|
||||||
</Form>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
<Row style={{ padding: 0 }}>
|
|
||||||
<Col span="24" style={{ padding: 0 }}>
|
|
||||||
<Table
|
|
||||||
dataSource={this.state.dataSource}
|
|
||||||
locale={{ empty: pubNoData }}
|
|
||||||
getRowProps={row => this.rowColor(row)}
|
|
||||||
>
|
|
||||||
<Column title={locale.columnServiceName} dataIndex="name" />
|
|
||||||
<Column title={locale.groupName} dataIndex="groupName" />
|
|
||||||
<Column title={locale.columnClusterCount} dataIndex="clusterCount" />
|
|
||||||
<Column title={locale.columnIpCount} dataIndex="ipCount" />
|
|
||||||
<Column
|
|
||||||
title={locale.columnHealthyInstanceCount}
|
|
||||||
dataIndex="healthyInstanceCount"
|
|
||||||
/>
|
/>
|
||||||
<Column title={locale.columnTriggerFlag} dataIndex="triggerFlag" />
|
</FormItem>
|
||||||
<Column
|
<FormItem label={groupName}>
|
||||||
title={operation}
|
<Input
|
||||||
align="center"
|
placeholder={groupNamePlaceholder}
|
||||||
cell={(value, index, record) => (
|
style={{ width: 200 }}
|
||||||
// @author yongchao9 #2019年05月18日 下午5:46:28
|
value={search.groupName}
|
||||||
/* Add a link to view "sample code"
|
onChange={groupName => this.setState({ search: { ...search, groupName } })}
|
||||||
|
onPressEnter={() =>
|
||||||
|
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<Form.Item label={`${hiddenEmptyService}:`}>
|
||||||
|
<Switch
|
||||||
|
checked={hasIpCount}
|
||||||
|
onChange={hasIpCount =>
|
||||||
|
this.setState({ hasIpCount, currentPage: 1 }, () => {
|
||||||
|
localStorage.setItem('hasIpCount', hasIpCount);
|
||||||
|
this.queryServiceList();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<FormItem label="">
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
|
||||||
|
style={{ marginRight: 10 }}
|
||||||
|
>
|
||||||
|
{query}
|
||||||
|
</Button>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="" style={{ float: 'right' }}>
|
||||||
|
<Button type="secondary" onClick={() => this.openEditServiceDialog()}>
|
||||||
|
{create}
|
||||||
|
</Button>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row style={{ padding: 0 }}>
|
||||||
|
<Col span="24" style={{ padding: 0 }}>
|
||||||
|
<Table
|
||||||
|
dataSource={this.state.dataSource}
|
||||||
|
locale={{ empty: pubNoData }}
|
||||||
|
getRowProps={row => this.rowColor(row)}
|
||||||
|
loading={this.state.loading}
|
||||||
|
>
|
||||||
|
<Column title={locale.columnServiceName} dataIndex="name" />
|
||||||
|
<Column title={locale.groupName} dataIndex="groupName" />
|
||||||
|
<Column title={locale.columnClusterCount} dataIndex="clusterCount" />
|
||||||
|
<Column title={locale.columnIpCount} dataIndex="ipCount" />
|
||||||
|
<Column title={locale.columnHealthyInstanceCount} dataIndex="healthyInstanceCount" />
|
||||||
|
<Column title={locale.columnTriggerFlag} dataIndex="triggerFlag" />
|
||||||
|
<Column
|
||||||
|
title={operation}
|
||||||
|
align="center"
|
||||||
|
cell={(value, index, record) => (
|
||||||
|
// @author yongchao9 #2019年05月18日 下午5:46:28
|
||||||
|
/* Add a link to view "sample code"
|
||||||
replace the original button with a label,
|
replace the original button with a label,
|
||||||
which is consistent with the operation style in configuration management.
|
which is consistent with the operation style in configuration management.
|
||||||
*/
|
*/
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const { name, groupName } = record;
|
const { name, groupName } = record;
|
||||||
this.props.history.push(
|
this.props.history.push(generateUrl('/serviceDetail', { name, groupName }));
|
||||||
generateUrl('/serviceDetail', { name, groupName })
|
}}
|
||||||
);
|
style={{ marginRight: 5 }}
|
||||||
}}
|
>
|
||||||
style={{ marginRight: 5 }}
|
{detail}
|
||||||
>
|
</a>
|
||||||
{detail}
|
<span style={{ marginRight: 5 }}>|</span>
|
||||||
</a>
|
<a style={{ marginRight: 5 }} onClick={() => this.showSampleCode(record)}>
|
||||||
<span style={{ marginRight: 5 }}>|</span>
|
{sampleCode}
|
||||||
<a style={{ marginRight: 5 }} onClick={() => this.showSampleCode(record)}>
|
</a>
|
||||||
{sampleCode}
|
<span style={{ marginRight: 5 }}>|</span>
|
||||||
</a>
|
<a onClick={() => this.deleteService(record)} style={{ marginRight: 5 }}>
|
||||||
<span style={{ marginRight: 5 }}>|</span>
|
{deleteAction}
|
||||||
<a onClick={() => this.deleteService(record)} style={{ marginRight: 5 }}>
|
</a>
|
||||||
{deleteAction}
|
</div>
|
||||||
</a>
|
)}
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Table>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
{this.state.total > this.state.pageSize && (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
marginTop: 10,
|
|
||||||
textAlign: 'right',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pagination
|
|
||||||
current={this.state.currentPage}
|
|
||||||
total={this.state.total}
|
|
||||||
pageSize={this.state.pageSize}
|
|
||||||
onChange={currentPage =>
|
|
||||||
this.setState({ currentPage }, () => this.queryServiceList())
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</Table>
|
||||||
)}
|
</Col>
|
||||||
</Loading>
|
</Row>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: 10,
|
||||||
|
textAlign: 'right',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Pagination
|
||||||
|
current={this.state.currentPage}
|
||||||
|
pageSizeList={GLOBAL_PAGE_SIZE_LIST}
|
||||||
|
pageSizePosition="start"
|
||||||
|
pageSizeSelector="dropdown"
|
||||||
|
popupProps={{ align: 'bl tl' }}
|
||||||
|
total={this.state.total}
|
||||||
|
pageSize={this.state.pageSize}
|
||||||
|
onPageSizeChange={pageSize => this.handlePageSizeChange(pageSize)}
|
||||||
|
onChange={currentPage => this.setState({ currentPage }, () => this.queryServiceList())}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ShowServiceCodeing ref={this.showcode} />
|
<ShowServiceCodeing ref={this.showcode} />
|
||||||
<EditServiceDialog
|
<EditServiceDialog
|
||||||
ref={this.editServiceDialog}
|
ref={this.editServiceDialog}
|
||||||
|
Loading…
Reference in New Issue
Block a user