active scritp production typo and add new page size

This commit is contained in:
Olivier Gagnon 2021-09-21 11:50:48 -04:00
parent db35fde42e
commit ffa9600302
3 changed files with 7 additions and 25 deletions

@ -4,6 +4,7 @@
*/ */
import * as React from "react"; import * as React from "react";
import { Money } from "../React/Money";
import { MoneyRate } from "../React/MoneyRate"; import { MoneyRate } from "../React/MoneyRate";
import { use } from "../Context"; import { use } from "../Context";
@ -40,18 +41,13 @@ export function ScriptProduction(): React.ReactElement {
<TableBody> <TableBody>
<TableRow> <TableRow>
<TableCell component="th" scope="row" classes={{ root: classes.cell }}> <TableCell component="th" scope="row" classes={{ root: classes.cell }}>
<Typography variant="body2">Total online production of Active scripts:</Typography> <Typography variant="body2">Total production:</Typography>
</TableCell> </TableCell>
<TableCell align="left" classes={{ root: classes.cell }}> <TableCell align="left" classes={{ root: classes.cell }}>
<Typography variant="body2"> <Typography variant="body2">
<MoneyRate money={player.scriptProdSinceLastAug} /> <Money money={player.scriptProdSinceLastAug} />
</Typography> </Typography>
</TableCell> </TableCell>
</TableRow>
<TableRow style={{ width: "1px" }}>
<TableCell component="th" scope="row" classes={{ root: classes.cell }}>
<Typography variant="body2">Total online production since last Aug installation:</Typography>
</TableCell>
<TableCell align="left" classes={{ root: classes.cell }}> <TableCell align="left" classes={{ root: classes.cell }}>
<Typography variant="body2"> <Typography variant="body2">
(<MoneyRate money={prodRateSinceLastAug} />) (<MoneyRate money={prodRateSinceLastAug} />)

@ -21,26 +21,19 @@ export function ServerAccordionContent(props: IProps): React.ReactElement {
setPage(0); setPage(0);
}; };
let safePage = page;
while (safePage * rowsPerPage + 1 > props.workerScripts.length) {
safePage--;
}
if (safePage != page) setPage(safePage);
return ( return (
<> <>
<List dense disablePadding> <List dense disablePadding>
{props.workerScripts.slice(safePage * rowsPerPage, safePage * rowsPerPage + rowsPerPage).map((ws) => ( {props.workerScripts.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((ws) => (
<WorkerScriptAccordion key={`${ws.name}_${ws.args}`} workerScript={ws} /> <WorkerScriptAccordion key={`${ws.name}_${ws.args}`} workerScript={ws} />
))} ))}
</List> </List>
<TablePagination <TablePagination
rowsPerPageOptions={[10, 15, 20]} rowsPerPageOptions={[10, 15, 20, 100]}
component="div" component="div"
count={props.workerScripts.length} count={props.workerScripts.length}
rowsPerPage={rowsPerPage} rowsPerPage={rowsPerPage}
page={safePage} page={page}
onPageChange={handleChangePage} onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage} onRowsPerPageChange={handleChangeRowsPerPage}
ActionsComponent={TablePaginationActionsAll} ActionsComponent={TablePaginationActionsAll}

@ -74,13 +74,6 @@ export function ServerAccordions(props: IProps): React.ReactElement {
function rerender(): void { function rerender(): void {
setRerender((old) => !old); setRerender((old) => !old);
let safePage = page;
while (safePage * rowsPerPage + 1 >= filtered.length) {
safePage--;
}
if (safePage != page) setPage(safePage);
} }
useEffect(() => WorkerScriptStartStopEventEmitter.subscribe(rerender)); useEffect(() => WorkerScriptStartStopEventEmitter.subscribe(rerender));
@ -108,7 +101,7 @@ export function ServerAccordions(props: IProps): React.ReactElement {
})} })}
</List> </List>
<TablePagination <TablePagination
rowsPerPageOptions={[10, 15, 20]} rowsPerPageOptions={[10, 15, 20, 100]}
component="div" component="div"
count={filtered.length} count={filtered.length}
rowsPerPage={rowsPerPage} rowsPerPage={rowsPerPage}