@abi-software/map-side-bar 2.12.4 → 2.13.0-acupoint.1

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.
@@ -12,7 +12,6 @@
12
12
  :envVars="envVars"
13
13
  :label="label"
14
14
  :datasetThumbnail="thumbnail"
15
- :dataset-biolucida="biolucidaData"
16
15
  :category="currentCategory"
17
16
  @card-clicked="galleryClicked"
18
17
  @datalink-clicked="galleryDatalinkClicked"
@@ -42,7 +41,6 @@
42
41
  <div class="badges-container">
43
42
  <BadgesGroup
44
43
  :entry="entry"
45
- :dataset-biolucida="biolucidaData"
46
44
  @categoryChanged="categoryChanged"
47
45
  />
48
46
  </div>
@@ -60,7 +58,6 @@
60
58
  <script>
61
59
  /* eslint-disable no-alert, no-console */
62
60
  import { View as ElIconView } from '@element-plus/icons-vue'
63
- import { Base64 } from 'js-base64';
64
61
  import BadgesGroup from './BadgesGroup.vue'
65
62
  import {
66
63
  ElButton as Button,
@@ -109,7 +106,6 @@ export default {
109
106
  loading: true,
110
107
  version: 1,
111
108
  lastDoi: undefined,
112
- biolucidaData: undefined,
113
109
  currentCategory: 'All',
114
110
  copyContent: '',
115
111
  }
@@ -237,7 +233,6 @@ export default {
237
233
  this.discoverId = data.id
238
234
  this.version = data.version
239
235
  this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
240
- this.getBiolucidaInfo()
241
236
  this.loading = false
242
237
  this.updateCopyContent();
243
238
  })
