@abi-software/map-side-bar 2.14.2-demo.0 → 2.14.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.
@@ -20,77 +20,38 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
- /* eslint-disable no-alert, no-console */
24
- const baseName = (str) => {
25
- return str.split('\\').pop().split('/').pop()
26
- }
27
-
28
- const capitalise = function (string) {
29
- return string.replace(/\b\w/g, (v) => v.toUpperCase())
30
- }
31
-
32
- import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
33
23
  import Gallery from "@abi-software/gallery";
34
24
  import "@abi-software/gallery/dist/style.css";
35
25
  //provide the s3Bucket related methods and data.
36
- import S3Bucket from '../mixins/S3Bucket.vue';
37
26
 
38
27
  export default {
39
28
  name: 'ImageGallery',
40
29
  components: { Gallery },
41
- mixins: [GalleryHelper, S3Bucket],
42
30
  props: {
43
- envVars: {
44
- type: Object,
45
- default: () => {},
46
- },
47
- label: {
48
- type: String,
49
- default: '',
50
- },
51
- plots: {
52
- type: Array,
53
- default: () => {
54
- return []
55
- },
56
- },
57
- datasetId: {
58
- type: Number,
59
- default: -1,
60
- },
61
- datasetVersion: {
62
- type: Number,
63
- default: -1,
64
- },
65
- datasetThumbnail: {
66
- type: String,
67
- default: '',
68
- },
69
31
  category: {
70
32
  type: String,
71
33
  default: 'All',
72
34
  },
73
- entry: {
35
+ items: {
74
36
  type: Object,
75
- default: () => {
76
- return {}
77
- },
78
- },
37
+ defualt: () => {
38
+ return {
39
+ Dataset: [],
40
+ Flatmaps:[],
41
+ Images: [],
42
+ Scaffolds: [],
43
+ Simulations: [],
44
+ Videos: [],
45
+ Plots: [],
46
+ }
47
+ }
48
+ }
79
49
  },
80
50
  data() {
81
51
  return {
82
52
  currentIndex: 0,
83
53
  ro: null,
84
54
  maxWidth: 3,
85
- items: {
86
- Dataset: [],
87
- Flatmaps:[],
88
- Images: [],
89
- Scaffolds: [],
90
- Simulations: [],
91
- Videos: [],
92
- Plots: [],
93
- },
94
55
  bodyStyle: { padding: '0px', background: '#ffffff' },
95
56
  imageContainerStyle: {
96
57
  width: '160px',
@@ -112,314 +73,11 @@ export default {
112
73
  datalinkClicked: function (payload) {
113
74
  this.$emit('datalink-clicked', payload);
114
75
  },
115
- createSciCurnchItems: function () {
116
- this.updateS3Bucket(this.entry.s3uri)
117
- this.createDatasetItem()
118
- this.createFlatmapItems()
119
- this.createScaffoldItems()
120
- this.createSimulationItems()
121
- this.createPlotItems()
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
- hideTitle: true,
139
- })
140
- }
141
- },
142
- createFlatmapItems: function () {
143
- if (this.entry.flatmaps) {
144
- this.entry.flatmaps.forEach((flatmap) => {
145
- if (flatmap.associated_flatmap?.identifier) {
146
- const filePath = flatmap.dataset.path
147
- const id = flatmap.identifier
148
- const thumbnail = this.getThumbnailForPlot(
149
- flatmap,
150
- this.entry.thumbnails
151
- )
152
- let thumbnailURL = undefined
153
- let mimetype = ''
154
- if (thumbnail) {
155
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
156
- id,
157
- prefix: this.getS3Prefix(),
158
- file_path: thumbnail.dataset.path,
159
- s3Bucket: this.s3Bucket,
160
- })
161
- mimetype = thumbnail.mimetype.name
162
- }
163
- let action = {
164
- label: capitalise(this.label),
165
- resource: flatmap.associated_flatmap.identifier,
166
- title: 'View Flatmap',
167
- type: 'Flatmap',
168
- discoverId: this.datasetId,
169
- version: this.datasetVersion,
170
- }
171
- this.items['Flatmaps'].push({
172
- id,
173
- title: baseName(filePath),
174
- type: 'Flatmap',
175
- thumbnail: thumbnailURL,
176
- userData: action,
177
- hideType: true,
178
- mimetype,
179
- })
180
- }
181
- })
182
- }
183
- },
184
- createImageItems: function () {
185
- if (this.entry.images) {
186
- this.entry.images.forEach((image) => {
187
- const filePath = image.dataset.path
188
- const id = image.identifier
189
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.datasetId}&dataset_version=${this.datasetVersion}&file_path=${filePath}&mimetype=${image.mimetype.name}`
190
- this.items['Images'].push({
191
- id,
192
- title: baseName(filePath),
193
- type: 'Image',
194
- link: linkUrl,
195
- hideType: true,
196
- })
197
- })
198
- }
199
- },
200
- createPlotItems: function () {
201
- if (this.entry.plots) {
202
- this.entry.plots.forEach((plot) => {
203
- const filePath = plot.dataset.path
204
- const id = plot.identifier
205
- const thumbnail = this.getThumbnailForPlot(
206
- plot,
207
- this.entry.thumbnails
208
- )
209
- let thumbnailURL = undefined
210
- let mimetype = ''
211
- if (thumbnail) {
212
-
213
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
214
- id,
215
- prefix: this.getS3Prefix(),
216
- file_path: thumbnail.dataset.path,
217
- s3Bucket: this.s3Bucket,
218
- })
219
- mimetype = thumbnail.mimetype.name
220
- }
221
- const plotAnnotation = plot.datacite;
222
- const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
223
- const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
224
-
225
- //plotAnnotation.supplemental_json_metadata.description can be undefined or
226
- //contain an empty string causing an error with JSON.parse
227
- let metadata = {}
228
- try {
229
- metadata = JSON.parse(
230
- plotAnnotation.supplemental_json_metadata.description
231
- )
232
- } catch (error) {
233
- console.warn(error)
234
- }
235
-
236
- let supplementalData = []
237
- if (plotAnnotation.isDescribedBy) {
238
- supplementalData.push({
239
- url: filePathPrefix + plotAnnotation.isDescribedBy.path,
240
- })
241
- }
242
-
243
- const resource = {
244
- dataSource: { url: sourceUrl },
245
- metadata,
246
- supplementalData,
247
- }
248
-
249
- let action = {
250
- label: capitalise(this.label),
251
- resource: resource,
252
- s3uri: this.entry.s3uri,
253
- title: 'View plot',
254
- type: 'Plot',
255
- discoverId: this.discoverId,
256
- version: this.datasetVersion,
257
- }
258
- this.items['Plots'].push({
259
- id,
260
- title: baseName(filePath),
261
- type: 'Plot',
262
- thumbnail: thumbnailURL,
263
- userData: action,
264
- hideType: true,
265
- mimetype,
266
- })
267
- })
268
- }
269
- },
270
- createScaffoldItems: function () {
271
- if (this.entry.scaffolds) {
272
- let index = 0
273
- this.entry.scaffolds.forEach((scaffold, i) => {
274
- const filePath = scaffold.dataset.path
275
- const id = scaffold.identifier
276
- const thumbnail = this.getThumbnailForScaffold(
277
- scaffold,
278
- this.entry.scaffoldViews,
279
- this.entry.thumbnails,
280
- index
281
- )
282
- let mimetype = ''
283
- let thumbnailURL = undefined
284
- if (thumbnail) {
285
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
286
- id,
287
- prefix: this.getS3Prefix(),
288
- file_path: thumbnail.dataset.path,
289
- s3Bucket: this.s3Bucket,
290
- })
291
- mimetype = thumbnail.mimetype.name
292
- }
293
- let action = {
294
- label: capitalise(this.label),
295
- resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
296
- title: "View 3D scaffold",
297
- type: "Scaffold",
298
- discoverId: this.datasetId,
299
- apiLocation: this.envVars.API_LOCATION,
300
- version: this.datasetVersion,
301
- banner: this.datasetThumbnail,
302
- s3uri: this.entry.s3uri,
303
- contextCardUrl: this.getContextCardUrl(i),
304
- }
305
- this.items['Scaffolds'].push({
306
- id,
307
- title: baseName(filePath),
308
- type: 'Scaffold',
309
- thumbnail: thumbnailURL,
310
- userData: action,
311
- hideType: true,
312
- mimetype,
313
- })
314
- })
315
- }
316
- },
317
- createSimulationItems: function () {
318
- if (this.entry.simulation) {
319
- this.entry.simulation.forEach((simulation) => {
320
- if (simulation.additional_mimetype.name === "application/x.vnd.abi.simulation+json") {
321
- let action = {
322
- label: undefined,
323
- apiLocation: this.envVars.API_LOCATION,
324
- s3uri: this.entry.s3uri,
325
- version: this.datasetVersion,
326
- title: 'View simulation',
327
- type: 'Simulation',
328
- name: this.entry.name,
329
- description: this.entry.description,
330
- discoverId: this.datasetId,
331
- dataset: `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`,
332
- }
333
- this.items['Simulations'].push({
334
- id: 'simulation',
335
- title: ' ',
336
- type: 'Simulation',
337
- hideType: true,
338
- hideTitle: true,
339
- userData: action,
340
- })
341
- } else {
342
- const filePath = simulation.dataset.path
343
- const id = simulation.identifier
344
- //Despite of the name, this method can be used to retreive
345
- //the thumbnail information for any none scaffold type thumbnail
346
- const thumbnail = this.getThumbnailForPlot(
347
- simulation,
348
- this.entry.thumbnails
349
- )
350
- let thumbnailURL = undefined
351
- let mimetype = ''
352
- if (thumbnail) {
353
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
354
- id,
355
- prefix: this.getS3Prefix(),
356
- file_path: thumbnail.dataset.path,
357
- s3Bucket: this.s3Bucket,
358
- })
359
- mimetype = thumbnail.mimetype.name
360
- }
361
- const resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
362
- let action = {
363
- label: capitalise(this.label),
364
- resource: resource,
365
- s3uri: this.entry.s3uri,
366
- title: 'View simulation',
367
- type: 'Simulation',
368
- discoverId: this.discoverId,
369
- version: this.datasetVersion,
370
- }
371
- this.items['Simulations'].push({
372
- id,
373
- title: baseName(filePath),
374
- type: 'Simulation',
375
- thumbnail: thumbnailURL,
376
- userData: action,
377
- hideType: true,
378
- mimetype,
379
- })
380
- }
381
- })
382
- }
383
- },
384
- createVideoItems: function () {
385
- if (this.entry.videos) {
386
- this.entry.videos.forEach((video) => {
387
- const filePath = this.getS3FilePath(
388
- this.datasetId,
389
- this.datasetVersion,
390
- video.dataset.path
391
- )
392
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.datasetVersion}&dataset_id=${this.datasetId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
393
- this.items['Videos'].push({
394
- title: video.name,
395
- type: 'Video',
396
- thumbnail: this.defaultVideoImg,
397
- hideType: true,
398
- link: linkUrl,
399
- })
400
- })
401
- }
402
- },
403
76
  onResize: function () {
404
77
  this.maxWidth = this.$el.clientWidth
405
78
  // this.$emit('resize', this.$el.clientWidth)
406
79
  },
407
- getContextCardUrl: function(scaffoldIndex){
408
- if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
409
- return undefined
410
- } else {
411
- // 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.
412
- let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
413
- return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
414
- }
415
- },
416
- getImageURL: function(apiEndpoint, info) {
417
- let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
418
- if (info.s3Bucket) {
419
- url = url + `&s3BucketName=${info.s3Bucket}`
420
- }
421
- return url
422
- },
80
+
423
81
  },
424
82
  computed: {
425
83
  galleryItems() {
@@ -435,9 +93,6 @@ export default {
435
93
  } else return [...this.items[this.category]]
436
94
  },
437
95
  },
438
- created: function () {
439
- this.createSciCurnchItems()
440
- },
441
96
  watch: {
442
97
  category: function () {
443
98
  this.resetIndex = true