Skip to content

Commit

Permalink
Merge pull request #152 from ddjnw1yu/hide-biolucida-if-not-in-scicrunch
Browse files Browse the repository at this point in the history
Display biolucida images in gallery based on scicrunch
  • Loading branch information
egauzens authored Jul 10, 2024
2 parents 8f17291 + 5529917 commit d42e0a6
Showing 1 changed file with 23 additions and 33 deletions.
56 changes: 23 additions & 33 deletions components/ImagesGallery/ImagesGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { baseName, extractSection, extractS3BucketName } from '@/utils/common'
* @param {Number} datasetId
*/
const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFacetsData) => {
let biolucidaImageData = {}
let scicrunchData = {}
let scicrunch_response = []
let biolucida_response = []
Expand All @@ -59,19 +58,15 @@ const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFa
biolucida_response = response
})
if (biolucida_response.status === 'success') {
const scicrunchData = pathOr([], ['data','result'], scicrunch_response)
biolucidaImageData = biolucida_response
biolucidaImageData['discover_dataset_version'] = datasetVersion
biolucidaImageData['dataset_info'] = scicrunchData.length > 0 ? scicrunchData[0] : {}
}
if (scicrunch_response.data.result.length > 0) {
scicrunchData = scicrunch_response.data.result[0]
scicrunchData.discover_dataset = {
id: Number(datasetId),
version: datasetVersion
}
if (biolucida_response.status === 'success') {
scicrunchData['dataset_images'] = pathOr([], ['dataset_images'], biolucida_response)
}
// Check for flatmap data
if (scicrunchData.organs) {
let flatmapData = []
Expand Down Expand Up @@ -133,13 +128,11 @@ const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFa
e
)
return {
biolucidaImageData: {},
scicrunchData: {},
hasError: true
}
}
return {
biolucidaImageData,
scicrunchData,
hasError: false
}
Expand Down Expand Up @@ -213,7 +206,6 @@ export default {
timeseriesItems: [],
timeseriesData: [],
datasetScicrunch: {},
datasetBiolucida: {},
}
},
computed: {
Expand Down Expand Up @@ -259,13 +251,12 @@ export default {
},
async created() {
this.loading = true
const { biolucidaImageData, scicrunchData, hasError } = await getThumbnailData(
const { scicrunchData, hasError } = await getThumbnailData(
this.datasetInfo.doi,
this.datasetId,
this.datasetInfo.version,
this.datasetFacetsData
)
this.datasetBiolucida = biolucidaImageData
this.datasetScicrunch = scicrunchData
this.hasError = hasError
Expand Down Expand Up @@ -324,6 +315,7 @@ export default {
immediate: true,
handler: function(scicrunchData) {
let items = []
let bItems = []
const baseRoute = this.$router.options.base || '/'
let datasetId = -1
let datasetVersion = -1
Expand Down Expand Up @@ -507,31 +499,29 @@ export default {
)
}
this.scicrunchItems = items
}
},
datasetBiolucida: {
deep: true,
immediate: true,
handler: function(biolucidaData) {
const biolucida2DItems = pathOr([], ['dataset_info','biolucida-2d'], biolucidaData)
let items = []
const baseRoute = this.$router.options.base || '/'
if ('dataset_images' in biolucidaData) {
items.push(
...Array.from(biolucidaData.dataset_images.filter((obj, index) => {
return index === biolucidaData.dataset_images.findIndex(o => obj.image_id === o.image_id);
}), dataset_image => {
if ('dataset_images' in scicrunchData && ('biolucida-2d' in scicrunchData || 'biolucida-3d' in scicrunchData)) {
const biolucida2DItems = pathOr([],['biolucida-2d'], scicrunchData)
// Images need to exist in both Scicrunch and Biolucida
const biolucidaItems = biolucida2DItems.concat(pathOr([],['biolucida-3d'], scicrunchData)).filter((bObject) => {
return scicrunchData['dataset_images'].some(image => image.image_id == pathOr("", ['biolucida','identifier'], bObject))
})
bItems.push(
...Array.from(biolucidaItems, biolucida_item => {
let filePath = ""
const dataset_image = scicrunchData['dataset_images'].find((image) => {
return image.image_id == pathOr("", ['biolucida','identifier'], biolucida_item)
})
biolucida2DItems.forEach(biolucida2DItem => {
if (pathOr("", ['biolucida','identifier'], biolucida2DItem) == dataset_image.image_id) {
filePath = "files/" + pathOr("", ['dataset','path'], biolucida2DItem)
}
})
this.getThumbnailFromBiolucida(items, {
this.getThumbnailFromBiolucida(bItems, {
id: dataset_image.image_id,
fetchAttempts: 0
})
this.getImageInfoFromBiolucida(items, {
this.getImageInfoFromBiolucida(bItems, {
id: dataset_image.image_id,
fetchAttempts: 0
})
Expand All @@ -542,16 +532,16 @@ export default {
// If we can naviagte directly to the file path then do it, otherwise we have to redirect from the datasets/biolucida page
let linkUrl = filePath != "" ?
baseRoute +
`datasets/file/${biolucidaData.discover_dataset_id}/${biolucidaData.discover_dataset_version}?path=${filePath}` :
`datasets/file/${datasetId}/${datasetVersion}?path=${filePath}` :
baseRoute +
'datasets/biolucidaviewer/' +
dataset_image.image_id +
'?view=' +
viewEncoding +
'&dataset_version=' +
biolucidaData.discover_dataset_version +
datasetVersion +
'&dataset_id=' +
biolucidaData.discover_dataset_id +
datasetId +
'&item_id=' +
dataset_image.sourcepkg_id
Expand All @@ -565,7 +555,7 @@ export default {
})
)
}
this.biolucidaItems = items
this.biolucidaItems = bItems
}
}
},
Expand Down

0 comments on commit d42e0a6

Please sign in to comment.