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

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.1-simulation.0",
3
+ "version": "2.14.1-simulation.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
package/src/App.vue CHANGED
@@ -19,6 +19,7 @@
19
19
  <el-button @click="getFacets">Get facets</el-button>
20
20
  <el-button @click="toggleCreateData">Create Data/Annotation</el-button>
21
21
  <el-button @click="openConnectivitySearch()">Connectivity Search</el-button>
22
+ <el-button @click="displayFileInfo()">Display file info</el-button>
22
23
  </div>
23
24
  <SideBar
24
25
  :envVars="envVars"
@@ -367,6 +368,10 @@ export default {
367
368
  },
368
369
  onConnectivityCollapseChange: function () {
369
370
  this.connectivityEntry = [...exampleConnectivityInput]
371
+ },
372
+ displayFileInfo: function() {
373
+ this.$refs.sideBar.displayFileInfo(1024, "csv", "reveal")
374
+
370
375
  }
371
376
  },
372
377
  mounted: async function () {
@@ -73,6 +73,7 @@ export default {
73
73
  this.addToCategories(this.entry.flatmaps, 'Flatmaps')
74
74
  this.addToCategories(this.entry.plots, 'Plots')
75
75
  this.addToCategories(this.entry.scaffolds, 'Scaffolds')
76
+ this.addToCategories(this.entry['protocol-data'], 'Protocol Data')
76
77
  this.addSimulationsToCategories(this.entry.simulation)
77
78
  /** disable the following
78
79
  this.addToCategories(this.entry.images, 'Images');
@@ -6,12 +6,7 @@
6
6
  <span class="card-left">
7
7
  <ImageGallery
8
8
  v-if="!loading && discoverId"
9
- :datasetId="discoverId"
10
- :datasetVersion="version"
11
- :entry="entry"
12
- :envVars="envVars"
13
- :label="label"
14
- :datasetThumbnail="thumbnail"
9
+ :items="items"
15
10
  :category="currentCategory"
16
11
  @card-clicked="galleryClicked"
17
12
  @datalink-clicked="galleryDatalinkClicked"
@@ -44,7 +39,15 @@
44
39
  @categoryChanged="categoryChanged"
45
40
  />
46
41
  </div>
47
-
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>
48
51
  <!-- Copy to clipboard button container -->
49
52
  <div class="float-button-container">
50
53
  <CopyToClipboard :content="copyContent" />
@@ -56,6 +59,15 @@
56
59
  </template>
57
60
 
58
61
  <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
+
59
71
  /* eslint-disable no-alert, no-console */
60
72
  import { View as ElIconView } from '@element-plus/icons-vue'
61
73
  import BadgesGroup from './BadgesGroup.vue'
@@ -68,7 +80,10 @@ import speciesMap from './species-map.js'
68
80
  import ImageGallery from './ImageGallery.vue'
69
81
  import MissingImage from '@/../assets/missing-image.svg'
70
82
  import { CopyToClipboard } from '@abi-software/map-utilities';
83
+ import S3Bucket from '../mixins/S3Bucket.vue';
71
84
  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";
72
87
 
73
88
  export default {
74
89
  data() {
@@ -84,6 +99,7 @@ export default {
84
99
  Icon,
85
100
  CopyToClipboard,
86
101
  },
102
+ mixins: [GalleryHelper, S3Bucket],
87
103
  props: {
88
104
  /**
89
105
  * Object containing information for
@@ -103,6 +119,14 @@ export default {
103
119
  thumbnail: MissingImage,
104
120
  dataLocation: this.entry.doi,
105
121
  discoverId: undefined,
122
+ items: {
123
+ Dataset: [],
124
+ Flatmaps:[],
125
+ Scaffolds: [],
126
+ Simulations: [],
127
+ Plots: [],
128
+ "Protocol Data": [],
129
+ },
106
130
  loading: true,
107
131
  version: 1,
108
132
  lastDoi: undefined,
@@ -127,6 +151,15 @@ export default {
127
151
  }
128
152
  return text
129
153
  },
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
+ },
130
163
  samples: function () {
131
164
  let text = ''
132
165
  if (this.entry.species) {
@@ -170,15 +203,383 @@ export default {
170
203
  categoryChanged: function (name) {
171
204
  this.currentCategory = name
172
205
  },
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: capitalise(this.label),
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
+ title: baseName(filePath),
278
+ filePath: filePath,
279
+ type: 'Flatmap',
280
+ thumbnail: thumbnailURL,
281
+ userData: action,
282
+ hideType: true,
283
+ mimetype,
284
+ })
285
+ }
286
+ })
287
+ }
288
+ },
289
+ createImageItems: function () {
290
+ if (this.entry.images) {
291
+ this.entry.images.forEach((image) => {
292
+ const filePath = image.dataset.path
293
+ const id = image.identifier
294
+ const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.discoverId}&dataset_version=${this.version}&file_path=${filePath}&mimetype=${image.mimetype.name}`
295
+ this.items['Images'].push({
296
+ id,
297
+ title: baseName(filePath),
298
+ filePath: filePath,
299
+ type: 'Image',
300
+ link: linkUrl,
301
+ hideType: true,
302
+ })
303
+ })
304
+ }
305
+ },
306
+ createPlotItems: function () {
307
+ if (this.entry.plots) {
308
+ this.entry.plots.forEach((plot) => {
309
+ const filePath = plot.dataset.path
310
+ const id = plot.identifier
311
+ const thumbnail = this.getThumbnailForPlot(
312
+ plot,
313
+ this.entry.thumbnails
314
+ )
315
+ let thumbnailURL = undefined
316
+ let mimetype = ''
317
+ if (thumbnail) {
318
+
319
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
320
+ id,
321
+ prefix: this.getS3Prefix(),
322
+ file_path: thumbnail.dataset.path,
323
+ s3Bucket: this.s3Bucket,
324
+ })
325
+ mimetype = thumbnail.mimetype.name
326
+ }
327
+ const plotAnnotation = plot.datacite;
328
+ const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
329
+ const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
330
+
331
+ //plotAnnotation.supplemental_json_metadata.description can be undefined or
332
+ //contain an empty string causing an error with JSON.parse
333
+ let metadata = {}
334
+ try {
335
+ metadata = JSON.parse(
336
+ plotAnnotation.supplemental_json_metadata.description
337
+ )
338
+ } catch (error) {
339
+ console.warn(error)
340
+ }
341
+
342
+ let supplementalData = []
343
+ if (plotAnnotation.isDescribedBy) {
344
+ supplementalData.push({
345
+ url: filePathPrefix + plotAnnotation.isDescribedBy.path,
346
+ })
347
+ }
348
+
349
+ const resource = {
350
+ dataSource: { url: sourceUrl },
351
+ metadata,
352
+ supplementalData,
353
+ }
354
+
355
+ let action = {
356
+ label: capitalise(this.label),
357
+ resource: resource,
358
+ s3uri: this.entry.s3uri,
359
+ title: 'View plot',
360
+ type: 'Plot',
361
+ discoverId: this.discoverId,
362
+ version: this.version,
363
+ }
364
+ this.items['Plots'].push({
365
+ id,
366
+ title: baseName(filePath),
367
+ filePath: filePath,
368
+ type: 'Plot',
369
+ thumbnail: thumbnailURL,
370
+ userData: action,
371
+ hideType: true,
372
+ mimetype,
373
+ })
374
+ })
375
+ }
376
+ },
377
+ createScaffoldItems: function () {
378
+ if (this.entry.scaffolds) {
379
+ let index = 0
380
+ this.entry.scaffolds.forEach((scaffold, i) => {
381
+ const filePath = scaffold.dataset.path
382
+ const id = scaffold.identifier
383
+ const thumbnail = this.getThumbnailForScaffold(
384
+ scaffold,
385
+ this.entry.scaffoldViews,
386
+ this.entry.thumbnails,
387
+ index
388
+ )
389
+ let mimetype = ''
390
+ let thumbnailURL = undefined
391
+ if (thumbnail) {
392
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
393
+ id,
394
+ prefix: this.getS3Prefix(),
395
+ file_path: thumbnail.dataset.path,
396
+ s3Bucket: this.s3Bucket,
397
+ })
398
+ mimetype = thumbnail.mimetype.name
399
+ }
400
+ let action = {
401
+ label: capitalise(this.label),
402
+ resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
403
+ title: "View 3D scaffold",
404
+ type: "Scaffold",
405
+ discoverId: this.discoverId,
406
+ apiLocation: this.envVars.API_LOCATION,
407
+ version: this.version,
408
+ banner: this.datasetThumbnail,
409
+ s3uri: this.entry.s3uri,
410
+ contextCardUrl: this.getContextCardUrl(i),
411
+ }
412
+ this.items['Scaffolds'].push({
413
+ id,
414
+ title: baseName(filePath),
415
+ filePath: filePath,
416
+ type: 'Scaffold',
417
+ thumbnail: thumbnailURL,
418
+ userData: action,
419
+ hideType: true,
420
+ mimetype,
421
+ })
422
+ })
423
+ }
424
+ },
425
+ createSimulationItems: function () {
426
+ if (this.entry.simulation) {
427
+ this.entry.simulation.forEach((simulation) => {
428
+ if (simulation.additional_mimetype.name === "application/x.vnd.abi.simulation+json") {
429
+ let action = {
430
+ label: undefined,
431
+ apiLocation: this.envVars.API_LOCATION,
432
+ s3uri: this.entry.s3uri,
433
+ version: this.version,
434
+ title: 'View simulation',
435
+ type: 'Simulation',
436
+ name: this.entry.name,
437
+ description: this.entry.description,
438
+ discoverId: this.discoverId,
439
+ dataset: `${this.envVars.ROOT_URL}/datasets/${this.discoverId}?type=dataset`,
440
+ }
441
+ this.items['Simulations'].push({
442
+ id: 'simulation',
443
+ title: ' ',
444
+ type: 'Simulation',
445
+ hideType: true,
446
+ hideTitle: true,
447
+ userData: action,
448
+ })
449
+ } else {
450
+ const filePath = simulation.dataset.path
451
+ const id = simulation.identifier
452
+ //Despite of the name, this method can be used to retreive
453
+ //the thumbnail information for any none scaffold type thumbnail
454
+ let thumbnailURL = undefined;
455
+ if (simulation.thumbnail?.url) {
456
+ thumbnailURL = resolveURL(simulation.thumbnail.url,
457
+ this.envVars.TEST_DATA_LOCATION)
458
+ }
459
+ let mimetype = ''
460
+ if (!thumbnailURL) {
461
+ const thumbnail = this.getThumbnailForPlot(
462
+ simulation,
463
+ this.entry.thumbnails
464
+ )
465
+ if (thumbnail) {
466
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
467
+ id,
468
+ prefix: this.getS3Prefix(),
469
+ file_path: thumbnail.dataset.path,
470
+ s3Bucket: this.s3Bucket,
471
+ })
472
+ mimetype = thumbnail.mimetype.name
473
+ }
474
+ }
475
+ let resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
476
+ if (simulation.resource?.url) {
477
+ resource = resolveURL(simulation.resource.url,
478
+ this.envVars.TEST_DATA_LOCATION)
479
+ }
480
+ let action = {
481
+ label: capitalise(this.label),
482
+ resource: resource,
483
+ s3uri: this.entry.s3uri,
484
+ title: 'View simulation',
485
+ type: 'Simulation',
486
+ discoverId: this.discoverId,
487
+ version: this.version,
488
+ }
489
+ this.items['Simulations'].push({
490
+ id,
491
+ title: baseName(filePath),
492
+ filePath: filePath,
493
+ type: 'Simulation',
494
+ thumbnail: thumbnailURL,
495
+ userData: action,
496
+ hideType: true,
497
+ mimetype,
498
+ })
499
+ }
500
+ })
501
+ }
502
+ },
503
+ createProtocolDataItems: function () {
504
+ if (this.entry['protocol-data']) {
505
+ this.entry['protocol-data'].forEach((protocol) => {
506
+ //Despite of the name, this method can be used to retreive
507
+ //the thumbnail information for any none scaffold type thumbnail
508
+ let thumbnailURL = protocol.thumbnail
509
+ let mimetype = ''
510
+ let resource = protocol.protocol
511
+ let action = {
512
+ label: capitalise(this.label),
513
+ csv_file: protocol.csv_file,
514
+ columns: protocol.columns,
515
+ resource: resource,
516
+ title: 'View protocol',
517
+ type: 'Protocol',
518
+ discoverId: this.discoverId,
519
+ version: this.version,
520
+ }
521
+ this.items['Protocol Data'].push({
522
+ title: baseName(protocol.csv_file),
523
+ description: protocol.description,
524
+ filePath: protocol.csv_file,
525
+ protocol: protocol.protocol,
526
+ columns: protocol.columns,
527
+ type: 'Protocol',
528
+ thumbnail: thumbnailURL,
529
+ userData: action,
530
+ hideType: true,
531
+ mimetype,
532
+ })
533
+ })
534
+ }
535
+ },
536
+ createVideoItems: function () {
537
+ if (this.entry.videos) {
538
+ this.entry.videos.forEach((video) => {
539
+ const filePath = this.getS3FilePath(
540
+ this.discoverId,
541
+ this.version,
542
+ video.dataset.path
543
+ )
544
+ const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.version}&dataset_id=${this.discoverId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
545
+ this.items['Videos'].push({
546
+ title: video.name,
547
+ type: 'Video',
548
+ thumbnail: this.defaultVideoImg,
549
+ hideType: true,
550
+ link: linkUrl,
551
+ })
552
+ })
553
+ }
554
+ },
173
555
  galleryClicked: function (payload) {
174
556
  this.propogateCardAction(payload)
175
557
  },
176
558
  galleryDatalinkClicked: function (payload) {
177
559
  EventBus.emit('datalink-clicked', payload); // Pass to mapintegratedvuer
178
560
  },
561
+ getContextCardUrl: function(scaffoldIndex){
562
+ if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
563
+ return undefined
564
+ } else {
565
+ // 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.
566
+ let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
567
+ return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
568
+ }
569
+ },
570
+ getImageURL: function(apiEndpoint, info) {
571
+ let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
572
+ if (info.s3Bucket) {
573
+ url = url + `&s3BucketName=${info.s3Bucket}`
574
+ }
575
+ return url
576
+ },
179
577
  openDataset: function () {
180
578
  window.open(this.dataLocation, '_blank')
181
579
  },
580
+ openFileBrowser: function() {
581
+ this.$emit('openFileBrowser', {datasetID: this.discoverId, items: this.items})
582
+ },
182
583
  openRepository: function () {
183
584
  let apiLocation = this.envVars.API_LOCATION
184
585
  this.entry.additionalLinks.forEach(function (el) {
@@ -243,11 +644,15 @@ export default {
243
644
  //set defaults if we hit an error
244
645
  this.thumbnail = MissingImage
245
646
  if (this.entry.thumbnail) {
246
- this.thumbnail = this.entry.thumbnail
647
+ const resolved = new URL(this.entry.thumbnail, this.envVars.TEST_DATA_LOCATION);
648
+ this.thumbnail = resolved.href;
247
649
  }
248
650
  this.discoverId = Number(this.entry.datasetId)
249
651
  this.loading = false
250
652
  })
653
+ .finally(() => {
654
+ this.createSciCurnchItems()
655
+ })
251
656
  }
252
657
  },
253
658
  lastName: function (fullName) {
@@ -420,6 +825,10 @@ export default {
420
825
  stroke: $app-primary-color;
421
826
  }
422
827
 
828
+ .browsable-list {
829
+ margin-top: 12px;
830
+ }
831
+
423
832
  .float-button-container {
424
833
  position: absolute;
425
834
  bottom: 8px;
@@ -432,4 +841,5 @@ export default {
432
841
  visibility: visible;
433
842
  }
434
843
  }
844
+
435
845
  </style>