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

feat: add reload table button #450

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
14 changes: 13 additions & 1 deletion frontend/src/components/Logs/IndexerLogs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const IndexerLogsComponent = () => {
return mergedEntries;
};

useEffect(() => {
const initializeTable = () => {
const grid = new Grid({
columns: [
{
Expand Down Expand Up @@ -204,8 +204,19 @@ const IndexerLogsComponent = () => {
});

grid.render(indexerLogsRef.current);
};

useEffect(() => {
initializeTable();
}, []);

const reloadData = () => {
indexerLogsRef.current.innerHTML = "";
setTimeout(() => {
initializeTable();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this reset the pagination?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It empties the dom element that represents the table, and then re-renders it thus reseting the table.

if you are on page 6 and reload, you'll be reset back to page 0

}, 500);
};

return (
<>
<div
Expand All @@ -222,6 +233,7 @@ const IndexerLogsComponent = () => {
setHeights={setHeights}
latestHeight={height}
isUserIndexer={indexerDetails.accountId === currentUserAccountId}
reloadData={reloadData}
/>
<Status
functionName={functionName}
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/components/Logs/LogButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const LogButtons = ({
setHeights,
latestHeight,
isUserIndexer,
reloadData
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this be called Reload Logs instead?

}) => {
const {
indexerName,
Expand Down Expand Up @@ -93,6 +94,20 @@ const LogButtons = ({
aria-label="Action Button Group"
>
<>
<OverlayTrigger
placement="bottom"
overlay={<Tooltip>Reload Data</Tooltip>}
>
<Button
size="sm"
variant="secondary"
className="flex align-center"
onClick={() => reloadData()}
>
<ArrowCounterclockwise style={{ paddingRight: "2px" }} size={24} />
Reload
</Button>
</OverlayTrigger>
<OverlayTrigger
placement="bottom"
overlay={<Tooltip>Open Editor</Tooltip>}
Expand Down