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

Download json file of saved positions #1237

Merged
merged 37 commits into from
Jan 26, 2023
Merged

Conversation

vanithaak
Copy link
Contributor

Fixes #998 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

GIF

MapKnitter.Lite.-.Google.Chrome.2022-10-26.01-34-40.1.mp4

Screenshot

image

@gitpod-io
Copy link

gitpod-io bot commented Oct 25, 2022

@vanithaak
Copy link
Contributor Author

@jywarren, please review my pr! For now I'm trying to make the downloaded file more readable.

@vanithaak
Copy link
Contributor Author

hi @jywarren , I was trying to make the JSON pretty, with JSON.stringify( obj, undefined, "\t")(Also, tried null instead of undefined). Usually this works but it's not showing any tabs in downloaded file, rather it's showing "\t" . Is their anything else I can try?

}

function downloadFromLocalStorage(getImages) {
var obj = localStorage.getItem('locations');
Copy link
Member

@jywarren jywarren Jan 3, 2023

Choose a reason for hiding this comment

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

Per our conversation, after generateExportJson() is changed, we can just do this!

Suggested change
var obj = localStorage.getItem('locations');
var obj = generateExportJson(true);

@jywarren
Copy link
Member

jywarren commented Jan 17, 2023

OK, resuming here, we want to add a default generateExportJson(allImages = false) { parameter, and a conditional (referencing this conversation: #1161 (comment)):

     if (allImages || this.isCollected(layer)) {

generateExportJson() {
const json = {};
json.images = [];
this.eachLayer(function(layer) {
if (this.isCollected(layer)) {


function downloadFromLocalStorage(getImages) {
var obj = localStorage.getItem('locations');
var data = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(obj, prettyJson));
Copy link
Member

Choose a reason for hiding this comment

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

From here down is what you want. Let's just connect it to a button! And we can probably skip the prettyJson below - could do it later with a library!

@jywarren
Copy link
Member

Referencing this function could work like:

document.getElementById('export').onclick = function() { map.imgGroup.generateExportJson(true); }

@7malikk
Copy link
Collaborator

7malikk commented Jan 24, 2023

Hello @jywarren, I've been able to integrate the downloadJSON trigger in the Export Images button
Kindly review and let me know what you think.

UI Changes

downloadJSON

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

Exciting to see this function get completed!!

examples/js/archive.js Outdated Show resolved Hide resolved
src/DistortableCollection.js Outdated Show resolved Hide resolved
src/edit/DistortableCollection.Edit.js Outdated Show resolved Hide resolved
src/DistortableCollection.js Outdated Show resolved Hide resolved
@7malikk
Copy link
Collaborator

7malikk commented Jan 25, 2023

Hello @jywarren, per our discussion here are the changes
Let me know what you think, thank you!

UI Changes

downloadJSON-two

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

This looks super. Great work!!

@jywarren jywarren merged commit 9ec3d46 into publiclab:main Jan 26, 2023
@jywarren jywarren changed the title Download json file of saved positions in localStorage Download json file of saved positions Feb 10, 2023
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.

MapKnitter Lite: fetch images from Internet Archive
3 participants