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