@abi-software/map-side-bar 2.7.2-beta.1 → 2.7.2-beta.3

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.2-beta.1",
3
+ "version": "2.7.2-beta.3",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
package/src/App.vue CHANGED
@@ -25,13 +25,14 @@
25
25
  :visible="sideBarVisibility"
26
26
  :annotationEntry="annotationEntry"
27
27
  :createData="createData"
28
- :connectivityInfo="connectivityInput"
28
+ :connectivityEntry="connectivityEntry"
29
29
  :connectivityKnowledge="connectivityKnowledge"
30
30
  @search-changed="searchChanged($event)"
31
31
  @hover-changed="hoverChanged($event)"
32
32
  @connectivity-clicked="openConnectivitySearch"
33
33
  @connectivity-hovered="onConnectivityHovered"
34
34
  @actionClick="action"
35
+ @connectivity-explorer-clicked="onConnectivityExplorerClicked"
35
36
  />
36
37
  </div>
37
38
  </template>
@@ -39,12 +40,9 @@
39
40
  <script>
40
41
  /* eslint-disable no-alert, no-console */
41
42
  // optionally import default styles
42
- import { markRaw } from "vue";
43
43
  import SideBar from './components/SideBar.vue'
44
44
  import EventBus from './components/EventBus.js'
45
45
  import exampleConnectivityInput from './exampleConnectivityInput.js'
46
- // import { FlatmapQueries } from "@abi-software/map-utilities/src/services/flatmapQueries.js";
47
- // import { getKnowledgeSource, loadAndStoreKnowledge } from "@abi-software/map-utilities/src/services/flatmapKnowledge.js";
48
46
 
49
47
 
50
48
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
@@ -138,7 +136,7 @@ export default {
138
136
  ROOT_URL: import.meta.env.VITE_APP_ROOT_URL,
139
137
  FLATMAPAPI_LOCATION: import.meta.env.VITE_FLATMAPAPI_LOCATION,
140
138
  },
141
- connectivityInput: exampleConnectivityInput,
139
+ connectivityEntry: {},
142
140
  createData: {
143
141
  toBeConfirmed: false,
144
142
  points: [],
@@ -156,11 +154,7 @@ export default {
156
154
  }
157
155
  },
