@abi-software/map-side-bar 2.2.0 → 2.2.1-alpha-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.
@@ -1,542 +1,542 @@
1
- <template>
2
- <div class="full-size">
3
- <Gallery
4
- :bottomSpacer="bottomSpacer"
5
- :cardWidth="10"
6
- :items="galleryItems"
7
- :max-width="maxWidth"
8
- :show-indicator-bar="false"
9
- :show-card-details="true"
10
- :highlight-active="false"
11
- :image-style="imageStyle"
12
- :image-container-style="imageContainerStyle"
13
- :body-style="bodyStyle"
14
- :shadow="shadow"
15
- @card-clicked="cardClicked"
16
- @datalink-clicked="datalinkClicked"
17
- ref="gallery"
18
- />
19
- </div>
20
- </template>
21
-
22
- <script>
23
- /* eslint-disable no-alert, no-console */
24
- const baseName = (str) => {
25
- return str.split('\\').pop().split('/').pop()
26
- }
27
-
28
- const capitalise = function (string) {
29
- return string.replace(/\b\w/g, (v) => v.toUpperCase())
30
- }
31
-
32
- import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
33
- import Gallery from "@abi-software/gallery";
34
- import "@abi-software/gallery/dist/style.css";
35
- //provide the s3Bucket related methods and data.
36
- import S3Bucket from '../mixins/S3Bucket.vue'
37
-
38
- export default {
39
- name: 'ImageGallery',
40
- components: { Gallery },
41
- mixins: [GalleryHelper, S3Bucket],
42
- props: {
43
- datasetBiolucida: {
44
- type: Object,
45
- default: () => {
46
- return {}
47
- },
48
- },
49
- envVars: {
50
- type: Object,
51
- default: () => {},
52
- },
53
- label: {
54
- type: String,
55
- default: '',
56
- },
57
- plots: {
58
- type: Array,
59
- default: () => {
60
- return []
61
- },
62
- },
63
- datasetId: {
64
- type: Number,
65
- default: -1,
66
- },
67
- datasetVersion: {
68
- type: Number,
69
- default: -1,
70
- },
71
- datasetThumbnail: {
72
- type: String,
73
- default: '',
74
- },
75
- category: {
76
- type: String,
77
- default: 'All',
78
- },
79
- entry: {
80
- type: Object,
81
- default: () => {
82
- return {}
83
- },
84
- },
85
- },
86
- data() {
87
- return {
88
- currentIndex: 0,
89
- ro: null,
90
- maxWidth: 3,
91
- items: {
92
- //Use the Images instead for Biolucida Images
93
- //"Biolucida Images": [],
94
- Dataset: [],
95
- Images: [],
96
- Scaffolds: [],
97
- Segmentations: [],
98
- Simulations: [],
99
- Videos: [],
100
- Plots: [],
101
- },
102
- bodyStyle: { padding: '0px', background: '#ffffff' },
103
- imageContainerStyle: {
104
- width: '160px',
105
- height: '160px',
106
- display: 'flex',
107
- alignItems: 'center',
108
- justifyContent: 'center',
109
- },
110
- imageStyle: { maxWidth: '160px', maxHeight: '160px' },
111
- shadow: 'never',
112
- bottomSpacer: { minHeight: '0rem' },
113
- resetIndex: false,
114
- }
115
- },
116
- methods: {
117
- cardClicked: function (payload) {
118
- this.$emit('card-clicked', payload)
119
- },
120
- datalinkClicked: function (payload) {
121
- this.$emit('datalink-clicked', payload);
122
- },
123
- createSciCurnchItems: function () {
124
- this.updateS3Bucket(this.entry.s3uri)
125
- this.createDatasetItem()
126
- this.createScaffoldItems()
127
- this.createSimulationItems()
128
- this.createPlotItems()
129
- this.createSegmentationItems()
130
- /* Disable these two
131
- this.createImageItems();
132
- this.createVideoItems();
133
- */
134
- },
135
- createDatasetItem: function () {
136
- const link = `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`
137
- if (this.datasetThumbnail) {
138
- this.items['Dataset'].push({
139
- id: -1,
140
- //Work around gallery requires a truthy string
141
- title: ' ',
142
- type: `Dataset ${this.datasetId}`,
143
- thumbnail: this.datasetThumbnail,
144
- link,
145
- hideType: true,
146
- hideTitle: true,
147
- })
148
- }
149
- },
150
- createImageItems: function () {
151
- if (this.entry.images) {
152
- this.entry.images.forEach((image) => {
153
- const filePath = image.dataset.path
154
- const id = image.identifier
155
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.datasetId}&dataset_version=${this.datasetVersion}&file_path=${filePath}&mimetype=${image.mimetype.name}`
156
- this.items['Images'].push({
157
- id,
158
- title: baseName(filePath),
159
- type: 'Image',
160
- link: linkUrl,
161
- hideType: true,
162
- })
163
- })
164
- }
165
- },
166
- createPlotItems: function () {
167
- if (this.entry.plots) {
168
- this.entry.plots.forEach((plot) => {
169
- const filePath = plot.dataset.path
170
- const id = plot.identifier
171
- const thumbnail = this.getThumbnailForPlot(
172
- plot,
173
- this.entry.thumbnails
174
- )
175
- let thumbnailURL = undefined
176
- let mimetype = ''
177
- if (thumbnail) {
178
-
179
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
180
- id,
181
- prefix: this.getS3Prefix(),
182
- file_path: thumbnail.dataset.path,
183
- s3Bucket: this.s3Bucket,
184
- })
185
- mimetype = thumbnail.mimetype.name
186
- }
187
- const plotAnnotation = plot.datacite;
188
- const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
189
- const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
190
-
191
- //plotAnnotation.supplemental_json_metadata.description can be undefined or
192
- //contain an empty string causing an error with JSON.parse
193
- let metadata = {}
194
- try {
195
- metadata = JSON.parse(
196
- plotAnnotation.supplemental_json_metadata.description
197
- )
198
- } catch (error) {
199
- console.warn(error)
200
- }
201
-
202
- let supplementalData = []
203
- if (plotAnnotation.isDescribedBy) {
204
- supplementalData.push({
205
- url: filePathPrefix + plotAnnotation.isDescribedBy.path,
206
- })
207
- }
208
-
209
- const resource = {
210
- dataSource: { url: sourceUrl },
211
- metadata,
212
- supplementalData,
213
- }
214
-
215
- let action = {
216
- label: capitalise(this.label),
217
- resource: resource,
218
- s3uri: this.entry.s3uri,
219
- title: 'View plot',
220
- type: 'Plot',
221
- discoverId: this.discoverId,
222
- version: this.datasetVersion,
223
- }
224
- this.items['Plots'].push({
225
- id,
226
- title: baseName(filePath),
227
- type: 'Plot',
228
- thumbnail: thumbnailURL,
229
- userData: action,
230
- hideType: true,
231
- mimetype,
232
- })
233
- })
234
- }
235
- },
236
- createScaffoldItems: function () {
237
- if (this.entry.scaffolds) {
238
- let index = 0
239
- this.entry.scaffolds.forEach((scaffold, i) => {
240
- const filePath = scaffold.dataset.path
241
- const id = scaffold.identifier
242
- const thumbnail = this.getThumbnailForScaffold(
243
- scaffold,
244
- this.entry.scaffoldViews,
245
- this.entry.thumbnails,
246
- index
247
- )
248
- let mimetype = ''
249
- let thumbnailURL = undefined
250
- if (thumbnail) {
251
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
252
- id,
253
- prefix: this.getS3Prefix(),
254
- file_path: thumbnail.dataset.path,
255
- s3Bucket: this.s3Bucket,
256
- })
257
- mimetype = thumbnail.mimetype.name
258
- }
259
- let action = {
260
- label: capitalise(this.label),
261
- resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
262
- title: "View 3D scaffold",
263
- type: "Scaffold",
264
- discoverId: this.datasetId,
265
- apiLocation: this.envVars.API_LOCATION,
266
- version: this.datasetVersion,
267
- banner: this.datasetThumbnail,
268
- s3uri: this.entry.s3uri,
269
- contextCardUrl: this.getContextCardUrl(i),
270
- }
271
- this.items['Scaffolds'].push({
272
- id,
273
- title: baseName(filePath),
274
- type: 'Scaffold',
275
- thumbnail: thumbnailURL,
276
- userData: action,
277
- hideType: true,
278
- mimetype,
279
- })
280
- })
281
- }
282
- },
283
- createSegmentationItems: function () {
284
- if (this.entry.segmentation) {
285
- this.entry.segmentation.forEach((segmentation) => {
286
- const id = segmentation.id
287
- let filePath = segmentation.dataset.path
288
- filePath = filePath.replaceAll(' ', '_')
289
- filePath = filePath.replaceAll(',', '_')
290
- const prefix = this.envVars.NL_LINK_PREFIX
291
- const resource = {
292
- share_link: `${prefix}/dataviewer?datasetId=${this.datasetId}&version=${this.datasetVersion}&path=files/${filePath}`,
293
- }
294
- let action = {
295
- label: capitalise(this.label),
296
- resource: resource,
297
- datasetId: this.datasetId,
298
- s3uri: this.entry.s3uri,
299
- title: 'View segmentation',
300
- type: 'Segmentation',
301
- }
302
- const thumbnailURL = this.getSegmentationThumbnailURL(
303
- this.envVars.API_LOCATION,
304
- {
305
- id,
306
- datasetId: this.datasetId,
307
- datasetVersion: this.datasetVersion,
308
- segmentationFilePath: filePath,
309
- s3Bucket: this.s3Bucket,
310
- }
311
- )
312
- this.items['Segmentations'].push({
313
- id,
314
- title: baseName(filePath),
315
- type: 'Segmentation',
316
- thumbnail: thumbnailURL,
317
- userData: action,
318
- hideType: true,
319
- mimetype: 'image/png',
320
- })
321
- })
322
- }
323
- },
324
- createSimulationItems: function () {
325
- if (this.entry.simulation && this.entry.simulation.length > 0) {
326
- let action = {
327
- label: undefined,
328
- apiLocation: this.envVars.API_LOCATION,
329
- s3uri: this.entry.s3uri,
330
- version: this.datasetVersion,
331
- title: 'View simulation',
332
- type: 'Simulation',
333
- name: this.entry.name,
334
- description: this.entry.description,
335
- discoverId: this.datasetId,
336
- dataset: `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`,
337
- }
338
- this.items['Simulations'].push({
339
- id: 'simulation',
340
- title: ' ',
341
- type: 'Simulation',
342
- hideType: true,
343
- hideTitle: true,
344
- userData: action,
345
- })
346
- }
347
- },
348
- createVideoItems: function () {
349
- if (this.entry.videos) {
350
- this.entry.videos.forEach((video) => {
351
- const filePath = this.getS3FilePath(
352
- this.datasetId,
353
- this.datasetVersion,
354
- video.dataset.path
355
- )
356
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.datasetVersion}&dataset_id=${this.datasetId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
357
- this.items['Videos'].push({
358
- title: video.name,
359
- type: 'Video',
360
- thumbnail: this.defaultVideoImg,
361
- hideType: true,
362
- link: linkUrl,
363
- })
364
- })
365
- }
366
- },
367
- onResize: function () {
368
- this.maxWidth = this.$el.clientWidth
369
- // this.$emit('resize', this.$el.clientWidth)
370
- },
371
- getContextCardUrl: function(scaffoldIndex){
372
- if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
373
- return undefined
374
- } else {
375
- // 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.
376
- let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
377
- return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
378
- }
379
- },
380
- getImageURL: function(apiEndpoint, info) {
381
- let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
382
- if (info.s3Bucket) {
383
- url = url + `&s3BucketName=${info.s3Bucket}`
384
- }
385
- return url
386
- },
387
- },
388
- computed: {
389
- galleryItems() {
390
- if (this.resetIndex) {
391
- this.$refs.gallery.indicatorClicked(0)
392
- }
393
- let items = [...this.items['Dataset']]
394
- if (this.category === 'All') {
395
- for (const [key, value] of Object.entries(this.items)) {
396
- if (key !== 'Dataset') items = items.concat(value)
397
- }
398
- return items
399
- } else return [...this.items[this.category]]
400
- },
401
- },
402
- created: function () {
403
- this.createSciCurnchItems()
404
- },
405
- watch: {
406
- category: function () {
407
- this.resetIndex = true
408
- },
409
- galleryItems: function () {
410
- this.resetIndex = false
411
- },
412
- datasetBiolucida: {
413
- deep: true,
414
- immediate: true,
415
- handler: function (biolucidaData) {
416
- let items = []
417
- if ('dataset_images' in biolucidaData) {
418
- items.push(
419
- ...Array.from(biolucidaData.dataset_images, (dataset_image) => {
420
- const thumbnailURL = this.getThumbnailURLFromBiolucida(
421
- this.envVars.API_LOCATION,
422
- {
423
- id: dataset_image.image_id,
424
- }
425
- )
426
- const resource = {
427
- share_link: dataset_image.share_link,
428
- id: dataset_image.image_id,
429
- itemId: dataset_image.sourcepkg_id,
430
- }
431
- let action = {
432
- label: capitalise(this.label),
433
- resource: resource,
434
- datasetId: this.datasetId,
435
- title: 'View image',
436
- name: capitalise(this.label),
437
- type: 'Biolucida',
438
- }
439
- return {
440
- id: dataset_image.image_id,
441
- title: `Image`,
442
- type: 'Image',
443
- thumbnail: thumbnailURL,
444
- userData: action,
445
- mimetype: 'image/png',
446
- hideType: true,
447
- }
448
- })
449
- )
450
- }
451
- this.items['Images'] = items
452
- },
453
- },
454
- },
455
- mounted() {
456
- this.ro = new ResizeObserver(this.onResize).observe(this.$el)
457
- },
458
- unmounted() {
459
- delete this.ro
460
- },
461
- }
462
- </script>
463
-
464
- <style lang="scss" scoped>
465
- .full-size {
466
- height: 100%;
467
- width: 244px;
468
- }
469
-
470
- .key-image-span.active {
471
- transform: scale(1.16);
472
- border: 4px $app-primary-color solid;
473
- }
474
-
475
- .key-image-span {
476
- display: flex;
477
- position: relative;
478
- }
479
-
480
- .overlay {
481
- position: absolute;
482
- right: 5px;
483
- top: 5px;
484
- width: 1.61em;
485
- height: 1em;
486
- border-radius: 3px;
487
- opacity: 0.8;
488
- }
489
-
490
- img {
491
- vertical-align: bottom;
492
- }
493
-
494
- a.prev,
495
- a.next {
496
- display: flex;
497
- font-size: 3em;
498
- }
499
-
500
- a.prev:not(.underline),
501
- a.next:not(.underline) {
502
- text-decoration: none;
503
- }
504
-
505
- a.prev {
506
- justify-content: flex-start;
507
- }
508
-
509
- a.next {
510
- justify-content: flex-end;
511
- }
512
-
513
- .standard-gallery {
514
- display: flex;
515
- flex-wrap: nowrap;
516
- justify-content: space-around;
517
- align-items: center;
518
- }
519
-
520
- .image-line {
521
- display: flex;
522
- margin-top: 1%;
523
- margin-bottom: 1%;
524
- flex-grow: 1;
525
- justify-content: space-between;
526
- }
527
- .disabled {
528
- opacity: 0.2;
529
- cursor: default;
530
- }
531
-
532
- .rectangle {
533
- height: 1em;
534
- width: 2em;
535
- border-radius: 3px;
536
- background-color: #555;
537
- }
538
-
539
- .full-size :deep(.el-card) {
540
- border: 0px;
541
- }
542
- </style>
1
+ <template>
2
+ <div class="full-size">
3
+ <Gallery
4
+ :bottomSpacer="bottomSpacer"
5
+ :cardWidth="10"
6
+ :items="galleryItems"
7
+ :max-width="maxWidth"
8
+ :show-indicator-bar="false"
9
+ :show-card-details="true"
10
+ :highlight-active="false"
11
+ :image-style="imageStyle"
12
+ :image-container-style="imageContainerStyle"
13
+ :body-style="bodyStyle"
14
+ :shadow="shadow"
15
+ @card-clicked="cardClicked"
16
+ @datalink-clicked="datalinkClicked"
17
+ ref="gallery"
18
+ />
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ /* eslint-disable no-alert, no-console */
24
+ const baseName = (str) => {
25
+ return str.split('\\').pop().split('/').pop()
26
+ }
27
+
28
+ const capitalise = function (string) {
29
+ return string.replace(/\b\w/g, (v) => v.toUpperCase())
30
+ }
31
+
32
+ import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
33
+ import Gallery from "@abi-software/gallery";
34
+ import "@abi-software/gallery/dist/style.css";
35
+ //provide the s3Bucket related methods and data.
36
+ import S3Bucket from '../mixins/S3Bucket.vue'
37
+
38
+ export default {
39
+ name: 'ImageGallery',
40
+ components: { Gallery },
41
+ mixins: [GalleryHelper, S3Bucket],
42
+ props: {
43
+ datasetBiolucida: {
44
+ type: Object,
45
+ default: () => {
46
+ return {}
47
+ },
48
+ },
49
+ envVars: {
50
+ type: Object,
51
+ default: () => {},
52
+ },
53
+ label: {
54
+ type: String,
55
+ default: '',
56
+ },
57
+ plots: {
58
+ type: Array,
59
+ default: () => {
60
+ return []
61
+ },
62
+ },
63
+ datasetId: {
64
+ type: Number,
65
+ default: -1,
66
+ },
67
+ datasetVersion: {
68
+ type: Number,
69
+ default: -1,
70
+ },
71
+ datasetThumbnail: {
72
+ type: String,
73
+ default: '',
74
+ },
75
+ category: {
76
+ type: String,
77
+ default: 'All',
78
+ },
79
+ entry: {
80
+ type: Object,
81
+ default: () => {
82
+ return {}
83
+ },
84
+ },
85
+ },
86
+ data() {
87
+ return {
88
+ currentIndex: 0,
89
+ ro: null,
90
+ maxWidth: 3,
91
+ items: {
92
+ //Use the Images instead for Biolucida Images
93
+ //"Biolucida Images": [],
94
+ Dataset: [],
95
+ Images: [],
96
+ Scaffolds: [],
97
+ Segmentations: [],
98
+ Simulations: [],
99
+ Videos: [],
100
+ Plots: [],
101
+ },
102
+ bodyStyle: { padding: '0px', background: '#ffffff' },
103
+ imageContainerStyle: {
104
+ width: '160px',
105
+ height: '160px',
106
+ display: 'flex',
107
+ alignItems: 'center',
108
+ justifyContent: 'center',
109
+ },
110
+ imageStyle: { maxWidth: '160px', maxHeight: '160px' },
111
+ shadow: 'never',
112
+ bottomSpacer: { minHeight: '0rem' },
113
+ resetIndex: false,
114
+ }
115
+ },
116
+ methods: {
117
+ cardClicked: function (payload) {
118
+ this.$emit('card-clicked', payload)
119
+ },
120
+ datalinkClicked: function (payload) {
121
+ this.$emit('datalink-clicked', payload);
122
+ },
123
+ createSciCurnchItems: function () {
124
+ this.updateS3Bucket(this.entry.s3uri)
125
+ this.createDatasetItem()
126
+ this.createScaffoldItems()
127
+ this.createSimulationItems()
128
+ this.createPlotItems()
129
+ this.createSegmentationItems()
130
+ /* Disable these two
131
+ this.createImageItems();
132
+ this.createVideoItems();
133
+ */
134
+ },
135
+ createDatasetItem: function () {
136
+ const link = `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`
137
+ if (this.datasetThumbnail) {
138
+ this.items['Dataset'].push({
139
+ id: -1,
140
+ //Work around gallery requires a truthy string
141
+ title: ' ',
142
+ type: `Dataset ${this.datasetId}`,
143
+ thumbnail: this.datasetThumbnail,
144
+ link,
145
+ hideType: true,
146
+ hideTitle: true,
147
+ })
148
+ }
149
+ },
150
+ createImageItems: function () {
151
+ if (this.entry.images) {
152
+ this.entry.images.forEach((image) => {
153
+ const filePath = image.dataset.path
154
+ const id = image.identifier
155
+ const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.datasetId}&dataset_version=${this.datasetVersion}&file_path=${filePath}&mimetype=${image.mimetype.name}`
156
+ this.items['Images'].push({
157
+ id,
158
+ title: baseName(filePath),
159
+ type: 'Image',
160
+ link: linkUrl,
161
+ hideType: true,
162
+ })
163
+ })
164
+ }
165
+ },
166
+ createPlotItems: function () {
167
+ if (this.entry.plots) {
168
+ this.entry.plots.forEach((plot) => {
169
+ const filePath = plot.dataset.path
170
+ const id = plot.identifier
171
+ const thumbnail = this.getThumbnailForPlot(
172
+ plot,
173
+ this.entry.thumbnails
174
+ )
175
+ let thumbnailURL = undefined
176
+ let mimetype = ''
177
+ if (thumbnail) {
178
+
179
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
180
+ id,
181
+ prefix: this.getS3Prefix(),
182
+ file_path: thumbnail.dataset.path,
183
+ s3Bucket: this.s3Bucket,
184
+ })
185
+ mimetype = thumbnail.mimetype.name
186
+ }
187
+ const plotAnnotation = plot.datacite;
188
+ const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
189
+ const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
190
+
191
+ //plotAnnotation.supplemental_json_metadata.description can be undefined or
192
+ //contain an empty string causing an error with JSON.parse
193
+ let metadata = {}
194
+ try {
195
+ metadata = JSON.parse(
196
+ plotAnnotation.supplemental_json_metadata.description
197
+ )
198
+ } catch (error) {
199
+ console.warn(error)
200
+ }
201
+
202
+ let supplementalData = []
203
+ if (plotAnnotation.isDescribedBy) {
204
+ supplementalData.push({
205
+ url: filePathPrefix + plotAnnotation.isDescribedBy.path,
206
+ })
207
+ }
208
+
209
+ const resource = {
210
+ dataSource: { url: sourceUrl },
211
+ metadata,
212
+ supplementalData,
213
+ }
214
+
215
+ let action = {
216
+ label: capitalise(this.label),
217
+ resource: resource,
218
+ s3uri: this.entry.s3uri,
219
+ title: 'View plot',
220
+ type: 'Plot',
221
+ discoverId: this.discoverId,
222
+ version: this.datasetVersion,
223
+ }
224
+ this.items['Plots'].push({
225
+ id,
226
+ title: baseName(filePath),
227
+ type: 'Plot',
228
+ thumbnail: thumbnailURL,
229
+ userData: action,
230
+ hideType: true,
231
+ mimetype,
232
+ })
233
+ })
234
+ }
235
+ },
236
+ createScaffoldItems: function () {
237
+ if (this.entry.scaffolds) {
238
+ let index = 0
239
+ this.entry.scaffolds.forEach((scaffold, i) => {
240
+ const filePath = scaffold.dataset.path
241
+ const id = scaffold.identifier
242
+ const thumbnail = this.getThumbnailForScaffold(
243
+ scaffold,
244
+ this.entry.scaffoldViews,
245
+ this.entry.thumbnails,
246
+ index
247
+ )
248
+ let mimetype = ''
249
+ let thumbnailURL = undefined
250
+ if (thumbnail) {
251
+ thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
252
+ id,
253
+ prefix: this.getS3Prefix(),
254
+ file_path: thumbnail.dataset.path,
255
+ s3Bucket: this.s3Bucket,
256
+ })
257
+ mimetype = thumbnail.mimetype.name
258
+ }
259
+ let action = {
260
+ label: capitalise(this.label),
261
+ resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
262
+ title: "View 3D scaffold",
263
+ type: "Scaffold",
264
+ discoverId: this.datasetId,
265
+ apiLocation: this.envVars.API_LOCATION,
266
+ version: this.datasetVersion,
267
+ banner: this.datasetThumbnail,
268
+ s3uri: this.entry.s3uri,
269
+ contextCardUrl: this.getContextCardUrl(i),
270
+ }
271
+ this.items['Scaffolds'].push({
272
+ id,
273
+ title: baseName(filePath),
274
+ type: 'Scaffold',
275
+ thumbnail: thumbnailURL,
276
+ userData: action,
277
+ hideType: true,
278
+ mimetype,
279
+ })
280
+ })
281
+ }
282
+ },
283
+ createSegmentationItems: function () {
284
+ if (this.entry.segmentation) {
285
+ this.entry.segmentation.forEach((segmentation) => {
286
+ const id = segmentation.id
287
+ let filePath = segmentation.dataset.path
288
+ filePath = filePath.replaceAll(' ', '_')
289
+ filePath = filePath.replaceAll(',', '_')
290
+ const prefix = this.envVars.NL_LINK_PREFIX
291
+ const resource = {
292
+ share_link: `${prefix}/dataviewer?datasetId=${this.datasetId}&version=${this.datasetVersion}&path=files/${filePath}`,
293
+ }
294
+ let action = {
295
+ label: capitalise(this.label),
296
+ resource: resource,
297
+ datasetId: this.datasetId,
298
+ s3uri: this.entry.s3uri,
299
+ title: 'View segmentation',
300
+ type: 'Segmentation',
301
+ }
302
+ const thumbnailURL = this.getSegmentationThumbnailURL(
303
+ this.envVars.API_LOCATION,
304
+ {
305
+ id,
306
+ datasetId: this.datasetId,
307
+ datasetVersion: this.datasetVersion,
308
+ segmentationFilePath: filePath,
309
+ s3Bucket: this.s3Bucket,
310
+ }
311
+ )
312
+ this.items['Segmentations'].push({
313
+ id,
314
+ title: baseName(filePath),
315
+ type: 'Segmentation',
316
+ thumbnail: thumbnailURL,
317
+ userData: action,
318
+ hideType: true,
319
+ mimetype: 'image/png',
320
+ })
321
+ })
322
+ }
323
+ },
324
+ createSimulationItems: function () {
325
+ if (this.entry.simulation && this.entry.simulation.length > 0) {
326
+ let action = {
327
+ label: undefined,
328
+ apiLocation: this.envVars.API_LOCATION,
329
+ s3uri: this.entry.s3uri,
330
+ version: this.datasetVersion,
331
+ title: 'View simulation',
332
+ type: 'Simulation',
333
+ name: this.entry.name,
334
+ description: this.entry.description,
335
+ discoverId: this.datasetId,
336
+ dataset: `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`,
337
+ }
338
+ this.items['Simulations'].push({
339
+ id: 'simulation',
340
+ title: ' ',
341
+ type: 'Simulation',
342
+ hideType: true,
343
+ hideTitle: true,
344
+ userData: action,
345
+ })
346
+ }
347
+ },
348
+ createVideoItems: function () {
349
+ if (this.entry.videos) {
350
+ this.entry.videos.forEach((video) => {
351
+ const filePath = this.getS3FilePath(
352
+ this.datasetId,
353
+ this.datasetVersion,
354
+ video.dataset.path
355
+ )
356
+ const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.datasetVersion}&dataset_id=${this.datasetId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
357
+ this.items['Videos'].push({
358
+ title: video.name,
359
+ type: 'Video',
360
+ thumbnail: this.defaultVideoImg,
361
+ hideType: true,
362
+ link: linkUrl,
363
+ })
364
+ })
365
+ }
366
+ },
367
+ onResize: function () {
368
+ this.maxWidth = this.$el.clientWidth
369
+ // this.$emit('resize', this.$el.clientWidth)
370
+ },
371
+ getContextCardUrl: function(scaffoldIndex){
372
+ if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
373
+ return undefined
374
+ } else {
375
+ // 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.
376
+ let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
377
+ return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
378
+ }
379
+ },
380
+ getImageURL: function(apiEndpoint, info) {
381
+ let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
382
+ if (info.s3Bucket) {
383
+ url = url + `&s3BucketName=${info.s3Bucket}`
384
+ }
385
+ return url
386
+ },
387
+ },
388
+ computed: {
389
+ galleryItems() {
390
+ if (this.resetIndex) {
391
+ this.$refs.gallery.indicatorClicked(0)
392
+ }
393
+ let items = [...this.items['Dataset']]
394
+ if (this.category === 'All') {
395
+ for (const [key, value] of Object.entries(this.items)) {
396
+ if (key !== 'Dataset') items = items.concat(value)
397
+ }
398
+ return items
399
+ } else return [...this.items[this.category]]
400
+ },
401
+ },
402
+ created: function () {
403
+ this.createSciCurnchItems()
404
+ },
405
+ watch: {
406
+ category: function () {
407
+ this.resetIndex = true
408
+ },
409
+ galleryItems: function () {
410
+ this.resetIndex = false
411
+ },
412
+ datasetBiolucida: {
413
+ deep: true,
414
+ immediate: true,
415
+ handler: function (biolucidaData) {
416
+ let items = []
417
+ if ('dataset_images' in biolucidaData) {
418
+ items.push(
419
+ ...Array.from(biolucidaData.dataset_images, (dataset_image) => {
420
+ const thumbnailURL = this.getThumbnailURLFromBiolucida(
421
+ this.envVars.API_LOCATION,
422
+ {
423
+ id: dataset_image.image_id,
424
+ }
425
+ )
426
+ const resource = {
427
+ share_link: dataset_image.share_link,
428
+ id: dataset_image.image_id,
429
+ itemId: dataset_image.sourcepkg_id,
430
+ }
431
+ let action = {
432
+ label: capitalise(this.label),
433
+ resource: resource,
434
+ datasetId: this.datasetId,
435
+ title: 'View image',
436
+ name: capitalise(this.label),
437
+ type: 'Biolucida',
438
+ }
439
+ return {
440
+ id: dataset_image.image_id,
441
+ title: `Image`,
442
+ type: 'Image',
443
+ thumbnail: thumbnailURL,
444
+ userData: action,
445
+ mimetype: 'image/png',
446
+ hideType: true,
447
+ }
448
+ })
449
+ )
450
+ }
451
+ this.items['Images'] = items
452
+ },
453
+ },
454
+ },
455
+ mounted() {
456
+ this.ro = new ResizeObserver(this.onResize).observe(this.$el)
457
+ },
458
+ unmounted() {
459
+ delete this.ro
460
+ },
461
+ }
462
+ </script>
463
+
464
+ <style lang="scss" scoped>
465
+ .full-size {
466
+ height: 100%;
467
+ width: 244px;
468
+ }
469
+
470
+ .key-image-span.active {
471
+ transform: scale(1.16);
472
+ border: 4px $app-primary-color solid;
473
+ }
474
+
475
+ .key-image-span {
476
+ display: flex;
477
+ position: relative;
478
+ }
479
+
480
+ .overlay {
481
+ position: absolute;
482
+ right: 5px;
483
+ top: 5px;
484
+ width: 1.61em;
485
+ height: 1em;
486
+ border-radius: 3px;
487
+ opacity: 0.8;
488
+ }
489
+
490
+ img {
491
+ vertical-align: bottom;
492
+ }
493
+
494
+ a.prev,
495
+ a.next {
496
+ display: flex;
497
+ font-size: 3em;
498
+ }
499
+
500
+ a.prev:not(.underline),
501
+ a.next:not(.underline) {
502
+ text-decoration: none;
503
+ }
504
+
505
+ a.prev {
506
+ justify-content: flex-start;
507
+ }
508
+
509
+ a.next {
510
+ justify-content: flex-end;
511
+ }
512
+
513
+ .standard-gallery {
514
+ display: flex;
515
+ flex-wrap: nowrap;
516
+ justify-content: space-around;
517
+ align-items: center;
518
+ }
519
+
520
+ .image-line {
521
+ display: flex;
522
+ margin-top: 1%;
523
+ margin-bottom: 1%;
524
+ flex-grow: 1;
525
+ justify-content: space-between;
526
+ }
527
+ .disabled {
528
+ opacity: 0.2;
529
+ cursor: default;
530
+ }
531
+
532
+ .rectangle {
533
+ height: 1em;
534
+ width: 2em;
535
+ border-radius: 3px;
536
+ background-color: #555;
537
+ }
538
+
539
+ .full-size :deep(.el-card) {
540
+ border: 0px;
541
+ }
542
+ </style>