Skip to content

Download json file of saved positions #1237

Merged
jywarren merged 37 commits into
publiclab:mainfrom
vanithaak:downloadJSON
Jan 26, 2023
Merged

Download json file of saved positions #1237
jywarren merged 37 commits into
publiclab:mainfrom
vanithaak:downloadJSON

Conversation

@vanithaak

Copy link
Copy Markdown
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

gitpod-io Bot commented Oct 25, 2022

Copy link
Copy Markdown

@vanithaak

Copy link
Copy Markdown
Contributor Author

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

@vanithaak

Copy link
Copy Markdown
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?

Comment thread src/DistortableCollection.js Outdated
}

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

@jywarren jywarren Jan 3, 2023

Copy link
Copy Markdown
Member

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

jywarren commented Jan 17, 2023

Copy link
Copy Markdown
Member

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)) {

Comment thread src/DistortableCollection.js Outdated
Comment thread src/DistortableCollection.js Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
Member

Referencing this function could work like:

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

@7malikk

7malikk commented Jan 24, 2023

Copy link
Copy Markdown
Collaborator

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

@jywarren jywarren left a comment

Copy link
Copy Markdown
Member

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!!

Comment thread examples/js/archive.js Outdated
Comment thread src/DistortableCollection.js Outdated
Comment thread src/edit/DistortableCollection.Edit.js Outdated
Comment thread src/DistortableCollection.js Outdated
@7malikk

7malikk commented Jan 25, 2023

Copy link
Copy Markdown
Collaborator

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

UI Changes

downloadJSON-two

@jywarren jywarren left a comment

Copy link
Copy Markdown
Member

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