@abi-software/map-side-bar 1.3.37 → 2.0.0-response.0
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/dist/map-side-bar.common.js +419 -268
- package/dist/map-side-bar.common.js.map +1 -1
- package/dist/map-side-bar.css +1 -1
- package/dist/map-side-bar.umd.js +419 -268
- package/dist/map-side-bar.umd.js.map +1 -1
- package/dist/map-side-bar.umd.min.js +1 -1
- package/dist/map-side-bar.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/App.vue +6 -1
- package/src/components/BadgesGroup.vue +5 -1
- package/src/components/DatasetCard.vue +36 -12
- package/src/components/ImageGallery.vue +85 -27
- package/src/components/SearchFilters.vue +60 -38
- package/src/components/SideBar.vue +9 -0
- package/src/components/SidebarContent.vue +52 -24
- package/src/demo/AlternateResponse.js +141 -0
|
@@ -90,7 +90,7 @@ var handleErrors = async function(response) {
|
|
|
90
90
|
return response;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const initial_state = {
|
|
94
94
|
searchInput: "",
|
|
95
95
|
lastSearch: "",
|
|
96
96
|
results: [],
|
|
@@ -127,6 +127,11 @@ export default {
|
|
|
127
127
|
default: () => {}
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
|
+
inject: {
|
|
131
|
+
'alternateSearch' : {
|
|
132
|
+
default: undefined,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
130
135
|
data: function() {
|
|
131
136
|
return {
|
|
132
137
|
...this.entry,
|
|
@@ -153,7 +158,6 @@ export default {
|
|
|
153
158
|
},
|
|
154
159
|
resetSearch: function() {
|
|
155
160
|
this.numberOfHits = 0
|
|
156
|
-
this.discoverIds = []
|
|
157
161
|
this._dois = []
|
|
158
162
|
this.results = []
|
|
159
163
|
this.loadingCards = false
|
|
@@ -172,7 +176,7 @@ export default {
|
|
|
172
176
|
this.$refs.filtersRef.checkShowAllBoxes();
|
|
173
177
|
this.resetSearch();
|
|
174
178
|
} else if (this.filter) {
|
|
175
|
-
this.
|
|
179
|
+
this.performSearch(this.filter, search);
|
|
176
180
|
this.$refs.filtersRef.setCascader(this.filter);
|
|
177
181
|
}
|
|
178
182
|
} else {
|
|
@@ -180,7 +184,7 @@ export default {
|
|
|
180
184
|
//otherwise waith for cascader to be ready
|
|
181
185
|
this.filter = filter;
|
|
182
186
|
if (!filter || filter.length == 0) {
|
|
183
|
-
this.
|
|
187
|
+
this.performSearch(this.filter, search);
|
|
184
188
|
}
|
|
185
189
|
}
|
|
186
190
|
},
|
|
@@ -206,23 +210,52 @@ export default {
|
|
|
206
210
|
clearSearchClicked: function() {
|
|
207
211
|
this.searchInput = "";
|
|
208
212
|
this.resetPageNavigation();
|
|
209
|
-
this.
|
|
213
|
+
this.performSearch(this.filters, this.searchInput);
|
|
210
214
|
},
|
|
211
215
|
searchEvent: function(event = false) {
|
|
212
216
|
if (event.keyCode === 13 || event instanceof MouseEvent) {
|
|
213
217
|
this.resetPageNavigation();
|
|
214
|
-
this.
|
|
218
|
+
this.performSearch(this.filters, this.searchInput);
|
|
215
219
|
}
|
|
216
220
|
},
|
|
217
221
|
filterUpdate: function(filters) {
|
|
218
222
|
this.filters = [...filters]
|
|
219
223
|
this.resetPageNavigation()
|
|
220
|
-
this.
|
|
224
|
+
this.performSearch(filters, this.searchInput)
|
|
221
225
|
this.$emit("search-changed", {
|
|
222
226
|
value: filters,
|
|
223
227
|
type: "filter-update"
|
|
224
228
|
});
|
|
225
229
|
},
|
|
230
|
+
processSearchData: function(searchData) {
|
|
231
|
+
this.numberOfHits = searchData.total
|
|
232
|
+
this._dois = searchData.dois
|
|
233
|
+
this.results = searchData.items
|
|
234
|
+
this.loadingCards = false
|
|
235
|
+
this.scrollToTop()
|
|
236
|
+
this.$emit("search-changed", { value: this.searchInput, type: "query-update" })
|
|
237
|
+
},
|
|
238
|
+
alternateSearchCB: function(payload) {
|
|
239
|
+
this.loadingCards = false;
|
|
240
|
+
this.processSearchData(payload)
|
|
241
|
+
//console.log(payload)
|
|
242
|
+
},
|
|
243
|
+
performSearch(filters, query='') {
|
|
244
|
+
if (this.alternateSearch) {
|
|
245
|
+
this.loadingCards = true;
|
|
246
|
+
const payload = {
|
|
247
|
+
requestType: 'Search',
|
|
248
|
+
filters,
|
|
249
|
+
query,
|
|
250
|
+
numberPerPage: this.numberPerPage,
|
|
251
|
+
page: this.page
|
|
252
|
+
};
|
|
253
|
+
this.alternateSearch(payload, this.alternateSearchCB);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
this.searchAlgolia(filters, query);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
226
259
|
searchAlgolia(filters, query=''){
|
|
227
260
|
// Algolia search
|
|
228
261
|
this.loadingCards = true
|
|
@@ -230,13 +263,7 @@ export default {
|
|
|
230
263
|
EventBus.$emit("anatomyFound", anatomy)
|
|
231
264
|
})
|
|
232
265
|
this.algoliaClient.search(getFilters(filters), query, this.numberPerPage, this.page).then(searchData => {
|
|
233
|
-
this.
|
|
234
|
-
this.discoverIds = searchData.discoverIds
|
|
235
|
-
this._dois = searchData.dois
|
|
236
|
-
this.results = searchData.items
|
|
237
|
-
this.loadingCards = false
|
|
238
|
-
this.scrollToTop()
|
|
239
|
-
this.$emit("search-changed", { value: this.searchInput, type: "query-update" })
|
|
266
|
+
this.processSearchData(searchData)
|
|
240
267
|
if (this._abortController)
|
|
241
268
|
this._abortController.abort()
|
|
242
269
|
this._abortController = new AbortController()
|
|
@@ -254,8 +281,8 @@ export default {
|
|
|
254
281
|
},
|
|
255
282
|
pageChange: function(page) {
|
|
256
283
|
this.start = (page - 1) * this.numberPerPage;
|
|
257
|
-
this.page = page
|
|
258
|
-
this.
|
|
284
|
+
this.page = page;
|
|
285
|
+
this.performSearch(this.filters, this.searchInput);
|
|
259
286
|
},
|
|
260
287
|
handleMissingData: function(doi) {
|
|
261
288
|
let i = this.results.findIndex(res=> res.doi === doi)
|
|
@@ -275,7 +302,7 @@ export default {
|
|
|
275
302
|
if (result.numberOfHits === 0)
|
|
276
303
|
this.handleMissingData(doi);
|
|
277
304
|
else
|
|
278
|
-
this.
|
|
305
|
+
this.perItemProcessing(result);
|
|
279
306
|
this.$refs.content.style["overflow-y"] = "scroll";
|
|
280
307
|
data.count--;
|
|
281
308
|
//Async::Download finished, get the next one
|
|
@@ -303,9 +330,8 @@ export default {
|
|
|
303
330
|
this.start = 0;
|
|
304
331
|
this.page = 1;
|
|
305
332
|
},
|
|
306
|
-
|
|
333
|
+
perItemProcessing: function(data) {
|
|
307
334
|
this.lastSearch = this.searchInput;
|
|
308
|
-
|
|
309
335
|
if (data.results.length === 0) {
|
|
310
336
|
return;
|
|
311
337
|
}
|
|
@@ -367,8 +393,8 @@ export default {
|
|
|
367
393
|
callSciCrunch: function(apiLocation, params = {}, signal) {
|
|
368
394
|
return new Promise((resolve, reject) => {
|
|
369
395
|
// Add parameters if we are sent them
|
|
370
|
-
let fullEndpoint =
|
|
371
|
-
fetch(fullEndpoint, {signal})
|
|
396
|
+
let fullEndpoint = apiLocation + this.searchEndpoint + "?" + this.createfilterParams(params);
|
|
397
|
+
fetch(fullEndpoint, { signal })
|
|
372
398
|
.then(handleErrors)
|
|
373
399
|
.then(response => response.json())
|
|
374
400
|
.then(data => resolve(data))
|
|
@@ -377,9 +403,11 @@ export default {
|
|
|
377
403
|
},
|
|
378
404
|
},
|
|
379
405
|
mounted: function() {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
406
|
+
if (!this.alternateSearch) {
|
|
407
|
+
// initialise algolia
|
|
408
|
+
this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
|
|
409
|
+
this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
|
|
410
|
+
}
|
|
383
411
|
this.openSearch(this.filter, this.searchInput);
|
|
384
412
|
},
|
|
385
413
|
created: function() {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* eslint-disable no-alert, no-console */
|
|
2
|
+
const searchDataset = async (payload, callback) => {
|
|
3
|
+
let data = {};
|
|
4
|
+
let search = "";
|
|
5
|
+
let allFilter = {};
|
|
6
|
+
|
|
7
|
+
if (payload.query) {
|
|
8
|
+
search = payload.query;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 0; i < payload.filters.length; i++) {
|
|
11
|
+
let filter = payload.filters[i];
|
|
12
|
+
let node;
|
|
13
|
+
let field;
|
|
14
|
+
let element;
|
|
15
|
+
let subFilter = {};
|
|
16
|
+
let exist = false;
|
|
17
|
+
if (filter.facet != "Show all") {
|
|
18
|
+
let filterPayload = filter.facetPropPath.split(">");
|
|
19
|
+
node = filterPayload[0];
|
|
20
|
+
field = filterPayload[1];
|
|
21
|
+
element = filter.facet
|
|
22
|
+
Object.entries(allFilter).forEach((entry) => {
|
|
23
|
+
const [key, value] = entry;
|
|
24
|
+
if (node == value.node) {
|
|
25
|
+
Object.keys(value.filter).forEach((subkey) => {
|
|
26
|
+
if (node == value.node && field == subkey) {
|
|
27
|
+
exist = true;
|
|
28
|
+
allFilter[key]["filter"][field].push(element);
|
|
29
|
+
} else {
|
|
30
|
+
exist = false;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (exist == false) {
|
|
36
|
+
subFilter["node"] = node;
|
|
37
|
+
subFilter["filter"] = {};
|
|
38
|
+
subFilter["filter"][field] = []
|
|
39
|
+
subFilter["filter"][field].push(element);
|
|
40
|
+
allFilter[i] = subFilter;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let url = `${process.env.VUE_APP_API_LOCATION}/graphql/pagination/?search=${search}`;
|
|
45
|
+
let postPayload = {
|
|
46
|
+
filter: allFilter,
|
|
47
|
+
limit: payload.numberPerPage,
|
|
48
|
+
page: payload.page,
|
|
49
|
+
};
|
|
50
|
+
await fetch(url, {
|
|
51
|
+
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
|
52
|
+
headers: {
|
|
53
|
+
Accept: "application.json",
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify(postPayload), // body data type must match "Content-Type" header
|
|
57
|
+
Cache: "default",
|
|
58
|
+
})
|
|
59
|
+
.then((response) => response.json())
|
|
60
|
+
.then((json) => (data = json));
|
|
61
|
+
// const element = {};
|
|
62
|
+
// const searchData = {
|
|
63
|
+
// total: 5, //Total number of items
|
|
64
|
+
// items: [
|
|
65
|
+
// {
|
|
66
|
+
// numberSamples: 6,
|
|
67
|
+
// numberSubjects: 5,
|
|
68
|
+
// updated: "the time in string format",
|
|
69
|
+
// url: "uri to dataset page",
|
|
70
|
+
// datasetId: "1231",
|
|
71
|
+
// datasetRevision: "4",
|
|
72
|
+
// datasetVersion: "5",
|
|
73
|
+
// organs: ["heart", "lungs"],
|
|
74
|
+
// species: ["human", "rat"], // This processing only includes each gender once into 'sexes'
|
|
75
|
+
// scaffolds: element["abi-scaffold-metadata-file"],
|
|
76
|
+
// thumbnails: element["abi-thumbnail"]
|
|
77
|
+
// ? element["abi-thumbnail"]
|
|
78
|
+
// : element["abi-scaffold-thumbnail"],
|
|
79
|
+
// scaffoldViews: element["abi-scaffold-view-file"],
|
|
80
|
+
// videos: element.video,
|
|
81
|
+
// plots: element["abi-plot"],
|
|
82
|
+
// images: element["common-images"],
|
|
83
|
+
// contextualInformation: undefined,
|
|
84
|
+
// simulation: element["abi-simulation-file"],
|
|
85
|
+
// detailsReady: true,
|
|
86
|
+
// },
|
|
87
|
+
// ], //actual returns information
|
|
88
|
+
// };
|
|
89
|
+
const searchData = data;
|
|
90
|
+
callback(searchData);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const getFacets = async (payload, callback) => {
|
|
94
|
+
let facet = {};
|
|
95
|
+
let url = `${process.env.VUE_APP_API_LOCATION}/filter/?sidebar=true`;
|
|
96
|
+
await fetch(url, {
|
|
97
|
+
method: "GET", // *GET, POST, PUT, DELETE, etc.
|
|
98
|
+
headers: {
|
|
99
|
+
Accept: "application.json",
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
},
|
|
102
|
+
Cache: "default",
|
|
103
|
+
})
|
|
104
|
+
.then((response) => response.json())
|
|
105
|
+
.then((json) => (facet = json));
|
|
106
|
+
// const facets = [
|
|
107
|
+
// {
|
|
108
|
+
// key: "anatomy.organ.name",
|
|
109
|
+
// label: "Anatomical Structure",
|
|
110
|
+
// value: "anatomy.organ.name",
|
|
111
|
+
// children: [
|
|
112
|
+
// {
|
|
113
|
+
// facetPropPath: "anatomy.organ.name", //Should be the same as the parent's key
|
|
114
|
+
// label: "Lung",
|
|
115
|
+
// value: "Anatomical Structure>Lung",
|
|
116
|
+
// },
|
|
117
|
+
// {
|
|
118
|
+
// facetPropPath: "anatomy.organ.name", //Should be the same as the parent's key
|
|
119
|
+
// label: "Heart",
|
|
120
|
+
// value: "Anatomical Structure>Heart",
|
|
121
|
+
// },
|
|
122
|
+
// ],
|
|
123
|
+
// }
|
|
124
|
+
// ];
|
|
125
|
+
const facets = facet;
|
|
126
|
+
const returnedPayload = {
|
|
127
|
+
data: facets,
|
|
128
|
+
};
|
|
129
|
+
callback(returnedPayload);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const mySearch = (payload, callback) => {
|
|
133
|
+
if (payload && callback) {
|
|
134
|
+
if (payload.requestType == "Search") {
|
|
135
|
+
searchDataset(payload, callback);
|
|
136
|
+
return;
|
|
137
|
+
} else if (payload.requestType == "getFacets") {
|
|
138
|
+
getFacets(payload, callback);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|