@@ -252,31 +247,6 @@ export default {
252
247
  lastName: function (fullName) {
253
248
  return fullName.split(',')[0]
254
249
  },
255
- getBiolucidaInfo: function () {
256
- const dataset_images = [];
257
- const biolucida2DItems = 'biolucida-2d' in this.entry ? this.entry['biolucida-2d'] :[];
258
- const biolucida3DItems = 'biolucida-3d' in this.entry ? this.entry['biolucida-3d'] :[];
259
- // We use information from SciCrunch to create the sharelink
260
- biolucida2DItems.concat(biolucida3DItems).forEach((bObject) => {
261
- const image_id = bObject.biolucida?.identifier;
262
- if (image_id) {
263
- const sourcepkg_id = 'identifier' in bObject ? bObject['identifier'] : "";
264
- // The encoded string is in the following format -
265
- // ${image_id}-col-${collection_id}, collection id can be any valid collection id
266
- // and 260 is used for now.
267
- const code = encodeURIComponent(Base64.encode(`${image_id}-col-260`));
268
- const share_link = `https://sparc.biolucida.net/image?c=${code}`
269
- dataset_images.push({
270
- share_link,
271
- image_id,
272
- sourcepkg_id,
273
- });
274
- }
275
- });
276
- if (dataset_images.length > 0) {
277
- this.biolucidaData = { dataset_images };
278
- }
279
- },
280
250
  updateCopyContent: function () {
281
251
  const contentArray = [];
282
252
 
@@ -499,7 +499,6 @@ export default {
499
499
  element['abi-contextual-information'].length > 0
500
500
  ? element['abi-contextual-information']
501
501
  : undefined,
502
- segmentation: element['mbf-segmentation'],
503
502
  //omex format will be the preferred mimetype
504
503
  simulation: element['abi-simulation-omex-file'] ? element['abi-simulation-omex-file'] : element['abi-simulation-file'],
505
504
  flatmaps: element['abi-flatmap-file'],
@@ -40,12 +40,6 @@ export default {
40
40
  components: { Gallery },
41
41
  mixins: [GalleryHelper, S3Bucket],
42
42
  props: {
43
- datasetBiolucida: {
44
- type: Object,
45
- default: () => {
46
- return {}
47
- },
48
- },
49
43
  envVars: {
50
44
  type: Object,
51
45
  default: () => {},
@@ -89,13 +83,10 @@ export default {
89
83
  ro: null,
90
84
  maxWidth: 3,
91
85
  items: {
92
- //Use the Images instead for Biolucida Images
93
- //"Biolucida Images": [],
94
86
  Dataset: [],
95
87
  Flatmaps:[],
96
88
  Images: [],
97
89
  Scaffolds: [],
98
- Segmentations: [],
99
90
  Simulations: [],
100
91
  Videos: [],
101
92
  Plots: [],
@@ -128,7 +119,6 @@ export default {
128
119
  this.createScaffoldItems()
129
120
  this.createSimulationItems()
130
121
  this.createPlotItems()
131
- this.createSegmentationItems()
132
122
  /* Disable these two
133
123
  this.createImageItems();
134
124
  this.createVideoItems();
@@ -324,47 +314,6 @@ export default {
324
314
  })
325
315
  }
326
316
  },
327
- createSegmentationItems: function () {
328
- if (this.entry.segmentation) {
329
- this.entry.segmentation.forEach((segmentation) => {
330
- const id = segmentation.id
331
- let filePath = segmentation.dataset.path
332
- filePath = filePath.replaceAll(' ', '_')
333
- filePath = filePath.replaceAll(',', '_')
334
- const prefix = this.envVars.NL_LINK_PREFIX
335
- const resource = {
336
- share_link: `${prefix}/dataviewer?datasetId=${this.datasetId}&version=${this.datasetVersion}&path=files/${filePath}`,
337
- }
338
- let action = {
339
- label: capitalise(this.label),
340
- resource: resource,
341
- datasetId: this.datasetId,
342
- s3uri: this.entry.s3uri,
343
- title: 'View segmentation',
344
- type: 'Segmentation',
345
- }
346
- const thumbnailURL = this.getSegmentationThumbnailURL(
347
- this.envVars.API_LOCATION,
348
- {
349
- id,
350
- datasetId: this.datasetId,
351
- datasetVersion: this.datasetVersion,
352
- segmentationFilePath: filePath,
353
- s3Bucket: this.s3Bucket,
354
- }
355
- )
356
- this.items['Segmentations'].push({
357
- id,
358
- title: baseName(filePath),
359
- type: 'Segmentation',
360
- thumbnail: thumbnailURL,
361
- userData: action,
362
- hideType: true,
363
- mimetype: 'image/png',
364
- })
365
- })
366
- }
367
- },
368
317
  createSimulationItems: function () {
369
318
  if (this.entry.simulation) {
370
319
  this.entry.simulation.forEach((simulation) => {
@@ -496,48 +445,6 @@ export default {
496
445
  galleryItems: function () {
497
446
  this.resetIndex = false
498
447
  },
499
- datasetBiolucida: {
500
- deep: true,
501
- immediate: true,
502
- handler: function (biolucidaData) {
503
- let items = []
504
- if ('dataset_images' in biolucidaData) {
505
- items.push(
506
- ...Array.from(biolucidaData.dataset_images, (dataset_image) => {
507
- const thumbnailURL = this.getThumbnailURLFromBiolucida(
508
- this.envVars.API_LOCATION,
509
- {
510
- id: dataset_image.image_id,
511
- }
512
- )
513
- const resource = {
514
- share_link: dataset_image.share_link,
515
- id: dataset_image.image_id,
516
- itemId: dataset_image.sourcepkg_id,
517
- }
518
- let action = {
519
- label: capitalise(this.label),
520
- resource: resource,
521
- datasetId: this.datasetId,
522
- title: 'View image',
523
- name: capitalise(this.label),
524
- type: 'Biolucida',
525
- }
526
- return {
527
- id: dataset_image.image_id,
528
- title: `Image`,
529
- type: 'Image',
530
- thumbnail: thumbnailURL,
531
- userData: action,
532
- mimetype: 'image/png',
533
- hideType: true,
534
- }
535
- })
536
- )
537
- }
538
- this.items['Images'] = items
539
- },
540
- },
541
448
  },
542
449
  mounted() {
543
450
  this.ro = new ResizeObserver(this.onResize).observe(this.$el)
@@ -105,10 +105,10 @@
105
105
  trigger="hover"
106
106
  popper-class="filter-help-popover"
107
107
  >
108
- <template #reference>
108
+ <template v-if="entry.helper" #reference>
109
109
  <MapSvgIcon icon="help" class="help" />
110
110
  </template>
111
- <div>
111
+ <div v-if="entry.helper">
112
112
  <strong>Within categories:</strong> OR
113
113
  <br />
114
114
  example: {{ entry.helper.within }}
@@ -362,7 +362,7 @@ export default {
362
362
  })
363
363
 
364
364
  // trigger reactivity only once
365
- Object.assign(this.options, processedOptions);
365
+ Object.assign(this.options, processedOptions)
366
366
  },
367
367
  populateCascader: function () {
368
368
  if (this.entry.options) {
@@ -542,6 +542,13 @@ export default {
542
542
  })
543
543
  return count
544
544
  }
545
+ const found = facet.children.find((item) => {
546
+ return item.label === "Show all"
547
+ })
548
+ if (found) {
549
+ return facet.children.length - 1
550
+ }
551
+
545
552
  return facet.children.length
546
553
  },
547
554
  /**
@@ -64,6 +64,15 @@
64
64
  @connectivity-item-close="onConnectivityItemClose"
65
65
  />
66
66
  </template>
67
+ <template v-else-if="tab.type === 'acupoints' && acupointsInfoList">
68
+ <acupoints-info-search
69
+ :ref="'acupointsTab_' + tab.id"
70
+ :entry="acupointsInfoList"
71
+ @on-acupoints-click="acupointsClicked"
72
+ @acupoints-result="acupointsResult"
73
+ v-show="tab.id === activeTabId"
74
+ />
75
+ </template>
67
76
  <template v-else>
68
77
  <DatasetExplorer
69
78
  class="sidebar-content-container"
@@ -92,6 +101,7 @@ import { ElDrawer as Drawer, ElIcon as Icon } from 'element-plus'
92
101
  import DatasetExplorer from './DatasetExplorer.vue'
93
102
  import EventBus from './EventBus.js'
94
103
  import Tabs from './Tabs.vue'
104
+ import AcupointsInfoSearch from './AcupointsInfoSearch.vue'
95
105
  import AnnotationTool from './AnnotationTool.vue'
96
106
  import ConnectivityExplorer from './ConnectivityExplorer.vue'
97
107
  import { removeShowAllFacets } from '../algolia/utils.js'
@@ -129,9 +139,8 @@ export default {
129
139
  },
130
140
  /**
131
141
  * The environment variables object with
132
- * `API_LOCATION`, `ALGOLIA_KEY`, `ALGOLIA_ID`,
133
- * `ALGOLIA_INDEX`, `PENNSIEVE_API_LOCATION`, `BL_SERVER_URL`,
134
- * `NL_LINK_PREFIX`, `ROOT_URL`
142
+ * `API_LOCATION`, `ALGOLIA_KEY`, `ALGOLIA_ID`, `ALGOLIA_INDEX`,
143
+ * `PENNSIEVE_API_LOCATION`, `BL_SERVER_URL`, `ROOT_URL`
135
144
  */
136
145
  envVars: {
137
146
  type: Object,
@@ -151,6 +160,13 @@ export default {
151
160
  type: Array,
152
161
  default: [],
153
162
  },
163
+ /**
164
+ * The acupoints info to show in sidebar.
165
+ */
166
+ acupointsInfoList: {
167
+ type: Object,
168
+ default: null,
169
+ },
154
170
  /**
155
171
  * The annotation data to show in sidebar.
156
172
  */
@@ -204,6 +220,16 @@ export default {
204
220
  }
205
221
  },
206
222
  methods: {
223
+ /**
224
+ * This event is emitted with a mouse click on acupoint card
225
+ * @arg data
226
+ */
227
+ acupointsClicked: function (data) {
228
+ this.$emit('acupoints-clicked', data)
229
+ },
230
+ acupointsResult: function (data) {
231
+ this.$emit('acupoints-result', data)
232
+ },
207
233
  onConnectivityCollapseChange: function (data) {
208
234
  this.$emit('connectivity-collapse-change', data)
209
235
  },
@@ -295,9 +321,6 @@ export default {
295
321
  datasetExplorerTabRef.openSearch(facets, query);
296
322
  })
297
323
  },
298
- /**
299
- * Get the ref id of the tab by id and type.
300
- */
301
324
  getTabRef: function (id, type, switchTab = false) {
302
325
  const matchedTab = this.tabEntries.filter((tabEntry) => {
303
326
  return (id === undefined || tabEntry.id === id) &&
@@ -407,6 +430,14 @@ export default {
407
430
  updateConnectivityError: function (errorInfo) {
408
431
  EventBus.emit('connectivity-error', errorInfo);
409
432
  },
433
+ openAcupointsSearch: function (term) {
434
+ this.drawerOpen = true
435
+ // Because refs are in v-for, nextTick is needed here
436
+ this.$nextTick(() => {
437
+ const tabRef = this.getTabRef(undefined, 'acupoints', true);
438
+ tabRef.search(term);
439
+ })
440
+ },
410
441
  /**
411
442
  * Store available anatomy facets data for connectivity list component
412
443
  */
@@ -503,6 +534,11 @@ export default {
503
534
  // This should respect the information provided by the property
504
535
  tabEntries: function () {
505
536
  return this.tabs.filter((tab) =>
537
+ (tab.type === "acupoints" &&
538
+ (
539
+ this.acupointsInfoList &&
540
+ Object.keys(this.acupointsInfoList).length > 0
541
+ )) ||
506
542
  tab.type === "datasetExplorer" ||
507
543
  tab.type === "connectivityExplorer" ||
508
544
  (
@@ -565,6 +601,16 @@ export default {
565
601
  this.$emit('connectivity-source-change', payLoad);
566
602
  })
567
603
 
604
+ // Emit acupoints clicked event
605
+ EventBus.on('acupoints-clicked', (payLoad) => {
606
+ this.$emit('acupoints-clicked', payLoad);
607
+ })
608
+
609
+ // Emit acupoints hovered event
610
+ EventBus.on('acupoints-hovered', (payLoad) => {
611
+ this.$emit('acupoints-hovered', payLoad);
612
+ })
613
+
568
614
  // Get available anatomy facets for the connectivity info
569
615
  EventBus.on('available-facets', (payLoad) => {
570
616
  this.availableAnatomyFacets = payLoad.find((facet) => facet.label === 'Anatomical Structure').children
@@ -7,6 +7,8 @@ export {}
7
7
 
8
8
  declare module 'vue' {
9
9
  export interface GlobalComponents {
10
+ AcupointsCard: typeof import('./components/AcupointsCard.vue')['default']
11
+ AcupointsInfoSearch: typeof import('./components/AcupointsInfoSearch.vue')['default']
10
12
  AnnotationTool: typeof import('./components/AnnotationTool.vue')['default']
11
13
  BadgesGroup: typeof import('./components/BadgesGroup.vue')['default']
12
14
  ConnectivityCard: typeof import('./components/ConnectivityCard.vue')['default']
@@ -19,6 +21,8 @@ declare module 'vue' {
19
21
  ElCascader: typeof import('element-plus/es')['ElCascader']
20
22
  ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
21
23
  ElCol: typeof import('element-plus/es')['ElCol']
24
+ ElCollapse: typeof import('element-plus/es')['ElCollapse']
25
+ ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
22
26
  ElDrawer: typeof import('element-plus/es')['ElDrawer']
23
27
  ElDropdown: typeof import('element-plus/es')['ElDropdown']
24
28
  ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
@@ -0,0 +1,94 @@
1
+ async function getReferenceConnectivitiesFromStorage(resource) {
2
+ const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
3
+
4
+ if (flatmapKnowledgeRaw) {
5
+ const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
6
+ const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
7
+ const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
8
+
9
+ if (foundData.length) {
10
+ const featureIds = foundData.map((x) => x.id);
11
+ return featureIds;
12
+ }
13
+ }
14
+ return [];
15
+ }
16
+
17
+ async function getReferenceConnectivitiesByAPI(mapImp, resource, flatmapQueries) {
18
+ const knowledgeSource = getKnowledgeSource(mapImp);
19
+ const sql = `select knowledge from knowledge
20
+ where source="${knowledgeSource}" and
21
+ knowledge like "%${resource}%" order by source desc`;
22
+ console.log(sql)
23
+ const response = await flatmapQueries.flatmapQuery(sql);
24
+ const mappedData = response.values.map((x) => x[0]);
25
+ const parsedData = mappedData.map((x) => JSON.parse(x));
26
+ const featureIds = parsedData.map((x) => x.id);
27
+ return featureIds;
28
+ }
29
+
30
+ function getKnowledgeSource(mapImp) {
31
+ let mapKnowledgeSource = '';
32
+ if (mapImp.provenance?.connectivity) {
33
+ const sckanProvenance = mapImp.provenance.connectivity;
34
+ if ('knowledge-source' in sckanProvenance) {
35
+ mapKnowledgeSource = sckanProvenance['knowledge-source'];
36
+ } else if ('npo' in sckanProvenance) {
37
+ mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
38
+ }
39
+ }
40
+
41
+ return mapKnowledgeSource;
42
+ }
43
+
44
+ function loadAndStoreKnowledge(mapImp, flatmapQueries) {
45
+ const knowledgeSource = getKnowledgeSource(mapImp);
46
+ const sql = `select knowledge from knowledge
47
+ where source="${knowledgeSource}"
48
+ order by source desc`;
49
+ const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
50
+
51
+ if (!flatmapKnowledge) {
52
+ flatmapQueries.flatmapQuery(sql).then((response) => {
53
+ const mappedData = response.values.map(x => x[0]);
54
+ const parsedData = mappedData.map(x => JSON.parse(x));
55
+ sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
56
+ updateFlatmapKnowledgeCache();
57
+ });
58
+ }
59
+ }
60
+
61
+ function updateFlatmapKnowledgeCache() {
62
+ const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
63
+ const now = new Date();
64
+ const expiry = now.getTime() + CACHE_LIFETIME;
65
+
66
+ sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
67
+ }
68
+
69
+ function removeFlatmapKnowledgeCache() {
70
+ const keys = [
71
+ 'flatmap-knowledge',
72
+ 'flatmap-knowledge-expiry',
73
+ ];
74
+ keys.forEach((key) => {
75
+ sessionStorage.removeItem(key);
76
+ });
77
+ }
78
+
79
+ function refreshFlatmapKnowledgeCache() {
80
+ const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
81
+ const now = new Date();
82
+
83
+ if (now.getTime() > expiry) {
84
+ removeFlatmapKnowledgeCache();
85
+ }
86
+ }
87
+
88
+ export {
89
+ getReferenceConnectivitiesFromStorage,
90
+ getReferenceConnectivitiesByAPI,
91
+ loadAndStoreKnowledge,
92
+ getKnowledgeSource,
93
+ refreshFlatmapKnowledgeCache,
94
+ }