@abi-software/map-side-bar 1.3.16 → 1.3.19

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": "1.3.16",
3
+ "version": "1.3.19",
4
4
  "main": "./dist/map-side-bar.common.js",
5
5
  "files": [
6
6
  "dist/*",
package/src/App.vue CHANGED
@@ -3,9 +3,10 @@
3
3
  <link rel="stylesheet"
4
4
  href="https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap">
5
5
  Click arrow to open sidebar
6
- <el-button @click="openSearch">search 'heart' from refs</el-button>
6
+ <el-button @click="openSearch">search Uberon from refs</el-button>
7
7
  <el-button @click="singleFacets">Add heart to Filter</el-button>
8
- <el-button @click="addStomach">Add stomach to Filter</el-button>
8
+ <el-button @click="addStomach">Add stomach to Filter</el-button>
9
+ <el-button @click="AddInvalidTerm">Add invalid term to Filter</el-button>
9
10
  <el-button @click="multiFacets">multiple facets</el-button>
10
11
  <el-button @click="neuronSearch">open neuron search</el-button>
11
12
  <el-button @click="keywordSearch">keyword search</el-button>
@@ -115,8 +116,12 @@ export default {
115
116
  addStomach: function(){
116
117
  this.$refs.sideBar.addFilter({facet: 'Stomach', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND: true})
117
118
  },
119
+ addInvalidTerm: function(){
120
+ this.$refs.sideBar.addFilter({facet: 'Invalid', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND: true})
121
+ },
118
122
  multiFacets: function(){
119
- this.$refs.sideBar.openSearch([{facet: 'Male', term:'Sex', facetPropPath:'attributes.subject.sex.value'}, {facet: 'Heart', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name'}], '')
123
+ this.$refs.sideBar.openSearch([{facet: 'Male', term:'Sex', facetPropPath:'attributes.subject.sex.value'}, {facet: 'Heart', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name'},
124
+ {facet: 'Not correct', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name'}], '')
120
125
  },
121
126
  keywordSearch: function(){
122
127
  this.$refs.sideBar.addFilter({type: 'Facet', label: undefined, facet: '3d model', facetPropPath: 'item.keywords.keyword', term: 'Keywords', AND: true})
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-alert, no-console */
2
2
  import algoliasearch from 'algoliasearch'
3
- import markerZoomLevels from './markerZoomLevels';
4
3
 
5
4
  // export `createAlgoliaClient` to use it in page components
6
5
  export class AlgoliaClient {
@@ -104,13 +103,11 @@ export class AlgoliaClient {
104
103
  }
105
104
  })
106
105
  }
107
- if (hit.anatomy && hit.anatomy.organ) {
106
+ if (hit.anatomy && hit.anatomy.organ ) {
108
107
  hit.anatomy.organ.forEach(anatomy => {
109
- markerZoomLevels.forEach(marker => {
110
- if (anatomy.name.toLowerCase() === marker.name.toLowerCase()) {
111
- foundKeyWords.push(marker.id)
112
- }
113
- })
108
+ if (anatomy.curie) {
109
+ foundKeyWords.push(anatomy.curie)
110
+ }
114
111
  })
115
112
  }
116
113
  })
@@ -173,6 +170,7 @@ export class AlgoliaClient {
173
170
  attributesToRetrieve: [
174
171
  'item.keywords.keyword',
175
172
  'anatomy.organ.name',
173
+ 'anatomy.organ.curie'
176
174
  ],
177
175
  })
178
176
  .then(response => {
@@ -62,7 +62,6 @@ export function getFilters(selectedFacetArray=undefined) {
62
62
 
63
63
  filters = filters.split('()AND ').join(''); // Handle case where there where no OR facets
64
64
  });
65
- console.log('filter string: ', filters.substring(0, filters.lastIndexOf(" AND ")))
66
65
  return filters.substring(0, filters.lastIndexOf(" AND "));
67
66
  }
68
67
 
@@ -48,7 +48,7 @@
48
48
  <div class="view-description">{{view.description}}<i class="el-icon-warning-outline info"></i> </div>
49
49
  </span>
50
50
  <div v-if="sampleDetails[i]" v-html="samplesMatching(view.id).description" :key="i+'_2'"/>
51
- <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(samplesMatching(view.id).path)" target="_blank">View Source</a>
51
+ <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(samplesMatching(view.id))" target="_blank">View Source</a>
52
52
  <div :key="i" class="padding"/>
53
53
 
54
54
  <!-- Extra padding if sample details is open -->
@@ -79,6 +79,26 @@ Vue.use(Button);
79
79
  Vue.use(Select);
80
80
  Vue.use(Input);
81
81
 
82
+ const addFilesToPathIfMissing = function(path){
83
+ if (!path.includes('files')){
84
+ return 'files/' + path
85
+ } else {
86
+ return path
87
+ }
88
+ }
89
+
90
+ const convertBackslashToForwardSlash = function(path){
91
+ path = path.replaceAll('\\','/')
92
+ path = path.replaceAll('\\\\', '/')
93
+ return path
94
+ }
95
+
96
+ // const switchPathToDirectory = function(path){
97
+ // let newPath = path.split('/')
98
+ // newPath.pop()
99
+ // return newPath.join('/')
100
+ // }
101
+
82
102
 
83
103
  export default {
84
104
  name: "contextCard",
@@ -88,6 +108,7 @@ export default {
88
108
  * the required viewing.
89
109
  */
90
110
  entry: Object,
111
+ envVars: Object,
91
112
  },
92
113
  data: function () {
93
114
  return {
@@ -162,9 +183,11 @@ export default {
162
183
  .then((data) => {
163
184
  this.contextData = data
164
185
  this.loading = false
186
+ this.addDiscoverIdsToContextData()
165
187
  })
166
- .catch(() => {
188
+ .catch((err) => {
167
189
  //set defaults if we hit an error
190
+ console.error('caught error!', err)
168
191
  this.thumbnail = require('@/../assets/missing-image.svg')
169
192
  this.discoverId = undefined
170
193
  this.loading = false
@@ -192,15 +215,39 @@ export default {
192
215
  return path
193
216
  }
194
217
  path = this.removeDoubleFilesPath(path)
195
- return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
218
+ return `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
196
219
  },
197
- generateFileLink(path){
198
- return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
220
+ // This is used later when generateing links to the resource on sparc.science (see generateFileLink)
221
+ addDiscoverIdsToContextData(){
222
+ this.contextData.samples.forEach((sample, i)=>{
223
+ if (sample && sample.doi && sample.doi !== ""){
224
+ fetch(`${this.envVars.PENNSIEVE_API_LOCATION}/discover/datasets/doi/${this.splitDoiFromUrl(sample.doi)}`)
225
+ .then((response) => response.json())
226
+ .then((data) => {
227
+ this.contextData.samples[i].discoverId = data.id
228
+ this.contextData.samples[i].version = data.version
229
+ })
230
+ } else {
231
+ this.contextData.samples[i].discoverId = this.entry.discoverId
232
+ this.contextData.samples[i].version = this.entry.version
233
+ }
234
+ })
235
+ },
236
+ processPathForUrl(path){
237
+ path = convertBackslashToForwardSlash(path)
238
+ path = addFilesToPathIfMissing(path)
239
+ return encodeURI(path)
240
+ },
241
+ splitDoiFromUrl(url){
242
+ return url.split('https://doi.org/').pop()
243
+ },
244
+ generateFileLink(sample){
245
+ return `https://sparc.science/file/${sample.discoverId}/${sample.version}?path=${this.processPathForUrl(sample.path)}`
199
246
 
200
247
  },
201
248
  openViewFile: function(view){
202
249
  // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
203
- this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
250
+ this.entry.viewUrl = `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
204
251
  this.entry.type = 'Scaffold View'
205
252
  EventBus.$emit("PopoverActionClick", this.entry)
206
253
  }
@@ -237,7 +284,7 @@ export default {
237
284
 
238
285
  .view-image {
239
286
  width: 34px;
240
- height: auto;
287
+ height: 34px;
241
288
  flex: 1;
242
289
  margin-right: 4px;
243
290
  }
@@ -178,7 +178,7 @@ export default {
178
178
  this.createCascaderItemValue(facet.label, facetItem.label);
179
179
  });
180
180
  });
181
- this.createDataTypeFacet()
181
+ this.createDataTypeFacet();
182
182
  })
183
183
  .finally(() => {
184
184
  resolve();
@@ -225,7 +225,7 @@ export default {
225
225
  this.makeCascadeLabelsClickable();
226
226
  }
227
227
  },
228
- // showAllEventModifier: Modifies a cascade event to unlick all selections in category if "show all" is clicked. Also unchecks "Show all" if any secection is clicked
228
+ // showAllEventModifier: Modifies a cascade event to unclick all selections in category if "show all" is clicked. Also unchecks "Show all" if any secection is clicked
229
229
  // *NOTE* Does NOT remove 'Show all' selections from showing in 'cascadeSelected'
230
230
  showAllEventModifier: function (event) {
231
231
  // check if show all is in the cascader checked option list
@@ -363,13 +363,13 @@ export default {
363
363
  addFilter: function (filter) {
364
364
  //Do not set the value unless it is ready
365
365
  if (this.cascaderIsReady && filter) {
366
- this.cascadeSelected.filter(f=>f.term != filter.term)
367
- this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
368
-
369
- this.cascadeSelectedWithBoolean.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
370
- // The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
371
-
372
-
366
+ if (this.validateFilter(filter)) {
367
+ this.cascadeSelected.filter(f=>f.term != filter.term)
368
+ this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
369
+ this.cascadeSelectedWithBoolean.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
370
+ // The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
371
+ return true;
372
+ }
373
373
  }
374
374
  },
375
375
  initiateSearch: function() {
@@ -406,13 +406,45 @@ export default {
406
406
  });
407
407
  });
408
408
  },
409
+ /**
410
+ * Validate ther filter term to make sure the term is correct
411
+ */
412
+ validateFilter: function(filter) {
413
+ if (filter && filter.facet && filter.term) {
414
+ const item = this.createCascaderItemValue(filter.term, filter.facet);
415
+ const facet = this.options.find(element => element.value === filter.facetPropPath);
416
+ if (facet) {
417
+ const filter = facet.children.find(element => element.value === item);
418
+ if (filter)
419
+ return true;
420
+ }
421
+ }
422
+ return false;
423
+ },
424
+ /**
425
+ * Return a list of valid filers given a list of filters,
426
+ */
427
+ getValidatedFilters: function (filters) {
428
+ if (filters) {
429
+ if (this.cascaderIsReady) {
430
+ const result = [];
431
+ filters.forEach(filter => {
432
+ if (this.validateFilter(filter)) {
433
+ result.push(filter);
434
+ }
435
+ });
436
+ return result;
437
+ } else return filters;
438
+ }
439
+ return [];
440
+ },
409
441
  },
410
442
  mounted: function () {
411
443
  this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
412
444
  this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
413
445
  this.populateCascader().then(() => {
414
446
  this.cascaderIsReady = true;
415
- this.checkShowAllBoxes()
447
+ this.checkShowAllBoxes();
416
448
  this.setCascader(this.entry.filterFacets);
417
449
  this.makeCascadeLabelsClickable();
418
450
  });
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <el-card :body-style="bodyStyle" class="content-card">
3
3
  <div slot="header" class="header">
4
- <context-card v-if="contextCardEntry && contextCardEnabled" :entry="contextCardEntry" />
4
+ <context-card v-if="contextCardEntry && contextCardEnabled" :entry="contextCardEntry" :envVars="envVars"/>
5
5
  <el-input
6
6
  class="search-input"
7
7
  placeholder="Search"
@@ -153,20 +153,34 @@ export default {
153
153
  contextCardUpdate: function(val){
154
154
  this.contextCardEntry = val
155
155
  },
156
+ resetSearch: function() {
157
+ this.numberOfHits = 0
158
+ this.discoverIds = []
159
+ this._dois = []
160
+ this.results = []
161
+ this.loadingCards = false
162
+ },
156
163
  openSearch: function(filter, search='') {
157
164
  this.searchInput = search;
158
165
  this.resetPageNavigation();
159
- this.searchAlgolia(filter, search);
160
- if (filter) {
161
- this.filter = [...filter];
166
+ this.filter = this.$refs.filtersRef.getValidatedFilters(filter);
167
+ //Facets provided but cannot find at least one valid
168
+ //facet. Tell the users the search is invalid and reset
169
+ //facets check boxes.
170
+ if ((filter && filter.length > 0) &&
171
+ (this.filter && this.filter.length === 0)) {
172
+ this.$refs.filtersRef.checkShowAllBoxes();
173
+ this.resetSearch();
174
+ } else if (this.filter) {
175
+ this.searchAlgolia(this.filter, search);
162
176
  this.$refs.filtersRef.setCascader(this.filter);
163
177
  }
164
178
  },
165
179
  addFilter: function(filter) {
166
180
  this.resetPageNavigation();
167
181
  if (filter) {
168
- this.$refs.filtersRef.addFilter(filter);
169
- this.$refs.filtersRef.initiateSearch()
182
+ if (this.$refs.filtersRef.addFilter(filter))
183
+ this.$refs.filtersRef.initiateSearch();
170
184
  }
171
185
  },
172
186
  clearSearchClicked: function() {
@@ -0,0 +1,27 @@
1
+ {
2
+ "description": "Mean luminal pressure (represented by a color field with red as high pressure and blue as low pressure) recorded from the proximal, transverse and distal sections of the pig colon are mapped on the scaffold. \n\nBaseline data was collected for 30min, followed by 15min of stimulation and 30min of post-stimulation.",
3
+ "heading": "Direct proximal colon stimulation",
4
+ "id": "sparc.science.context_data",
5
+ "samples": [
6
+ {
7
+ "annotation": "",
8
+ "description": "Manometry data recorded from pigs under direct proximal colon stimulation.",
9
+ "doi": "https://doi.org/10.26275/up27-ibcr",
10
+ "heading": "Proximal direct stimulation samples",
11
+ "id": "Sample 1",
12
+ "path": "derivative\\stim_proximal-colon_manometry.csv",
13
+ "view": "View 1"
14
+ }
15
+ ],
16
+ "version": "0.1.0",
17
+ "views": [
18
+ {
19
+ "annotation": "--",
20
+ "description": "Sections of pig colon scaffold with mapped manometry data where the data are collected from. ",
21
+ "id": "View 1",
22
+ "path": "colon_Layout1_view.json",
23
+ "sample": "Sample 1",
24
+ "thumbnail": "derivative\\pig_colon_main_thumbnail.jpeg"
25
+ }
26
+ ]
27
+ }
@@ -1,213 +0,0 @@
1
- // Set zoom values for micro and mesoscopic
2
- let microscopic = 7
3
- let mesoscopic = 5
4
-
5
- // Set what level each uberon shows at
6
- export default [
7
- {
8
- "id": "UBERON:0000948",
9
- "name": "heart",
10
- "showAtZoom": 1,
11
- },
12
- {
13
- "id": "UBERON:0001759",
14
- "name": "vagus nerve",
15
- "showAtZoom": 1
16
- },
17
- {
18
- "id": "UBERON:0001155",
19
- "name": "colon",
20
- "showAtZoom": 1
21
- },
22
- {
23
- "id": "UBERON:0000945",
24
- "name": "stomach",
25
- "showAtZoom": 1
26
- },
27
- {
28
- "id": "UBERON:0001013",
29
- "name": "adipose tissue",
30
- "showAtZoom": 1
31
- },
32
- {
33
- "id": "UBERON:0001255",
34
- "name": "urinary bladder",
35
- "showAtZoom": 1
36
- },
37
- {
38
- "id": "UBERON:0001348",
39
- "name": "brown adipose tissue",
40
- "showAtZoom": 6
41
- },
42
- {
43
- "id": "UBERON:0002008",
44
- "name": "cardiac nerve plexus",
45
- "showAtZoom": 1
46
- },
47
- {
48
- "id": "UBERON:0002240",
49
- "name": "spinal cord",
50
- "showAtZoom": 1
51
- },
52
- {
53
- "id": "UBERON:0002005",
54
- "name": "Enteric Nervous System",
55
- "showAtZoom": 4
56
- },
57
- {
58
- "id": "UBERON:0013702",
59
- "name": "body proper",
60
- "showAtZoom": 1
61
- },
62
- {
63
- "id": "UBERON:0002298",
64
- "name": "brainstem",
65
- "showAtZoom": 1
66
- },
67
- {
68
- "id": "UBERON:0002439",
69
- "name": "myenteric nerve plexus",
70
- "showAtZoom": 6
71
- },
72
- {
73
- "id": "UBERON:0000010",
74
- "name": "peripheral nervous system",
75
- "showAtZoom": 6
76
- },
77
- {
78
- "id": "UBERON:0002048",
79
- "name": "lung",
80
- "showAtZoom": 1
81
- },
82
- {
83
- "id": "UBERON:0002410",
84
- "name": "autonomic nervous system",
85
- "showAtZoom": 6
86
- },
87
- {
88
- "id": "UBERON:0002441",
89
- "name": "cervicothoracic ganglion",
90
- "showAtZoom": 6
91
- },
92
- {
93
- "id": "UBERON:0005363",
94
- "name": "inferior vagus X ganglion",
95
- "showAtZoom": 6
96
- },
97
- {
98
- "id": "UBERON:0001264",
99
- "name": "pancreas",
100
- "showAtZoom": 1
101
- },
102
- {
103
- "id": "UBERON:0001884",
104
- "name": "phrenic nerve",
105
- "showAtZoom": 6
106
- },
107
- {
108
- "id": "UBERON:0002059",
109
- "name": "submandibular ganglion",
110
- "showAtZoom": 7
111
- },
112
- {
113
- "id": "UBERON:0001347",
114
- "name": "white adipose tissue",
115
- "showAtZoom": 6
116
- },
117
- {
118
- "id": "UBERON:0001556",
119
- "name": "lower urinary tract",
120
- "showAtZoom": 1
121
- },
122
- {
123
- "id": "UBERON:0002262",
124
- "name": "celiac ganglion",
125
- "showAtZoom": 5
126
- },
127
- {
128
- "id": "UBERON:0000955",
129
- "name": "Brain",
130
- "showAtZoom": 1
131
- },
132
- {
133
- "id": "UBERON:0000160",
134
- "name": "intestine",
135
- "showAtZoom": 1
136
- },
137
- {
138
- "id": "UBERON:0001322",
139
- "name": "sciatic nerve",
140
- "showAtZoom": 1
141
- },
142
- {
143
- "id": "UBERON:0001649",
144
- "name": "glossopharyngeal nerve",
145
- "showAtZoom": 6
146
- },
147
- {
148
- "id": "UBERON:0002063",
149
- "name": "sinus venosus",
150
- "showAtZoom": 6
151
- },
152
- {
153
- "id": "UBERON:0002107",
154
- "name": "liver",
155
- "showAtZoom": 1
156
- },
157
- {
158
- "id": "UBERON:0002113",
159
- "name": "kidney",
160
- "showAtZoom": 1
161
- },
162
- {
163
- "id": "UBERON:0002481",
164
- "name": "bone tissue",
165
- "showAtZoom": 1
166
- },
167
- {
168
- "id": "UBERON:0004907",
169
- "name": "lower digestive tract",
170
- "showAtZoom": 4
171
- },
172
- {
173
- "id": "UBERON:0000044",
174
- "name": "Dorsal root ganglion",
175
- "showAtZoom": 5
176
- },
177
- // New levels from Keeran
178
- {
179
- "id": "UBERON:0001736",
180
- "name": "Submandibular gland",
181
- "showAtZoom": microscopic
182
- },
183
- {
184
- "id": "UBERON:0001103",
185
- "name": "Diaphragm",
186
- "showAtZoom": mesoscopic
187
- },
188
- {
189
- "id": "UBERON:0001160",
190
- "name": "Fundus of stomach",
191
- "showAtZoom": mesoscopic
192
- },
193
- {
194
- "id": "UBERON:0000955",
195
- "name": "Brain",
196
- "showAtZoom": mesoscopic
197
- },
198
- {
199
- "id": "UBERON:0003708",
200
- "name": "Carotid sinus",
201
- "showAtZoom": microscopic
202
- },
203
- {
204
- "id": "UBERON:0002079",
205
- "name": "Left cardiac atrium",
206
- "showAtZoom": mesoscopic
207
- },
208
- {
209
- "id": "ILX:0485722",
210
- "name": "Nodose ganglion",
211
- "showAtZoom": microscopic
212
- },
213
- ]