-
Notifications
You must be signed in to change notification settings - Fork 204
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
Connect LDI exports downstream #782
Conversation
Code Climate has analyzed commit e673eaf7 and detected 0 issues on this pull request. View more on Code Climate. |
Codecov Report
@@ Coverage Diff @@
## main #782 +/- ##
==========================================
+ Coverage 71.41% 72.43% +1.01%
==========================================
Files 35 35
Lines 1333 1335 +2
==========================================
+ Hits 952 967 +15
+ Misses 381 368 -13
|
actions: [Exports] | ||
}).addTo(map); | ||
|
||
/** TODO: make an addLayers func */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO found
@jywarren this is working now! The code still needs a lot of cleaning but whats happening here is we are passing a custom action to the collection, which is created in the There, we overrwrite the group.startExport({ handleStatusUrl: addUrlToModel, updater: updateUI }); the handler
var addUrlToModel = function(data) {
var statusUrl = "//export.mapknitter.org" + data;
console.log("statusUrl: " + statusUrl);
// repeatedly fetch the status.json
var updateInterval = function () {
setInterval(function intervalUpdater() {
$.ajax(statusUrl, {
type: "GET",
crossDomain: true
}).done(function (data) {
updateUI(data);
});
}, 3000);
}
window.updateInterval = updateInterval;
/**
* TODO: update API to say if you pass in a custom `handleStatusUrl` you must also build your own updater
* and also create your own a frequency
* or fix this part
*/
$.ajax({
url: "/export",
type: 'POST',
data: { status_url: statusUrl }
}).done(function (data) {
console.log('success!!' + data);
updateInterval();
});
} Need advice on how to proceed based on the above points! |
OK, so we need to supply an $.ajax("http://mapknitter-exports-warps.storage.googleapis.com/1562106910/status.json", {
type: "GET",
crossDomain: true
}).done(function(data) {
console.log(data);
}); So, you can add a timestamp to the end of the URL and it'll bust the cache now: $.ajax("http://export.mapknitter.org/id/1560202769/status.json?1", {
type: "GET",
crossDomain: true
}).done(function(data) {
console.log(data);
}); That should work! |
You can test it here: http://jywarren.github.io/Leaflet.DistortableImage/examples/select |
note that if we overrwrote every action we could probably get around the svg icon issue quickly if that becomes necessary |
OK if you can't solve the SVG issue otherwise we can do that as a quick solution and solve later... Note - i'm going to fix the cache-busting upstream in the default in LDI too, i'll open a PR and link here. But it shouldn't matter for this PR if you're overriding the updater anyways! |
@jywarren right ok ill try that! Sounds good! |
OK just note I put the cache buster in the wrong place in my PR (i'm updating now) -- i put it in |
I think the |
And will this PR have the spinner appear? Thanks @sashadev-sky we are really almost there! Great work! |
http://jywarren.github.io/Leaflet.DistortableImage/examples/select is now working with the code from publiclab/Leaflet.DistortableImage#318 ! |
Yes I can add that on next! |
OK we won't be able to merge this unless Travis fixes its outage, but let's get everything ready and we can likely first thing tomorrow morning! |
@jywarren ok so should I just overrwrite every action to fix the icons? I can do some more research on it but I can't say if i'll find the right answer / how long will take if it is in fact a leaflet-toolbar issue. The good thing is we are almost at |
@jywarren it is still not working for me from MK after 8 minutes |
Yeah... i guess so. Let's mark the lines you're adding with the short-term fix and link to an issue in LDI from in the in-code comments so we're sure to fix this later. But I think that's the best path for now. Thank you! |
And let's link from the new issue on the SVG stuff /back/ to the relevant lines of code to be fixed downstream as well? |
the cache bust was not working was not referring to the icons in my last comment! but sounds good for the icons |
@jywarren I rewrote the icons. They use inline svg, which could also be used upstream in LDI. the syntax isn't worse in my opinion but I read that it bloats pages and is difficult to cache. I think maybe to just leave it and I should try again with the pipeline in Rails 5? I don't think its a leaflet-toolbar issue because I copied the I couldn't get the exporting to work with the cache busting so there's no UI yet but we already use |
get collection group API working custom export action working clean up more cleanup
Hmm, i'm seeing:
For this line:
|
Solved the first issue. Now seeing:
|
OK, this works now! The multiple export button itself, with no other manual scripting, generates this: https://mapknitter-exports-warps.storage.googleapis.com/1562186552/1562186552.jpg Hooray! I'm adding an "alert" when it completes, and merging this asap! |
keymapper: false, | ||
actions: mapknitter.imgActionArray(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is being called on mapknitter and the other time its called its called on this
. but I believe they both work so it should just be called on this
? Not sure because I was never getting the error you pointed out:
Uncaught TypeError: this.imgActionArray is not a function
at Object.<anonymous> (VM525 Map.self-c76b499773e2ed70a649cbce2df6162c1988da7e73aad1b2376e307b41ae80a3.js:106)
actions: mapknitter.imgActionArray(), | |
actions: this.imgActionArray(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For images added at runtime by the user, this
works, but for images that were loaded on the page already at load time, this
was not being preserved through the nested constructors. So I assigned this
to a local variable mapknitter
with the correct scope, to get past the errors. In general, this
usage is a bit brittle since it can so easily be overridden, so fixing it to a named locally scoped variable is a pretty good practice.
OK got it -- the status JSON is passed in the |
@jywarren for me, multiple image select is no longer possible with the pulled in changes. The images highlight yellow but only one image can be dragged at a time. Looking into it |
Hmm, i'm able to drag these two images on unstable -- can you? http://mapknitter-unstable.laboratoriopublico.org/maps/mestia |
Oh sorry it's building with the JSON.parse fix. Also check out publiclab/Leaflet.DistortableImage#321 as this will make testing much easier! |
I think that although without publiclab/Leaflet.DistortableImage#321 it's not super easy to use, this is worth merging and publishing to try out on production. It's a bit hidden of a feature right now, which for early release is actually a good thing! We can try exporting a bunch of maps, esp. on stable. Actually I need to check with icarito about SSL on the exporter container anyways! |
@jywarren ok I don't know why it wont allow me to multiple select but it had some conflicts when I pulled it in so I could've missed something there. If its working in unstable for you I'd say we can go for a merge! |
I keep making silly mistakes on handling the response, but as soon as I get it to put up an alert with the completed JPG URL I'll merge it. Thanks!!! |
OK, fixed a test. I think we'll be good now! |
@divyabaid16 note here that Sasha has started storing |
@jywarren ok does the spinner need to be done tonight? |
We win!!! No, I think we're good to publish to the live site now. Spinner can be any time you like -- would it be here or upstream in LDI? |
Thanks for sticking with this, @sashadev-sky ! The dots are connected! |
@jywarren Awesome! So what I want is to make an animated svg spinner icon that replaces the export icon in LDI while it's exporting. I have to learn how to animate svg first so for this I need a little time to learn. This could downstream to mapknitter too, but if we needed a quick implementation I would have gone with a |
* update ldi and leaflt-toolbar dependencies get collection group API working custom export action working clean up more cleanup * fix for some /this/ scope issues * selection working * LDI v0.5.2 with correct ordering, timestamp logging * test * removed package-lock.json * completion alert * JSON.parse(data) for returned status * null as non-string * response fix * prompt for scale * change status_url to export_url in test
Fixes #756 (<=== Add issue number here)
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/mapknitter-reviewers
for help, in a comment belowIf 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!