Skip to content

Commit

Permalink
Merge pull request #107 from alan-wu/biolucida-sharelink
Browse files Browse the repository at this point in the history
Change the way to get the list of biolucida images
  • Loading branch information
alan-wu authored Jan 23, 2025
2 parents af52886 + bcfb424 commit a0bc85c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@element-plus/icons-vue": "^2.3.1",
"algoliasearch": "^4.10.5",
"element-plus": "2.8.4",
"js-base64": "^3.7.7",
"marked": "^4.1.1",
"mitt": "^3.0.1",
"unplugin-vue-components": "^0.26.0",
Expand Down
36 changes: 26 additions & 10 deletions src/components/DatasetCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<script>
/* eslint-disable no-alert, no-console */
import { View as ElIconView } from '@element-plus/icons-vue'
import { Base64 } from 'js-base64';
import BadgesGroup from './BadgesGroup.vue'
import {
ElButton as Button,
Expand Down Expand Up @@ -236,7 +237,7 @@ export default {
this.discoverId = data.id
this.version = data.version
this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
this.getBiolucidaInfo(this.discoverId)
this.getBiolucidaInfo()
this.loading = false
this.updateCopyContent();
})
Expand All @@ -251,15 +252,30 @@ export default {
lastName: function (fullName) {
return fullName.split(',')[0]
},
getBiolucidaInfo: function (id) {
let apiLocation = this.envVars.API_LOCATION
let endpoint = apiLocation + 'image_search/' + id
// Add parameters if we are sent them
fetch(endpoint)
.then((response) => response.json())
.then((data) => {
if (data.status == 'success') this.biolucidaData = data
})
getBiolucidaInfo: function () {
const dataset_images = [];
const biolucida2DItems = 'biolucida-2d' in this.entry ? this.entry['biolucida-2d'] :[];
const biolucida3DItems = 'biolucida-3d' in this.entry ? this.entry['biolucida-3d'] :[];
// We use information from SciCrunch to create the sharelink
biolucida2DItems.concat(biolucida3DItems).forEach((bObject) => {
const image_id = bObject.biolucida?.identifier;
if (image_id) {
const sourcepkg_id = 'identifier' in bObject ? bObject['identifier'] : "";
// The encoded string is in the following format -
// ${image_id}-col-${collection_id}, collection id can be any valid collection id
// and 260 is used for now.
const code = encodeURIComponent(Base64.encode(`${image_id}-col-260`));
const share_link = `https://sparc.biolucida.net/image?c=${code}`
dataset_images.push({
share_link,
image_id,
sourcepkg_id,
});
}
});
if (dataset_images.length > 0) {
this.biolucidaData = { dataset_images };
}
},
updateCopyContent: function () {
const contentArray = [];
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
import Gallery from "@abi-software/gallery";
import "@abi-software/gallery/dist/style.css";
//provide the s3Bucket related methods and data.
import S3Bucket from '../mixins/S3Bucket.vue'
import S3Bucket from '../mixins/S3Bucket.vue';
export default {
name: 'ImageGallery',
Expand Down

0 comments on commit a0bc85c

Please sign in to comment.