@abi-software/map-side-bar 2.9.1-beta.2 → 2.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "2.9.1-beta.2",
3
+ "version": "2.9.1",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@abi-software/gallery": "^1.1.2",
42
- "@abi-software/map-utilities": "^1.6.1-beta.0",
42
+ "@abi-software/map-utilities": "^1.6.0",
43
43
  "@abi-software/svg-sprite": "^1.0.1",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
45
  "algoliasearch": "^4.10.5",
@@ -22,7 +22,7 @@
22
22
  <el-button
23
23
  link
24
24
  class="el-button-link"
25
- @click="onResetClick"
25
+ @click="openSearch([], '')"
26
26
  size="large"
27
27
  >
28
28
  Reset
@@ -363,10 +363,6 @@ export default {
363
363
  this.openSearch([], '');
364
364
  }
365
365
  },
366
- onResetClick: function () {
367
- this.openSearch([], '');
368
- this.$emit('connectivity-explorer-reset');
369
- },
370
366
  openSearch: function (filter, search = "") {
371
367
  this.searchInput = search;
372
368
  this.resetPageNavigation();
@@ -571,7 +567,6 @@ export default {
571
567
  width: 298px !important;
572
568
  height: 40px;
573
569
  padding-right: 14px;
574
- font-family: inherit;
575
570
 
576
571
  :deep(.el-input__inner) {
577
572
  font-family: inherit;
@@ -277,7 +277,7 @@ export default {
277
277
  return this.entry.destinationsWithDatasets;
278
278
  },
279
279
  resources: function () {
280
- return this.entry.hyperlinks || [];
280
+ return this.entry.hyperlinks;
281
281
  },
282
282
  sckanVersion: function () {
283
283
  return this.entry.knowledgeSource;
@@ -528,17 +528,17 @@ export default {
528
528
  }
529
529
  },
530
530
  getConnectionsFromMap: async function () {
531
- if (this.entry.mapuuid) {
531
+ if (this.entry.mapuuid) {
532
532
  const url =
533
533
  this.flatmapApi +
534
534
  `flatmap/${this.entry.mapuuid}/connectivity/${this.entry.featureId[0]}`;
535
-
535
+
536
536
  try {
537
537
  const response = await fetch(url);
538
538
  if (!response.ok) {
539
539
  throw new Error(`Response status: ${response.status}`);
540
540
  }
541
-
541
+
542
542
  return await response.json();
543
543
  } catch (error) {
544
544
  throw new Error(error);
@@ -63,32 +63,16 @@
63
63
  popper-class="sidebar-cascader-popper"
64
64
  >
65
65
  <template #default="{ node, data }">
66
- <div v-if="isFlatmapConnectionsFilterNode(node)">
67
- <div class="el-input">
68
- <div class="el-input__wrapper">
69
- <input
70
- class="el-input__inner"
71
- :value="searchInputs[node.value]"
72
- @input="searchInputChange($event, node)"
73
- style="width: 100%"
74
- autocomplete="off"
75
- placeholder="Search"
76
- />
66
+ <el-row>
67
+ <el-col :span="4" v-if="hasLineStyles(data)">
68
+ <div class="path-visual" :style="getLineStyles(data)"></div>
69
+ </el-col>
70
+ <el-col :span="20">
71
+ <div :style="getBackgroundStyles(data)">
72
+ {{ data.label }}
77
73
  </div>
78
- </div>
79
- </div>
80
- <div v-else>
81
- <el-row>
82
- <el-col :span="4" v-if="hasLineStyles(data)">
83
- <div class="path-visual" :style="getLineStyles(data)"></div>
84
- </el-col>
85
- <el-col :span="20">
86
- <div :style="getBackgroundStyles(data)">
87
- {{ data.label }}
88
- </div>
89
- </el-col>
90
- </el-row>
91
- </div>
74
+ </el-col>
75
+ </el-row>
92
76
  </template>
93
77
  </el-cascader>
94
78
  <div v-if="showFiltersText" class="filter-default-value">Filters</div>
@@ -215,7 +199,6 @@ export default {
215
199
  },
216
200
  ],
217
201
  presentTags:[],
218
- searchInputs: {},
219
202
  }
220
203
  },
221
204
  setup() {
@@ -271,14 +254,6 @@ export default {
271
254
  )
272
255
  return value
273
256
  },
274
- isFlatmapConnectionsFilterNode: function (node) {
275
- return (
276
- node.pathValues[0].includes('flatmap.connectivity.source') &&
277
- node.pathLabels.includes('Filters') &&
278
- node.isDisabled &&
279
- node.isLeaf
280
- )
281
- },
282
257
  processOptions: function () {
283
258
  // create top level of options in cascader
284
259
  this.options.forEach((facet, i) => {
@@ -298,14 +273,6 @@ export default {
298
273
  })
299
274
  }
300
275
 
301
- if (facet.key.includes('flatmap.connectivity.source')) {
302
- this.options[i].children.unshift({
303
- value: this.createCascaderItemValue('ConnectivityFilters'),
304
- label: 'Filters',
305
- disabled: true,
306
- });
307
- }
308
-
309
276
  // populate second level of options
310
277
  this.options[i].children.forEach((facetItem, j) => {
311
278
  // Format labels except funding program
@@ -682,24 +649,6 @@ export default {
682
649
  this.__expandItem__ = event
683
650
  this.cssMods()
684
651
  },
685
- searchInputChange: function (event, node) {
686
- event.preventDefault();
687
- const { target } = event;
688
- if (target) {
689
- const value = target.value;
690
- const ul = target.closest('.el-cascader-menu__list');
691
- ul.querySelectorAll('.el-cascader-node').forEach((li, index) => {
692
- if (index > 0) {
693
- const content = li.querySelector('.el-cascader-node__label').textContent;
694
- if (content.toLowerCase().includes(value.toLowerCase())) {
695
- li.classList.remove('hide');
696
- } else {
697
- li.classList.add('hide');
698
- }
699
- }
700
- })
701
- }
702
- },
703
652
  numberShownChanged: function (event) {
704
653
  this.$emit('numberPerPage', parseInt(event))
705
654
  },
@@ -1144,36 +1093,6 @@ export default {
1144
1093
  border-color: $app-primary-color;
1145
1094
  }
1146
1095
 
1147
- .sidebar-cascader-popper .el-cascader-menu:last-child .el-cascader-node {
1148
- &.is-disabled {
1149
- border-bottom: 1px solid #e4e7ed;
1150
- padding-bottom: 0.5rem;
1151
- position: sticky;
1152
- top: 0.5rem;
1153
- background-color: white;
1154
- z-index: 20;
1155
- box-shadow: 0px -6px 0px 6px white;
1156
-
1157
- .el-checkbox.is-disabled {
1158
- display: none;
1159
- }
1160
-
1161
- .el-cascader-node__label {
1162
- padding-left: 0;
1163
- padding-right: 0;
1164
- }
1165
-
1166
- // hide show all for connection filters
1167
- + .el-cascader-node {
1168
- display: none;
1169
- }
1170
- }
1171
-
1172
- &.hide {
1173
- display: none;
1174
- }
1175
- }
1176
-
1177
1096
  .filter-help-popover,
1178
1097
  .cascade-tags-popover {
1179
1098
  font-family: 'Asap', sans-serif;
@@ -50,12 +50,11 @@
50
50
  :envVars="envVars"
51
51
  :connectivityEntry="connectivityEntry"
52
52
  :availableAnatomyFacets="availableAnatomyFacets"
53
- :connectivityFilterOptions="filterOptions"
54
53
  @filter-visibility="$emit('filter-visibility', $event)"
54
+ :connectivityFilterOptions="filterOptions"
55
55
  :showVisibilityFilter="showVisibilityFilter"
56
56
  @search-changed="searchChanged(tab.id, $event)"
57
57
  @hover-changed="hoverChanged(tab.id, $event)"
58
- @connectivity-explorer-reset="onConnectivityExplorerReset"
59
58
  @show-connectivity="showConnectivity"
60
59
  @show-reference-connectivities="onShowReferenceConnectivities"
61
60
  @connectivity-hovered="onConnectivityHovered"
@@ -216,12 +215,6 @@ export default {
216
215
  this.activeAnnotationData = data;
217
216
  }
218
217
  },
219
- /**
220
- * This event is emitted after clicking reset button in connectivity explorer
221
- */
222
- onConnectivityExplorerReset: function () {
223
- this.$emit('connectivity-explorer-reset');
224
- },
225
218
  /**
226
219
  * This event is emitted when the show connectivity button is clicked.
227
220
  * @arg featureIds
@@ -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
+ }