From ece1edf47540f0f0bdde2abeb60c26a0586233bf Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Thu, 18 Apr 2024 19:32:56 +1200 Subject: [PATCH 1/7] Get context cards working for external scaffold opens --- src/mixins/RetrieveContextCardMixin.js | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/mixins/RetrieveContextCardMixin.js diff --git a/src/mixins/RetrieveContextCardMixin.js b/src/mixins/RetrieveContextCardMixin.js new file mode 100644 index 00000000..f1808485 --- /dev/null +++ b/src/mixins/RetrieveContextCardMixin.js @@ -0,0 +1,67 @@ + +/* eslint-disable no-alert, no-console */ +export default { + // Note that the setting store is included in MapContent.vue + methods: { + retrieveContextCardFromUrl: async function (url) { + console.log('retrieveContextCardFromUrl', url); + // split the url to get the datasetId + const [datasetId, basePath] = this.splitInfoFromUrl(url); + + console.log('datasetId', datasetId); + // get the context file from scicrunch + const sciResults = await this.getContextFileFromScicrunch(datasetId); + if (!sciResults.success){ + return {} // return empty object if no context file is found (the empty object will be added to the entry) + } + + // return the context file + const fullPath = basePath + sciResults.contextFile; + console.log('contextFile', fullPath); + return { + contextCardUrl: fullPath, + s3uri: sciResults.s3uri + } + }, + splitInfoFromUrl: function (url) { + // example url: "https://mapcore-demo.org/current/sparc-api-v2/s3-resource/221/3/files/derivative/Scaffolds/mouse_colon_metadata.json", + // find the part after 's3-resource' + let s3path = url.split('s3-resource')[1]; + let basePath = url.split('files/')[0] + 'files/' // This gives us the base path for our relative path we will get from scicrunch + + // split the url by '/' + const parts = s3path.split('/'); + // remove the first part + parts.shift(); + // return the parts + const datasetId = parts[0]; + + return [datasetId, basePath]; + }, + getContextFileFromScicrunch: async function (datasetId) { + // get the context file from scicrunch + let results = await fetch(`${this.settingsStore.sparcApi}/dataset_info/using_multiple_discoverIds/?discoverIds=${datasetId}`) + .then(response => response.json()) + .then(data => { + // get the context file + if (data.numberOfHits === 1) { // chgeck if there is only one hit + const contextFile = data.results[0]['abi-contextual-information'] + + // check if there is only one context file (We have no way of knowing which one to choose if there are multiple) + if ( contextFile && contextFile.length === 1) { + return { + success: true, + contextFile: contextFile[0], + s3uri: data.results[0]['s3uri'] + } + } + } + return {success: false}; + }).catch(error => { + console.error('Error:', error); + return {success: false}; + }); + return results; + } + } +} From e2ae57ea357354165ef7db4f99fb1f9f2441f53e Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Thu, 18 Apr 2024 22:38:23 +1200 Subject: [PATCH 2/7] Add the case for multiple context cards per dataset --- src/components/MapContent.vue | 9 +++++-- src/mixins/RetrieveContextCardMixin.js | 35 ++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/components/MapContent.vue b/src/components/MapContent.vue index 9316239c..194a24f1 100644 --- a/src/components/MapContent.vue +++ b/src/components/MapContent.vue @@ -26,6 +26,7 @@ import { useSettingsStore } from '../stores/settings'; import { findSpeciesKey } from './scripts/utilities.js'; import { MapSvgSpriteColor} from '@abi-software/svg-sprite'; import { initialState } from "./scripts/utilities.js"; +import RetrieveContextCardMixin from "../mixins/RetrieveContextCardMixin.js" import { ElLoading as Loading } from "element-plus"; @@ -40,6 +41,7 @@ export default { Loading, SplitFlow, }, + mixins: [RetrieveContextCardMixin], props: { /** * A link (URL) to share. @@ -158,7 +160,7 @@ export default { * instead change the current entry by setting the state. * @arg state */ - setCurrentEntry: function(state) { + setCurrentEntry: async function(state) { if (state && state.type) { if (state.type === "Scaffold" && state.url) { //State for scaffold containing the following items: @@ -167,7 +169,7 @@ export default { // resource - the url to metadata // state - state to restore (viewport) // viewUrl - relative path of the view file to metadata - const newView = { + let newView = { type: state.type, label: state.label, region: state.region, @@ -175,6 +177,9 @@ export default { state: state.state, viewUrl: state.viewUrl }; + // Add content from scicrunch for the context card + const contextCardInfo = await this.retrieveContextCardFromUrl(state.url); + newView = {...newView, ...contextCardInfo}; this.$refs.flow.createNewEntry(newView); } else if (state.type === "MultiFlatmap") { //State for scaffold containing the following items: diff --git a/src/mixins/RetrieveContextCardMixin.js b/src/mixins/RetrieveContextCardMixin.js index f1808485..60891dc3 100644 --- a/src/mixins/RetrieveContextCardMixin.js +++ b/src/mixins/RetrieveContextCardMixin.js @@ -4,23 +4,20 @@ export default { // Note that the setting store is included in MapContent.vue methods: { retrieveContextCardFromUrl: async function (url) { - console.log('retrieveContextCardFromUrl', url); // split the url to get the datasetId - const [datasetId, basePath] = this.splitInfoFromUrl(url); + const [datasetId, basePath, scaffoldPath, s3uri] = this.splitInfoFromUrl(url); - console.log('datasetId', datasetId); // get the context file from scicrunch - const sciResults = await this.getContextFileFromScicrunch(datasetId); + const sciResults = await this.getContextFileFromScicrunch(datasetId, scaffoldPath); if (!sciResults.success){ return {} // return empty object if no context file is found (the empty object will be added to the entry) } // return the context file - const fullPath = basePath + sciResults.contextFile; - console.log('contextFile', fullPath); + const fullPath = basePath + sciResults.contextFile + s3uri; return { + s3uri: sciResults.s3uri, contextCardUrl: fullPath, - s3uri: sciResults.s3uri } }, splitInfoFromUrl: function (url) { @@ -28,6 +25,8 @@ export default { // find the part after 's3-resource' let s3path = url.split('s3-resource')[1]; let basePath = url.split('files/')[0] + 'files/' // This gives us the base path for our relative path we will get from scicrunch + let scaffoldPath = url.split('files/')[1].split('?')[0] // This gives us the relative path to the file we want to get from scicrunch + let s3uri = '?' + url.split('?')[1] // This gives us the full path to the file we want to get from scicrunch // split the url by '/' const parts = s3path.split('/'); @@ -36,9 +35,9 @@ export default { // return the parts const datasetId = parts[0]; - return [datasetId, basePath]; + return [datasetId, basePath, scaffoldPath, s3uri]; }, - getContextFileFromScicrunch: async function (datasetId) { + getContextFileFromScicrunch: async function (datasetId, scaffoldPath) { // get the context file from scicrunch let results = await fetch(`${this.settingsStore.sparcApi}/dataset_info/using_multiple_discoverIds/?discoverIds=${datasetId}`) .then(response => response.json()) @@ -47,7 +46,7 @@ export default { if (data.numberOfHits === 1) { // chgeck if there is only one hit const contextFile = data.results[0]['abi-contextual-information'] - // check if there is only one context file (We have no way of knowing which one to choose if there are multiple) + // check if there is only one context file if ( contextFile && contextFile.length === 1) { return { success: true, @@ -55,6 +54,18 @@ export default { s3uri: data.results[0]['s3uri'] } } + + // If there are multiple context files, find the one that matches the scaffold path + else if (contextFile && contextFile.length > 1) { + let search = this.findContextInforForFilePath(data.results[0]['abi-context-file'], scaffoldPath); + if (search) { + return { + success: true, + contextFile: search, + s3uri: data.results[0]['s3uri'] + } + } + } } return {success: false}; }).catch(error => { @@ -62,6 +73,10 @@ export default { return {success: false}; }); return results; + }, + findContextInforForFilePath: function (dataciteInfo, filePath) { + let result = dataciteInfo.find((info) => info.datacite.isDerivedFrom.path.includes(filePath)) + return result?.dataset?.path } } } From 68095c9110d1f97c38648b53e3b0a083bdb4d875 Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Thu, 18 Apr 2024 22:39:31 +1200 Subject: [PATCH 3/7] Publish as under alpha tag --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4116df5..95588e4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@abi-software/mapintegratedvuer", - "version": "0.7.1-vue3.0", + "version": "0.7.2-vue3.0-alpha.0", "license": "Apache-2.0", "scripts": { "serve": "vite --host --force", From f29fc97525669c29cef3af9b09a39572ca08d96d Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Fri, 19 Apr 2024 13:29:55 +1200 Subject: [PATCH 4/7] Clean up the comments --- src/mixins/RetrieveContextCardMixin.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mixins/RetrieveContextCardMixin.js b/src/mixins/RetrieveContextCardMixin.js index 60891dc3..8827d68f 100644 --- a/src/mixins/RetrieveContextCardMixin.js +++ b/src/mixins/RetrieveContextCardMixin.js @@ -32,7 +32,7 @@ export default { const parts = s3path.split('/'); // remove the first part parts.shift(); - // return the parts + // return the datasetId which is the first part const datasetId = parts[0]; return [datasetId, basePath, scaffoldPath, s3uri]; @@ -42,11 +42,11 @@ export default { let results = await fetch(`${this.settingsStore.sparcApi}/dataset_info/using_multiple_discoverIds/?discoverIds=${datasetId}`) .then(response => response.json()) .then(data => { - // get the context file - if (data.numberOfHits === 1) { // chgeck if there is only one hit + // get the context info from the response + if (data.numberOfHits === 1) { // check if there is only one hit (We don't want to use the data if there are multiple hits) const contextFile = data.results[0]['abi-contextual-information'] - // check if there is only one context file + // check if there is only one context file and if so return it if ( contextFile && contextFile.length === 1) { return { success: true, @@ -75,6 +75,7 @@ export default { return results; }, findContextInforForFilePath: function (dataciteInfo, filePath) { + // find the context file that matches the scaffold path let result = dataciteInfo.find((info) => info.datacite.isDerivedFrom.path.includes(filePath)) return result?.dataset?.path } From 037f6068756a7686963eb8ec30a9a343f857e774 Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Fri, 19 Apr 2024 13:31:37 +1200 Subject: [PATCH 5/7] Fix a misleading comment --- src/mixins/RetrieveContextCardMixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/RetrieveContextCardMixin.js b/src/mixins/RetrieveContextCardMixin.js index 8827d68f..293ab250 100644 --- a/src/mixins/RetrieveContextCardMixin.js +++ b/src/mixins/RetrieveContextCardMixin.js @@ -26,7 +26,7 @@ export default { let s3path = url.split('s3-resource')[1]; let basePath = url.split('files/')[0] + 'files/' // This gives us the base path for our relative path we will get from scicrunch let scaffoldPath = url.split('files/')[1].split('?')[0] // This gives us the relative path to the file we want to get from scicrunch - let s3uri = '?' + url.split('?')[1] // This gives us the full path to the file we want to get from scicrunch + let s3uri = '?' + url.split('?')[1] // This gives us the uri needed to get the file from s3 // split the url by '/' const parts = s3path.split('/'); From 4fcf5d0dc8350b30485dcfe244615063d06b2439 Mon Sep 17 00:00:00 2001 From: alan-wu Date: Thu, 2 May 2024 10:10:56 +1200 Subject: [PATCH 6/7] Update flatmapvuer and scaffoldvuer. --- package-lock.json | 20 ++++++++++---------- package.json | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4169b4d..6b6b1ef6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,10 @@ "version": "1.0.1", "license": "Apache-2.0", "dependencies": { - "@abi-software/flatmapvuer": "1.0.0", - "@abi-software/map-side-bar": "^2.0.1", + "@abi-software/flatmapvuer": "1.0.1", + "@abi-software/map-side-bar": "2.0.1", "@abi-software/plotvuer": "1.0.0", - "@abi-software/scaffoldvuer": "^1.0.0", + "@abi-software/scaffoldvuer": "1.0.1", "@abi-software/simulationvuer": "1.0.0", "@abi-software/svg-sprite": "1.0.0", "@element-plus/icons-vue": "^2.3.1", @@ -94,9 +94,9 @@ } }, "node_modules/@abi-software/flatmapvuer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@abi-software/flatmapvuer/-/flatmapvuer-1.0.0.tgz", - "integrity": "sha512-FCBQtVncTIMAhMyezTR1veUHTcX5qU5d8+TXZkSIrbBGyloTP+aA1nigPy6YURBXhcQ94uVLW//3YNxmZTJZ3g==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@abi-software/flatmapvuer/-/flatmapvuer-1.0.1.tgz", + "integrity": "sha512-D6Ydew2OL9Kes5SSKfmX4Wk+t7BCmUDEgRSlerUIMKG4Ne9jRW6cjT4sLCBK5h7xHPzHu+PmGotD0nf2FGpHLA==", "dependencies": { "@abi-software/flatmap-viewer": "2.6.2", "@abi-software/sparc-annotation": "0.2.0", @@ -161,11 +161,11 @@ } }, "node_modules/@abi-software/scaffoldvuer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@abi-software/scaffoldvuer/-/scaffoldvuer-1.0.0.tgz", - "integrity": "sha512-+OjWbfoCVsd+3h896hEmPCg5XkEUHBKL/IRwhqPdO6F5umCnkyx/eNDRWxMFNgd/n1lLcxmCi2V1rgq1Tz9zZg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@abi-software/scaffoldvuer/-/scaffoldvuer-1.0.1.tgz", + "integrity": "sha512-w+RSgkhZnVg6OBawkkYftqAw176DAk2WtQ9xg1XQ1YBD/HnSY19nmgmC1iXkxv/ITztwJRDsYzVaA5eUxaRLOw==", "dependencies": { - "@abi-software/flatmapvuer": "^1.0.0", + "@abi-software/flatmapvuer": "^1.0.1", "@abi-software/svg-sprite": "^1.0.0", "@element-plus/icons-vue": "^2.3.1", "@vue/compat": "^3.4.15", diff --git a/package.json b/package.json index 774114ed..b269b56e 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,10 @@ "*.js" ], "dependencies": { - "@abi-software/flatmapvuer": "1.0.0", - "@abi-software/map-side-bar": "^2.0.1", + "@abi-software/flatmapvuer": "1.0.1", + "@abi-software/map-side-bar": "2.0.1", "@abi-software/plotvuer": "1.0.0", - "@abi-software/scaffoldvuer": "^1.0.0", + "@abi-software/scaffoldvuer": "1.0.1", "@abi-software/simulationvuer": "1.0.0", "@abi-software/svg-sprite": "1.0.0", "@element-plus/icons-vue": "^2.3.1", From 814abbe37c97992d651de727c472c4a6fe256f30 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 1 May 2024 22:17:47 +0000 Subject: [PATCH 7/7] 1.0.2 --- CHANGELOG.md | 17 ++++++++++++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89081e29..f1913854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -## [v1.0.1](https://github.com/ABI-Software/mapintegratedvuer/compare/v1.0.0...v1.0.1) +## [v1.0.2](https://github.com/ABI-Software/mapintegratedvuer/compare/v1.0.1...v1.0.2) + +### Commits + +- Update flatmapvuer and scaffoldvuer. [`4fcf5d0`](https://github.com/ABI-Software/mapintegratedvuer/commit/4fcf5d0dc8350b30485dcfe244615063d06b2439) + +## [v1.0.1](https://github.com/ABI-Software/mapintegratedvuer/compare/v1.0.0...v1.0.1) - 2024-04-28 + +### Merged + +- Include a fix which fixes facets issue on the sidebar. [`#205`](https://github.com/ABI-Software/mapintegratedvuer/pull/205) +- 1.0.0 [`#204`](https://github.com/ABI-Software/mapintegratedvuer/pull/204) + +### Commits + +- Update build and release script. [`4ab5714`](https://github.com/ABI-Software/mapintegratedvuer/commit/4ab5714f042d012b0e561dd834a48a37beb24fe4) ## [v1.0.0](https://github.com/ABI-Software/mapintegratedvuer/compare/v0.6.7...v1.0.0) - 2024-04-24 diff --git a/package-lock.json b/package-lock.json index 6b6b1ef6..8417d5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@abi-software/mapintegratedvuer", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@abi-software/mapintegratedvuer", - "version": "1.0.1", + "version": "1.0.2", "license": "Apache-2.0", "dependencies": { "@abi-software/flatmapvuer": "1.0.1", diff --git a/package.json b/package.json index b269b56e..de85de6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@abi-software/mapintegratedvuer", - "version": "1.0.1", + "version": "1.0.2", "license": "Apache-2.0", "scripts": { "serve": "vite --host --force",