Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5551'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 26, 2025
2 parents 6485930 + 87e995b commit 6316745
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/assets/javascripts/index/layers/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ OSM.initializeDataLayer = function (map) {
.click(add)));
}

function displayLoadError(message) {
$("#browse_status").html(
$("<div class='p-3'>").append(
$("<h2 class='flex-grow-1 text-break'>")
.text(I18n.t("browse.start_rjs.load_data")),
$("<div>").append(
$("<div class='d-flex'>").append(
$("<p class='alert alert-warning'>")
.text(I18n.t("browse.start_rjs.feature_error", { message: message }))))));
}

var dataLoader;

function getData() {
Expand Down Expand Up @@ -114,6 +125,18 @@ OSM.initializeDataLayer = function (map) {
}

dataLoader = null;
},
error: function (XMLHttpRequest, textStatus) {
dataLoader = null;
if (textStatus === "abort") { return; }

if (XMLHttpRequest.status === 400 && XMLHttpRequest.responseText) {
displayLoadError(XMLHttpRequest.responseText);
} else if (XMLHttpRequest.statusText) {
displayLoadError(XMLHttpRequest.statusText);
} else {
displayLoadError(String(XMLHttpRequest.status));
}
}
});
}
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ en:
relation: "relation"
start_rjs:
feature_warning: "Loading %{num_features} features, which may make your browser slow or unresponsive. Are you sure you want to display this data?"
feature_error: "Features could not be loaded: %{message}"
load_data: "Load Data"
loading: "Loading..."
tag_details:
Expand Down

0 comments on commit 6316745

Please sign in to comment.