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: Remove loading spinner after image export #477

Merged
merged 5 commits into from
Dec 14, 2019
Merged

FIX: Remove loading spinner after image export #477

merged 5 commits into from
Dec 14, 2019

Conversation

VladimirMikulic
Copy link
Contributor

@VladimirMikulic VladimirMikulic commented Dec 8, 2019

In the old UI, the spinner would continue spinning after the images have been
exported. Now it's fixed.

Resolves #470

@sashadev-sky could you review this, please?

In the old UI, the spinner would continue spinning after the images have been
exported.

Resolves #470
@welcome
Copy link

welcome bot commented Dec 8, 2019

Thanks for opening this pull request! Dangerbot will test out your code and reply in a bit with some pointers and requests.
There may be some errors, but don't worry! We're here to help! 👍🎉😄

Copy link
Contributor

@chen-robert chen-robert left a comment

Choose a reason for hiding this comment

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

Is there a way to test this without waiting for the download to complete? It's been taking a very long time for me (over 15 minutes) for some reason.


L.IconUtil.toggleXlink(link, 'get_app', 'spinner');
L.IconUtil.toggleTitle(link, 'Export Images', 'Loading...');
L.DomUtil.removeClass(link.firstChild, 'loader');
}
if (data.status === 'complete' && data.jpg !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could probably move the data.jpg !== null condition inside the data.status === 'complete' to make the code cleaner.

Something like

if (data.status === 'complete') {
        L.IconUtil.toggleXlink(link, 'get_app', 'spinner');
        L.IconUtil.toggleTitle(link, 'Export Images', 'Loading...');
        L.DomUtil.removeClass(link.firstChild, 'loader');

        if (data.jpg !== null) {
    

@sashadev-sky
Copy link
Member

@chen-robert @VladimirMikulic SORRY should have mentioned this. The exporter never actually completes locally, it needs to be up on github pages. For my testing, I use https://sasha.mapknitter.org/examples/select.html. I added @VladimirMikulic work there and it works, you can check it out!

The exporter is really the only thing you would need you own page for, but if you plan on helping out with it you might want to get one setup! You will need a custom domain which I think @jywarren can provide you guys with, and I'll walk you through how to do it. Let me know!

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

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

@VladimirMikulic This is really great! My one concern here is that a lot of people using this library use it without our toolbar, and bind the action methods to their own custom UI. So, we would want to keep all logic related to the toolbar outside of the export functionality, in ExportAction.js. Also just promotes modularity.

Maybe by doing something like a Promise with startExport and moving those lines into a then?

Also @chen-robert your point is valid, but @VladimirMikulic didn't write the conditional, so refactoring them is technically outside the scope of this. But if he/ you wants to fix them -- all for it!

@VladimirMikulic
Copy link
Contributor Author

@sashadev-sky I wrapped startExport function inside of a promise and tested it.
It works as expected.

@VladimirMikulic
Copy link
Contributor Author

@sashadev-sky I would be thankful if you could review this.

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

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

this is really impressive!! Thank you! It does work.

Our library actually doesn't support ES6 😣Meaning we don't have a module bundler like webpack to compile the code back to ES5 - and it might not run in some browsers

We could polyfill the Promise but then were still left with the arrow functions.
options would be to

  1. set the library up with the module bundler of your choice (this would be considered another hard task)
  2. add a polyfill for the Promise and replace the arrow functions with ES5 syntax (not another task)
  3. accomplish this Promise idea using an ES5 compliant way (not sure what this would be exactly)

@VladimirMikulic
Copy link
Contributor Author

@sashadev-sky polyfill added!

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

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

@VladimirMikulic awesome thank you! So you're still using an arrow function here in the Promise so that needs to be updated. And then one more thing: run $ grunt concat:dist to build the dist file with your changes and commit that. Typically I develop with $ grunt running in the background in another terminal tab and it automatically builds changes (although occasionally it does not for some reason)

Change was necessary because arrow functions are not supported in ES5.
@VladimirMikulic
Copy link
Contributor Author

VladimirMikulic commented Dec 12, 2019

@sashadev-sky I missed it, sorry, but here is the improved version.

@SidharthBansal
Copy link
Member

@chen-robert @jywarren can you please review?

@VladimirMikulic
Copy link
Contributor Author

@sashadev-sky ?

@jywarren
Copy link
Member

This is great, can you share a gif of this working, or a link to it running in a GitHub pages branch? Thanks!

The change was necessary because in the Promise the value of
keyword this gets lost
@VladimirMikulic
Copy link
Contributor Author

@jywarren @sashadev-sky here is the showcase video: https://streamable.com/ye1oz

@jywarren
Copy link
Member

This is wonderful! Thanks so much, great work!

@jywarren jywarren merged commit af4bea8 into publiclab:main Dec 14, 2019
@welcome
Copy link

welcome bot commented Dec 14, 2019

Congrats on merging your first pull request! 🙌🎉⚡️
Your code will likely be published to https://mapknitter.org in the next few days.
In the meantime, can you tell us your Twitter handle so we can thank you properly?
Now that you've completed this, you can help someone else take their first step!
See: Public Lab's coding community!

@VladimirMikulic VladimirMikulic deleted the fix/remove-spinner-after-export branch December 14, 2019 16:08
@VladimirMikulic
Copy link
Contributor Author

@jywarren could you also approve the task on GCI, so I can move on?
Thanks.

@SidharthBansal
Copy link
Member

SidharthBansal commented Dec 15, 2019 via email

@VladimirMikulic
Copy link
Contributor Author

Thank you @SidharthBansal.

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.

Remove spinner after an export is complete
5 participants