@abi-software/flatmapvuer 1.13.1-simulation.1 → 1.13.1-simulation.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "1.13.1-simulation.1",
3
+ "version": "1.13.1-simulation.3",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
package/src/App.vue CHANGED
@@ -80,6 +80,7 @@
80
80
  :enableOpenMapUI="true"
81
81
  :flatmapAPI="flatmapAPI"
82
82
  :disableUI="disableUI"
83
+ :sparcAPI="sparcAPI"
83
84
  @open-pubmed-url="onOpenPubmedUrl"
84
85
  @pathway-selection-changed="onPathwaySelectionChanged"
85
86
  @flatmapChanged="onFlatmapChanged"
@@ -231,6 +232,15 @@ export default {
231
232
  }
232
233
  },
233
234
  },
235
+ computed : {
236
+ testDataLocation() {
237
+ return import.meta.env.VITE_TEST_DATA_LOCATION
238
+
239
+ },
240
+ sparcAPI() {
241
+ return import.meta.env.VITE_API_LOCATION
242
+ },
243
+ },
234
244
  provide() {
235
245
  return {
236
246
  $annotator: this.annotator,
@@ -290,6 +300,10 @@ export default {
290
300
  "taxo": "NCBITaxon:1",
291
301
  "displayWarning": true
292
302
  },
303
+ FC: {
304
+ taxo: 'FC',
305
+ uuid: "7720709d-683c-5def-a1e5-8d7c3b0784f7",
306
+ },
293
307
  },
294
308
  tooltipContent: undefined,
295
309
  tStyle: {
@@ -705,6 +705,9 @@ import {
705
705
  getKnowledgeSource,
706
706
  getReferenceConnectivitiesByAPI,
707
707
  } from '../services/flatmapKnowledge.js'
708
+ import {
709
+ retrieveOmexData,
710
+ } from '../services/apsTestData.js'
708
711
  import { capitalise } from './utilities.js'
709
712
  import yellowstar from '../icons/yellowstar'
710
713
  import ResizeSensor from 'css-element-queries/src/ResizeSensor'
@@ -3468,7 +3471,7 @@ export default {
3468
3471
  }
3469
3472
 
3470
3473
  // If not in cache, call the API
3471
- const apiLocation = import.meta.env.VITE_API_LOCATION
3474
+ const apiLocation = this.sparcAPI
3472
3475
  if (!apiLocation) {
3473
3476
  console.warn('VITE_API_LOCATION is not defined.')
3474
3477
  return
@@ -3479,12 +3482,22 @@ export default {
3479
3482
  // Ensure the URL matches your backend route structure
3480
3483
  const response = await fetch(`${apiLocation}flatmap/uuid?uuid=${uuid}`)
3481
3484
 
3482
- if (!response.ok)
3483
- throw new Error(`API call failed: ${response.statusText}`)
3485
+ let data = undefined;
3486
+
3487
+ if (!response.ok) {
3488
+ if (this.testDataLocation) {
3489
+ data = await retrieveOmexData(this.testDataLocation, uuid)
3490
+ }
3491
+ } else {
3492
+ data = await response.json()
3493
+ }
3484
3494
 
3485
- const data = await response.json()
3495
+ if (!data) {
3496
+ throw new Error(`No protocol data available for map`)
3497
+ }
3486
3498
 
3487
3499
  // Save to cache and process
3500
+
3488
3501
  this.setSessionCache(cacheKey, data)
3489
3502
  this.datasetInfo = data
3490
3503
  this.processDatasetFiles(data)
@@ -3513,30 +3526,44 @@ export default {
3513
3526
  * Iterates through the file list, constructs full URLs, and checks for simulation content.
3514
3527
  */
3515
3528
  async processDatasetFiles(data) {
3516
- if (!data || data.length === 0) return
3517
-
3518
- this.simulationInfo = [] // Reset list
3519
-
3520
- //FIXME: Currently only process the first dataset entry
3521
- const firstData = data[0]
3522
- const apiLocation = import.meta.env.VITE_API_LOCATION
3523
- // Base URL for Pennsieve public assets
3524
- const baseUrl = `${apiLocation}/s3-resource/${firstData.dataset_id}/files`
3525
- const bucketName = this.extractBucketNameFromS3Uri(firstData.s3uri)
3526
-
3527
- firstData.urls.map(async (filePath) => {
3528
- const fullUrl = `${baseUrl}/${filePath}?s3BucketName=${bucketName}`
3529
- // Add to our list of valid files
3530
- this.simulationInfo.push({
3531
- label: firstData.title,
3532
- s3uri: firstData.s3uri,
3533
- dataset_id: firstData.dataset_id,
3534
- version: firstData.version,
3535
- path: filePath,
3536
- type: 'Simulation',
3537
- resource: fullUrl,
3529
+ if (!data) return
3530
+
3531
+ if (data.testData) {
3532
+ this.simulationInfo = [] // Reset list
3533
+ data.simulation.forEach((item) => {
3534
+ this.simulationInfo.push({
3535
+ label: item.name,
3536
+ path: item.dataset.path,
3537
+ dataset_id: item.datasetId,
3538
+ type: 'Simulation',
3539
+ resource: item.resource.url,
3540
+ })
3538
3541
  })
3539
- })
3542
+ } else {
3543
+ if (data.length !== 0) {
3544
+ this.simulationInfo = [] // Reset list
3545
+ //FIXME: Currently only process the first dataset entry
3546
+ const firstData = data[0]
3547
+ const apiLocation = this.sparcAPI
3548
+ // Base URL for Pennsieve public assets
3549
+ const baseUrl = `${apiLocation}/s3-resource/${firstData.dataset_id}/files`
3550
+ const bucketName = this.extractBucketNameFromS3Uri(firstData.s3uri)
3551
+
3552
+ firstData.urls.map(async (filePath) => {
3553
+ const fullUrl = `${baseUrl}/${filePath}?s3BucketName=${bucketName}`
3554
+ // Add to our list of valid files
3555
+ this.simulationInfo.push({
3556
+ label: firstData.title,
3557
+ s3uri: firstData.s3uri,
3558
+ dataset_id: firstData.dataset_id,
3559
+ version: firstData.version,
3560
+ path: filePath,
3561
+ type: 'Simulation',
3562
+ resource: fullUrl,
3563
+ })
3564
+ })
3565
+ }
3566
+ }
3540
3567
  },
3541
3568
  /**
3542
3569
  * Retrieve data from session storage if it hasn't expired.
@@ -3580,7 +3607,6 @@ export default {
3580
3607
  }
3581
3608
  },
3582
3609
  getSimulationLabel(info) {
3583
- console.log(info.path)
3584
3610
  return info.path.split('/').pop()
3585
3611
  },
3586
3612
  openSimulation() {
@@ -3776,6 +3802,13 @@ export default {
3776
3802
  type: String,
3777
3803
  default: 'https://api.sparc.science/',
3778
3804
  },
3805
+ /**
3806
+ * Specify the endpoint of the SPARC API.
3807
+ */
3808
+ testDataLocation: {
3809
+ type: String,
3810
+ default: '',
3811
+ },
3779
3812
  /**
3780
3813
  * Flag to disable UIs on Map
3781
3814
  */
@@ -4935,4 +4968,4 @@ export default {
4935
4968
  }
4936
4969
  }
4937
4970
  }
4938
- </style>
4971
+ </style>
@@ -0,0 +1,40 @@
1
+ const resolveURL = (relative, base) => {
2
+ const resolved = new URL(relative, base);
3
+ return resolved.href;
4
+ }
5
+
6
+ const retrieveOmexData = async (url, uuid) => {
7
+ if (url) {
8
+ const response = await fetch(url);
9
+ const data = await response.json();
10
+ const simulation = [];
11
+ for (const entry of data) {
12
+ let found = false;
13
+ if (entry.flatmaps) {
14
+ for (const flatmap of entry.flatmaps) {
15
+ if (flatmap.associated_flatmap?.identifier === uuid) {
16
+ found = true;
17
+ }
18
+ }
19
+ }
20
+ if (found && ('simulation' in entry)) {
21
+ entry.simulation.forEach((item) => {
22
+ if (item.resource?.url) {
23
+ item.resource.url = resolveURL(item.resource.url, url);
24
+ }
25
+ item.datasetId = entry.datasetId;
26
+ });
27
+ simulation.push(...entry.simulation);
28
+ }
29
+ }
30
+ if (simulation.length) {
31
+ return {testData: true, simulation};
32
+ }
33
+ }
34
+ return undefined;
35
+ }
36
+
37
+
38
+ export {
39
+ retrieveOmexData,
40
+ };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * a single source for the flatmap-viewer library import
3
3
  */
4
- import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.5.3/+esm';
4
+ import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.6.0/+esm';
5
5
 
6
6
  export default flatmap;