Skip to content

Commit

Permalink
make loadImageList async
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Mar 30, 2021
1 parent 273aaf8 commit e5fbb8f
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ function calculateImageScale() {
/**
* Load the image list from tye server applying a new filter.
*/
function loadImageList() {
async function loadImageList() {
let filterElem = $('#filter_annotation_type');
let filter = filterElem.val();
let params = {
Expand All @@ -902,24 +902,25 @@ function calculateImageScale() {
handleAnnotationTypeChange();
}

$.ajax(API_IMAGES_BASE_URL + 'imageset/load/?' + $.param(params), {
type: 'GET',
headers: gHeaders,
dataType: 'json',
success: function(data, textStatus, jqXHR) {
if (data.image_set.images.length === 0) {
// redirect to image set view.
displayFeedback($('#feedback_image_set_empty'));
filterElem.val('').change();
return;
}
$('.annotate_button').prop('disabled', true);
try {
let response = await fetch(API_IMAGES_BASE_URL + 'imageset/load/?' + $.param(params), {
method: 'GET',
headers: gHeaders,
});
let data = await response.json();
if (data.image_set.images.length === 0) {
// set is empty, reset filter
displayFeedback($('#feedback_image_set_empty'));
filterElem.val('').change();
} else {
displayImageList(data.image_set.images);
},
error: function() {
$('.annotate_button').prop('disabled', false);
displayFeedback($('#feedback_connection_error'));
}
});
} catch {
displayFeedback($('#feedback_connection_error'));
} finally {
$('.annotate_button').prop('disabled', false);
}
}

/**
Expand Down Expand Up @@ -1172,7 +1173,7 @@ function calculateImageScale() {
if (tool instanceof BoundingBoxes) {
tool.cancelSelection();
}
loadImageList();
await loadImageList();
await loadAdjacentImage(-1);
});
$('#back_button').click(async function(event) {
Expand Down

0 comments on commit e5fbb8f

Please sign in to comment.