158
156
  methods: {
159
- loadConnectivityKnowledge: async function (flatmap) {
160
- // const sckanVersion = getKnowledgeSource(flatmap);
161
- // const flatmapQueries = markRaw(new FlatmapQueries());
162
- // flatmapQueries.initialise(this.envVars.FLATMAPAPI_LOCATION);
163
- // const knowledge = await loadAndStoreKnowledge(flatmap, flatmapQueries);
157
+ loadConnectivityKnowledge: async function () {
164
158
  const sql = `select knowledge from knowledge
165
159
  where source="${this.sckanVersion}"
166
160
  order by source desc`;
@@ -173,7 +167,7 @@ export default {
173
167
  });
174
168
  this.connectivityKnowledge = this.flatmapKnowledge;
175
169
  },
176
- connectivityQueryFilter: async function (flatmap, payload) {
170
+ connectivityQueryFilter: async function (payload) {
177
171
  let results = this.flatmapKnowledge;
178
172
  if (payload.type === "query-update") {
179
173
  if (this.query !== payload.value) this.target = [];
@@ -187,18 +181,11 @@ export default {
187
181
  this.target = payload.data;
188
182
  }
189
183
  if (this.query) {
190
- let flag = "", order = [], suggestions = [], paths = [];
191
- // this.searchSuggestions(this.query, suggestions);
192
- // const labels = [...new Set(suggestions)];
184
+ let flag = "", order = [], paths = [];
193
185
  const labels = ['neuron type aacar 11'];
194
186
  flag = 'label';
195
187
  order = labels;
196
188
  if (labels.length === 1) {
197
- // const options = {
198
- // type: this.filter.map(f => f.facet.toLowerCase()),
199
- // target: this.target.map(d => d.id),
200
- // };
201
- // paths = await flatmap.retrieveConnectedPaths(this.query, options);
202
189
  paths =['ilxtr:neuron-type-aacar-11', 'ilxtr:neuron-type-bolew-unbranched-11'];
203
190
  flag = 'id';
204
191
  order = [this.query, ...paths.filter(item => item !== this.query)];
@@ -212,9 +199,11 @@ export default {
212
199
  console.log('hoverChanged', data)
213
200
  },
214
201
  searchChanged: function (data) {
215
- console.log(data)
216
- if (data.id === 4) {
217
- this.connectivityQueryFilter({}, data)
202
+ if (!this.flatmapKnowledge.length) {
203
+ this.loadConnectivityKnowledge();
204
+ }
205
+ if (data.id === 2) {
206
+ this.connectivityQueryFilter(data)
218
207
  }
219
208
  },
220
209
  // For connectivity input actions
@@ -354,6 +343,9 @@ export default {
354
343
  const query = entry ? entry.query : 'ilxtr:neuron-type-aacar-5'
355
344
  const filter = entry ? entry.filter : []
356
345
  this.$refs.sideBar.openConnectivitySearch(filter, query)
346
+ },
347
+ onConnectivityExplorerClicked: function () {
348
+ this.connectivityEntry = {...exampleConnectivityInput}
357
349
  }
358
350
  },
359
351
  mounted: async function () {
@@ -364,9 +356,6 @@ export default {
364
356
  EventBus.on('datalink-clicked', (payLoad) => {
365
357
  console.log('datalink-clicked', payLoad)
366
358
  });
367
- setTimeout(()=>{
368
- this.loadConnectivityKnowledge({ 'provenance': { 'connectivity': { 'knowledge-source': this.sckanVersion } } });
369
- }, 2000)
370
359
  },
371
360
  }
372
361
  </script>
@@ -2,32 +2,26 @@
2
2
  <div class="connectivity-card-container" ref="container">
3
3
  <div class="connectivity-card" ref="card">
4
4
  <div class="seperator-path"></div>
5
- <div class="card">
6
- <div class="title" @click="cardClicked(entry)">{{ entry.label }}</div>
5
+ <div class="card" @click="cardClicked(entry)">
6
+ <div class="title">{{ entry.label }}</div>
7
7
  <template v-for="field in displayFields" :key="field">
8
8
  <div class="details" v-if="entry[field]">
9
9
  <strong>{{ field }}:</strong> {{ entry[field] }}
10
10
  </div>
11
11
  </template>
12
- <el-button @click="cardClicked(entry)" size="small" class="button">
13
- View connectivity
14
- </el-button>
15
12
  </div>
16
13
  </div>
17
14
  </div>
18
15
  </template>
19
16
 
20
17
  <script>
21
- /* eslint-disable no-alert, no-console */
22
- import EventBus from "./EventBus.js";
23
-
24
18
  export default {
19
+ name: "ConnectivityCard",
25
20
  data() {
26
21
  return {
27
- displayFields: ["label", "id"],
22
+ displayFields: ["id"],
28
23
  };
29
24
  },
30
- name: "ConnectivityCard",
31
25
  props: {
32
26
  /**
33
27
  * Object containing information for
@@ -40,7 +34,7 @@ export default {
40
34
  },
41
35
  methods: {
42
36
  cardClicked: function (data) {
43
- EventBus.emit("connectivity-explorer-clicked", data);
37
+ this.$emit("connectivity-explorer-clicked", data);
44
38
  },
45
39
  },
46
40
  };
@@ -50,12 +44,13 @@ export default {
50
44
  .connectivity-card {
51
45
  padding-left: 5px;
52
46
  position: relative;
53
- min-height: 8.5rem;
47
+ min-height: 5rem;
54
48
  }
55
49
 
56
50
  .card {
57
51
  padding-top: 18px;
58
52
  padding-left: 6px;
53
+ cursor: pointer;
59
54
  }
60
55
 
61
56
  .title {
@@ -63,7 +58,6 @@ export default {
63
58
  font-weight: bold;
64
59
  line-height: 1.5;
65
60
  letter-spacing: 1.05px;
66
- cursor: pointer;
67
61
  }
68
62
 
69
63
  .details {
@@ -72,6 +66,7 @@ export default {
72
66
  }
73
67
 
74
68
  .button {
69
+ margin-right: 3.5rem;
75
70
  font-family: Asap;
76
71
  font-size: 14px;
77
72
  font-weight: normal;
@@ -31,6 +31,11 @@
31
31
  @loading="filtersLoading"
32
32
  @cascaderReady="cascaderReady"
33
33
  ></SearchFilters>
34
+ <SearchHistory
35
+ ref="searchHistory"
36
+ localStorageKey="sparc.science-connectivity-search-history"
37
+ @search="searchHistorySearch"
38
+ ></SearchHistory>
34
39
  <div class="content scrollbar" v-loading="loadingCards" ref="content">
35
40
  <div class="error-feedback" v-if="results.length === 0 && !loadingCards">
36
41
  No results found - Please change your search / filter criteria.
@@ -43,9 +48,26 @@
43
48
  <ConnectivityCard
44
49
  class="dataset-card"
45
50
  :entry="result"
51
+ @connectivity-explorer-clicked="onConnectivityExplorerClicked"
46
52
  @mouseenter="hoverChanged(result)"
47
53
  @mouseleave="hoverChanged(undefined)"
48
54
  />
55
+ <ConnectivityInfo
56
+ v-show="
57
+ Object.keys(connectivityEntry).length > 0 &&
58
+ result.id === connectivityEntry.featureId[0] &&
59
+ displayConnectivity
60
+ "
61
+ :entry="connectivityEntry"
62
+ :availableAnatomyFacets="availableAnatomyFacets"
63
+ :envVars="envVars"
64
+ @show-connectivity="$emit('show-connectivity', $event)"
65
+ @show-reference-connectivities="
66
+ $emit('show-reference-connectivities', $event)
67
+ "
68
+ @connectivity-clicked="onConnectivityClicked"
69
+ @connectivity-hovered="$emit('connectivity-hovered', $event)"
70
+ />
49
71
  </div>
50
72
  <el-pagination
51
73
  class="pagination"
@@ -71,7 +93,9 @@ import {
71
93
  ElPagination as Pagination,
72
94
  } from "element-plus";
73
95
  import SearchFilters from "./SearchFilters.vue";
96
+ import SearchHistory from "./SearchHistory.vue";
74
97
  import ConnectivityCard from "./ConnectivityCard.vue";
98
+ import ConnectivityInfo from "./ConnectivityInfo.vue";
75
99
 
76
100
  var initial_state = {
77
101
  filters: [],
@@ -89,7 +113,9 @@ var initial_state = {
89
113
  export default {
90
114
  components: {
91
115
  SearchFilters,
116
+ SearchHistory,
92
117
  ConnectivityCard,
118
+ ConnectivityInfo,
93
119
  Button,
94
120
  Card,
95
121
  Icon,
@@ -110,6 +136,14 @@ export default {
110
136
  type: Object,
111
137
  default: () => {},
112
138
  },
139
+ connectivityEntry: {
140
+ type: Object,
141
+ default: {},
142
+ },
143
+ availableAnatomyFacets: {
144
+ type: Object,
145
+ default: [],
146
+ },
113
147
  },
114
148
  data: function () {
115
149
  return {
@@ -144,6 +178,7 @@ export default {
144
178
  },
145
179
  ],
146
180
  cascaderIsReady: false,
181
+ displayConnectivity: false,
147
182
  };
148
183
  },
149
184
  computed: {
@@ -156,10 +191,7 @@ export default {
156
191
  };
157
192
  },
158
193
  paginatedResults: function () {
159
- return this.results.slice(
160
- this.start,
161
- this.start + this.numberPerPage
162
- );
194
+ return this.results.slice(this.start, this.start + this.numberPerPage);
163
195
  },
164
196
  },
165
197
  watch: {
@@ -171,8 +203,48 @@ export default {
171
203
  paginatedResults: function () {
172
204
  this.loadingCards = false;
173
205
  },
206
+ connectivityEntry: {
207
+ handler(newVal, oldVal) {
208
+ if (newVal && newVal.featureId) {
209
+ if (
210
+ oldVal &&
211
+ oldVal.featureId &&
212
+ newVal.featureId[0] === oldVal.featureId[0]
213
+ ) {
214
+ // switch between show and hide when click on the same card
215
+ this.displayConnectivity = !this.displayConnectivity;
216
+ } else {
217
+ // always show when click on different cards
218
+ this.displayConnectivity = true;
219
+ }
220
+ }
221
+ },
222
+ deep: true,
223
+ },
174
224
  },
175
225
  methods: {
226
+ onConnectivityClicked: function (data) {
227
+ this.$refs.searchHistory.selectValue = "Search history";
228
+ if (data.query.trim()) {
229
+ this.$refs.searchHistory.addSearchToHistory(
230
+ data.filter,
231
+ data.query,
232
+ data.data
233
+ );
234
+ }
235
+ this.$emit("connectivity-clicked", data);
236
+ },
237
+ onConnectivityExplorerClicked: function (data) {
238
+ if (
239
+ Object.keys(this.connectivityEntry).length > 0 &&
240
+ data.id === this.connectivityEntry.featureId[0]
241
+ ) {
242
+ this.displayConnectivity = !this.displayConnectivity;
243
+ } else {
244
+ // retrieve new entry when different connectivity clicked
245
+ this.$emit("connectivity-explorer-clicked", data);
246
+ }
247
+ },
176
248
  hoverChanged: function (data) {
177
249
  const payload = data ? { ...data, type: "connectivity" } : data;
178
250
  this.$emit("hover-changed", payload);
@@ -251,8 +323,6 @@ export default {
251
323
  value: filters,
252
324
  type: "filter-update",
253
325
  });
254
- // The filter currently should work together with query
255
- if (this.searchInput === "") this.loadingCards = false;
256
326
  },
257
327
  /**
258
328
  * Transform filters for third level items to perform search
@@ -275,15 +345,24 @@ export default {
275
345
  this.searchKnowledge(transformedFilters, this.searchInput);
276
346
  },
277
347
  searchKnowledge: function (filters, query = "") {
348
+ this.$refs.searchHistory.selectValue = "Search history";
349
+ if (this.searchInput.trim()) {
350
+ this.$refs.searchHistory.addSearchToHistory(
351
+ this.filters,
352
+ this.searchInput
353
+ );
354
+ }
278
355
  this.loadingCards = true;
279
- if (query !== "") this.filter = filters;
280
356
  this.scrollToTop();
281
357
  if (this.searchInput !== this.lastSearch) {
358
+ this.lastSearch = query;
282
359
  this.$emit("search-changed", {
283
360
  value: this.searchInput,
284
361
  type: "query-update",
285
362
  });
286
- this.lastSearch = query;
363
+ } else {
364
+ // fix forever loading when only filter apply
365
+ this.loadingCards = false;
287
366
  }
288
367
  },
289
368
  filtersLoading: function (val) {
@@ -307,9 +386,15 @@ export default {
307
386
  this.start = 0;
308
387
  this.page = 1;
309
388
  },
389
+ searchHistorySearch: function (item) {
390
+ this.$emit("connectivity-clicked", {
391
+ data: item.data,
392
+ filter: item.filters,
393
+ query: item.search,
394
+ });
395
+ },
310
396
  },
311
397
  mounted: function () {
312
- this.mapServer = this.envVars.FLATMAPAPI_LOCATION;
313
398
  this.openSearch(this.filter, this.searchInput);
314
399
  },
315
400
  };
@@ -109,7 +109,7 @@
109
109
  class="connectivity-search-icon"
110
110
  @click="connectivityClicked(entry.featureId[0], 'Origins', origin)"
111
111
  >
112
- <el-icon-location />
112
+ <el-icon-search />
113
113
  </el-icon>
114
114
  </div>
115
115
  <el-button
@@ -141,7 +141,7 @@
141
141
  class="connectivity-search-icon"
142
142
  @click="connectivityClicked(entry.featureId[0], 'Components', component)"
143
143
  >
144
- <el-icon-location />
144
+ <el-icon-search />
145
145
  </el-icon>
146
146
  </div>
147
147
  </div>
@@ -178,7 +178,7 @@
178
178
  class="connectivity-search-icon"
179
179
  @click="connectivityClicked(entry.featureId[0], 'Destinations', destination)"
180
180
  >
181
- <el-icon-location />
181
+ <el-icon-search />
182
182
  </el-icon>
183
183
  </div>
184
184
  <el-button v-show="hasDestinationsWithDatasets" class="button" @click="openAxons"
@@ -229,7 +229,8 @@
229
229
  /* eslint-disable no-alert, no-console */
230
230
  import {
231
231
  Warning as ElIconWarning,
232
- Connection as ElIconLocation,
232
+ Location as ElIconLocation,
233
+ Search as ElIconSearch,
233
234
  } from '@element-plus/icons-vue'
234
235
  import {
235
236
  ElButton as Button,
@@ -266,6 +267,7 @@ export default {
266
267
  Icon,
267
268
  ElIconWarning,
268
269
  ElIconLocation,
270
+ ElIconSearch,
269
271
  CopyToClipboard,
270
272
  ConnectivityGraph,
271
273
  ExternalResourceCard
@@ -307,7 +309,6 @@ export default {
307
309
  motor: 'is the location of the initial cell body of the circuit',
308
310
  sensory: 'is the location of the initial cell body in the PNS circuit',
309
311
  },
310
- componentsWithDatasets: [],
311
312
  uberons: [{ id: undefined, name: undefined }],
312
313
  connectivityError: null,
313
314
  timeoutID: undefined,
@@ -164,12 +164,22 @@ function generateUUID() {
164
164
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
165
165
  }
166
166
 
167
+ const capitalise = function (txt) {
168
+ return txt.charAt(0).toUpperCase() + txt.slice(1)
169
+ }
170
+
167
171
  export default {
168
172
  name: 'SearchHistory',
169
173
  components: {
170
174
  Tag,
171
175
  Select
172
176
  },
177
+ props: {
178
+ localStorageKey: {
179
+ type: String,
180
+ default: '',
181
+ },
182
+ },
173
183
  data() {
174
184
  return {
175
185
  searchHistory: [],
@@ -186,16 +196,14 @@ export default {
186
196
  },
187
197
  methods: {
188
198
  getSearchHistory() {
189
- if (localStorage.getItem('sparc.science-sidebar-search-history')) {
190
- this.searchHistory = JSON.parse(
191
- localStorage.getItem('sparc.science-sidebar-search-history')
192
- )
199
+ if (localStorage.getItem(this.localStorageKey)) {
200
+ this.searchHistory = JSON.parse(localStorage.getItem(this.localStorageKey))
193
201
  } else {
194
202
  this.searchHistory = []
195
203
  }
196
204
  },
197
205
  clearSearchHistory() {
198
- localStorage.removeItem('sparc.science-sidebar-search-history')
206
+ localStorage.removeItem(this.localStorageKey)
199
207
  this.searchHistory = []
200
208
  },
201
209
  sortFilters(a, b) {
@@ -219,7 +227,7 @@ export default {
219
227
  }
220
228
  return filterItem;
221
229
  },
222
- addSearchToHistory(filters = [], search = '') {
230
+ addSearchToHistory(filters = [], search = '', data = []) {
223
231
  search = search.trim() // remove whitespace
224
232
 
225
233
  const isExistingItem = this.searchHistory.some((item) => {
@@ -244,10 +252,11 @@ export default {
244
252
  });
245
253
 
246
254
  if (!isExistingItem) {
247
- const {label, longLabel} = this.searchHistoryItemLabel(search, filters);
255
+ const {label, longLabel} = this.searchHistoryItemLabel(search, filters, data);
248
256
  const newItem = {
249
257
  filters: filters,
250
258
  search: search,
259
+ data: data,
251
260
  saved: false,
252
261
  label: label,
253
262
  longLabel: longLabel,
@@ -263,10 +272,7 @@ export default {
263
272
  this.trimSearchHistory();
264
273
 
265
274
  // Save new data
266
- localStorage.setItem(
267
- 'sparc.science-sidebar-search-history',
268
- JSON.stringify(this.searchHistory)
269
- );
275
+ localStorage.setItem(this.localStorageKey, JSON.stringify(this.searchHistory));
270
276
  }
271
277
  },
272
278
  /**
@@ -325,7 +331,7 @@ export default {
325
331
  }
326
332
 
327
333
  if (!item.label) {
328
- const {label, longLabel} = this.searchHistoryItemLabel(item.search, item.filters);
334
+ const {label, longLabel} = this.searchHistoryItemLabel(item.search, item.filters, item.data);
329
335
  item['label'] = label;
330
336
  item['longLabel'] = longLabel;
331
337
  }
@@ -356,28 +362,33 @@ export default {
356
362
  this.trimSearchHistory();
357
363
 
358
364
  // Save updated data
359
- localStorage.setItem(
360
- 'sparc.science-sidebar-search-history',
361
- JSON.stringify(this.searchHistory)
362
- )
365
+ localStorage.setItem(this.localStorageKey, JSON.stringify(this.searchHistory))
363
366
  },
364
367
  search: function (item) {
365
368
  this.$emit('search', item)
366
369
  },
367
- searchHistoryItemLabel: function (search, filters) {
370
+ searchHistoryItemLabel: function (search, filters, data) {
368
371
  let label = search ? `"${search.trim()}"` : '';
369
372
  let longLabel = '';
370
373
  let filterItems = [];
371
374
  let filterLabels = [];
375
+ let dataLabels = [];
372
376
 
373
377
  if (filters) {
374
378
  filterItems = filters.filter((filterItem) => filterItem.facet !== 'Show all');
375
379
  filterLabels = filterItems.map((item) => item.facet2 || item.facet);
380
+ if (data) {
381
+ dataLabels = data.map((item) => capitalise(item.label));
382
+ }
376
383
  }
384
+
377
385
 
378
386
  if (label && filterItems.length) {
379
387
  longLabel += label;
380
388
  longLabel += `, ${filterLabels.join(', ')}`;
389
+ if (data.length) {
390
+ longLabel += `(${dataLabels.join(', ')})`;
391
+ }
381
392
  label += ` (+${filterItems.length})`;
382
393
  }
383
394