Skip to content

Commit

Permalink
merge: PR #801 from dev
Browse files Browse the repository at this point in the history
Weekly release 2024-08-20
  • Loading branch information
alycejenni authored Aug 20, 2024
2 parents 4d99b9d + e1ce685 commit 2bfc512
Show file tree
Hide file tree
Showing 55 changed files with 256 additions and 489 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
uses: actions/checkout@v3

- name: Build images
run: docker-compose build
run: docker compose build

- name: Run tests
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: docker-compose run -e COVERALLS_REPO_TOKEN ckan bash /opt/scripts/run-tests.sh -c ckanext.nhm
run: docker compose run -e COVERALLS_REPO_TOKEN ckan bash /opt/scripts/run-tests.sh -c ckanext.nhm
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ To run the tests against ckan 2.9.x on Python3:

1. Build the required images:
```shell
docker-compose build
docker compose build
```

2. Then run the tests.
The root of the repository is mounted into the ckan container as a volume by the Docker compose
configuration, so you should only need to rebuild the ckan image if you change the extension's
dependencies.
```shell
docker-compose run ckan
docker compose run ckan
```
<!--testing-end-->
8 changes: 4 additions & 4 deletions ckanext/nhm/theme/assets/less/nhm.less
Original file line number Diff line number Diff line change
Expand Up @@ -1624,9 +1624,7 @@ select {
.btn-group {
&,
& + .btn {
margin-top: floor(
(@min-pad / 3)
); // to center it - looks better than halving
margin-top: floor((@min-pad / 3)); // to center it - looks better than halving
}

&.open .btn-primary.dropdown-toggle {
Expand Down Expand Up @@ -2939,7 +2937,9 @@ select,
min-width: 350px;
z-index: 1000;
background: @baseBackgroundColor;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
box-shadow:
0 0 0 1px rgba(0, 0, 0, 0.3),
0 1px 4px rgba(0, 0, 0, 0.2);
border: 0;
border-radius: 3px;

Expand Down
36 changes: 18 additions & 18 deletions ckanext/nhm/theme/assets/scripts/apps/liv/dist/liv.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
>close
</zoa-button>
<Viewer v-show="showOverlay" />
<div
:class="$style.record"
v-if="showOverlay && (currentRecord || currentImage)"
>
<div :class="$style.record" v-if="showOverlay && (currentRecord || currentImage)">
<div :class="$style.header">
<h2 :class="$style.title">
{{ currentRecord ? currentRecord.title : currentImage.name }}
Expand Down Expand Up @@ -39,9 +36,7 @@
<div :class="$style.shareLinks">
<span>Record</span>
<Copyable v-model="shareUrlRecord">
<a :href="currentRecord.imageViewerUrl">{{
shareUrlRecord
}}</a>
<a :href="currentRecord.imageViewerUrl">{{ shareUrlRecord }}</a>
</Copyable>
<span>Image</span>
<Copyable v-model="shareUrlImage">
Expand Down Expand Up @@ -86,11 +81,9 @@
<template v-for="item in currentImage.displayData">
<dt>{{ useOriginalLabels ? item.key : sentenceCase(item.key) }}</dt>
<dd>
<a
:href="item.value"
v-if="item.value.toString().startsWith('http')"
>{{ item.value }}</a
>
<a :href="item.value" v-if="item.value.toString().startsWith('http')">{{
item.value
}}</a>
<template v-else>{{ item.value }}</template>
</dd>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
<div>
<div :class="$style.resultsHeader">
<span :class="$style.status"
>Loaded {{ store.allImages.length }} images from
{{ store.totalRecords }} total records</span
>Loaded {{ store.allImages.length }} images from {{ store.totalRecords }} total
records</span
>
<i class="fas fa-spinner fa-spin fa-lg" v-if="store.state.loading"></i>
</div>
<div :class="$style.buttons">
<zoa-tabs
:options="tabOptions"
v-model="currentTab"
:class="$style.viewTabs"
/>
<zoa-tabs :options="tabOptions" v-model="currentTab" :class="$style.viewTabs" />
<zoa-button @click="resetAll" size="sm" :class="$style.resetButton">
<i class="fas fa-undo-alt" />
<span class="sr-only">Reset to defaults</span>
Expand Down Expand Up @@ -42,13 +38,7 @@
</template>

<script setup>
import {
computed,
defineAsyncComponent,
onMounted,
ref,
shallowRef,
} from 'vue';
import { computed, defineAsyncComponent, onMounted, ref, shallowRef } from 'vue';
import { useStore, useModeStore } from '../store';
import { ZoaTabs, ZoaToggleButton, ZoaButton } from '@nhm-data/zoa';
import Search from './Search.vue';
Expand Down
21 changes: 10 additions & 11 deletions ckanext/nhm/theme/assets/scripts/apps/liv/src/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,16 @@ function parseQuery() {
if (termParts[0] === 'or') {
_parseGroup(termParts[1]);
}
if (termParts[0] !== 'string_equals') {
return;
}
if (termParts[1].fields[0] === 'typeStatus') {
_typeStatus.push(termParts[1].value);
} else if (termParts[1].fields[0] === 'associatedMedia.category') {
_imageCategory.push(termParts[1].value);
} else if (
JSON.stringify(termParts[1].fields.sort()) === _taxaFields
) {
_taxa = termParts[1].value;
if (termParts[0] === 'string_equals') {
if (termParts[1].fields[0] === 'typeStatus') {
_typeStatus.push(termParts[1].value);
} else if (termParts[1].fields[0] === 'associatedMedia.category') {
_imageCategory.push(termParts[1].value);
}
} else if (termParts[0] === 'string_contains') {
if (JSON.stringify(termParts[1].fields.sort()) === _taxaFields) {
_taxa = termParts[1].value;
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const store = useStore();
onMounted(() => {
viewer.value = OpenSeadragon({
id: 'osdViewer',
prefixUrl:
'https://cdn.jsdelivr.net/gh/Benomrans/openseadragon-icons@main/images/',
prefixUrl: 'https://cdn.jsdelivr.net/gh/Benomrans/openseadragon-icons@main/images/',
sequenceMode: false,
showRotationControl: true,
tileSources: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<template>
<div :class="$style.list" ref="listContainer">
<div
:class="$style.item"
v-for="record in store.allRecords"
:key="record.id"
>
<div :class="$style.item" v-for="record in store.allRecords" :key="record.id">
<div :class="$style.header">
<span :class="$style.title">{{ record.title }}</span>
<span :class="$style.subtitle">{{ record.subtitle }}</span>
Expand Down Expand Up @@ -47,12 +43,7 @@ const listContainer = ref(null);
useInfiniteScroll(
listContainer,
() => {
if (
listContainer.value &&
store.more &&
!store.pending &&
!store.disableAutoLoad
) {
if (listContainer.value && store.more && !store.pending && !store.disableAutoLoad) {
store.getRecords();
}
},
Expand Down
19 changes: 11 additions & 8 deletions ckanext/nhm/theme/assets/scripts/apps/liv/src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export const useStore = defineStore('liv', () => {
if (currentImage.value == null) {
return null;
} else {
return recordRepo.value
.withAllRecursive()
.find(currentImage.value.recordId);
return recordRepo.value.withAllRecursive().find(currentImage.value.recordId);
}
});

Expand Down Expand Up @@ -82,10 +80,7 @@ export const useStore = defineStore('liv', () => {
let promises = [];

function _addImgField(resourceModel) {
if (
resourceModel.imgField &&
!imageFields.includes(resourceModel.imgField)
) {
if (resourceModel.imgField && !imageFields.includes(resourceModel.imgField)) {
imageFields.push(resourceModel.imgField);
}
}
Expand Down Expand Up @@ -172,6 +167,9 @@ export const useStore = defineStore('liv', () => {
if (next.done) {
_done.value = true;
}
if (next.value == null) {
return Promise.resolve(null);
}
return addRecordAndImages(next.value, qH);
})
.catch((e) => {
Expand Down Expand Up @@ -221,7 +219,11 @@ export const useStore = defineStore('liv', () => {
.then((data) => {
return new Promise((resolve) => {
let recordImgData = {};
if (resource && resource.dwc) {
if (
resource &&
resource.hasAssociatedMedia &&
recordData.data.associatedMedia
) {
recordImgData = recordData.data.associatedMedia.filter(
(m) => m.identifier === imgUrl,
)[0];
Expand All @@ -240,6 +242,7 @@ export const useStore = defineStore('liv', () => {
}
return q[1].includes(val);
} catch (e) {
console.error(e);
return false;
}
});
Expand Down
18 changes: 5 additions & 13 deletions ckanext/nhm/theme/assets/scripts/apps/liv/src/store/modes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { get, post } from '../utils/api';
import { useRepo } from 'pinia-orm';
import { Image, Record, Resource } from '../utils/models';
import { useRoute } from 'vue-router';
import { indexLotsId, specimensId } from '../utils/constants';

export const useModeStore = defineStore('modes', () => {
// other stores
Expand Down Expand Up @@ -66,8 +67,7 @@ export const useModeStore = defineStore('modes', () => {

// validate by trying to retrieve a matching config
let matching = modeConfigs.filter(
(m) =>
m.externalUrl === modeName && m.paramCount === modeParams.value.length,
(m) => m.externalUrl === modeName && m.paramCount === modeParams.value.length,
);
if (matching.length > 0) {
return matching[0];
Expand Down Expand Up @@ -104,11 +104,7 @@ export const useModeStore = defineStore('modes', () => {
break;
case 'recordImage':
// single image within a record
recordMode(
modeParams.value[0],
modeParams.value[1],
modeParams.value[2],
);
recordMode(modeParams.value[0], modeParams.value[1], modeParams.value[2]);
break;
case 'slug':
// a search slug
Expand Down Expand Up @@ -188,10 +184,7 @@ export const useModeStore = defineStore('modes', () => {
],
},
},
resource_ids: [
'05ff2255-c38a-40c9-b657-4ccb55ab2feb',
'bb909597-dedf-427d-8c04-4c02b3a24db3',
],
resource_ids: [specimensId, indexLotsId],
});
}

Expand All @@ -209,8 +202,7 @@ class ModeConfig {
this.paramCount = config.paramCount == null ? 0 : config.paramCount;
this.enableResources =
config.enableResources == null ? false : config.enableResources;
this.enableFilters =
config.enableFilters == null ? false : config.enableFilters;
this.enableFilters = config.enableFilters == null ? false : config.enableFilters;
}

get lockAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const breakpoints = {
xl: 1200,
xxl: 2000,
};

export const specimensId = '05ff2255-c38a-40c9-b657-4ccb55ab2feb';
export const indexLotsId = 'bb909597-dedf-427d-8c04-4c02b3a24db3';
8 changes: 6 additions & 2 deletions ckanext/nhm/theme/assets/scripts/apps/liv/src/utils/models.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Model } from 'pinia-orm';
import { indexLotsId, specimensId } from './constants';

export class Resource extends Model {
static entity = 'resources';
Expand All @@ -17,6 +18,10 @@ export class Resource extends Model {
records: this.hasMany(Record, 'resourceId'),
};
}

get hasAssociatedMedia() {
return this.dwc || [indexLotsId, specimensId].includes(this.id);
}
}

export class Record extends Model {
Expand Down Expand Up @@ -173,8 +178,7 @@ export class Image extends Model {
function transformData(obj, outputData, exclude = [], rootKey = []) {
return Object.entries(obj)
.filter(
(item) =>
item[0] !== 'id' && item[0] !== '_id' && !exclude.includes(item[0]),
(item) => item[0] !== 'id' && item[0] !== '_id' && !exclude.includes(item[0]),
)
.sort((a, b) => {
return a[0].localeCompare(b[0]);
Expand Down
Loading

0 comments on commit 2bfc512

Please sign in to comment.