Skip to content

Commit

Permalink
better response handling (#323)
Browse files Browse the repository at this point in the history
* better response handling

* fixed typo

* syntax fix
  • Loading branch information
jywarren authored Jul 3, 2019
1 parent 522befc commit 37e68da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,14 @@ L.DistortableCollection = L.FeatureGroup.extend({

// this may be overridden to update the UI to show export progress or completion
function _defaultUpdater(data) {
data = JSON.parse(data);
// optimization: fetch status directly from google storage:
if (data.hasOwnProperty('status_url') && statusUrl !== data.status_url && data.status_url.match('.json')) { statusUrl = data.status_url; } if (data.status === "complete") {
if (statusUrl !== data.status_url && data.status_url.match('.json')) { statusUrl = data.status_url; }
if (data.status === "complete") {
clearInterval(updateInterval);
alert("Export complete. " + data.jpg);
}
if (data.status === 'complete' && data.jpg !== null) {
alert("Export succeeded. http://export.mapknitter.org/" + data.jpg);
}
// TODO: update to clearInterval when status == "failed" if we update that in this file:
// https://github.com/publiclab/mapknitter-exporter/blob/main/lib/mapknitterExporter.rb
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-distortableimage",
"version": "0.5.2",
"version": "0.5.3",
"description": "Leaflet plugin enabling image overlays to be distorted, stretched, and warped (built for Public Lab's MapKnitter: http://publiclab.org).",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
8 changes: 6 additions & 2 deletions src/DistortableCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,14 @@ L.DistortableCollection = L.FeatureGroup.extend({

// this may be overridden to update the UI to show export progress or completion
function _defaultUpdater(data) {
data = JSON.parse(data);
// optimization: fetch status directly from google storage:
if (data.hasOwnProperty('status_url') && statusUrl !== data.status_url && data.status_url.match('.json')) { statusUrl = data.status_url; } if (data.status === "complete") {
if (statusUrl !== data.status_url && data.status_url.match('.json')) { statusUrl = data.status_url; }
if (data.status === "complete") {
clearInterval(updateInterval);
alert("Export complete. " + data.jpg);
}
if (data.status === 'complete' && data.jpg !== null) {
alert("Export succeeded. http://export.mapknitter.org/" + data.jpg);
}
// TODO: update to clearInterval when status == "failed" if we update that in this file:
// https://github.com/publiclab/mapknitter-exporter/blob/main/lib/mapknitterExporter.rb
Expand Down

0 comments on commit 37e68da

Please sign in to comment.