@abi-software/map-side-bar 2.14.0 → 2.14.1-simulation.0

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/map-side-bar",
3
- "version": "2.14.0",
3
+ "version": "2.14.1-simulation.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@abi-software/gallery": "1.3.0",
47
- "@abi-software/map-utilities": "1.8.0",
47
+ "@abi-software/map-utilities": "1.8.1",
48
48
  "@abi-software/svg-sprite": "^1.0.2",
49
49
  "@element-plus/icons-vue": "^2.3.1",
50
50
  "algoliasearch": "^4.10.5",
package/src/App.vue CHANGED
@@ -135,6 +135,7 @@ export default {
135
135
  PENNSIEVE_API_LOCATION: import.meta.env.VITE_APP_PENNSIEVE_API_LOCATION,
136
136
  BL_SERVER_URL: import.meta.env.VITE_APP_BL_SERVER_URL,
137
137
  ROOT_URL: import.meta.env.VITE_APP_ROOT_URL,
138
+ TEST_DATA_LOCATION: import.meta.env.VITE_APP_TEST_DATA_LOCATION,
138
139
  FLATMAPAPI_LOCATION: import.meta.env.VITE_FLATMAPAPI_LOCATION,
139
140
  },
140
141
  connectivityEntry: [],
@@ -230,6 +230,9 @@ export default {
230
230
  })
231
231
  .then((data) => {
232
232
  this.thumbnail = data.banner
233
+ if (this.entry.thumbnail) {
234
+ this.thumbnail = this.entry.thumbnail
235
+ }
233
236
  this.discoverId = data.id
234
237
  this.version = data.version
235
238
  this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
@@ -239,6 +242,9 @@ export default {
239
242
  .catch(() => {
240
243
  //set defaults if we hit an error
241
244
  this.thumbnail = MissingImage
245
+ if (this.entry.thumbnail) {
246
+ this.thumbnail = this.entry.thumbnail
247
+ }
242
248
  this.discoverId = Number(this.entry.datasetId)
243
249
  this.loading = false
244
250
  })
@@ -406,6 +406,23 @@ export default {
406
406
  let i = this.results.findIndex((res) => res.doi === doi)
407
407
  if (this.results[i]) this.results[i].detailsReady = true
408
408
  },
409
+ readTestData: function () {
410
+ const endpoint = this.envVars.TEST_DATA_LOCATION
411
+ if (endpoint) {
412
+ fetch(endpoint)
413
+ .then(response => {
414
+ if (!response.ok) {
415
+ throw new Error(`Cannot download test data from server: ${response.status}`)
416
+ }
417
+ return response.json()
418
+ })
419
+ .then((data) => {
420
+ if (this.searchInput.toLowerCase().includes("reveal")) {
421
+ this.results.unshift(...data)
422
+ }
423
+ })
424
+ }
425
+ },
409
426
  perItemSearch: function (signal, data) {
410
427
  //Maximum 10 downloads at once to prevent long waiting time
411
428
  //between unfinished search and new search
@@ -434,6 +451,11 @@ export default {
434
451
  //Check and make another request until it gets to max downloads
435
452
  this.perItemSearch(signal, data)
436
453
  }
454
+ } else {
455
+ //Do some post downloading hacking
456
+ if (this.searchInput.toLowerCase().includes("reveal")) {
457
+ this.readTestData();
458
+ }
437
459
  }
438
460
  },
439
461
  scrollToTop: function () {
@@ -145,20 +145,22 @@ export default {
145
145
  if (flatmap.associated_flatmap?.identifier) {
146
146
  const filePath = flatmap.dataset.path
147
147
  const id = flatmap.identifier
148
- const thumbnail = this.getThumbnailForPlot(
149
- flatmap,
150
- this.entry.thumbnails
151
- )
152
- let thumbnailURL = undefined
148
+ let thumbnailURL = flatmap.thumbnail?.url
153
149
  let mimetype = ''
154
- if (thumbnail) {
155
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
156
- id,
157
- prefix: this.getS3Prefix(),
158
- file_path: thumbnail.dataset.path,
159
- s3Bucket: this.s3Bucket,
160
- })
161
- mimetype = thumbnail.mimetype.name
150
+ if (!thumbnailURL) {
151
+ let thumbnail = this.getThumbnailForPlot(
152
+ flatmap,
153
+ this.entry.thumbnails
154
+ )
155
+ if (thumbnail) {
156
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
157
+ id,
158
+ prefix: this.getS3Prefix(),
159
+ file_path: thumbnail.dataset.path,
160
+ s3Bucket: this.s3Bucket,
161
+ })
162
+ mimetype = thumbnail.mimetype.name
163
+ }
162
164
  }
163
165
  let action = {
164
166
  label: capitalise(this.label),
@@ -343,22 +345,27 @@ export default {
343
345
  const id = simulation.identifier
344
346
  //Despite of the name, this method can be used to retreive
345
347
  //the thumbnail information for any none scaffold type thumbnail
346
- const thumbnail = this.getThumbnailForPlot(
347
- simulation,
348
- this.entry.thumbnails
349
- )
350
- let thumbnailURL = undefined
348
+ let thumbnailURL = simulation.thumbnail?.url
351
349
  let mimetype = ''
352
- if (thumbnail) {
353
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
354
- id,
355
- prefix: this.getS3Prefix(),
356
- file_path: thumbnail.dataset.path,
357
- s3Bucket: this.s3Bucket,
358
- })
359
- mimetype = thumbnail.mimetype.name
350
+ if (!thumbnailURL) {
351
+ const thumbnail = this.getThumbnailForPlot(
352
+ simulation,
353
+ this.entry.thumbnails
354
+ )
355
+ if (thumbnail) {
356
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
357
+ id,
358
+ prefix: this.getS3Prefix(),
359
+ file_path: thumbnail.dataset.path,
360
+ s3Bucket: this.s3Bucket,
361
+ })
362
+ mimetype = thumbnail.mimetype.name
363
+ }
364
+ }
365
+ let resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
366
+ if (simulation.resource?.url) {
367
+ resource = simulation.resource.url
360
368
  }
361
- const resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
362
369
  let action = {
363
370
  label: capitalise(this.label),
364
371
  resource: resource,