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

fix(DHIS2-16988): download uncompressed json rather than open inline #2015

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kabaros
Copy link
Contributor

@kabaros kabaros commented Apr 24, 2024

In new tracker API, the backend no longer sends a content-disposition header which means that, when exporting events or tracked entity instances, the JSON file doesn't get downloaded but they open inline instead.

To get around this, we're able to control the behaviour from the frontend by making use of the download property of an anchor element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download. Since the download in our case is triggered with JavaScript, rather than an anchor element in the HTML, we need to create an element on the fly with JavaScript and trigger a click programatically.

While working on this, I also changed the name of the downloaded file to include extra information so the file looks something like trackedEntities_2024-04-24_ouMode_CAPTURE__program_lxAQ7Zs9VYR.json or events_2024-04-24_orgUnit_ImspTQPwCqd__program_lxAQ7Zs9VYR__ouMode_SELECTED.json rather than just trackedEntities.json and events.json as before - the extra info in the file name are a timestamp of the download, and some extra info related to the exported entities (program, orgUnits, ouMode, trackedEntityType).

@kabaros kabaros requested a review from a team April 24, 2024 20:39
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Apr 24, 2024

🚀 Deployed on https://pr-2015--dhis2-import-export.netlify.app

@kabaros kabaros force-pushed the DHIS2-16988/download-json-uncompressed branch from 3820226 to 954156b Compare April 24, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants