@abi-software/map-side-bar 2.7.3-beta.5 → 2.7.3-beta.7

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.7.3-beta.5",
3
+ "version": "2.7.3-beta.7",
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.5.0-beta.2",
42
+ "@abi-software/map-utilities": "^1.5.0-beta.3",
43
43
  "@abi-software/svg-sprite": "^1.0.1",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
45
  "algoliasearch": "^4.10.5",
@@ -48,7 +48,7 @@ export default {
48
48
  },
49
49
  cardClicked: function (data) {
50
50
  if (!this.loading) {
51
- this.$emit("connectivity-explorer-clicked", data);
51
+ this.$emit("connectivity-card-clicked", data);
52
52
  }
53
53
  },
54
54
  },
@@ -66,7 +66,7 @@
66
66
  <ConnectivityCard
67
67
  class="dataset-card"
68
68
  :entry="result"
69
- @connectivity-explorer-clicked="onConnectivityExplorerClicked"
69
+ @connectivity-card-clicked="onConnectivityExplorerClicked"
70
70
  />
71
71
  <ConnectivityInfo
72
72
  v-if="expanded === result.id"
@@ -80,7 +80,7 @@
80
80
  @connectivity-clicked="onConnectivityClicked"
81
81
  @connectivity-hovered="$emit('connectivity-hovered', $event)"
82
82
  @loaded="onConnectivityInfoLoaded(result)"
83
- @close-connectivity="toggleConnectivityOpen(result)"
83
+ @close-connectivity="closeConnectivity(result)"
84
84
  />
85
85
  </div>
86
86
  <el-pagination
@@ -212,7 +212,10 @@ export default {
212
212
  },
213
213
  },
