Skip to content

Commit

Permalink
merge: PR #738 from dev
Browse files Browse the repository at this point in the history
Weekly release 2023-12-11
  • Loading branch information
alycejenni authored Dec 11, 2023
2 parents b0ff566 + d1840a4 commit 4d7d813
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
install:
- requirements: docs/requirements.txt
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Share />
<Download v-if="total > 0" />
</div>
<div v-show="hasResult" :class="{ disabled: invalidated }">
<div v-show="hasResult" :class="{ disabled: invalidated }" key="resultView">
<div class="flex-container flex-stretch-first flex-center">
<ul class="nav nav-tabs">
<li
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,9 @@ export default {
if (wasAdded) {
return this.runSearch(0);
} else {
return new Promise((resolve) => {
resolve();
});
return this.loadAndCheckImages();
}
})
.then(this.loadAndCheckImages)
.then(() => {
this.setFilteredRecordTag(this.recordTag + '$ with images');
this.loading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ let images = {
},
getters: {
loadedImageRecords: (state) => {
return state.imageRecords.filter(
let loadedImgRecords = state.imageRecords.filter(
(r) => r.image.canLoad && !r.image.loading,
);
loadedImgRecords.sort((a, b) => {
const recordOrder = a.recordIndex - b.recordIndex;
return recordOrder === 0
? a.recordImageIndex - b.recordImageIndex
: recordOrder;
});
return loadedImgRecords;
},
getItemImages:
(state, getters, rootState, rootGetters) =>
Expand Down Expand Up @@ -105,7 +112,8 @@ let images = {
},
},
actions: {
loadAndCheckImages(context) {
loadAndCheckImages(context, searchId) {
const isAborted = context.rootGetters['results/isAborted'];
Vue.set(context.state, 'imageRecords', []);
if (context.state.locked) {
return;
Expand Down Expand Up @@ -134,7 +142,13 @@ let images = {
resolve(ratio);
};
imageElement.onerror = reject;
imageElement.src = url;
if (isAborted(searchId)) {
// don't try and load if this request has been aborted
reject();
} else {
// this starts the loading test
imageElement.src = url;
}
});
}

Expand All @@ -150,10 +164,17 @@ let images = {
})
.finally(() => {
r.image.loading = false;
context.state.imageRecords.push(r);
if (!isAborted(searchId)) {
// only add to the state if the search is still ongoing
context.state.imageRecords.push(r);
}
});
});
return Promise.allSettled(brokenChecks).then(() => {
if (isAborted(searchId)) {
// remove everything already added to the state
Vue.set(context.state, 'imageRecords', []);
}
context.commit(
'results/display/addPageImages',
context.getters.loadedImageRecords,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ let results = {
return [a[0], a[1], getters['query/resources/sortedResources'][a[2]]];
});
},
isAborted: (state) => (searchId) => {
return state.searchControllers[searchId].controller.signal.aborted;
},
},
mutations: {
addPage(state, after) {
Expand Down Expand Up @@ -134,9 +137,7 @@ let results = {
{ signal: context.state.searchControllers[searchId].signal },
).then((data) => {
// check to see if this request was aborted and don't add any data if so
if (
context.state.searchControllers[searchId].controller.signal.aborted
) {
if (context.getters.isAborted(searchId)) {
throw new AbortError(searchId);
}

Expand Down Expand Up @@ -218,20 +219,12 @@ let results = {
}
})
.then(() => {
Vue.set(
context.rootState.appState.status.resultData,
'loading',
false,
);
context.state.invalidated = false;
const aborted =
context.state.searchControllers[searchId].controller.signal.aborted;
Vue.delete(context.state.searchControllers, searchId);
if (aborted) {
if (context.getters.isAborted(searchId)) {
throw new AbortError(searchId);
}
if (context.state.display.view.toLowerCase() === 'gallery') {
return context.dispatch('images/loadAndCheckImages');
return context.dispatch('images/loadAndCheckImages', searchId);
}
return new Promise((r) => {
r();
Expand All @@ -246,6 +239,13 @@ let results = {
);
throw e;
}
})
.finally(() => {
Vue.set(
context.rootState.appState.status.resultData,
'loading',
false,
);
Vue.delete(context.state.searchControllers, searchId);
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions ckanext/nhm/theme/templates/home/snippets/featured/dataset4.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% extends "home/snippets/featured/base.html" %}

{% set title = "Join the Dots" %}
{% set url="/dataset/join-the-dots-collection-level-descriptions" %}
{% set title = "Aphid Slide Digitisation" %}
{% set url="/search/aphid-slides" %}

{% block image %}
<div class="featured-image"
style="background-image:url('/images/featured-binders.jpg'); background-position-x: 50%;"
style="background-image:url('/images/featured-aphid.jpg'); background-position-x: 60%; background-position-y: 2%; background-size: 250%;"
role="img"
aria-label="A stack of cardboard binders filled with papers and notebooks. Some binders are tied with black ribbon."
title="seargreyson/unsplash">
aria-label="A zoomed-in view of a slide for a specimen of the species Myzus (Nectarosiphon) persicae."
title="NHMUK014801150, Myzus (Nectarosiphon) persicae">
</div>
{% endblock %}

{% block description %}
Join the Dots is an extensive project giving a high-level overview of the Museum's collections, including undigitised material.
Browse the museum's fully digitised collection of Aphidoidea slides! Over the past 14 months, digitisers at the museum have imaged more than 200,000 of these slides.
{% endblock %}

0 comments on commit 4d7d813

Please sign in to comment.