@abi-software/map-side-bar 2.14.1-simulation.8 → 2.14.2-demo.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.
@@ -6,7 +6,12 @@
6
6
  <span class="card-left">
7
7
  <ImageGallery
8
8
  v-if="!loading && discoverId"
9
- :items="items"
9
+ :datasetId="discoverId"
10
+ :datasetVersion="version"
11
+ :entry="entry"
12
+ :envVars="envVars"
13
+ :label="label"
14
+ :datasetThumbnail="thumbnail"
10
15
  :category="currentCategory"
11
16
  @card-clicked="galleryClicked"
12
17
  @datalink-clicked="galleryDatalinkClicked"
@@ -35,19 +40,11 @@
35
40
  </div>
36
41
  <div class="badges-container">
37
42
  <BadgesGroup
38
- :items="items"
43
+ :entry="entry"
39
44
  @categoryChanged="categoryChanged"
40
45
  />
41
46
  </div>
42
- <div v-if="totalFiles" class="browsable-list" @click="openFiles">
43
- <el-button
44
- @click="openFileBrowser"
45
- size="small"
46
- class="button"
47
- :icon="ElIconView"
48
- >Open file browser</el-button
49
- >
50
- </div>
47
+
51
48
  <!-- Copy to clipboard button container -->
52
49
  <div class="float-button-container">
53
50
  <CopyToClipboard :content="copyContent" />
@@ -59,15 +56,6 @@
59
56
  </template>
60
57
 
61
58
  <script>
62
- /* eslint-disable no-alert, no-console */
63
- const baseName = (str) => {
64
- return str.split('\\').pop().split('/').pop()
65
- }
66
-
67
- const capitalise = function (string) {
68
- return string.replace(/\b\w/g, (v) => v.toUpperCase())
69
- }
70
-
71
59
  /* eslint-disable no-alert, no-console */
72
60
  import { View as ElIconView } from '@element-plus/icons-vue'
73
61
  import BadgesGroup from './BadgesGroup.vue'
@@ -80,10 +68,7 @@ import speciesMap from './species-map.js'
80
68
  import ImageGallery from './ImageGallery.vue'
81
69
  import MissingImage from '@/../assets/missing-image.svg'
82
70
  import { CopyToClipboard } from '@abi-software/map-utilities';
83
- import S3Bucket from '../mixins/S3Bucket.vue';
84
71
  import '@abi-software/map-utilities/dist/style.css';
85
- import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
86
- import { resolveURL } from "./scripts/utilities.js";
87
72
 
