Skip to content

Commit

Permalink
fix: pagination of inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Sep 29, 2022
1 parent 5246cd8 commit 951208d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
15 changes: 8 additions & 7 deletions frontend/packages/manager/src/components/groups/GroupsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function GroupsList() {
const [totalPages, setTotalPages] = useState(1);
const [openedGroupId, setOpenedGroupId] = useState(null);
const [pageNum, setPageNum] = useState(1);
const DEVICES_PER_PAGE = 10;
const DEVICES_PER_PAGE = 3;

useEffect(() => {
let isMounted = true;
Expand Down Expand Up @@ -171,14 +171,15 @@ function GroupsList() {
<Table.Cell>{row.securityEngine}</Table.Cell>
</Table.Row>
))}
<Paginator
onChange={(event, { page }) => (handlePagination(page, group._id.$oid))}
current={pageNum}
alwaysShowLastPageLink
totalPages={totalPages}
/>

</Table.Body>
</Table>
<Paginator
onChange={(event, { page }) => (handlePagination(page, group._id.$oid))}
current={pageNum}
alwaysShowLastPageLink
totalPages={totalPages}
/>
</CollapsiblePanel>
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SortableColumns extends Component {
let url = this.BASE_URL_GET_ALL+page.toString()+"/"+this.DEVICES_PER_PAGE.toString()
axios.get(`${url}`)
.then((response) => {
if (currentRecords.length != response.data.length){
if (currentRecords.length != response.data.inventory.length){
this.reload = true;
}
this.setState({allInventoryRecords: response.data.inventory,
Expand Down Expand Up @@ -97,7 +97,7 @@ class SortableColumns extends Component {
};

handlePagination = (event, { page }) => {
getFetchInventoryRows(page);
this.getFetchInventoryRows(page);
};

handleSort = (e, {sortKey}) => {
Expand Down Expand Up @@ -170,14 +170,14 @@ class SortableColumns extends Component {
<Table.Cell>{row.smartProfiles.toString()}</Table.Cell>
</Table.Row>
))}
<Paginator
onChange={this.handlePagination}
current={this.state.pageNum}
alwaysShowLastPageLink
totalPages={this.state.totalPages}
/>
</Table.Body>
</Table>
<Paginator
onChange={this.handlePagination}
current={this.state.pageNum}
alwaysShowLastPageLink
totalPages={this.state.totalPages}
/>
<ButtonsModal handleRequestDelete={() => (this.buttonsRequestDelete(this.context))}
handleRequestEdit={() => (this.buttonsRequestEdit(this.context))}
context={this.context}/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/manager/src/store/inventory-contxt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function InventoryContextProvider(props){
// data for editing in AddInventoryModal
const [isEdit, setIsEdit] = useState(false);
const [address, setAddress] = useState('');
const [port, setPort] = useState(161);
const [port, setPort] = useState('161');
const [version, setVersion] = useState('2c');
const [community, setCommunity] = useState('');
const [secret, setSecret] = useState('');
Expand All @@ -38,7 +38,7 @@ export function InventoryContextProvider(props){
function resetFormData() {
setInventoryId(null);
setAddress('');
setPort(161);
setPort('161');
setVersion('2c');
setCommunity('');
setSecret('');
Expand Down

0 comments on commit 951208d

Please sign in to comment.