@abi-software/flatmapvuer 1.13.1-simulation.2 → 1.13.1-simulation.4

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.2",
3
+ "version": "1.13.1-simulation.4",
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,
@@ -3,3 +3,15 @@
3
3
  @import url('https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap');
4
4
 
5
5
  $--color-primary: $app-primary-color !default;
6
+
7
+ .flatmap-dropdown {
8
+ min-width: 160px !important;
9
+ .el-select-dropdown__item {
10
+ white-space: nowrap;
11
+ text-align: left;
12
+ &.is-selected {
13
+ color: $app-primary-color;
14
+ font-weight: normal;
15
+ }
16
+ }
17
+ }
@@ -187,7 +187,7 @@ Please use `const` to assign meaningful names to them...
187
187
  >
188
188
  <template #reference>
189
189
  <div
190
- class="popover-location top"
190
+ class="popover-location simulation top"
191
191
  :class="{
192
192
  open: simulationDrawerOpen,
193
193
  close: !simulationDrawerOpen,
@@ -206,6 +206,7 @@ Please use `const` to assign meaningful names to them...
206
206
  Available Protocols
207
207
  </h4>
208
208
  <el-select
209
+ popper-class="flatmap-dropdown"
209
210
  v-model="selectedSimulation"
210
211
  placeholder="Select a simulation"
211
212
  size="default"
@@ -705,6 +706,9 @@ import {
705
706
  getKnowledgeSource,
706
707
  getReferenceConnectivitiesByAPI,
707
708
  } from '../services/flatmapKnowledge.js'
709
+ import {
710
+ retrieveOmexData,
711
+ } from '../services/apsTestData.js'
708
712
  import { capitalise } from './utilities.js'
709
713
  import yellowstar from '../icons/yellowstar'
710
714
  import ResizeSensor from 'css-element-queries/src/ResizeSensor'
@@ -3468,7 +3472,7 @@ export default {
3468
3472
  }
3469
3473
 
3470
3474
  // If not in cache, call the API
3471
- const apiLocation = import.meta.env.VITE_API_LOCATION
3475
+ const apiLocation = this.sparcAPI
3472
3476
  if (!apiLocation) {
3473
3477
  console.warn('VITE_API_LOCATION is not defined.')
3474
3478
  return
@@ -3479,12 +3483,22 @@ export default {
3479
3483
  // Ensure the URL matches your backend route structure
3480
3484
  const response = await fetch(`${apiLocation}flatmap/uuid?uuid=${uuid}`)
3481
3485
 
3482
- if (!response.ok)
3483
- throw new Error(`API call failed: ${response.statusText}`)
3486
+ let data = undefined;
3484
3487
 
3485
- const data = await response.json()
3488
+ if (!response.ok) {
3489
+ if (this.testDataLocation) {
3490
+ data = await retrieveOmexData(this.testDataLocation, uuid)
3491
+ }
3492
+ } else {
3493
+ data = await response.json()
3494
+ }
3495
+
3496
+ if (!data) {
3497
+ throw new Error(`No protocol data available for map`)
3498
+ }
3486
3499
 
3487
3500
  // Save to cache and process
3501
+
3488
3502
  this.setSessionCache(cacheKey, data)
3489
3503
  this.datasetInfo = data
3490
3504
  this.processDatasetFiles(data)
@@ -3513,30 +3527,44 @@ export default {
3513
3527
  * Iterates through the file list, constructs full URLs, and checks for simulation content.
3514
3528
  */
3515
3529
  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,
3530
+ if (!data) return
3531
+
3532
+ if (data.testData) {
3533
+ this.simulationInfo = [] // Reset list
3534
+ data.simulation.forEach((item) => {
3535
+ this.simulationInfo.push({
3536
+ label: item.name,
3537
+ path: item.dataset.path,
3538
+ dataset_id: item.datasetId,
3539
+ type: 'Simulation',
3540
+ resource: item.resource.url,
3541
+ })
3538
3542
  })
3539
- })
3543
+ } else {
3544
+ if (data.length !== 0) {
3545
+ this.simulationInfo = [] // Reset list
3546
+ //FIXME: Currently only process the first dataset entry
3547
+ const firstData = data[0]
3548
+ const apiLocation = this.sparcAPI
3549
+ // Base URL for Pennsieve public assets
3550
+ const baseUrl = `${apiLocation}/s3-resource/${firstData.dataset_id}/files`
3551
+ const bucketName = this.extractBucketNameFromS3Uri(firstData.s3uri)
3552
+
3553
+ firstData.urls.map(async (filePath) => {
3554
+ const fullUrl = `${baseUrl}/${filePath}?s3BucketName=${bucketName}`
3555
+ // Add to our list of valid files
3556
+ this.simulationInfo.push({
3557
+ label: firstData.title,
3558
+ s3uri: firstData.s3uri,
3559
+ dataset_id: firstData.dataset_id,
3560
+ version: firstData.version,
3561
+ path: filePath,
3562
+ type: 'Simulation',
3563
+ resource: fullUrl,
3564
+ })
3565
+ })
3566
+ }
3567
+ }
3540
3568
  },
3541
3569
  /**
3542
3570
  * Retrieve data from session storage if it hasn't expired.
@@ -3580,7 +3608,6 @@ export default {
3580
3608
  }
3581
3609
  },
3582
3610
  getSimulationLabel(info) {
3583
- console.log(info.path)
3584
3611
  return info.path.split('/').pop()
3585
3612
  },
3586
3613
  openSimulation() {
@@ -3776,6 +3803,13 @@ export default {
3776
3803
  type: String,
3777
3804
  default: 'https://api.sparc.science/',
3778
3805
  },
3806
+ /**
3807
+ * Specify the endpoint of the SPARC API.
3808
+ */
3809
+ testDataLocation: {
3810
+ type: String,
3811
+ default: '',
3812
+ },
3779
3813
  /**
3780
3814
  * Flag to disable UIs on Map
3781
3815
  */
@@ -4228,6 +4262,14 @@ export default {
4228
4262
  flex-direction: row;
4229
4263
  align-items: center;
4230
4264
 
4265
+ &.simulation {
4266
+ .el-button {
4267
+ background: $app-primary-color;
4268
+ }
4269
+ }
4270
+
4271
+
4272
+
4231
4273
  &.open {
4232
4274
  transform: translateX(0);
4233
4275
  }
@@ -4580,7 +4622,6 @@ export default {
4580
4622
  border-color: $app-primary-color;
4581
4623
  color: $app-primary-color;
4582
4624
  }
4583
-
4584
4625
  .el-popper__arrow {
4585
4626
  &:before {
4586
4627
  border-color: $app-primary-color;
@@ -4935,4 +4976,4 @@ export default {
4935
4976
  }
4936
4977
  }
4937
4978
  }
4938
- </style>
4979
+ </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.6.0/+esm';
4
+ import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.6.1/+esm';
5
5
 
6
6
  export default flatmap;