Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Pagenation,Collapse #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cesi/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"supervisor"
],
"dependencies": {
"antd": "^4.21.4",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"react": "^16.13.1",
Expand Down
1 change: 1 addition & 0 deletions cesi/ui/src/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '~antd/dist/antd.css';
.App {
text-align: center;
}
Expand Down
48 changes: 37 additions & 11 deletions cesi/ui/src/common/helpers/Processes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import {
ModalBody
} from "reactstrap";
import PropTypes from "prop-types";
import { Pagination, Collapse } from 'antd';

import api from "services/api";

const { Panel } = Collapse;

class ProcessLog extends React.Component {
state = {
modal: false,
Expand Down Expand Up @@ -103,11 +106,11 @@ const Process = ({ node, process, refresh }) => {
return (
<React.Fragment>
<tr key={process.name} class={rowClass}>
<td>{process.name}</td>
<td>{process.group}</td>
<td>{process.pid}</td>
<td>{process.uptime}</td>
<td>{process.statename}</td>
<td style={{width:'17%'}}>{process.name}</td>
<td style={{width:'17%'}}>{process.group}</td>
<td style={{width:'17%'}}>{process.pid}</td>
<td style={{width:'17%'}}>{process.uptime}</td>
<td style={{width:'17%'}}>{process.statename}</td>
<td>
<Button color="success" onClick={() => handleProcess("start")}>
Start
Expand All @@ -126,6 +129,10 @@ const Process = ({ node, process, refresh }) => {
};

class Processes extends React.Component {
state = {
current_page: 1,
pagesize: 5
}
static propTypes = {
node: PropTypes.object.isRequired,
filterFunc: PropTypes.func
Expand All @@ -134,6 +141,21 @@ class Processes extends React.Component {
filterFunc: () => true
};

onChange = (current_page,pagesize) => {
// console.log(current_page,pagesize)
this.setState({
current_page: current_page,
pagesize: pagesize
});
}

onShowSizeChange = (current_page,pagesize) => {
this.setState({
current_page: current_page,
pagesize: pagesize
});
}

handleAllProcess = action => {
const nodeName = this.props.node.general.name;
api.nodes.allProcesses[action](nodeName).then(() => {
Expand Down Expand Up @@ -170,31 +192,35 @@ class Processes extends React.Component {
</Button>{" "}
</CardTitle>
{node.processes.length !== 0 ? (
<Table hover>
<Table hover> <Collapse defaultActiveKey={['1']}>
<Panel header="Collapse" key="1">
<thead>
<tr>
<tr>
<th>Name</th>
<th>Group</th>
<th>Pid</th>
<th>Uptime</th>
<th>State</th>
<th>Action</th>
</tr>
</thead>
</thead >
<tbody>
{node.processes.filter(filterFunc).map(process => (
{node.processes.filter(filterFunc).slice((this.state.current_page-1)*this.state.pagesize,this.state.current_page*this.state.pagesize).map(process => (
<Process
key={`${node.name}:${process.name}`}
node={node}
node={node}
process={process}
refresh={this.props.refresh}
/>
))}
</tbody>
</tbody> </Panel>
</Collapse>
</Table>
) : (
<p>No processes configured.</p>
)}
{/* antd Pagination */}
<Pagination defaultPageSize={5} pageSizeOptions={[5,10,20,50]} showQuickJumper defaultCurrent={1} total={node.processes.length} showTotal={total => `Total ${total} items`} onChange={(current_page,pagesize) => this.onChange(current_page,pagesize)} onShowSizeChange={(current_page,pagesize) => this.onShowSizeChange(current_page,pagesize)} />
</Card>
<br />
</React.Fragment>
Expand Down
Loading