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