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