Skip to content

Commit

Permalink
Merge branch 'main' into remove-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ddjnw1yu committed May 10, 2024
2 parents 4a11219 + bdd88c0 commit 711dc90
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 19 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/components/MapContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -40,6 +41,7 @@ export default {
Loading,
SplitFlow,
},
mixins: [RetrieveContextCardMixin],
props: {
/**
* A link (URL) to share.
Expand Down Expand Up @@ -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:
Expand All @@ -167,14 +169,17 @@ 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,
resource: state.url,
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:
Expand Down
83 changes: 83 additions & 0 deletions src/mixins/RetrieveContextCardMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

/* eslint-disable no-alert, no-console */
export default {
// Note that the setting store is included in MapContent.vue
methods: {
retrieveContextCardFromUrl: async function (url) {
// split the url to get the datasetId
const [datasetId, basePath, scaffoldPath, s3uri] = this.splitInfoFromUrl(url);

// get the context file from scicrunch
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 + s3uri;
return {
s3uri: sciResults.s3uri,
contextCardUrl: fullPath,
}
},
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
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 uri needed to get the file from s3

// split the url by '/'
const parts = s3path.split('/');
// remove the first part
parts.shift();
// return the datasetId which is the first part
const datasetId = parts[0];

return [datasetId, basePath, scaffoldPath, s3uri];
},
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())
.then(data => {
// 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 and if so return it
if ( contextFile && contextFile.length === 1) {
return {
success: true,
contextFile: contextFile[0],
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 => {
console.error('Error:', error);
return {success: false};
});
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
}
}
}

0 comments on commit 711dc90

Please sign in to comment.