@abi-software/map-side-bar 2.8.3-beta.3 → 2.8.3-beta.5

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.8.3-beta.3",
3
+ "version": "2.8.3-beta.5",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -5,7 +5,7 @@
5
5
  @mouseleave="hoverChanged(undefined)"
6
6
  >
7
7
  <template #header>
8
- <div class="header" @mouseleave="hoverChanged(undefined)">
8
+ <div class="header">
9
9
  <el-input
10
10
  class="search-input"
11
11
  placeholder="Search"
@@ -30,10 +30,6 @@
30
30
  >
31
31
  Reset
32
32
  </el-button>
33
- <el-radio-group v-model="filterVisibility">
34
- <el-radio :value="true">Focused</el-radio>
35
- <el-radio :value="false">Contextual</el-radio>
36
- </el-radio-group>
37
33
  </div>
38
34
  </template>
39
35
  <SearchFilters
@@ -82,8 +78,8 @@
82
78
  :availableAnatomyFacets="availableAnatomyFacets"
83
79
  :envVars="envVars"
84
80
  :withCloseButton="true"
85
- @show-connectivity="onShowConnectivity"
86
- @show-reference-connectivities="onShowReferenceConnectivities"
81
+ @show-connectivity="$emit('show-connectivity', $event)"
82
+ @show-reference-connectivities="$emit('show-reference-connectivities', $event)"
87
83
  @connectivity-clicked="onConnectivityClicked"
88
84
  @connectivity-hovered="$emit('connectivity-hovered', $event)"
89
85
  @loaded="onConnectivityInfoLoaded(result)"
@@ -113,6 +109,7 @@ import {
113
109
  ElInput as Input,
114
110
  ElPagination as Pagination,
115
111
  } from "element-plus";
112
+ import EventBus from './EventBus.js'
116
113
  import SearchFilters from "./SearchFilters.vue";
117
114
  import SearchHistory from "./SearchHistory.vue";
118
115
  import ConnectivityCard from "./ConnectivityCard.vue";
@@ -178,11 +175,10 @@ export default {
178
175
  display: "flex",
179
176
  },
180
177
  cascaderIsReady: false,
181
- freezeTimeout: undefined,
182
- freezed: false,
178
+ displayConnectivity: false,
183
179
  initLoading: true,
184
180
  expanded: "",
185
- filterVisibility: true
181
+ expandedData: null,
186
182
  };
187
183
  },
