@abi-software/map-side-bar 2.14.1-simulation.1 → 2.14.1-simulation.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,82 +20,36 @@
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 = (string) => {
29
- return string.replace(/\b\w/g, (v) => v.toUpperCase())
30
- }
31
-
32
- const resolveURL = (relative, base) => {
33
- const resolved = new URL(relative, base);
34
- return resolved.href;
35
- }
36
-
37
- import GalleryHelper from '@abi-software/gallery/src/mixins/GalleryHelpers.js'
38
23
  import Gallery from "@abi-software/gallery";
39
24
  import "@abi-software/gallery/dist/style.css";
40
25
  //provide the s3Bucket related methods and data.
41
- import S3Bucket from '../mixins/S3Bucket.vue';
42
26
 
43
27
  export default {
44
28
  name: 'ImageGallery',
45
29
  components: { Gallery },
46
- mixins: [GalleryHelper, S3Bucket],
47
30
  props: {
48
- envVars: {
49
- type: Object,
50
- default: () => {},
51
- },
52
- label: {
53
- type: String,
54
- default: '',
55
- },
56
- plots: {
57
- type: Array,
58
- default: () => {
59
- return []
60
- },
61
- },
62
- datasetId: {
63
- type: Number,
64
- default: -1,
65
- },
66
- datasetVersion: {
67
- type: Number,
68
- default: -1,
69
- },
70
- datasetThumbnail: {
71
- type: String,
72
- default: '',
73
- },
74
31
  category: {
75
32
  type: String,
76
33
  default: 'All',
77
34
  },
78
- entry: {
35
+ items: {
79
36
  type: Object,
80
- default: () => {
81
- return {}
82
- },
83
- },
37
+ defualt: () => {
38
+ return {
39
+ Dataset: [],
40
+ Flatmaps:[],
41
+ Scaffolds: [],
42
+ Simulations: [],
43
+ Plots: [],
44
+ }
45
+ }
46
+ }
84
47
  },
85
48
  data() {
86
49
  return {
87
50
  currentIndex: 0,
88
51
  ro: null,
89
52
  maxWidth: 3,
90
- items: {
91
- Dataset: [],
92
- Flatmaps:[],
93
- Images: [],
94
- Scaffolds: [],
95
- Simulations: [],
96
- Videos: [],
97
- Plots: [],
98
- },
99
53
  bodyStyle: { padding: '0px', background: '#ffffff' },
100
54
  imageContainerStyle: {
101
55
  width: '160px',
@@ -117,330 +71,10 @@ export default {
117
71
  datalinkClicked: function (payload) {
118
72
  this.$emit('datalink-clicked', payload);
119
73
  },
120
- createSciCurnchItems: function () {
121
- this.updateS3Bucket(this.entry.s3uri)
122
- this.createDatasetItem()
123
- this.createFlatmapItems()
124
- this.createScaffoldItems()
125
- this.createSimulationItems()
126
- this.createPlotItems()
127
- /* Disable these two
128
- this.createImageItems();
129
- this.createVideoItems();
130
- */
131
- },
132
- createDatasetItem: function () {
133
- const link = `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`
134
- if (this.datasetThumbnail) {
135
- this.items['Dataset'].push({
136
- id: -1,
137
- //Work around gallery requires a truthy string
138
- title: ' ',
139
- type: `Dataset ${this.datasetId}`,
140
- thumbnail: this.datasetThumbnail,
141
- link,
142
- hideType: true,
143
- hideTitle: true,
144
- })
145
- }
146
- },
147
- createFlatmapItems: function () {
148
- if (this.entry.flatmaps) {
149
- this.entry.flatmaps.forEach((flatmap) => {
150
- if (flatmap.associated_flatmap?.identifier) {
151
- const filePath = flatmap.dataset.path
152
- const id = flatmap.identifier
153
- let thumbnailURL = undefined
154
- if (flatmap.thumbnail?.url) {
155
- thumbnailURL = resolveURL(flatmap.thumbnail.url,
156
- this.envVars.TEST_DATA_LOCATION)
157
- }
158
- let mimetype = ''
159
- if (!thumbnailURL) {
160
- let thumbnail = this.getThumbnailForPlot(
161
- flatmap,
162
- this.entry.thumbnails
163
- )
164
- if (thumbnail) {
165
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
166
- id,
167
- prefix: this.getS3Prefix(),
168
- file_path: thumbnail.dataset.path,
169
- s3Bucket: this.s3Bucket,
170
- })
171
- mimetype = thumbnail.mimetype.name
172
- }
173
- }
174
- let action = {
175
- label: capitalise(this.label),
176
- resource: flatmap.associated_flatmap.identifier,
177
- title: 'View Flatmap',
178
- type: 'Flatmap',
179
- discoverId: this.datasetId,
180
- version: this.datasetVersion,
181
- }
182
- this.items['Flatmaps'].push({
183
- id,
184
- title: baseName(filePath),
185
- type: 'Flatmap',
186
- thumbnail: thumbnailURL,
187
- userData: action,
188
- hideType: true,
189
- mimetype,
190
- })
191
- }
192
- })
193
- }
194
- },
195
- createImageItems: function () {
196
- if (this.entry.images) {
197
- this.entry.images.forEach((image) => {
198
- const filePath = image.dataset.path
199
- const id = image.identifier
200
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/imageviewer?dataset_id=${this.datasetId}&dataset_version=${this.datasetVersion}&file_path=${filePath}&mimetype=${image.mimetype.name}`
201
- this.items['Images'].push({
202
- id,
203
- title: baseName(filePath),
204
- type: 'Image',
205
- link: linkUrl,
206
- hideType: true,
207
- })
208
- })
209
- }
210
- },
211
- createPlotItems: function () {
212
- if (this.entry.plots) {
213
- this.entry.plots.forEach((plot) => {
214
- const filePath = plot.dataset.path
215
- const id = plot.identifier
216
- const thumbnail = this.getThumbnailForPlot(
217
- plot,
218
- this.entry.thumbnails
219
- )
220
- let thumbnailURL = undefined
221
- let mimetype = ''
222
- if (thumbnail) {
223
-
224
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
225
- id,
226
- prefix: this.getS3Prefix(),
227
- file_path: thumbnail.dataset.path,
228
- s3Bucket: this.s3Bucket,
229
- })
230
- mimetype = thumbnail.mimetype.name
231
- }
232
- const plotAnnotation = plot.datacite;
233
- const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
234
- const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
235
-
236
- //plotAnnotation.supplemental_json_metadata.description can be undefined or
237
- //contain an empty string causing an error with JSON.parse
238
- let metadata = {}
239
- try {
240
- metadata = JSON.parse(
241
- plotAnnotation.supplemental_json_metadata.description
242
- )
243
- } catch (error) {
244
- console.warn(error)
245
- }
246
-
247
- let supplementalData = []
248
- if (plotAnnotation.isDescribedBy) {
249
- supplementalData.push({
250
- url: filePathPrefix + plotAnnotation.isDescribedBy.path,
251
- })
252
- }
253
-
254
- const resource = {
255
- dataSource: { url: sourceUrl },
256
- metadata,
257
- supplementalData,
258
- }
259
-
260
- let action = {
261
- label: capitalise(this.label),
262
- resource: resource,
263
- s3uri: this.entry.s3uri,
264
- title: 'View plot',
265
- type: 'Plot',
266
- discoverId: this.discoverId,
267
- version: this.datasetVersion,
268
- }
269
- this.items['Plots'].push({
270
- id,
271
- title: baseName(filePath),
272
- type: 'Plot',
273
- thumbnail: thumbnailURL,
274
- userData: action,
275
- hideType: true,
276
- mimetype,
277
- })
278
- })
279
- }
280
- },
281
- createScaffoldItems: function () {
282
- if (this.entry.scaffolds) {
283
- let index = 0
284
- this.entry.scaffolds.forEach((scaffold, i) => {
285
- const filePath = scaffold.dataset.path
286
- const id = scaffold.identifier
287
- const thumbnail = this.getThumbnailForScaffold(
288
- scaffold,
289
- this.entry.scaffoldViews,
290
- this.entry.thumbnails,
291
- index
292
- )
293
- let mimetype = ''
294
- let thumbnailURL = undefined
295
- if (thumbnail) {
296
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
297
- id,
298
- prefix: this.getS3Prefix(),
299
- file_path: thumbnail.dataset.path,
300
- s3Bucket: this.s3Bucket,
301
- })
302
- mimetype = thumbnail.mimetype.name
303
- }
304
- let action = {
305
- label: capitalise(this.label),
306
- resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
307
- title: "View 3D scaffold",
308
- type: "Scaffold",
309
- discoverId: this.datasetId,
310
- apiLocation: this.envVars.API_LOCATION,
311
- version: this.datasetVersion,
312
- banner: this.datasetThumbnail,
313
- s3uri: this.entry.s3uri,
314
- contextCardUrl: this.getContextCardUrl(i),
315
- }
316
- this.items['Scaffolds'].push({
317
- id,
318
- title: baseName(filePath),
319
- type: 'Scaffold',
320
- thumbnail: thumbnailURL,
321
- userData: action,
322
- hideType: true,
323
- mimetype,
324
- })
325
- })
326
- }
327
- },
328
- createSimulationItems: function () {
329
- if (this.entry.simulation) {
330
- this.entry.simulation.forEach((simulation) => {
331
- if (simulation.additional_mimetype.name === "application/x.vnd.abi.simulation+json") {
332
- let action = {
333
- label: undefined,
334
- apiLocation: this.envVars.API_LOCATION,
335
- s3uri: this.entry.s3uri,
336
- version: this.datasetVersion,
337
- title: 'View simulation',
338
- type: 'Simulation',
339
- name: this.entry.name,
340
- description: this.entry.description,
341
- discoverId: this.datasetId,
342
- dataset: `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`,
343
- }
344
- this.items['Simulations'].push({
345
- id: 'simulation',
346
- title: ' ',
347
- type: 'Simulation',
348
- hideType: true,
349
- hideTitle: true,
350
- userData: action,
351
- })
352
- } else {
353
- const filePath = simulation.dataset.path
354
- const id = simulation.identifier
355
- //Despite of the name, this method can be used to retreive
356
- //the thumbnail information for any none scaffold type thumbnail
357
- let thumbnailURL = undefined;
358
- if (simulation.thumbnail?.url) {
359
- thumbnailURL = resolveURL(simulation.thumbnail.url,
360
- this.envVars.TEST_DATA_LOCATION)
361
- }
362
- let mimetype = ''
363
- if (!thumbnailURL) {
364
- const thumbnail = this.getThumbnailForPlot(
365
- simulation,
366
- this.entry.thumbnails
367
- )
368
- if (thumbnail) {
369
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
370
- id,
371
- prefix: this.getS3Prefix(),
372
- file_path: thumbnail.dataset.path,
373
- s3Bucket: this.s3Bucket,
374
- })
375
- mimetype = thumbnail.mimetype.name
376
- }
377
- }
378
- let resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
379
- if (simulation.resource?.url) {
380
- resource = resolveURL(simulation.resource.url,
381
- this.envVars.TEST_DATA_LOCATION)
382
- }
383
- let action = {
384
- label: capitalise(this.label),
385
- resource: resource,
386
- s3uri: this.entry.s3uri,
387
- title: 'View simulation',
388
- type: 'Simulation',
389
- discoverId: this.discoverId,
390
- version: this.datasetVersion,
391
- }
392
- this.items['Simulations'].push({
393
- id,
394
- title: baseName(filePath),
395
- type: 'Simulation',
396
- thumbnail: thumbnailURL,
397
- userData: action,
398
- hideType: true,
399
- mimetype,
400
- })
401
- }
402
- })
403
- }
404
- },
405
- createVideoItems: function () {
406
- if (this.entry.videos) {
407
- this.entry.videos.forEach((video) => {
408
- const filePath = this.getS3FilePath(
409
- this.datasetId,
410
- this.datasetVersion,
411
- video.dataset.path
412
- )
413
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.datasetVersion}&dataset_id=${this.datasetId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
414
- this.items['Videos'].push({
415
- title: video.name,
416
- type: 'Video',
417
- thumbnail: this.defaultVideoImg,
418
- hideType: true,
419
- link: linkUrl,
420
- })
421
- })
422
- }
423
- },
424
74
  onResize: function () {
425
75
  this.maxWidth = this.$el.clientWidth
426
76
  // this.$emit('resize', this.$el.clientWidth)
427
77
  },
428
- getContextCardUrl: function(scaffoldIndex){
429
- if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
430
- return undefined
431
- } else {
432
- // 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.
433
- let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
434
- return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
435
- }
436
- },
437
- getImageURL: function(apiEndpoint, info) {
438
- let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
439
- if (info.s3Bucket) {
440
- url = url + `&s3BucketName=${info.s3Bucket}`
441
- }
442
- return url
443
- },
444
78
  },
445
79
  computed: {
446
80
  galleryItems() {
@@ -456,9 +90,6 @@ export default {
456
90
  } else return [...this.items[this.category]]
457
91
  },
458
92
  },
459
- created: function () {
460
- this.createSciCurnchItems()
461
- },
462
93
  watch: {
463
94
  category: function () {
464
95
  this.resetIndex = true
@@ -299,6 +299,14 @@ export default {
299
299
  datasetExplorerTabRef.openSearch(facets, query);
300
300
  })
301
301
  },
302
+ displayFileInfo: function (datasetID, fileSearch, searchTerm = "") {
303
+ this.drawerOpen = true
304
+ // Because refs are in v-for, nextTick is needed here
305
+ this.$nextTick(() => {
306
+ const datasetExplorerTabRef = this.getTabRef(undefined, 'datasetExplorer', true);
307
+ datasetExplorerTabRef.displayFileInfo(datasetID, fileSearch, searchTerm);
308
+ })
309
+ },
302
310
  /**
303
311
  * Get the ref id of the tab by id and type.
304
312
  */
@@ -0,0 +1,50 @@
1
+ const resolveURL = (relative, base) => {
2
+ const resolved = new URL(relative, base);
3
+ return resolved.href;
4
+ }
5
+
6
+ const readProtocolData = async (item, baseUrl) => {
7
+ if (item && item.resource?.url) {
8
+ const resolvedUrl = resolveURL(item.resource.url, baseUrl)
9
+ const response = await fetch(resolvedUrl)
10
+ const data = await response.json()
11
+ //convert url
12
+ const fields = ["csv_file", "protocol", "thumbnail"]
13
+ data.forEach((protocol) => {
14
+ fields.forEach((field) => {
15
+ if (field in protocol) {
16
+ protocol[field] = resolveURL(protocol[field], resolvedUrl)
17
+ }
18
+ });
19
+ })
20
+ return data
21
+ }
22
+
23
+ return
24
+ }
25
+
26
+ const updateProtocolData = async (entry, baseUrl) => {
27
+ if (entry["simulation-protocols"]) {
28
+ const processedData = []
29
+ for (const item of entry["simulation-protocols"]) {
30
+ const data = await readProtocolData(item, baseUrl)
31
+ if (data) {
32
+ processedData.push(...data)
33
+ }
34
+ }
35
+ return processedData
36
+ }
37
+ }
38
+
39
+ const processProtocolsData = async (results, data, baseUrl) => {
40
+ for (const entry of data) {
41
+ const protocolData = await updateProtocolData(entry, baseUrl)
42
+ entry["protocol-data"] = protocolData
43
+ }
44
+ results.unshift(...data)
45
+ }
46
+
47
+ export {
48
+ processProtocolsData,
49
+ resolveURL,
50
+ }
@@ -19,6 +19,7 @@ declare module 'vue' {
19
19
  ElCascader: typeof import('element-plus/es')['ElCascader']
20
20
  ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
21
21
  ElCol: typeof import('element-plus/es')['ElCol']
22
+ ElDialog: typeof import('element-plus/es')['ElDialog']
22
23
  ElDrawer: typeof import('element-plus/es')['ElDrawer']
23
24
  ElDropdown: typeof import('element-plus/es')['ElDropdown']
24
25
  ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
@@ -34,6 +35,7 @@ declare module 'vue' {
34
35
  ElIconSearch: typeof import('@element-plus/icons-vue')['Search']
35
36
  ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
36
37
  ElIconWarnTriangleFilled: typeof import('@element-plus/icons-vue')['WarnTriangleFilled']
38
+ ElImage: typeof import('element-plus/es')['ElImage']
37
39
  ElInput: typeof import('element-plus/es')['ElInput']
38
40
  ElOption: typeof import('element-plus/es')['ElOption']
39
41
  ElPagination: typeof import('element-plus/es')['ElPagination']
@@ -42,7 +44,10 @@ declare module 'vue' {
42
44
  ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
43
45
  ElRow: typeof import('element-plus/es')['ElRow']
44
46
  ElSelect: typeof import('element-plus/es')['ElSelect']
47
+ ElTable: typeof import('element-plus/es')['ElTable']
48
+ ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
45
49
  ElTag: typeof import('element-plus/es')['ElTag']
50
+ FileBrowser: typeof import('./components/FileBrowser.vue')['default']
46
51
  ImageGallery: typeof import('./components/ImageGallery.vue')['default']
47
52
  SearchFilters: typeof import('./components/SearchFilters.vue')['default']
48
53
  SearchHistory: typeof import('./components/SearchHistory.vue')['default']