88
73
  export default {
89
74
  data() {
@@ -99,7 +84,6 @@ export default {
99
84
  Icon,
100
85
  CopyToClipboard,
101
86
  },
102
- mixins: [GalleryHelper, S3Bucket],
103
87
  props: {
104
88
  /**
105
89
  * Object containing information for
@@ -119,14 +103,6 @@ export default {
119
103
  thumbnail: MissingImage,
120
104
  dataLocation: this.entry.doi,
121
105
  discoverId: undefined,
122
- items: {
123
- Dataset: [],
124
- Flatmaps:[],
125
- Scaffolds: [],
126
- Simulations: [],
127
- Plots: [],
128
- "Protocol Data": [],
129
- },
130
106
  loading: true,
131
107
  version: 1,
132
108
  lastDoi: undefined,
@@ -151,15 +127,6 @@ export default {
151
127
  }
152
128
  return text
153
129
  },
154
- totalFiles: function() {
155
- let total = 0
156
- Object.keys(this.items).forEach(key => {
157
- if (key !== 'Dataset') {
158
- total += this.items[key].length
159
- }
160
- });
161
- return total
162
- },
163
130
  samples: function () {
164
131
  let text = ''
165
132
  if (this.entry.species) {
@@ -203,392 +170,15 @@ export default {
203
170
  categoryChanged: function (name) {
204
171
  this.currentCategory = name
205
172
  },
206
- createSciCurnchItems: function () {
207
- if (this.entry.detailsReady) {
208
- this.updateS3Bucket(this.entry.s3uri)
209
- this.createDatasetItem()
210
- this.createFlatmapItems()
211
- this.createScaffoldItems()
212
- this.createSimulationItems()
213
- this.createPlotItems()
214
- this.createProtocolDataItems()
215
- this.$nextTick(() => {
216
- this.$emit("fileInfoReady", {instance: this, id: this.discoverId})
217
- })
218
- }
219
-
220
- /* Disable these two
221
- this.createImageItems();
222
- this.createVideoItems();
223
- */
224
- },
225
- createDatasetItem: function () {
226
- const link = `${this.envVars.ROOT_URL}/datasets/${this.discoverId}?type=dataset`
227
- if (this.thumbnail) {
228
- this.items['Dataset'].push({
229
- id: -1,
230
- //Work around gallery requires a truthy string
231
- title: ' ',
232
- type: `Dataset ${this.discoverId}`,
233
- thumbnail: this.thumbnail,
234
- link,
235
- hideType: true,
236
- hideTitle: true,
237
- })
238
- }
239
- },
240
- createFlatmapItems: function () {
241
- if (this.entry.flatmaps) {
242
- this.entry.flatmaps.forEach((flatmap) => {
243
- if (flatmap.associated_flatmap?.identifier) {
244
- const filePath = flatmap.dataset.path
245
- const id = flatmap.identifier
246
- let thumbnailURL = undefined
247
- if (flatmap.thumbnail?.url) {
248
- thumbnailURL = resolveURL(flatmap.thumbnail.url,
249
- this.envVars.TEST_DATA_LOCATION)
250
- }
251
- let mimetype = ''
252
- if (!thumbnailURL) {
253
- let thumbnail = this.getThumbnailForPlot(
254
- flatmap,
255
- this.entry.thumbnails
256
- )
257
- if (thumbnail) {
258
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
259
- id,
260
- prefix: this.getS3Prefix(),
261
- file_path: thumbnail.dataset.path,
262
- s3Bucket: this.s3Bucket,
263
- })
264
- mimetype = thumbnail.mimetype.name
265
- }
266
- }
267
- let action = {
268
- label: baseName(filePath),
269
- resource: flatmap.associated_flatmap.identifier,
270
- title: 'View Flatmap',
271
- type: 'Flatmap',
272
- discoverId: this.discoverId,
273
- version: this.version,
274
- }
275
- this.items['Flatmaps'].push({
276
- id,
277
- description: flatmap.description,
278
- title: baseName(filePath),
279
- filePath: filePath,
280
- type: 'Flatmap',
281
- thumbnail: thumbnailURL,
282
- userData: action,
283
- hideType: true,
284
- mimetype,
285
- })
286
- }
287
- })
288
- }
289
- },
290
- createImageItems: function () {
291
- if (this.entry.images) {
292
- this.entry.images.forEach((image) => {
293
- const filePath = image.dataset.path
294
- const id = image.identifier
295
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.discoverId}&dataset_version=${this.version}&file_path=${filePath}&mimetype=${image.mimetype.name}`
296
- this.items['Images'].push({
297
- id,
298
- title: baseName(filePath),
299
- filePath: filePath,
300
- type: 'Image',
301
- link: linkUrl,
302
- hideType: true,
303
- })
304
- })
305
- }
306
- },
307
- createPlotItems: function () {
308
- if (this.entry.plots) {
309
- this.entry.plots.forEach((plot) => {
310
- const filePath = plot.dataset.path
311
- const id = plot.identifier
312
- const thumbnail = this.getThumbnailForPlot(
313
- plot,
314
- this.entry.thumbnails
315
- )
316
- let thumbnailURL = undefined
317
- let mimetype = ''
318
- if (thumbnail) {
319
-
320
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
321
- id,
322
- prefix: this.getS3Prefix(),
323
- file_path: thumbnail.dataset.path,
324
- s3Bucket: this.s3Bucket,
325
- })
326
- mimetype = thumbnail.mimetype.name
327
- }
328
- const plotAnnotation = plot.datacite;
329
- const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
330
- const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
331
-
332
- //plotAnnotation.supplemental_json_metadata.description can be undefined or
333
- //contain an empty string causing an error with JSON.parse
334
- let metadata = {}
335
- try {
336
- metadata = JSON.parse(
337
- plotAnnotation.supplemental_json_metadata.description
338
- )
339
- } catch (error) {
340
- console.warn(error)
341
- }
342
-
343
- let supplementalData = []
344
- if (plotAnnotation.isDescribedBy) {
345
- supplementalData.push({
346
- url: filePathPrefix + plotAnnotation.isDescribedBy.path,
347
- })
348
- }
349
-
350
- const resource = {
351
- dataSource: { url: sourceUrl },
352
- metadata,
353
- supplementalData,
354
- }
355
-
356
- let action = {
357
- label: baseName(filePath),
358
- resource: resource,
359
- s3uri: this.entry.s3uri,
360
- title: 'View plot',
361
- type: 'Plot',
362
- discoverId: this.discoverId,
363
- version: this.version,
364
- }
365
- this.items['Plots'].push({
366
- id,
367
- description: plot.description,
368
- title: baseName(filePath),
369
- filePath: filePath,
370
- type: 'Plot',
371
- thumbnail: thumbnailURL,
372
- userData: action,
373
- hideType: true,
374
- mimetype,
375
- })
376
- })
377
- }
378
- },
379
- createScaffoldItems: function () {
380
- if (this.entry.scaffolds) {
381
- let index = 0
382
- this.entry.scaffolds.forEach((scaffold, i) => {
383
- const filePath = scaffold.dataset.path
384
- const id = scaffold.identifier
385
- const thumbnail = this.getThumbnailForScaffold(
386
- scaffold,
387
- this.entry.scaffoldViews,
388
- this.entry.thumbnails,
389
- index
390
- )
391
- let mimetype = ''
392
- let thumbnailURL = undefined
393
- if (thumbnail) {
394
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
395
- id,
396
- prefix: this.getS3Prefix(),
397
- file_path: thumbnail.dataset.path,
398
- s3Bucket: this.s3Bucket,
399
- })
400
- mimetype = thumbnail.mimetype.name
401
- }
402
- let action = {
403
- label: baseName(filePath),
404
- resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
405
- title: "View 3D scaffold",
406
- type: "Scaffold",
407
- discoverId: this.discoverId,
408
- apiLocation: this.envVars.API_LOCATION,
409
- version: this.version,
410
- banner: this.thumbnail,
411
- s3uri: this.entry.s3uri,
412
- contextCardUrl: this.getContextCardUrl(i),
413
- }
414
- this.items['Scaffolds'].push({
415
- id,
416
- description: scaffold.description,
417
- title: baseName(filePath),
418
- filePath: filePath,
419
- type: 'Scaffold',
420
- thumbnail: thumbnailURL,
421
- userData: action,
422
- hideType: true,
423
- mimetype,
424
- })
425
- })
426
- }
427
- },
428
- createSimulationItems: function () {
429
- if (this.entry.simulation) {
430
- console.log(this.entry.simulation)
431
- this.entry.simulation.forEach((simulation) => {
432
- if (simulation.additional_mimetype.name === "application/x.vnd.abi.simulation+json") {
433
- let action = {
434
- label: undefined,
435
- apiLocation: this.envVars.API_LOCATION,
436
- s3uri: this.entry.s3uri,
437
- version: this.version,
438
- title: 'View simulation',
439
- type: 'Simulation',
440
- name: this.entry.name,
441
- description: this.entry.description,
442
- discoverId: this.discoverId,
443
- dataset: `${this.envVars.ROOT_URL}/datasets/${this.discoverId}?type=dataset`,
444
- }
445
- this.items['Simulations'].push({
446
- id: 'simulation',
447
- title: ' ',
448
- type: 'Simulation',
449
- hideType: true,
450
- hideTitle: true,
451
- userData: action,
452
- })
453
- } else {
454
- const filePath = simulation.dataset.path
455
- const id = simulation.identifier
456
- //Despite of the name, this method can be used to retreive
457
- //the thumbnail information for any none scaffold type thumbnail
458
- let thumbnailURL = undefined;
459
- if (simulation.thumbnail?.url) {
460
- thumbnailURL = resolveURL(simulation.thumbnail.url,
461
- this.envVars.TEST_DATA_LOCATION)
462
- }
463
- let mimetype = ''
464
- if (!thumbnailURL) {
465
- const thumbnail = this.getThumbnailForPlot(
466
- simulation,
467
- this.entry.thumbnails
468
- )
469
- if (thumbnail) {
470
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
471
- id,
472
- prefix: this.getS3Prefix(),
473
- file_path: thumbnail.dataset.path,
474
- s3Bucket: this.s3Bucket,
475
- })
476
- mimetype = thumbnail.mimetype.name
477
- }
478
- }
479
- let resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
480
- if (simulation.resource?.url) {
481
- resource = resolveURL(simulation.resource.url,
482
- this.envVars.TEST_DATA_LOCATION)
483
- }
484
- let action = {
485
- label: baseName(filePath),
486
- resource: resource,
487
- s3uri: this.entry.s3uri,
488
- title: 'View simulation',
489
- type: 'Simulation',
490
- discoverId: this.discoverId,
491
- version: this.version,
492
- }
493
- this.items['Simulations'].push({
494
- id,
495
- description: simulation.description,
496
- title: baseName(filePath),
497
- filePath: filePath,
498
- type: 'Simulation',
499
- thumbnail: thumbnailURL,
500
- userData: action,
501
- hideType: true,
502
- mimetype,
503
- })
504
- }
505
- })
506
- }
507
- },
508
- createProtocolDataItems: function () {
509
- if (this.entry['protocol-data']) {
510
- this.entry['protocol-data'].forEach((protocol) => {
511
- //Despite of the name, this method can be used to retreive
512
- //the thumbnail information for any none scaffold type thumbnail
513
- let thumbnailURL = protocol.thumbnail
514
- let mimetype = ''
515
- let resource = protocol.protocol
516
- let action = {
517
- label: baseName(protocol.csv_file),
518
- csv_file: protocol.csv_file,
519
- columns: protocol.columns,
520
- resource: resource,
521
- title: 'View protocol',
522
- type: 'Protocol',
523
- discoverId: this.discoverId,
524
- version: this.version,
525
- }
526
- this.items['Protocol Data'].push({
527
- title: baseName(protocol.csv_file),
528
- description: protocol.description,
529
- filePath: protocol.csv_file,
530
- protocol: protocol.protocol,
531
- columns: protocol.columns,
532
- type: 'Protocol',
533
- thumbnail: thumbnailURL,
534
- userData: action,
535
- hideType: true,
536
- mimetype,
537
- })
538
- })
539
- }
540
- },
541
- createVideoItems: function () {
542
- if (this.entry.videos) {
543
- this.entry.videos.forEach((video) => {
544
- const filePath = this.getS3FilePath(
545
- this.discoverId,
546
- this.version,
547
- video.dataset.path
548
- )
549
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.version}&dataset_id=${this.discoverId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
550
- this.items['Videos'].push({
551
- title: video.name,
552
- type: 'Video',
553
- thumbnail: this.defaultVideoImg,
554
- hideType: true,
555
- link: linkUrl,
556
- })
557
- })
558
- }
559
- },
560
173
  galleryClicked: function (payload) {
561
174
  this.propogateCardAction(payload)
562
175
  },
563
176
  galleryDatalinkClicked: function (payload) {
564
177
  EventBus.emit('datalink-clicked', payload); // Pass to mapintegratedvuer
565
178
  },
566
- getContextCardUrl: function(scaffoldIndex){
567
- if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
568
- return undefined
569
- } else {
570
- // The line below checks if there is a context file for each scaffold. If there is not, we use the first context card for each scaffold.
571
- let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
572
- return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
573
- }
574
- },
575
- getImageURL: function(apiEndpoint, info) {
576
- let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
577
- if (info.s3Bucket) {
578
- url = url + `&s3BucketName=${info.s3Bucket}`
579
- }
580
- return url
581
- },
582
179
  openDataset: function () {
583
180
  window.open(this.dataLocation, '_blank')
584
181
  },
585
- openFileBrowser: function() {
586
- this.$emit('openFileBrowser', {
587
- datasetID: this.discoverId,
588
- datasetName: this.entry.name,
589
- items: this.items,
590
- })
591
- },
592
182
  openRepository: function () {
593
183
  let apiLocation = this.envVars.API_LOCATION
594
184
  this.entry.additionalLinks.forEach(function (el) {
@@ -640,9 +230,6 @@ export default {
640
230
  })
641
231
  .then((data) => {
642
232
  this.thumbnail = data.banner
643
- if (this.entry.thumbnail) {
644
- this.thumbnail = this.entry.thumbnail
645
- }
646
233
  this.discoverId = data.id
647
234
  this.version = data.version
648
235
  this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
@@ -652,16 +239,9 @@ export default {
652
239
  .catch(() => {
653
240
  //set defaults if we hit an error
654
241
  this.thumbnail = MissingImage
655
- if (this.entry.thumbnail) {
656
- const resolved = new URL(this.entry.thumbnail, this.envVars.TEST_DATA_LOCATION);
657
- this.thumbnail = resolved.href;
658
- }
659
242
  this.discoverId = Number(this.entry.datasetId)
660
243
  this.loading = false
661
244
  })
662
- .finally(() => {
663
- this.createSciCurnchItems()
664
- })
665
245
  }
666
246
  },
667
247
  lastName: function (fullName) {
@@ -834,10 +414,6 @@ export default {
834
414
  stroke: $app-primary-color;
835
415
  }
836
416
 
837
- .browsable-list {
838
- margin-top: 12px;
839
- }
840
-
841
417
  .float-button-container {
842
418
  position: absolute;
843
419
  bottom: 8px;
@@ -850,5 +426,4 @@ export default {
850
426
  visibility: visible;
851
427
  }
852
428
  }
853
-
854
429
  </style>