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

BL-823_fe_i_want_export_raw-data #25

Open
wants to merge 103 commits into
base: main
Choose a base branch
from

Conversation

publiminal
Copy link

Description

This task implements a 'download data button' that allows a final user to download the whole data set in raw format (.csv) for their own consumption and run it in Excel or some other BI tool.

For this ticket was needed :

  • To perform a research about current/new js capabilities to create and download files instantly with a non-blocking ui.
  • To review libraries that already abstracted best options above.

Conclusions :
Backend :

  • It is expected to fetch a static .zip file containing a the whole dataset.
  • The fetched url should be included as .env var for easy further update.
    currently : REACT_APP_DOWNLOAD_RAW_CSV_DATA_URL=http://localhost:3000/test-raw-data.zip
  • There is work to do in BE side to confirm this zipped .csv file is available to FE to download.

FrontEnd :

  • Axios is the chosen library since it was already installed and also is capable to fetch files with the new stream capabilities available since ES6 2015.
  • Added 2 libs to display a beautiful download progress and actually trigger the download action from the browser. All above means there is no any other backend call required.
  • Added friendly messages to the final user at every step of the process (start download, download in progress, finish download) using ant message component.

Video Link

Loom Video

Jira Link

BL-823

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have removed unnecessary comments/console logs from my code
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings
  • No duplicate code left within changed files
  • Size of pull request kept to a minimum
  • Pull request description clearly describes changes made & motivations for said changes

XavierTwitty
XavierTwitty previously approved these changes Sep 5, 2022
Copy link
Contributor

@XavierTwitty XavierTwitty left a comment

Choose a reason for hiding this comment

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

I really enjoyed the UX for the download button, the progress bar feature makes the site more appealing to me. The code looks clean and easy to read. Good use of reusability.

lisamdespain
lisamdespain previously approved these changes Sep 6, 2022
Copy link

@lisamdespain lisamdespain left a comment

Choose a reason for hiding this comment

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

Greetings from the CoderHeroes team! I was excited to see this being implemented because we have a component that could use a download to csv feature. Curious if you considered installing react-csv instead of the library you used? ALSO - great job on the progress bar feature. Looks great! If you fix the linting errors (looks like missing semicolons), this should be good to go.

@publiminal
Copy link
Author

publiminal commented Sep 7, 2022

Greetings from the CoderHeroes team! I was excited to see this being implemented because we have a component that could use a download to csv feature. Curious if you considered installing react-csv instead of the library you used? ALSO - great job on the progress bar feature. Looks great! If you fix the linting errors (looks like missing semicolons), this should be good to go.

Hi @lisamdespain : I'll be more than glad you can reuse this work !
Use case in mind to create the component was fetch a url (.zip file containing a .csv file) and download it instantly without any data transformation or blocking the UI. So, the library chosen as 'save-window-opener' just have specific code to trigger the file-to-save-window only (js vanilla code). All main preparation work (fetching / streaming the file) is previously and separately made by Axios library.

Reviewing the react-csv will work better for cases when you want to download a .csv in memory already but prior data transformations are needed. So, the 'react-csv' library will work beautifully handling data transformations from array / object / json / string to csv. In addition,it also include typesecript for linter validation, and all react component scafolding to import it as a full react component.

Thanks for your review !

@publiminal publiminal closed this Sep 7, 2022
@publiminal
Copy link
Author

reopening PR ! Closed by mistake !

@publiminal publiminal reopened this Sep 7, 2022
@publiminal publiminal dismissed stale reviews from lisamdespain and XavierTwitty via 7ec0b8f September 7, 2022 01:56
Copy link
Contributor

@XavierTwitty XavierTwitty left a comment

Choose a reason for hiding this comment

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

The components look good , like your use of Redux . Great work!

@publiminal publiminal requested review from lisamdespain and removed request for ashtilawat23 September 9, 2022 05:27
Copy link

@lisamdespain lisamdespain left a comment

Choose a reason for hiding this comment

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

Greetings from CoderHeroes! I was happy to see this implemented, as we had something similar over on CH that needs to be implemented, except we were planning on using react-csv. I like how you did this one, especially the progress bar. Great job!

Copy link

@MaxT6 MaxT6 left a comment

Choose a reason for hiding this comment

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

Wow! Really extensive PR. Great job being so detailed in exporting the raw data.

function DownloadButton(props){
const info = props.downloadBtnInfo || defaultInfo;
const { BTN_TXT, MSG_LOADING, DOWNLOAD_TXT, MSG_DOWNLOAD_FINISHED, STYLING } = info;
const [txt, setTxt] = useState(BTN_TXT);
Copy link

Choose a reason for hiding this comment

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

Nice job using a hook to update the button text. Very dynamic!

const { set_view } = props;
return (
<div className="all-offices-route">
<GraphWrapper set_view={set_view} />
Copy link

Choose a reason for hiding this comment

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

Nice job deconstructing set_view from props and passing that to the GraphWrapper component

case 'time-series':
map_to_render = <TimeSeriesAll />;
break;
case 'office-heat-map':
Copy link

Choose a reason for hiding this comment

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

Good idea to utilize switch case here instead of if else

SET_DATE_FILTER_FORMAT,
SET_ASYLUM_OFFICE_FILTER,
SET_CONTINENT_FILTER,
SET_GEOPOLITICAL_FILTER,
Copy link

Choose a reason for hiding this comment

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

Excellent job cleaning up the imports!

Copy link

@ezra-casas ezra-casas left a comment

Choose a reason for hiding this comment

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

Loving the new and improved code! Ya'll doing wonderous work!

Copy link

@AlexiusThomas AlexiusThomas left a comment

Choose a reason for hiding this comment

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

Great work and great explanation of the values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants