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