214
214
  watch: {
215
- connectivityKnowledge: function (value) {
215
+ connectivityKnowledge: function (value, oldValue) {
216
+ if (JSON.stringify(value) === JSON.stringify(oldValue)) {
217
+ return;
218
+ }
216
219
  this.expanded = "";
217
220
  this.results = value.map((item) => {
218
221
  return {
@@ -239,19 +242,20 @@ export default {
239
242
  this.filters = data.filter;
240
243
  this.searchAndFilterUpdate();
241
244
  },
242
- toggleConnectivityOpen: function (data) {
243
- if (this.expanded === data.id) {
244
- this.expanded = "";
245
- } else {
246
- this.expanded = data.id;
247
- }
245
+ openConnectivity: function (data) {
246
+ this.expanded = data.id;
247
+ },
248
+ closeConnectivity: function (data) {
249
+ this.expanded = '';
248
250
  },
249
251
  onConnectivityExplorerClicked: function (data) {
250
- data.loaded = false; // reset loading
251
- this.toggleConnectivityOpen(data);
252
- const entry = this.connectivityEntry.filter(entry => entry.featureId[0] === data.id);
253
- if (entry.length === 0) {
254
- this.$emit("connectivity-explorer-clicked", data);
252
+ if (this.expanded !== data.id) {
253
+ data.loaded = false; // reset loading
254
+ this.openConnectivity(data);
255
+ const entry = this.connectivityEntry.filter(entry => entry.featureId[0] === data.id);
256
+ if (entry.length === 0) {
257
+ this.$emit("connectivity-explorer-clicked", data);
258
+ }
255
259
  }
256
260
  },
257
261
  hoverChanged: function (data) {
@@ -475,7 +479,7 @@ export default {
475
479
  }
476
480
 
477
481
  &.is-active {
478
- max-height: 1800px;
482
+ max-height: 9999px;
479
483
  background-color: #f7faff;
480
484
  border: 2px solid $app-primary-color;
481
485
  border-radius: var(--el-border-radius-base);
@@ -39,9 +39,7 @@
39
39
  <div class="title-content">
40
40
  <div class="block" v-if="entry.title">
41
41
  <div class="title">
42
- <span @click="onConnectivityClicked(entry.title)">
43
- {{ capitalise(entry.title) }}
44
- </span>
42
+ <span>{{ capitalise(entry.title) }}</span>
45
43
  <template v-if="entry.featuresAlert">
46
44
  <el-popover
47
45
  width="250"
@@ -58,6 +56,7 @@
58
56
  </el-popover>
59
57
  </template>
60
58
  </div>
59
+ <div class="subtitle"><strong>id: </strong>{{ entry.featureId[0] }}</div>
61
60
  <div v-if="hasProvenanceTaxonomyLabel" class="subtitle">
62
61
  {{ provSpeciesDescription }}
63
62
  </div>
@@ -105,10 +104,7 @@
105
104
  </div>
106
105
  </div>
107
106
 
108
- <div
109
- class="content-container population-display"
110
- :class="dualConnectionSource ? 'population-display-toolbar' : ''"
111
- >
107
+ <div class="content-container population-display">
112
108
  <div class="block attribute-title-container">
113
109
  <span class="attribute-title">Population Display</span>
114
110
  <el-popover
@@ -128,27 +124,23 @@
128
124
  </el-popover>
129
125
  </div>
130
126
  <div class="block buttons-row">
131
- <div v-if="dualConnectionSource">
132
- <span>Connectivity from:</span>
133
- <el-radio-group v-model="connectivitySource" @change="onConnectivitySourceChange">
134
- <el-radio value="map">Map</el-radio>
135
- <el-radio value="sckan">SCKAN</el-radio>
136
- </el-radio-group>
137
- </div>
138
- <div>
139
- <el-button
140
- :class="activeView === 'listView' ? 'button' : 'el-button-secondary'"
141
- @click="switchConnectivityView('listView')"
142
- >
143
- List view
144
- </el-button>
145
- <el-button
146
- :class="activeView === 'graphView' ? 'button' : 'el-button-secondary'"
147
- @click="switchConnectivityView('graphView')"
148
- >
149
- Graph view
150
- </el-button>
151
- </div>
127
+ <span>Connectivity from:</span>
128
+ <el-radio-group v-model="connectivitySource" @change="onConnectivitySourceChange">
129
+ <el-radio value="map">Map</el-radio>
130
+ <el-radio value="sckan">SCKAN</el-radio>
131
+ </el-radio-group>
132
+ <el-button
133
+ :class="activeView === 'listView' ? 'button' : 'el-button-secondary'"
134
+ @click="switchConnectivityView('listView')"
135
+ >
136
+ List view
137
+ </el-button>
138
+ <el-button
139
+ :class="activeView === 'graphView' ? 'button' : 'el-button-secondary'"
140
+ @click="switchConnectivityView('graphView')"
141
+ >
142
+ Graph view
143
+ </el-button>
152
144
  </div>
153
145
  </div>
154
146
 
@@ -180,8 +172,8 @@
180
172
  :mapServer="flatmapApi"
181
173
  :sckanVersion="sckanVersion"
182
174
  :connectivityFromMap="connectivityFromMap"
175
+ :connectivityError="connectivityError"
183
176
  @tap-node="onTapNode"
184
- ref="connectivityGraphRef"
185
177
  />
186
178
  </template>
187
179
  </div>
@@ -229,8 +221,6 @@ const capitalise = function (str) {
229
221
  return ''
230
222
  }
231
223
 
232
- const ERROR_TIMEOUT = 3000; // 3 seconds
233
-
234
224
  export default {
235
225
  name: 'ConnectivityInfo',
236
226
  components: {
@@ -272,11 +262,9 @@ export default {
272
262
  entryIndex: 0,
273
263
  updatedCopyContent: '',
274
264
  activeView: 'listView',
275
- timeoutID: undefined,
276
265
  connectivityLoading: false,
277
- dualConnectionSource: false,
278
266
  connectivitySource: 'sckan',
279
- connectivityError: null,
267
+ connectivityError: {},
280
268
  graphViewLoaded: false,
281
269
  connectivityFromMap: null,
282
270
  };
@@ -355,16 +343,19 @@ export default {
355
343
  handler: function (newVal, oldVal) {
356
344
  if (newVal !== oldVal) {
357
345
  this.connectivityLoading = true;
358
- this.activeView = localStorage.getItem('connectivity-active-view') || this.activeView;
346
+ this.activeView =
347
+ localStorage.getItem('connectivity-active-view') ||
348
+ this.activeView;
359
349
  if (this.activeView === 'graphView') {
360
350
  this.graphViewLoaded = true;
361
351
  }
362
-
363
- this.checkAndUpdateDualConnection();
364
352
  this.connectivitySource = this.entry.connectivitySource;
365
353
  this.updateGraphConnectivity();
366
354
  this.connectivityLoading = false;
367
- this.$emit('loaded');
355
+ // only emit to scroll when entire entry content changes
356
+ if (!oldVal || newVal?.featureId[0] !== oldVal?.featureId[0]) {
357
+ this.$emit('loaded');
358
+ }
368
359
  }
369
360
  },
370
361
  },
@@ -546,31 +537,9 @@ export default {
546
537
  this.$emit('connectivity-hovered', payload);
547
538
  },
548
539
  onConnectivityClicked: function (label) {
549
- const payload = {
550
- query: label,
551
- filter: []
552
- };
540
+ const payload = { query: label, filter: [] };
553
541
  this.$emit('connectivity-clicked', payload);
554
542
  },
555
- getErrorConnectivities: function (errorData) {
556
- const errorDataToEmit = [...new Set(errorData)];
557
- let errorConnectivities = '';
558
-
559
- errorDataToEmit.forEach((connectivity, i) => {
560
- const { label } = connectivity;
561
- errorConnectivities += (i === 0) ? capitalise(label) : label;
562
-
563
- if (errorDataToEmit.length > 1) {
564
- if ((i + 2) === errorDataToEmit.length) {
565
- errorConnectivities += ' and ';
566
- } else if ((i + 1) < errorDataToEmit.length) {
567
- errorConnectivities += ', ';
568
- }
569
- }
570
- });
571
-
572
- return errorConnectivities;
573
- },
574
543
  /**
575
544
  * Function to show error message.
576
545
  * `errorInfo` includes `errorData` array (optional) for error connectivities
@@ -579,33 +548,16 @@ export default {
579
548
  */
580
549
  getConnectivityError: function (errorInfo) {
581
550
  const { errorData, errorMessage } = errorInfo;
582
- const errorConnectivities = this.getErrorConnectivities(errorData);
551
+ const errorConnectivities = errorData
552
+ .map((connectivity) => capitalise(connectivity.label))
553
+ .join(', ')
554
+ .replace(/, ([^,]*)$/, ' and $1');
583
555
 
584
556
  return {
585
557
  errorConnectivities,
586
558
  errorMessage,
587
559
  };
588
560
  },
589
- pushConnectivityError: function (errorInfo) {
590
- const connectivityError = this.getConnectivityError(errorInfo);
591
- const connectivityGraphRef = this.$refs.connectivityGraphRef;
592
-
593
- // error for graph view
594
- if (connectivityGraphRef) {
595
- connectivityGraphRef.showErrorMessage(connectivityError);
596
- }
597
-
598
- // error for list view
599
- this.connectivityError = {...connectivityError};
600
-
601
- if (this.timeoutID) {
602
- clearTimeout(this.timeoutID);
603
- }
604
-
605
- this.timeoutID = setTimeout(() => {
606
- this.connectivityError = null;
607
- }, ERROR_TIMEOUT);
608
- },
609
561
  onConnectivitySourceChange: function (connectivitySource) {
610
562
  const { featureId } = this.entry;
611
563
 
@@ -615,7 +567,6 @@ export default {
615
567
  this.graphViewLoaded = false;
616
568
  }
617
569
 
618
- this.checkAndUpdateDualConnection();
619
570
  this.updateGraphConnectivity();
620
571
 
621
572
  EventBus.emit('connectivity-source-change', {
@@ -626,7 +577,11 @@ export default {
626
577
  updateGraphConnectivity: function () {
627
578
  if (this.connectivitySource === "map") {
628
579
  this.getConnectionsFromMap().then((response) => {
629
- this.connectivityFromMap = response;
580
+ // show sckan source graph if map source not exist
581
+ this.connectivityFromMap = null;
582
+ if (response?.connectivity?.length) {
583
+ this.connectivityFromMap = response;
584
+ }
630
585
  this.connectivityLoading = false;
631
586
  });
632
587
  } else {
@@ -658,22 +613,13 @@ export default {
658
613
  closeConnectivity: function () {
659
614
  this.$emit('close-connectivity');
660
615
  },
661
- checkAndUpdateDualConnection: async function () {
662
- const response = await this.getConnectionsFromMap()
663
-
664
- if (response?.connectivity?.length) {
665
- this.dualConnectionSource = true;
666
- } else {
667
- this.dualConnectionSource = false;
668
- this.connectivitySource = 'sckan';
669
- }
670
- },
671
616
  },
672
617
  mounted: function () {
673
618
  this.updatedCopyContent = this.getUpdateCopyContent();
674
619
 
675
- EventBus.on('connectivity-graph-error', (errorInfo) => {
676
- this.pushConnectivityError(errorInfo);
620
+ EventBus.on('connectivity-error', (errorInfo) => {
621
+ const connectivityError = this.getConnectivityError(errorInfo);
622
+ this.connectivityError = { ...connectivityError };
677
623
  });
678
624
  },
679
625
  }
@@ -706,17 +652,11 @@ export default {
706
652
 
707
653
  .title {
708
654
  text-align: left;
709
- // width: 16em;
710
655
  line-height: 1.3em !important;
711
656
  font-size: 18px;
712
- // font-family: Helvetica;
713
657
  font-weight: bold;
714
658
  padding-bottom: 8px;
715
659
  color: $app-primary-color;
716
-
717
- span:hover {
718
- cursor: pointer;
719
- }
720
660
  }
721
661
 
722
662
  .block + .block {
@@ -895,17 +835,15 @@ export default {
895
835
  border-bottom: 1px solid $app-primary-color;
896
836
  padding-bottom: 0.5rem !important;
897
837
 
898
- &.population-display-toolbar {
899
- flex-direction: column !important;
900
- align-items: start;
838
+ flex-direction: column !important;
839
+ align-items: start;
901
840
 
902
- .buttons-row {
903
- display: flex;
904
- flex-direction: row;
905
- align-items: center;
906
- justify-content: space-between;
907
- width: 100%;
908
- }
841
+ .buttons-row {
842
+ display: flex;
843
+ flex-direction: row;
844
+ align-items: center;
845
+ justify-content: space-between;
846
+ width: 100%;
909
847
  }
910
848
 
911
849
  .el-radio {
@@ -308,8 +308,8 @@ export default {
308
308
  * To receive error message for connectivity graph
309
309
  * @param {String} errorMessage
310
310
  */
311
- updateConnectivityGraphError: function (errorInfo) {
312
- EventBus.emit('connectivity-graph-error', errorInfo);
311
+ updateConnectivityError: function (errorInfo) {
312
+ EventBus.emit('connectivity-error', errorInfo);
313
313
  },
314
314
  /**
315
315
  * Store available anatomy facets data for connectivity list component
package/vite.config.js CHANGED
@@ -38,11 +38,12 @@ export default defineConfig({
38
38
  fileName: 'map-side-bar',
39
39
  },
40
40
  rollupOptions: {
41
- external: ["vue", "@abi-software/map-utilities"],
41
+ external: ["vue", "@abi-software/map-utilities", "@element-plus/icons-vue"],
42
42
  output: {
43
43
  globals: {
44
44
  vue: "Vue",
45
- "@abi-software/map-utilities": "@abi-software/map-utilities"
45
+ "@abi-software/map-utilities": "@abi-software/map-utilities",
46
+ "@element-plus/icons-vue": "@element-plus/icons-vue"
46
47
  },
47
48
  },
48
49
  },
@@ -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
- }