@abi-software/map-side-bar 2.14.0 → 2.14.1-acupoint.0
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.
- package/dist/map-side-bar.js +9503 -8633
- package/dist/map-side-bar.umd.cjs +65 -62
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/App.vue +28 -1
- package/src/acupoints.js +78 -0
- package/src/components/AcupointsCard.vue +286 -0
- package/src/components/AcupointsInfoSearch.vue +620 -0
- package/src/components/SearchFilters.vue +10 -3
- package/src/components/SideBar.vue +51 -3
- package/src/components.d.ts +4 -0
- package/src/services/flatmapKnowledge.js +94 -0
- package/src/services/flatmapQueries.js +498 -0
|
@@ -65,6 +65,15 @@
|
|
|
65
65
|
@connectivity-item-close="onConnectivityItemClose"
|
|
66
66
|
/>
|
|
67
67
|
</template>
|
|
68
|
+
<template v-else-if="tab.type === 'acupoints' && acupointsInfoList">
|
|
69
|
+
<acupoints-info-search
|
|
70
|
+
:ref="'acupointsTab_' + tab.id"
|
|
71
|
+
:entry="acupointsInfoList"
|
|
72
|
+
@on-acupoints-click="acupointsClicked"
|
|
73
|
+
@acupoints-result="acupointsResult"
|
|
74
|
+
v-show="tab.id === activeTabId"
|
|
75
|
+
/>
|
|
76
|
+
</template>
|
|
68
77
|
<template v-else>
|
|
69
78
|
<DatasetExplorer
|
|
70
79
|
class="sidebar-content-container"
|
|
@@ -93,6 +102,7 @@ import { ElDrawer as Drawer, ElIcon as Icon } from 'element-plus'
|
|
|
93
102
|
import DatasetExplorer from './DatasetExplorer.vue'
|
|
94
103
|
import EventBus from './EventBus.js'
|
|
95
104
|
import Tabs from './Tabs.vue'
|
|
105
|
+
import AcupointsInfoSearch from './AcupointsInfoSearch.vue'
|
|
96
106
|
import AnnotationTool from './AnnotationTool.vue'
|
|
97
107
|
import ConnectivityExplorer from './ConnectivityExplorer.vue'
|
|
98
108
|
import { removeShowAllFacets } from '../algolia/utils.js'
|
|
@@ -151,6 +161,13 @@ export default {
|
|
|
151
161
|
type: Array,
|
|
152
162
|
default: [],
|
|
153
163
|
},
|
|
164
|
+
/**
|
|
165
|
+
* The acupoints info to show in sidebar.
|
|
166
|
+
*/
|
|
167
|
+
acupointsInfoList: {
|
|
168
|
+
type: Object,
|
|
169
|
+
default: null,
|
|
170
|
+
},
|
|
154
171
|
/**
|
|
155
172
|
* The annotation data to show in sidebar.
|
|
156
173
|
*/
|
|
@@ -208,6 +225,16 @@ export default {
|
|
|
208
225
|
}
|
|
209
226
|
},
|
|
210
227
|
methods: {
|
|
228
|
+
/**
|
|
229
|
+
* This event is emitted with a mouse click on acupoint card
|
|
230
|
+
* @arg data
|
|
231
|
+
*/
|
|
232
|
+
acupointsClicked: function (data) {
|
|
233
|
+
this.$emit('acupoints-clicked', data)
|
|
234
|
+
},
|
|
235
|
+
acupointsResult: function (data) {
|
|
236
|
+
this.$emit('acupoints-result', data)
|
|
237
|
+
},
|
|
211
238
|
onConnectivityCollapseChange: function (data) {
|
|
212
239
|
this.$emit('connectivity-collapse-change', data)
|
|
213
240
|
},
|
|
@@ -277,6 +304,15 @@ export default {
|
|
|
277
304
|
toggleDrawer: function () {
|
|
278
305
|
this.drawerOpen = !this.drawerOpen
|
|
279
306
|
},
|
|
307
|
+
openAcupointsSearch: function (facets, query) {
|
|
308
|
+
this.drawerOpen = true
|
|
309
|
+
// Because refs are in v-for, nextTick is needed here
|
|
310
|
+
this.$nextTick(() => {
|
|
311
|
+
console.log("broken")
|
|
312
|
+
const acupointTabRef = this.getTabRef(undefined, 'acupoints', true);
|
|
313
|
+
acupointTabRef.openSearch(facets, query)
|
|
314
|
+
})
|
|
315
|
+
},
|
|
280
316
|
openConnectivitySearch: function (facets, query) {
|
|
281
317
|
this.drawerOpen = true;
|
|
282
318
|
// Because refs are in v-for, nextTick is needed here
|
|
@@ -299,9 +335,6 @@ export default {
|
|
|
299
335
|
datasetExplorerTabRef.openSearch(facets, query);
|
|
300
336
|
})
|
|
301
337
|
},
|
|
302
|
-
/**
|
|
303
|
-
* Get the ref id of the tab by id and type.
|
|
304
|
-
*/
|
|
305
338
|
getTabRef: function (id, type, switchTab = false) {
|
|
306
339
|
const matchedTab = this.tabEntries.filter((tabEntry) => {
|
|
307
340
|
return (id === undefined || tabEntry.id === id) &&
|
|
@@ -507,6 +540,11 @@ export default {
|
|
|
507
540
|
// This should respect the information provided by the property
|
|
508
541
|
tabEntries: function () {
|
|
509
542
|
return this.tabs.filter((tab) =>
|
|
543
|
+
(tab.type === "acupoints" &&
|
|
544
|
+
(
|
|
545
|
+
this.acupointsInfoList &&
|
|
546
|
+
Object.keys(this.acupointsInfoList).length > 0
|
|
547
|
+
)) ||
|
|
510
548
|
tab.type === "datasetExplorer" ||
|
|
511
549
|
tab.type === "connectivityExplorer" ||
|
|
512
550
|
(
|
|
@@ -572,6 +610,16 @@ export default {
|
|
|
572
610
|
this.$emit('show-connectivity-graph', payLoad);
|
|
573
611
|
})
|
|
574
612
|
|
|
613
|
+
// Emit acupoints clicked event
|
|
614
|
+
EventBus.on('acupoints-clicked', (payLoad) => {
|
|
615
|
+
this.$emit('acupoints-clicked', payLoad);
|
|
616
|
+
})
|
|
617
|
+
|
|
618
|
+
// Emit acupoints hovered event
|
|
619
|
+
EventBus.on('acupoints-hovered', (payLoad) => {
|
|
620
|
+
this.$emit('acupoints-hovered', payLoad);
|
|
621
|
+
})
|
|
622
|
+
|
|
575
623
|
// Get available anatomy facets for the connectivity info
|
|
576
624
|
EventBus.on('available-facets', (payLoad) => {
|
|
577
625
|
this.availableAnatomyFacets = payLoad.find((facet) => facet.label === 'Anatomical Structure').children
|
package/src/components.d.ts
CHANGED
|
@@ -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
|
+
}
|