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