188
184
  computed: {
@@ -202,6 +198,7 @@ export default {
202
198
  watch: {
203
199
  connectivityKnowledge: function (newVal, oldVal) {
204
200
  this.expanded = ""; // reset expanded state
201
+ this.expandedData = null;
205
202
  this.loadingCards = false;
206
203
  if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
207
204
  this.results = newVal;
@@ -211,6 +208,11 @@ export default {
211
208
  if (this.numberOfHits === 1 && !('ready' in this.results[0])) {
212
209
  this.onConnectivityCollapseChange(this.results[0]);
213
210
  }
211
+ if (this.numberOfHits > 0 && ('ready' in this.results[0])) {
212
+ this.$refs.filtersRef.checkShowAllBoxes();
213
+ this.searchInput = '';
214
+ this.filter = [];
215
+ }
214
216
  }
215
217
  },
216
218
  // watch for connectivityEntry changes
@@ -230,29 +232,8 @@ export default {
230
232
  paginatedResults: function () {
231
233
  this.loadingCards = false;
232
234
  },
233
- filterVisibility: function (state) {
234
- this.filterVisibility = state;
235
- this.$emit('filter-visibility', this.filterVisibility);
236
- },
237
235
  },
238
236
  methods: {
239
- freezeHoverChange: function () {
240
- this.freezed = true;
241
- if (this.freezeTimeout) {
242
- clearTimeout(this.freezeTimeout);
243
- }
244
- this.freezeTimeout = setTimeout(() => {
245
- this.freezed = false;
246
- }, 3000)
247
- },
248
- onShowConnectivity: function (data) {
249
- this.freezeHoverChange();
250
- this.$emit('show-connectivity', data);
251
- },
252
- onShowReferenceConnectivities: function (data) {
253
- this.freezeHoverChange();
254
- this.$emit('show-reference-connectivities', data);
255
- },
256
237
  onConnectivityClicked: function (data) {
257
238
  this.searchInput = data.query;
258
239
  this.filter = data.filter;
@@ -260,13 +241,21 @@ export default {
260
241
  },
261
242
  collapseChange:function (data) {
262
243
  this.expanded = this.expanded === data.id ? "" : data.id;
244
+ this.expandedData = this.expanded ? data : null;
245
+ },
246
+ closeConnectivity: function () {
247
+ if (!this.expanded) {
248
+ this.$emit('connectivity-item-close');
249
+ }
263
250
  },
264
251
  onConnectivityCollapseChange: function (data) {
265
252
  // close connectivity event will not trigger emit
266
253
  if (this.connectivityEntry.find(entry => entry.featureId[0] === data.id)) {
267
254
  this.collapseChange(data);
255
+ this.closeConnectivity();
268
256
  } else {
269
257
  this.expanded = "";
258
+ this.expandedData = null;
270
259
  // Make sure to emit the change after the next DOM update
271
260
  this.$nextTick(() => {
272
261
  this.$emit("connectivity-collapse-change", data);
@@ -274,11 +263,15 @@ export default {
274
263
  }
275
264
  },
276
265
  hoverChanged: function (data) {
277
- // disable hover changes when show connectivity is clicked
278
- if (!this.freezed) {
279
- const payload = data ? { ...data, tabType: "connectivity" } : { tabType: "connectivity" };
280
- this.$emit("hover-changed", payload);
266
+ let payload = { tabType: "connectivity" };
267
+
268
+ if (data) {
269
+ payload = {...payload, ...data};
270
+ } else if (this.expandedData) {
271
+ payload = {...payload, ...this.expandedData};
281
272
  }
273
+
274
+ this.$emit("hover-changed", payload);
282
275
  },
283
276
  resetSearch: function () {
284
277
  this.numberOfHits = 0;
@@ -376,6 +369,7 @@ export default {
376
369
  },
377
370
  searchKnowledge: function (filters, query = "") {
378
371
  this.expanded = "";
372
+ this.expandedData = null;
379
373
  this.loadingCards = true;
380
374
  this.scrollToTop();
381
375
  this.$emit("search-changed", {
@@ -426,6 +420,11 @@ export default {
426
420
  mounted: function () {
427
421
  localStorage.removeItem('connectivity-active-view');
428
422
  this.openSearch(this.filter, this.searchInput);
423
+
424
+ EventBus.on('close-connectivity', () => {
425
+ this.expanded = '';
426
+ this.expandedData = null;
427
+ });
429
428
  },
430
429
  };
431
430
  </script>
@@ -496,9 +495,6 @@ export default {
496
495
  }
497
496
 
498
497
  .header {
499
- display: flex;
500
- align-items: center;
501
-
502
498
  .el-button {
503
499
  font-family: inherit;
504
500
 
@@ -506,19 +502,7 @@ export default {
506
502
  &:focus {
507
503
  background: $app-primary-color;
508
504
  box-shadow: -3px 2px 4px #00000040;
509
- color: #ffffff;
510
- }
511
- }
512
-
513
- .el-radio-group {
514
- display: flex;
515
- flex-direction: column;
516
- align-items: flex-start;
517
-
518
- .el-radio {
519
- color: #ffffff;
520
- margin-left: 20px;
521
- height: 20px;
505
+ color: #fff;
522
506
  }
523
507
  }
524
508
  }
@@ -50,13 +50,13 @@
50
50
  :connectivityEntry="connectivityEntry"
51
51
  :availableAnatomyFacets="availableAnatomyFacets"
52
52
  :connectivityFilterOptions="filterOptions"
53
- @filter-visibility="$emit('filter-visibility', $event)"
54
53
  @search-changed="searchChanged(tab.id, $event)"
55
54
  @hover-changed="hoverChanged(tab.id, $event)"
56
55
  @show-connectivity="showConnectivity"
57
56
  @show-reference-connectivities="onShowReferenceConnectivities"
58
57
  @connectivity-hovered="onConnectivityHovered"
59
58
  @connectivity-collapse-change="onConnectivityCollapseChange"
59
+ @connectivity-item-close="onConnectivityItemClose"
60
60
  />
61
61
  </template>
62
62
  <template v-else>
@@ -182,6 +182,14 @@ export default {
182
182
  onConnectivityCollapseChange: function (data) {
183
183
  this.$emit('connectivity-collapse-change', data)
184
184
  },
185
+ /**
186
+ * This event is emitted when
187
+ * the close button of the opened connectivity card
188
+ * in connectivity explorer is clicked.
189
+ */
190
+ onConnectivityItemClose: function () {
191
+ this.$emit('connectivity-item-close');
192
+ },
185
193
  /**
186
194
  * This event is emitted when the mouse hover are changed.
187
195
  * @arg data
@@ -329,6 +337,9 @@ export default {
329
337
  storeAvailableAnatomyFacets: function (availableAnatomyFacets) {
330
338
  localStorage.setItem('available-anatomy-facets', JSON.stringify(availableAnatomyFacets))
331
339
  },
340
+ closeConnectivity: function () {
341
+ EventBus.emit('close-connectivity');
342
+ },
332
343
  },
333
344
  computed: {
334
345
  // This should respect the information provided by the property
@@ -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
+ }