usnistgov / oar-pdr

The NIST Open Access to Research (OAR) Public Data Repository (PDR) system software
11 stars 10 forks source link

Restore display of "Loading file list..." message on server-side #204

Closed RayPlante closed 3 years ago

RayPlante commented 3 years ago

In the last round of restructuring (PR #196), a bug was introduced that prevented the momentary display of the message, "Loading file list...". This message is generated on the server-side and is displayed in lieu of the file tree because this PrimeNG-based component cannot be generated on the server-side. Determining whether to display this message is based on whether there are any elements in the TreeNode[] data structure that powers the file tree component. This structure can be generated server-side; however, due to a bug in the set-up logic, it was not getting generated. Thus, on the server-side, it looked like this dataset had no files.

This PR fixes this bug by ensuring that building the TreeNode[] structure--via buildTree()--happens on the server-side. Because this function previously also updated the files' cart and download statuses, which requires access to the global data cart and, thus, can only happen browser-side, some changes in the logic for the latter was necessary. Additional changes were needed to ensure that the dataset's overall cart and download statuses were updated consistently.

I recommend testing this under oar-docker or standalone in server-side mode (using npm run build:ssr; npm run serve:ssr). Ensure the following for a dataset that includes files to display: