@abi-software/map-side-bar 2.14.1-simulation.0 → 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,77 +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 = 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
+ Scaffolds: [],
42
+ Simulations: [],
43
+ Plots: [],
44
+ }
45
+ }
46
+ }
79
47
  },
80
48
  data() {
81
49
  return {
82
50
  currentIndex: 0,
83
51
  ro: null,
84
52
  maxWidth: 3,
85
- items: {
86
- Dataset: [],
87
- Flatmaps:[],
88
- Images: [],
89
- Scaffolds: [],
90
- Simulations: [],
91
- Videos: [],
92
- Plots: [],
93
- },
94
53
  bodyStyle: { padding: '0px', background: '#ffffff' },
95
54
  imageContainerStyle: {
96
55
  width: '160px',
@@ -112,321 +71,10 @@ export default {
112
71
  datalinkClicked: function (payload) {
113
72
  this.$emit('datalink-clicked', payload);
114
73
  },
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
- let thumbnailURL = flatmap.thumbnail?.url
149
- let mimetype = ''
150
- if (!thumbnailURL) {
151
- let thumbnail = this.getThumbnailForPlot(
152
- flatmap,
153
- this.entry.thumbnails
154
- )
155
- if (thumbnail) {
156
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
157
- id,
158
- prefix: this.getS3Prefix(),
159
- file_path: thumbnail.dataset.path,
160
- s3Bucket: this.s3Bucket,
161
- })
162
- mimetype = thumbnail.mimetype.name
163
- }
164
- }
165
- let action = {
166
- label: capitalise(this.label),
167
- resource: flatmap.associated_flatmap.identifier,
168
- title: 'View Flatmap',
169
- type: 'Flatmap',
170
- discoverId: this.datasetId,
171
- version: this.datasetVersion,
172
- }
173
- this.items['Flatmaps'].push({
174
- id,
175
- title: baseName(filePath),
176
- type: 'Flatmap',
177
- thumbnail: thumbnailURL,
178
- userData: action,
179
- hideType: true,
180
- mimetype,
181
- })
182
- }
183
- })
184
- }
185
- },
186
- createImageItems: function () {
187
- if (this.entry.images) {
188
- this.entry.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
- hideType: true,
198
- })
199
- })
200
- }
201
- },
202
- createPlotItems: function () {
203
- if (this.entry.plots) {
204
- this.entry.plots.forEach((plot) => {
205
- const filePath = plot.dataset.path
206
- const id = plot.identifier
207
- const thumbnail = this.getThumbnailForPlot(
208
- plot,
209
- this.entry.thumbnails
210
- )
211
- let thumbnailURL = undefined
212
- let mimetype = ''
213
- if (thumbnail) {
214
-
215
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
216
- id,
217
- prefix: this.getS3Prefix(),
218
- file_path: thumbnail.dataset.path,
219
- s3Bucket: this.s3Bucket,
220
- })
221
- mimetype = thumbnail.mimetype.name
222
- }
223
- const plotAnnotation = plot.datacite;
224
- const filePathPrefix = `${this.envVars.API_LOCATION}/s3-resource/${this.getS3Prefix()}files/`;
225
- const sourceUrl = filePathPrefix + plot.dataset.path + this.getS3Args();
226
-
227
- //plotAnnotation.supplemental_json_metadata.description can be undefined or
228
- //contain an empty string causing an error with JSON.parse
229
- let metadata = {}
230
- try {
231
- metadata = JSON.parse(
232
- plotAnnotation.supplemental_json_metadata.description
233
- )
234
- } catch (error) {
235
- console.warn(error)
236
- }
237
-
238
- let supplementalData = []
239
- if (plotAnnotation.isDescribedBy) {
240
- supplementalData.push({
241
- url: filePathPrefix + plotAnnotation.isDescribedBy.path,
242
- })
243
- }
244
-
245
- const resource = {
246
- dataSource: { url: sourceUrl },
247
- metadata,
248
- supplementalData,
249
- }
250
-
251
- let action = {
252
- label: capitalise(this.label),
253
- resource: resource,
254
- s3uri: this.entry.s3uri,
255
- title: 'View plot',
256
- type: 'Plot',
257
- discoverId: this.discoverId,
258
- version: this.datasetVersion,
259
- }
260
- this.items['Plots'].push({
261
- id,
262
- title: baseName(filePath),
263
- type: 'Plot',
264
- thumbnail: thumbnailURL,
265
- userData: action,
266
- hideType: true,
267
- mimetype,
268
- })
269
- })
270
- }
271
- },
272
- createScaffoldItems: function () {
273
- if (this.entry.scaffolds) {
274
- let index = 0
275
- this.entry.scaffolds.forEach((scaffold, i) => {
276
- const filePath = scaffold.dataset.path
277
- const id = scaffold.identifier
278
- const thumbnail = this.getThumbnailForScaffold(
279
- scaffold,
280
- this.entry.scaffoldViews,
281
- this.entry.thumbnails,
282
- index
283
- )
284
- let mimetype = ''
285
- let thumbnailURL = undefined
286
- if (thumbnail) {
287
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
288
- id,
289
- prefix: this.getS3Prefix(),
290
- file_path: thumbnail.dataset.path,
291
- s3Bucket: this.s3Bucket,
292
- })
293
- mimetype = thumbnail.mimetype.name
294
- }
295
- let action = {
296
- label: capitalise(this.label),
297
- resource: `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`,
298
- title: "View 3D scaffold",
299
- type: "Scaffold",
300
- discoverId: this.datasetId,
301
- apiLocation: this.envVars.API_LOCATION,
302
- version: this.datasetVersion,
303
- banner: this.datasetThumbnail,
304
- s3uri: this.entry.s3uri,
305
- contextCardUrl: this.getContextCardUrl(i),
306
- }
307
- this.items['Scaffolds'].push({
308
- id,
309
- title: baseName(filePath),
310
- type: 'Scaffold',
311
- thumbnail: thumbnailURL,
312
- userData: action,
313
- hideType: true,
314
- mimetype,
315
- })
316
- })
317
- }
318
- },
319
- createSimulationItems: function () {
320
- if (this.entry.simulation) {
321
- this.entry.simulation.forEach((simulation) => {
322
- if (simulation.additional_mimetype.name === "application/x.vnd.abi.simulation+json") {
323
- let action = {
324
- label: undefined,
325
- apiLocation: this.envVars.API_LOCATION,
326
- s3uri: this.entry.s3uri,
327
- version: this.datasetVersion,
328
- title: 'View simulation',
329
- type: 'Simulation',
330
- name: this.entry.name,
331
- description: this.entry.description,
332
- discoverId: this.datasetId,
333
- dataset: `${this.envVars.ROOT_URL}/datasets/${this.datasetId}?type=dataset`,
334
- }
335
- this.items['Simulations'].push({
336
- id: 'simulation',
337
- title: ' ',
338
- type: 'Simulation',
339
- hideType: true,
340
- hideTitle: true,
341
- userData: action,
342
- })
343
- } else {
344
- const filePath = simulation.dataset.path
345
- const id = simulation.identifier
346
- //Despite of the name, this method can be used to retreive
347
- //the thumbnail information for any none scaffold type thumbnail
348
- let thumbnailURL = simulation.thumbnail?.url
349
- let mimetype = ''
350
- if (!thumbnailURL) {
351
- const thumbnail = this.getThumbnailForPlot(
352
- simulation,
353
- this.entry.thumbnails
354
- )
355
- if (thumbnail) {
356
- thumbnailURL = this.getImageURL(this.envVars.API_LOCATION, {
357
- id,
358
- prefix: this.getS3Prefix(),
359
- file_path: thumbnail.dataset.path,
360
- s3Bucket: this.s3Bucket,
361
- })
362
- mimetype = thumbnail.mimetype.name
363
- }
364
- }
365
- let resource = `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${filePath}${this.getS3Args()}`
366
- if (simulation.resource?.url) {
367
- resource = simulation.resource.url
368
- }
369
- let action = {
370
- label: capitalise(this.label),
371
- resource: resource,
372
- s3uri: this.entry.s3uri,
373
- title: 'View simulation',
374
- type: 'Simulation',
375
- discoverId: this.discoverId,
376
- version: this.datasetVersion,
377
- }
378
- this.items['Simulations'].push({
379
- id,
380
- title: baseName(filePath),
381
- type: 'Simulation',
382
- thumbnail: thumbnailURL,
383
- userData: action,
384
- hideType: true,
385
- mimetype,
386
- })
387
- }
388
- })
389
- }
390
- },
391
- createVideoItems: function () {
392
- if (this.entry.videos) {
393
- this.entry.videos.forEach((video) => {
394
- const filePath = this.getS3FilePath(
395
- this.datasetId,
396
- this.datasetVersion,
397
- video.dataset.path
398
- )
399
- const linkUrl = `${this.envVars.ROOT_URL}/datasets/videoviewer?dataset_version=${this.datasetVersion}&dataset_id=${this.datasetId}&file_path=${filePath}&mimetype=${video.mimetype.name}`
400
- this.items['Videos'].push({
401
- title: video.name,
402
- type: 'Video',
403
- thumbnail: this.defaultVideoImg,
404
- hideType: true,
405
- link: linkUrl,
406
- })
407
- })
408
- }
409
- },
410
74
  onResize: function () {
411
75
  this.maxWidth = this.$el.clientWidth
412
76
  // this.$emit('resize', this.$el.clientWidth)
413
77
  },
414
- getContextCardUrl: function(scaffoldIndex){
415
- if(!this.entry.contextualInformation || this.entry.contextualInformation.length == 0){
416
- return undefined
417
- } else {
418
- // 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.
419
- let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
420
- return `${this.envVars.API_LOCATION}s3-resource/${this.getS3Prefix()}files/${this.entry.contextualInformation[contextIndex]}${this.getS3Args()}`
421
- }
422
- },
423
- getImageURL: function(apiEndpoint, info) {
424
- let url = `${apiEndpoint}/s3-resource/${info.prefix}files/${info.file_path}?encodeBase64=true`
425
- if (info.s3Bucket) {
426
- url = url + `&s3BucketName=${info.s3Bucket}`
427
- }
428
- return url
429
- },
430
78
  },
431
79
  computed: {
432
80
  galleryItems() {
@@ -442,9 +90,6 @@ export default {
442
90
  } else return [...this.items[this.category]]
443
91
  },
444
92
  },
445
- created: function () {
446
- this.createSciCurnchItems()
447
- },
448
93
  watch: {
449
94
  category: function () {
450
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']