@abi-software/map-side-bar 2.12.0-acupoints.2 → 2.12.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.
@@ -1,430 +0,0 @@
1
- <template>
2
- <div v-if="entry" class="main">
3
- <div class="header">
4
- <el-row>
5
- <el-input
6
- class="search-input"
7
- placeholder="Search"
8
- v-model="searchInput"
9
- @keyup="search(searchInput)"
10
- clearable
11
- @clear="clearSearchClicked"
12
- ></el-input>
13
- <el-button
14
- v-show="false"
15
- type="primary"
16
- class="button"
17
- @click="search(searchInput)"
18
- size="large"
19
- >
20
- Search
21
- </el-button>
22
- </el-row>
23
- <el-row>
24
- <span class="filterText">
25
- Curated:&nbsp;&nbsp;
26
- </span>
27
- <el-radio-group v-model="currentFilters['curated']" size="small" class="acuRadioGroup">
28
- <el-radio-button
29
- v-for="(value, key) in curatedFilters"
30
- :key="key"
31
- :label="key"
32
- :value="value"
33
- />
34
- </el-radio-group>
35
- </el-row>
36
- <el-row>
37
- <span class="filterText">
38
- On MRI:&nbsp;&nbsp;
39
- </span>
40
- <el-radio-group v-model="currentFilters['mri']" size="small" class="acuRadioGroup">
41
- <el-radio-button
42
- v-for="(value, key) in mriFilters"
43
- :key="key"
44
- :label="key"
45
- :value="value"
46
- />
47
- </el-radio-group>
48
- </el-row>
49
- </div>
50
- <div class="content scrollbar" ref="content">
51
- <div v-if="paginatedResults.length > 0" v-for="result in paginatedResults" :key="result.Acupoint" class="step-item">
52
- <AcupointsCard
53
- class="dataset-card"
54
- :entry="result"
55
- @mouseenter="hoverChanged(result)"
56
- @mouseleave="hoverChanged(undefined)"
57
- />
58
- </div>
59
- <div v-else class="error-feedback">
60
- No results found - Please change your search / filter criteria.
61
- </div>
62
- <el-pagination
63
- class="pagination"
64
- v-model:current-page="page"
65
- hide-on-single-page
66
- large
67
- layout="prev, pager, next"
68
- :page-size="numberPerPage"
69
- :total="numberOfHits"
70
- @current-change="pageChange"
71
- ></el-pagination>
72
- </div>
73
- </div>
74
- </template>
75
-
76
- <script>
77
- /* eslint-disable no-alert, no-console */
78
- import {
79
- ElButton as Button,
80
- ElCard as Card,
81
- ElRadioButton as RadioButton,
82
- ElRadioGroup as RadioGroup,
83
- ElDrawer as Drawer,
84
- ElIcon as Icon,
85
- ElInput as Input,
86
- ElPagination as Pagination,
87
- ElRow as Row,
88
- } from 'element-plus'
89
- import AcupointsCard from './AcupointsCard.vue'
90
-
91
- export default {
92
- components: {
93
- AcupointsCard,
94
- Button,
95
- Card,
96
- RadioButton,
97
- RadioGroup,
98
- Drawer,
99
- Icon,
100
- Input,
101
- Pagination,
102
- Row
103
- },
104
- name: 'AcupointsInfoSearch',
105
- props: {
106
- entry: {
107
- type: Object,
108
- default: () => {},
109
- },
110
- },
111
- data: function () {
112
- return {
113
- curatedFilters: {
114
- "Yes": "Curated",
115
- "No": "Uncurated",
116
- "Both": "Both"
117
- },
118
- mriFilters: {
119
- "Yes": "On",
120
- "No": "Off",
121
- "Both": "Both"
122
- },
123
- currentFilters: {
124
- curated: "Both",
125
- mri: "Both",
126
- },
127
- previousFilters: {
128
- curated: "Both",
129
- mri: "Both",
130
- },
131
- previousInput: undefined,
132
- results: [],
133
- paginatedResults: [],
134
- searchInput: "",
135
- lastSearch: "",
136
- numberOfHits: 0,
137
- numberPerPage: 10,
138
- page: 1,
139
- }
140
- },
141
- watch: {
142
- "currentFilters.curated": {
143
- handler: function () {
144
- this.search(
145
- this.searchInput,
146
- this.numberPerPage,
147
- this.page
148
- )
149
- },
150
- },
151
- "currentFilters.mri": {
152
- handler: function () {
153
- this.search(
154
- this.searchInput,
155
- this.numberPerPage,
156
- this.page
157
- )
158
- },
159
- },
160
- entry: {
161
- handler: function () {
162
- this.search(
163
- this.searchInput,
164
- this.numberPerPage,
165
- this.page
166
- )
167
- },
168
- immediate: true,
169
- deep: true,
170
- },
171
- },
172
- methods: {
173
- hoverChanged: function (data) {
174
- this.$emit('hover-changed', data)
175
- },
176
- resetSearch: function () {
177
- this.numberOfHits = 0
178
- this.search(this.searchInput)
179
- },
180
- clearSearchClicked: function () {
181
- this.searchInput = '';
182
- this.search("");
183
- },
184
- search: function(input) {
185
- this.results = []
186
- if ((input !== this.previousInput) ||
187
- (this.currentFilters['curated'] !== this.previousFilters['curated']) ||
188
- (this.currentFilters['mri'] !== this.previousFilters['mri'])
189
- ) {
190
- this.previousFilters['curated'] = this.currentFilters['curated'];
191
- this.previousFilters['mri'] = this.currentFilters['mri'];
192
- this.previousInput = this.input
193
- let filteredList = Object.values(this.entry)
194
- if (this.currentFilters['curated'] !== "Both") {
195
- const curated = this.currentFilters['curated'] === "Curated" ? true : false
196
- filteredList = filteredList.filter(
197
- item => (item.Curated ? true : false) === curated)
198
- }
199
- if (this.currentFilters['mri'] !== "Both") {
200
- const curated = this.currentFilters['mri'] === "On" ? true : false
201
- filteredList = filteredList.filter(
202
- item => (item.onMRI ? true : false) === curated)
203
- }
204
- if (input === "") {
205
- this.results = filteredList
206
- } else {
207
- const lowerCase = input.toLowerCase()
208
- for (const value of filteredList) {
209
- const searchFields = [
210
- value["Acupoint"],
211
- value["Synonym"],
212
- value["Chinese Name"],
213
- value["English Name"],
214
- value["Reference"],
215
- value["Indications"],
216
- value["Acupuncture Method"],
217
- value["Vasculature"],
218
- value["Innervation"],
219
- value["Note"],
220
- ];
221
- const allstrings = searchFields.join();
222
- const myJSON = allstrings.toLowerCase();
223
- if (myJSON.includes(lowerCase)) {
224
- this.results.push(value)
225
- }
226
- }
227
- }
228
- }
229
- const start = this.numberPerPage * (this.page - 1)
230
- this.paginatedResults = this.results.slice(start, start + this.numberPerPage)
231
- this.numberOfHits = this.results.length
232
- this.searchInput = input
233
- this.lastSearch = input
234
- },
235
- numberPerPageUpdate: function (val) {
236
- this.numberPerPage = val
237
- this.pageChange(1)
238
- },
239
- pageChange: function (page) {
240
- this.page = page
241
- this.search( this.searchInput)
242
- },
243
- scrollToTop: function () {
244
- if (this.$refs.content) {
245
- this.$refs.content.scroll({ top: 0, behavior: 'smooth' })
246
- }
247
- },
248
- resetPageNavigation: function () {
249
- this.page = 1
250
- },
251
- },
252
- }
253
- </script>
254
-
255
- <style lang="scss" scoped>
256
-
257
- .acuRadioGroup {
258
- padding-top: 8px;
259
- }
260
-
261
- .dataset-card {
262
- position: relative;
263
-
264
- &::before {
265
- content: "";
266
- display: block;
267
- width: calc(100% - 15px);
268
- height: 100%;
269
- position: absolute;
270
- top: 7px;
271
- left: 7px;
272
- border-style: solid;
273
- border-radius: 5px;
274
- border-color: transparent;
275
- }
276
-
277
- &:hover {
278
- &::before {
279
- border-color: var(--el-color-primary);
280
- }
281
- }
282
- }
283
-
284
- .main {
285
- font-size: 14px;
286
- text-align: left;
287
- line-height: 1.5em;
288
- font-family: Asap, sans-serif, Helvetica;
289
- font-weight: 400;
290
- /* outline: thin red solid; */
291
- overflow-y: auto;
292
- scrollbar-width: thin;
293
- min-width: 16rem;
294
- background-color: #f7faff;
295
- height: 100%;
296
- border-left: 1px solid var(--el-border-color);
297
- border-top: 1px solid var(--el-border-color);
298
- display: flex;
299
- flex-direction: column;
300
- gap: 1rem;
301
- padding: 1rem;
302
- }
303
-
304
- .step-item {
305
- font-size: 14px;
306
- margin-bottom: 8px;
307
- text-align: left;
308
- }
309
-
310
- .search-input {
311
- width: 298px !important;
312
- height: 40px;
313
- padding-right: 14px;
314
-
315
- :deep(.el-input__inner) {
316
- font-family: inherit;
317
- }
318
- }
319
-
320
- .header {
321
- .el-button {
322
- font-family: inherit;
323
-
324
- &:hover,
325
- &:focus {
326
- background: $app-primary-color;
327
- box-shadow: -3px 2px 4px #00000040;
328
- color: #fff;
329
- }
330
- }
331
- }
332
-
333
- .pagination {
334
- padding-bottom: 16px;
335
- background-color: white;
336
- padding-left: 95px;
337
- font-weight: bold;
338
- }
339
-
340
- .pagination :deep(button) {
341
- background-color: white !important;
342
- }
343
- .pagination :deep(li) {
344
- background-color: white !important;
345
- }
346
- .pagination :deep(li.is-active) {
347
- color: $app-primary-color;
348
- }
349
-
350
- .error-feedback {
351
- font-family: Asap;
352
- font-size: 14px;
353
- font-style: italic;
354
- padding-top: 15px;
355
- }
356
-
357
- .content-card :deep(.el-card__header) {
358
- background-color: #292b66;
359
- padding: 1rem;
360
- }
361
-
362
- .content-card :deep(.el-card__body) {
363
- background-color: #f7faff;
364
- overflow-y: hidden;
365
- padding: 1rem;
366
- }
367
-
368
- .content {
369
- // width: 515px;
370
- flex: 1 1 auto;
371
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
372
- border: solid 1px #e4e7ed;
373
- background-color: #ffffff;
374
- overflow-y: scroll;
375
- scrollbar-width: thin;
376
- border-radius: var(--el-border-radius-base);
377
- }
378
-
379
- .content :deep(.el-loading-spinner .path) {
380
- stroke: $app-primary-color;
381
- }
382
-
383
- .content :deep(.step-item:first-child .seperator-path) {
384
- display: none;
385
- }
386
-
387
- .content :deep(.step-item:not(:first-child) .seperator-path) {
388
- width: 455px;
389
- height: 0px;
390
- border: solid 1px #e4e7ed;
391
- background-color: #e4e7ed;
392
- }
393
-
394
- .filterText {
395
- margin-top:8px;
396
- }
397
-
398
- .scrollbar::-webkit-scrollbar-track {
399
- border-radius: 10px;
400
- background-color: #f5f5f5;
401
- }
402
-
403
- .scrollbar::-webkit-scrollbar {
404
- width: 12px;
405
- right: -12px;
406
- background-color: #f5f5f5;
407
- }
408
-
409
- .scrollbar::-webkit-scrollbar-thumb {
410
- border-radius: 4px;
411
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
412
- background-color: #979797;
413
- }
414
-
415
- :deep(.el-input__suffix) {
416
- padding-right: 0px;
417
- }
418
-
419
- :deep(.my-drawer) {
420
- background: rgba(0, 0, 0, 0);
421
- box-shadow: none;
422
- }
423
-
424
- .error-feedback {
425
- font-family: Asap;
426
- font-size: 14px;
427
- font-style: italic;
428
- padding-top: 15px;
429
- }
430
- </style>
@@ -1,94 +0,0 @@
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
- }