@abi-software/mapintegratedvuer 1.1.0-beta.1 → 1.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+
2
+ /* eslint-disable no-alert, no-console */
3
+ export default {
4
+ // Note that the setting store is included in MapContent.vue
5
+ methods: {
6
+ retrieveContextCardFromUrl: async function (url) {
7
+ // split the url to get the datasetId
8
+ const [datasetId, basePath, scaffoldPath, s3uri] = this.splitInfoFromUrl(url);
9
+
10
+ // get the context file from scicrunch
11
+ const sciResults = await this.getContextFileFromScicrunch(datasetId, scaffoldPath);
12
+ if (!sciResults.success){
13
+ return {} // return empty object if no context file is found (the empty object will be added to the entry)
14
+ }
15
+
16
+ // return the context file
17
+ const fullPath = basePath + sciResults.contextFile + s3uri;
18
+ return {
19
+ s3uri: sciResults.s3uri,
20
+ contextCardUrl: fullPath,
21
+ }
22
+ },
23
+ splitInfoFromUrl: function (url) {
24
+ // example url: "https://mapcore-demo.org/current/sparc-api-v2/s3-resource/221/3/files/derivative/Scaffolds/mouse_colon_metadata.json",
25
+ // find the part after 's3-resource'
26
+ let s3path = url.split('s3-resource')[1];
27
+ let basePath = url.split('files/')[0] + 'files/' // This gives us the base path for our relative path we will get from scicrunch
28
+ let scaffoldPath = url.split('files/')[1].split('?')[0] // This gives us the relative path to the file we want to get from scicrunch
29
+ let s3uri = '?' + url.split('?')[1] // This gives us the uri needed to get the file from s3
30
+
31
+ // split the url by '/'
32
+ const parts = s3path.split('/');
33
+ // remove the first part
34
+ parts.shift();
35
+ // return the datasetId which is the first part
36
+ const datasetId = parts[0];
37
+
38
+ return [datasetId, basePath, scaffoldPath, s3uri];
39
+ },
40
+ getContextFileFromScicrunch: async function (datasetId, scaffoldPath) {
41
+ // get the context file from scicrunch
42
+ let results = await fetch(`${this.settingsStore.sparcApi}/dataset_info/using_multiple_discoverIds/?discoverIds=${datasetId}`)
43
+ .then(response => response.json())
44
+ .then(data => {
45
+ // get the context info from the response
46
+ if (data.numberOfHits === 1) { // check if there is only one hit (We don't want to use the data if there are multiple hits)
47
+ const contextFile = data.results[0]['abi-contextual-information']
48
+
49
+ // check if there is only one context file and if so return it
50
+ if ( contextFile && contextFile.length === 1) {
51
+ return {
52
+ success: true,
53
+ contextFile: contextFile[0],
54
+ s3uri: data.results[0]['s3uri']
55
+ }
56
+ }
57
+
58
+ // If there are multiple context files, find the one that matches the scaffold path
59
+ else if (contextFile && contextFile.length > 1) {
60
+ let search = this.findContextInforForFilePath(data.results[0]['abi-context-file'], scaffoldPath);
61
+ if (search) {
62
+ return {
63
+ success: true,
64
+ contextFile: search,
65
+ s3uri: data.results[0]['s3uri']
66
+ }
67
+ }
68
+ }
69
+ }
70
+ return {success: false};
71
+ }).catch(error => {
72
+ console.error('Error:', error);
73
+ return {success: false};
74
+ });
75
+ return results;
76
+ },
77
+ findContextInforForFilePath: function (dataciteInfo, filePath) {
78
+ // find the context file that matches the scaffold path
79
+ let result = dataciteInfo.find((info) => info.datacite.isDerivedFrom.path.includes(filePath))
80
+ return result?.dataset?.path
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,28 @@
1
+ export default {
2
+ sendEvent: function(data) {
3
+ const taggingData = {
4
+ event: data.event || '',
5
+ event_name: data.event_name || '',
6
+ files: data.files || '',
7
+ file_name: data.file_name || '',
8
+ file_path: data.file_path || '',
9
+ file_type: data.file_type || '',
10
+ category: data.category || '',
11
+ dataset_id: data.dataset_id || '',
12
+ version_id: data.version_id || '',
13
+ doi: data.doi || '',
14
+ citation_type: data.citation_type || '',
15
+ location: data.location || ''
16
+ };
17
+
18
+ // set debugging mode
19
+ if (localStorage.getItem('debugTagging') === 'yes') {
20
+ console.table(taggingData);
21
+ }
22
+
23
+ // push to dataLayer for GTM
24
+ if (typeof dataLayer !== 'undefined') {
25
+ dataLayer.push(taggingData);
26
+ }
27
+ }
28
+ }
@@ -17,6 +17,7 @@ export const useSettingsStore = defineStore('settings', {
17
17
  facets: { species: [], gender: [], organ: [] },
18
18
  facetLabels: [],
19
19
  markers: [],
20
+ hoveredMarkers: [],
20
21
  featuredMarkers: [],
21
22
  featuredMarkerIdentifiers: [],
22
23
  featuredMarkerDois: [],
@@ -67,6 +68,9 @@ export const useSettingsStore = defineStore('settings', {
67
68
  updateMarkers(markers) {
68
69
  this.markers = markers;
69
70
  },
71
+ updateHoveredMarkers(markers) {
72
+ this.hoveredMarkers = markers;
73
+ },
70
74
  updateFeatured(datasetIdentifiers) {
71
75
  this.featuredMarkerIdentifiers = new Array(datasetIdentifiers.length);
72
76
  this.featuredMarkers = new Array(datasetIdentifiers.length);