Skip to content

Commit

Permalink
Protect page from crashing on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
dsblank committed Apr 12, 2023
1 parent aee5f4f commit 8e23aab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/app/PagerBar/pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ const Pager = ({ dgid, aboutText, firstRow, totalRows, currentPage, totalPages,
const downloadName = dgid && dgid.includes("/") ? dgid.substring(dgid.lastIndexOf("/") + 1) : dgid;
const downloadLink = (totalPages > 0 && !config.hideSelector) ? (<a href={`${config.rootPath}api/download?dgid=${dgid}`} download={downloadName}><DownloadIcon/></a>) : (<></>);

const getLocaleString = (text) => {
if (text) {
return text.toLocaleString(config.locale);
}
return null;
};

const canGoto = (page) => {
return page > 0 && page <= totalPages && page !== currentPage;
};
Expand Down Expand Up @@ -75,7 +82,7 @@ const Pager = ({ dgid, aboutText, firstRow, totalRows, currentPage, totalPages,
</div>
<div className={cx("right-bar")}>
<span>
Showing {`${firstRow.toLocaleString(config.locale)} - ${maxRow.toLocaleString(config.locale)} of ${totalRows.toLocaleString(config.locale)} rows`}
Showing {`${getLocaleString(firstRow)} - ${getLocaleString(maxRow)} of ${getLocaleString(totalRows)} rows`}
</span>
<button
className={cx('rounded')}
Expand Down Expand Up @@ -112,7 +119,7 @@ const Pager = ({ dgid, aboutText, firstRow, totalRows, currentPage, totalPages,
}}
/>
<span>
of {`${totalPages.toLocaleString(config.locale)}`}
of {`${getLocaleString(totalPages)}`}
</span>
<button
className={cx('rounded')}
Expand Down

0 comments on commit 8e23aab

Please sign in to comment.