@abi-software/map-side-bar 1.2.0-beta.9 → 1.2.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.
@@ -1,458 +1,458 @@
1
- <template>
2
- <el-card :body-style="bodyStyle" class="content-card">
3
- <div slot="header" class="header">
4
- <context-card v-if="contextCardEntry && contextCardEnabled" :entry="contextCardEntry" />
5
- <el-input
6
- class="search-input"
7
- placeholder="Search"
8
- v-model="searchInput"
9
- @keyup.native="searchEvent"
10
- clearable
11
- @clear="clearSearchClicked"
12
- ></el-input>
13
- <el-button class="button" @click="searchEvent">Search</el-button>
14
- </div>
15
- <SearchFilters
16
- class="filters"
17
- ref="filtersRef"
18
- :entry="filterEntry"
19
- :envVars="envVars"
20
- @filterResults="filterUpdate"
21
- @numberPerPage="numberPerPageUpdate"
22
- @loading="filtersLoading"
23
- ></SearchFilters>
24
- <div class="content scrollbar" v-loading="loadingCards" ref="content">
25
- <div
26
- class="error-feedback"
27
- v-if="results.length === 0 && !loadingCards && !sciCrunchError"
28
- >No results found - Please change your search / filter criteria.</div>
29
- <div class="error-feedback" v-if="sciCrunchError">{{sciCrunchError}}</div>
30
- <div v-for="o in results" :key="o.id" class="step-item">
31
- <DatasetCard :entry="o" :envVars="envVars" @contextUpdate="contextCardUpdate"></DatasetCard>
32
- </div>
33
- <el-pagination
34
- class="pagination"
35
- :current-page.sync="page"
36
- hide-on-single-page
37
- large
38
- layout="prev, pager, next"
39
- :page-size="numberPerPage"
40
- :total="numberOfHits"
41
- @current-change="pageChange"
42
- ></el-pagination>
43
- </div>
44
- </el-card>
45
- </template>
46
-
47
-
48
- <script>
49
- /* eslint-disable no-alert, no-console */
50
- import Vue from "vue";
51
- import {
52
- Button,
53
- Card,
54
- Drawer,
55
- Icon,
56
- Input,
57
- Loading,
58
- Pagination
59
- } from "element-ui";
60
- import lang from "element-ui/lib/locale/lang/en";
61
- import locale from "element-ui/lib/locale";
62
- import SearchFilters from "./SearchFilters";
63
- import DatasetCard from "./DatasetCard";
64
- import ContextCard from "./ContextCard.vue";
65
-
66
- import {AlgoliaClient} from "../algolia/algolia.js";
67
- import {getFilters} from "../algolia/utils.js"
68
-
69
- locale.use(lang);
70
- Vue.use(Button);
71
- Vue.use(Card);
72
- Vue.use(Drawer);
73
- Vue.use(Icon);
74
- Vue.use(Input);
75
- Vue.use(Loading);
76
- Vue.use(Pagination);
77
-
78
- // handleErrors: A custom fetch error handler to recieve messages from the server
79
- // even when an error is found
80
- var handleErrors = async function(response) {
81
- if (!response.ok) {
82
- let parse = await response.json();
83
- if (parse) {
84
- throw new Error(parse.message);
85
- } else {
86
- throw new Error(response);
87
- }
88
- }
89
- return response;
90
- };
91
-
92
- var initial_state = {
93
- searchInput: "",
94
- lastSearch: "",
95
- results: [],
96
- numberOfHits: 0,
97
- filter: [],
98
- loadingCards: false,
99
- numberPerPage: 10,
100
- page: 1,
101
- pageModel: 1,
102
- start: 0,
103
- hasSearched: false,
104
- sciCrunchError: false,
105
- contextCardEntry: undefined,
106
- contextCardEnabled: true,
107
- };
108
-
109
- export default {
110
- components: { SearchFilters, DatasetCard, ContextCard },
111
- name: "SideBarContent",
112
- props: {
113
- visible: {
114
- type: Boolean,
115
- default: false
116
- },
117
- isDrawer: {
118
- type: Boolean,
119
- default: true
120
- },
121
- entry: {
122
- type: Object,
123
- default: () => initial_state
124
- },
125
- envVars: {
126
- type: Object,
127
- default: () => {}
128
- },
129
- firstSearch: {
130
- type: String,
131
- default: ""
132
- }
133
- },
134
- data: function() {
135
- return {
136
- ...this.entry,
137
- bodyStyle: {
138
- flex: "1 1 auto",
139
- "flex-flow": "column",
140
- display: "flex"
141
- }
142
- };
143
- },
144
- computed: {
145
- // This computed property populates filter data's entry object with $data from this sidebar
146
- filterEntry: function() {
147
- return {
148
- numberOfHits: this.numberOfHits,
149
- filterFacets: this.filter
150
- };
151
- }
152
- },
153
- methods: {
154
- contextCardUpdate: function(val){
155
- this.contextCardEntry = val
156
- },
157
- openSearch: function(filter, search='') {
158
- this.searchInput = search;
159
- this.resetPageNavigation();
160
- this.searchAlgolia(filter, search);
161
- if (filter) {
162
- this.filter = [...filter];
163
- this.$refs.filtersRef.setCascader(this.filter);
164
- }
165
- },
166
- addFilter: function(filter) {
167
- this.resetPageNavigation();
168
- if (filter) {
169
- this.$refs.filtersRef.addFilter(filter);
170
- this.$refs.filtersRef.initiateSearch()
171
- }
172
- },
173
- clearSearchClicked: function() {
174
- this.searchInput = "";
175
- this.resetPageNavigation();
176
- this.searchAlgolia(this.filters, this.searchInput);
177
- },
178
- searchEvent: function(event = false) {
179
- if (event.keyCode === 13 || event instanceof MouseEvent) {
180
- this.resetPageNavigation();
181
- this.searchAlgolia(this.filters, this.searchInput);
182
- }
183
- },
184
- filterUpdate: function(filters) {
185
- this.filters = [...filters]
186
- this.resetPageNavigation()
187
- this.searchAlgolia(filters, this.searchInput)
188
- this.$emit("search-changed", {
189
- value: filters,
190
- type: "filter-update"
191
- });
192
- },
193
- searchAlgolia(filters, query=''){
194
- // Algolia search
195
- this.algoliaClient.search(getFilters(filters), query, this.numberPerPage, this.page).then(searchData => {
196
- this.numberOfHits = searchData.total
197
- this.discoverIds = searchData.discoverIds
198
- this.dois = searchData.dois
199
- this.results = searchData.items
200
- this.searchSciCrunch({'dois': this.dois})
201
- })
202
- },
203
- filtersLoading: function (val) {
204
- this.loadingCards = val;
205
- },
206
- numberPerPageUpdate: function(val) {
207
- this.numberPerPage = val;
208
- this.pageChange(1);
209
- },
210
- pageChange: function(page) {
211
- this.start = (page - 1) * this.numberPerPage;
212
- this.page = page
213
- this.searchAlgolia(this.filters, this.searchInput, this.numberPerPage, this.page)
214
- },
215
- searchSciCrunch: function(params) {
216
- this.loadingCards = true;
217
- this.results = [];
218
- this.disableCards();
219
- this.$emit("search-changed", { value: this.searchInput, type: "query-update" });
220
- this.callSciCrunch(this.envVars.API_LOCATION, params)
221
- .then(result => {
222
- //Only process if the search term is the same as the last search term.
223
- //This avoid old search being displayed.
224
- this.sciCrunchError = false;
225
- this.resultsProcessing(result);
226
- this.$refs.content.style["overflow-y"] = "scroll";
227
- this.loadingCards = false;
228
- })
229
- .catch(result => {
230
- if (result.name !== 'AbortError') {
231
- this.loadingCards = false;
232
- this.sciCrunchError = result.message;
233
- }
234
- })
235
- },
236
- disableCards: function() {
237
- if (this.$refs.content) {
238
- this.$refs.content.scroll({ top: 0, behavior: "smooth" });
239
- this.$refs.content.style["overflow-y"] = "hidden";
240
- }
241
- },
242
- resetPageNavigation: function() {
243
- this.start = 0;
244
- this.page = 1;
245
- },
246
- resultsProcessing: function(data) {
247
- this.lastSearch = this.searchInput;
248
- this.results = [];
249
- if (data.results.length === 0) {
250
- return;
251
- }
252
- data.results.forEach(element => {
253
- // this.results.push(element) below should be once backend is ready
254
- let datasetInfo = {
255
- name: element.name,
256
- description: element.description,
257
- contributors: element.contributors,
258
- numberSamples: element.sampleSize
259
- ? parseInt(element.sampleSize)
260
- : 0,
261
- numberSubjects: element.subjectSize
262
- ? parseInt(element.subjectSize)
263
- : 0,
264
- updated: element.updated[0].timestamp.split("T")[0],
265
- url: element.uri[0],
266
- datasetId: element.dataset_identifier,
267
- datasetRevision: element.dataset_revision,
268
- datasetVersion: element.dataset_version,
269
- organs: (element.organs && element.organs.length > 0)
270
- ? [...new Set(element.organs.map(v => v.name))]
271
- : undefined,
272
- species: element.organisms
273
- ? element.organisms[0].species
274
- ? [...new Set(element.organisms.map((v) =>v.species ? v.species.name : null))]
275
- : undefined
276
- : undefined, // This processing only includes each gender once into 'sexes'
277
- doi: element.doi,
278
- publishDate: element.publishDate,
279
- scaffolds: element['abi-scaffold-metadata-file'],
280
- thumbnails: element['abi-thumbnail'] ? element['abi-thumbnail']: element['abi-scaffold-thumbnail'],
281
- scaffoldViews: element['abi-scaffold-view-file'],
282
- videos: element.video,
283
- plots: element.plot,
284
- images: element['common-images'],
285
- contextualInformation: element['abi-contextual-information'].length > 0 ? element['abi-contextual-information'] : undefined,
286
- additionalLinks: element.additionalLinks,
287
- segmentation: element['mbf-segmentation'],
288
- simulation: element.additionalLinks
289
- ? element.additionalLinks[0].description == 'Repository'
290
- : false,
291
- s3uri: element.s3uri
292
- };
293
- this.results.push(datasetInfo);
294
- });
295
- },
296
- createfilterParams: function(params) {
297
- let p = new URLSearchParams();
298
- //Check if field is array or value
299
- for (const key in params) {
300
- if (Array.isArray(params[key])) {
301
- params[key].forEach(e => {
302
- p.append(key, e);
303
- });
304
- } else {
305
- p.append(key, params[key]);
306
- }
307
- }
308
- return p.toString();
309
- },
310
- callSciCrunch: function(apiLocation, params = {}) {
311
- return new Promise((resolve, reject) => {
312
- // the following controller will abort current search
313
- // if a new one has been started
314
- if (this._controller) this._controller.abort();
315
- this._controller = new AbortController();
316
- let signal = this._controller.signal;
317
- // Add parameters if we are sent them
318
- let fullEndpoint = this.envVars.API_LOCATION + this.searchEndpoint + "?" + this.createfilterParams(params);
319
- fetch(fullEndpoint, { signal })
320
- .then(handleErrors)
321
- .then(response => response.json())
322
- .then(data => resolve(data))
323
- .catch(data => reject(data));
324
- });
325
- },
326
- },
327
- mounted: function() {
328
- // initialise algolia
329
- this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
330
- this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
331
-
332
- // temporarily disable flatmap search since there are no datasets
333
- if (this.firstSearch === "Flatmap" || this.firstSearch === "flatmap") {
334
- this.openSearch(undefined, '')
335
- } else {
336
- this.openSearch(undefined, '');
337
- }
338
- },
339
- created: function() {
340
- //Create non-reactive local variables
341
- this.searchEndpoint = "dataset_info/using_multiple_dois/";
342
- }
343
- };
344
- </script>
345
-
346
- <!-- Add "scoped" attribute to limit CSS to this component only -->
347
- <style scoped>
348
- .content-card {
349
- height: 100%;
350
- flex-flow: column;
351
- display: flex;
352
- }
353
-
354
- .button {
355
- background-color: #8300bf;
356
- border: #8300bf;
357
- color: white;
358
- }
359
-
360
- .step-item {
361
- font-size: 14px;
362
- margin-bottom: 18px;
363
- text-align: left;
364
- }
365
-
366
- .search-input {
367
- width: 298px !important;
368
- height: 40px;
369
- padding-right: 14px;
370
- align-items: left;
371
- }
372
-
373
- .header {
374
- border: solid 1px #292b66;
375
- background-color: #292b66;
376
- text-align: left;
377
- }
378
-
379
- .pagination {
380
- padding-bottom: 16px;
381
- background-color: white;
382
- text-align: center;
383
- }
384
-
385
- .pagination >>> button {
386
- background-color: white !important;
387
- }
388
- .pagination >>> li {
389
- background-color: white !important;
390
- }
391
- .pagination >>> li.active {
392
- color: #8300bf;
393
- }
394
-
395
- .error-feedback {
396
- font-family: Asap;
397
- font-size: 14px;
398
- font-style: italic;
399
- padding-top: 15px;
400
- }
401
-
402
- .content-card >>> .el-card__header {
403
- background-color: #292b66;
404
- border: solid 1px #292b66;
405
- }
406
-
407
- .content-card >>> .el-card__body {
408
- background-color: #f7faff;
409
- overflow-y: hidden;
410
- }
411
-
412
- .content {
413
- width: 518px;
414
- flex: 1 1 auto;
415
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
416
- border: solid 1px #e4e7ed;
417
- background-color: #ffffff;
418
- overflow-y: scroll;
419
- scrollbar-width: thin;
420
- }
421
-
422
- .content >>> .step-item:first-child .seperator-path{
423
- display: none;
424
- }
425
-
426
- .content >>> .step-item:not(:first-child) .seperator-path{
427
- width: 486px;
428
- height: 0px;
429
- border: solid 1px #e4e7ed;
430
- background-color: #e4e7ed;
431
- }
432
-
433
- .scrollbar::-webkit-scrollbar-track {
434
- border-radius: 10px;
435
- background-color: #f5f5f5;
436
- }
437
-
438
- .scrollbar::-webkit-scrollbar {
439
- width: 12px;
440
- right: -12px;
441
- background-color: #f5f5f5;
442
- }
443
-
444
- .scrollbar::-webkit-scrollbar-thumb {
445
- border-radius: 4px;
446
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
447
- background-color: #979797;
448
- }
449
-
450
- >>> .el-input__suffix {
451
- padding-right: 10px;
452
- }
453
-
454
- >>> .my-drawer {
455
- background: rgba(0, 0, 0, 0);
456
- box-shadow: none;
457
- }
458
- </style>
1
+ <template>
2
+ <el-card :body-style="bodyStyle" class="content-card">
3
+ <div slot="header" class="header">
4
+ <context-card v-if="contextCardEntry && contextCardEnabled" :entry="contextCardEntry" />
5
+ <el-input
6
+ class="search-input"
7
+ placeholder="Search"
8
+ v-model="searchInput"
9
+ @keyup.native="searchEvent"
10
+ clearable
11
+ @clear="clearSearchClicked"
12
+ ></el-input>
13
+ <el-button class="button" @click="searchEvent">Search</el-button>
14
+ </div>
15
+ <SearchFilters
16
+ class="filters"
17
+ ref="filtersRef"
18
+ :entry="filterEntry"
19
+ :envVars="envVars"
20
+ @filterResults="filterUpdate"
21
+ @numberPerPage="numberPerPageUpdate"
22
+ @loading="filtersLoading"
23
+ ></SearchFilters>
24
+ <div class="content scrollbar" v-loading="loadingCards" ref="content">
25
+ <div v-if="loadingScicrunch" class="loading-icon" v-loading="loadingScicrunch"></div>
26
+ <div
27
+ class="error-feedback"
28
+ v-if="results.length === 0 && !loadingCards && !sciCrunchError"
29
+ >No results found - Please change your search / filter criteria.</div>
30
+ <div class="error-feedback" v-if="sciCrunchError">{{sciCrunchError}}</div>
31
+ <div v-for="result in results" :key="result.id" class="step-item">
32
+ <DatasetCard :entry="result" :envVars="envVars" @contextUpdate="contextCardUpdate"></DatasetCard>
33
+ </div>
34
+ <el-pagination
35
+ class="pagination"
36
+ :current-page.sync="page"
37
+ hide-on-single-page
38
+ large
39
+ layout="prev, pager, next"
40
+ :page-size="numberPerPage"
41
+ :total="numberOfHits"
42
+ @current-change="pageChange"
43
+ ></el-pagination>
44
+ </div>
45
+ </el-card>
46
+ </template>
47
+
48
+
49
+ <script>
50
+ /* eslint-disable no-alert, no-console */
51
+ import Vue from "vue";
52
+ import {
53
+ Button,
54
+ Card,
55
+ Drawer,
56
+ Icon,
57
+ Input,
58
+ Loading,
59
+ Pagination
60
+ } from "element-ui";
61
+ import lang from "element-ui/lib/locale/lang/en";
62
+ import locale from "element-ui/lib/locale";
63
+ import SearchFilters from "./SearchFilters";
64
+ import DatasetCard from "./DatasetCard";
65
+ import ContextCard from "./ContextCard.vue";
66
+
67
+ import {AlgoliaClient} from "../algolia/algolia.js";
68
+ import {getFilters} from "../algolia/utils.js"
69
+
70
+ locale.use(lang);
71
+ Vue.use(Button);
72
+ Vue.use(Card);
73
+ Vue.use(Drawer);
74
+ Vue.use(Icon);
75
+ Vue.use(Input);
76
+ Vue.use(Loading);
77
+ Vue.use(Pagination);
78
+
79
+ // handleErrors: A custom fetch error handler to recieve messages from the server
80
+ // even when an error is found
81
+ var handleErrors = async function(response) {
82
+ if (!response.ok) {
83
+ let parse = await response.json();
84
+ if (parse) {
85
+ throw new Error(parse.message);
86
+ } else {
87
+ throw new Error(response);
88
+ }
89
+ }
90
+ return response;
91
+ };
92
+
93
+ var initial_state = {
94
+ searchInput: "",
95
+ lastSearch: "",
96
+ results: [],
97
+ numberOfHits: 0,
98
+ filter: [],
99
+ loadingCards: false,
100
+ numberPerPage: 10,
101
+ page: 1,
102
+ pageModel: 1,
103
+ start: 0,
104
+ hasSearched: false,
105
+ sciCrunchError: false,
106
+ contextCardEntry: undefined,
107
+ contextCardEnabled: true,
108
+ loadingScicrunch: false,
109
+ };
110
+
111
+ export default {
112
+ components: { SearchFilters, DatasetCard, ContextCard },
113
+ name: "SideBarContent",
114
+ props: {
115
+ visible: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ isDrawer: {
120
+ type: Boolean,
121
+ default: true
122
+ },
123
+ entry: {
124
+ type: Object,
125
+ default: () => initial_state
126
+ },
127
+ envVars: {
128
+ type: Object,
129
+ default: () => {}
130
+ },
131
+ firstSearch: {
132
+ type: String,
133
+ default: ""
134
+ }
135
+ },
136
+ data: function() {
137
+ return {
138
+ ...this.entry,
139
+ bodyStyle: {
140
+ flex: "1 1 auto",
141
+ "flex-flow": "column",
142
+ display: "flex"
143
+ }
144
+ };
145
+ },
146
+ computed: {
147
+ // This computed property populates filter data's entry object with $data from this sidebar
148
+ filterEntry: function() {
149
+ return {
150
+ numberOfHits: this.numberOfHits,
151
+ filterFacets: this.filter
152
+ };
153
+ }
154
+ },
155
+ methods: {
156
+ contextCardUpdate: function(val){
157
+ this.contextCardEntry = val
158
+ },
159
+ openSearch: function(filter, search='') {
160
+ this.searchInput = search;
161
+ this.resetPageNavigation();
162
+ this.searchAlgolia(filter, search);
163
+ if (filter) {
164
+ this.filter = [...filter];
165
+ this.$refs.filtersRef.setCascader(this.filter);
166
+ }
167
+ },
168
+ addFilter: function(filter) {
169
+ this.resetPageNavigation();
170
+ if (filter) {
171
+ this.$refs.filtersRef.addFilter(filter);
172
+ this.$refs.filtersRef.initiateSearch()
173
+ }
174
+ },
175
+ clearSearchClicked: function() {
176
+ this.searchInput = "";
177
+ this.resetPageNavigation();
178
+ this.searchAlgolia(this.filters, this.searchInput);
179
+ },
180
+ searchEvent: function(event = false) {
181
+ if (event.keyCode === 13 || event instanceof MouseEvent) {
182
+ this.resetPageNavigation();
183
+ this.searchAlgolia(this.filters, this.searchInput);
184
+ }
185
+ },
186
+ filterUpdate: function(filters) {
187
+ this.filters = [...filters]
188
+ this.resetPageNavigation()
189
+ this.searchAlgolia(filters, this.searchInput)
190
+ this.$emit("search-changed", {
191
+ value: filters,
192
+ type: "filter-update"
193
+ });
194
+ },
195
+ searchAlgolia(filters, query=''){
196
+ // Algolia search
197
+ this.algoliaClient.search(getFilters(filters), query, this.numberPerPage, this.page).then(searchData => {
198
+ this.numberOfHits = searchData.total
199
+ this.discoverIds = searchData.discoverIds
200
+ this.dois = searchData.dois
201
+ this.results = searchData.items
202
+ this.loadingCards = false
203
+ this.searchSciCrunch({'dois': this.dois})
204
+ })
205
+ },
206
+ filtersLoading: function (val) {
207
+ this.loadingCards = val;
208
+ },
209
+ numberPerPageUpdate: function(val) {
210
+ this.numberPerPage = val;
211
+ this.pageChange(1);
212
+ },
213
+ pageChange: function(page) {
214
+ this.start = (page - 1) * this.numberPerPage;
215
+ this.page = page
216
+ this.searchAlgolia(this.filters, this.searchInput, this.numberPerPage, this.page)
217
+ },
218
+ searchSciCrunch: function(params) {
219
+ this.loadingScicrunch = true
220
+ this.scrollToTop();
221
+ this.$emit("search-changed", { value: this.searchInput, type: "query-update" });
222
+ this.callSciCrunch(this.envVars.API_LOCATION, params)
223
+ .then(result => {
224
+ //Only process if the search term is the same as the last search term.
225
+ //This avoid old search being displayed.
226
+ this.sciCrunchError = false;
227
+ this.resultsProcessing(result);
228
+ this.$refs.content.style["overflow-y"] = "scroll";
229
+ this.loadingCards = false;
230
+ this.loadingScicrunch = false
231
+ })
232
+ .catch(result => {
233
+ if (result.name !== 'AbortError') {
234
+ this.loadingCards = false;
235
+ this.loadingScicrunch = false
236
+ this.sciCrunchError = result.message;
237
+ }
238
+ })
239
+ },
240
+ scrollToTop: function() {
241
+ if (this.$refs.content) {
242
+ this.$refs.content.scroll({ top: 0, behavior: "smooth" });
243
+ }
244
+ },
245
+ resetPageNavigation: function() {
246
+ this.start = 0;
247
+ this.page = 1;
248
+ },
249
+ resultsProcessing: function(data) {
250
+ this.lastSearch = this.searchInput;
251
+
252
+ let id = 0;
253
+ if (data.results.length === 0) {
254
+ return;
255
+ }
256
+ data.results.forEach(element => {
257
+
258
+ // match the scicrunch result with algolia result
259
+ let i = this.results.findIndex(res=> res.name === element.name)
260
+
261
+
262
+ // Assign scicrunch results to the object
263
+ Object.assign(this.results[i], element)
264
+
265
+ // Assign the attributes that need some processing
266
+ Object.assign(this.results[i],{
267
+ numberSamples: element.sampleSize
268
+ ? parseInt(element.sampleSize)
269
+ : 0,
270
+ numberSubjects: element.subjectSize
271
+ ? parseInt(element.subjectSize)
272
+ : 0,
273
+ updated: element.updated[0].timestamp.split("T")[0],
274
+ url: element.uri[0],
275
+ datasetId: element.identifier,
276
+ organs: (element.organs && element.organs.length > 0)
277
+ ? [...new Set(element.organs.map(v => v.name))]
278
+ : undefined,
279
+ species: element.organisms
280
+ ? element.organisms[0].species
281
+ ? [...new Set(element.organisms.map((v) =>v.species ? v.species.name : null))]
282
+ : undefined
283
+ : undefined, // This processing only includes each gender once into 'sexes'
284
+ id: id,
285
+ scaffolds: element['abi-scaffold-metadata-file'] ? element['abi-scaffold-metadata-file'] : undefined,
286
+ contextualInformation: element['abi-contextual-information'].length > 0 ? element['abi-contextual-information'] : undefined,
287
+ simulation: element.additionalLinks
288
+ ? element.additionalLinks[0].description == 'Repository'
289
+ : false,
290
+ });
291
+ id++;
292
+
293
+ Vue.set(this.results, i, this.results[i])
294
+ });
295
+ },
296
+ createfilterParams: function(params) {
297
+ let p = new URLSearchParams();
298
+ //Check if field is array or value
299
+ for (const key in params) {
300
+ if (Array.isArray(params[key])) {
301
+ params[key].forEach(e => {
302
+ p.append(key, e);
303
+ });
304
+ } else {
305
+ p.append(key, params[key]);
306
+ }
307
+ }
308
+ return p.toString();
309
+ },
310
+ callSciCrunch: function(apiLocation, params = {}) {
311
+ return new Promise((resolve, reject) => {
312
+ // the following controller will abort current search
313
+ // if a new one has been started
314
+ if (this._controller) this._controller.abort();
315
+ this._controller = new AbortController();
316
+ let signal = this._controller.signal;
317
+ // Add parameters if we are sent them
318
+ let fullEndpoint = this.envVars.API_LOCATION + this.searchEndpoint + "?" + this.createfilterParams(params);
319
+ fetch(fullEndpoint, { signal })
320
+ .then(handleErrors)
321
+ .then(response => response.json())
322
+ .then(data => resolve(data))
323
+ .catch(data => reject(data));
324
+ });
325
+ }
326
+ },
327
+ mounted: function() {
328
+ // initialise algolia
329
+ this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
330
+ this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
331
+ console.log('Algolia initialised in sidebar')
332
+
333
+ // temporarily disable flatmap search since there are no datasets
334
+ if (this.firstSearch === "Flatmap" || this.firstSearch === "flatmap") {
335
+ this.openSearch(undefined, '')
336
+ } else {
337
+ this.openSearch(undefined, '');
338
+ }
339
+ },
340
+ created: function() {
341
+ //Create non-reactive local variables
342
+ this.searchEndpoint = "dataset_info/using_multiple_dois/";
343
+ }
344
+ };
345
+ </script>
346
+
347
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
348
+ <style scoped>
349
+ .content-card {
350
+ height: 100%;
351
+ flex-flow: column;
352
+ display: flex;
353
+ }
354
+
355
+ .button {
356
+ background-color: #8300bf;
357
+ border: #8300bf;
358
+ color: white;
359
+ }
360
+
361
+ .step-item {
362
+ font-size: 14px;
363
+ margin-bottom: 18px;
364
+ text-align: left;
365
+ }
366
+
367
+ .search-input {
368
+ width: 298px !important;
369
+ height: 40px;
370
+ padding-right: 14px;
371
+ align-items: left;
372
+ }
373
+
374
+ .header {
375
+ border: solid 1px #292b66;
376
+ background-color: #292b66;
377
+ text-align: left;
378
+ }
379
+
380
+ .pagination {
381
+ padding-bottom: 16px;
382
+ background-color: white;
383
+ text-align: center;
384
+ }
385
+
386
+ .loading-icon {
387
+ position: relative;
388
+ display: flex;
389
+ float: right;
390
+ top: 0;
391
+ z-index: 20;
392
+ width: 40px;
393
+ height: 40px;
394
+ }
395
+
396
+ .pagination >>> button {
397
+ background-color: white !important;
398
+ }
399
+ .pagination >>> li {
400
+ background-color: white !important;
401
+ }
402
+ .pagination >>> li.active {
403
+ color: #8300bf;
404
+ }
405
+
406
+ .error-feedback {
407
+ font-family: Asap;
408
+ font-size: 14px;
409
+ font-style: italic;
410
+ padding-top: 15px;
411
+ }
412
+
413
+ .content-card >>> .el-card__header {
414
+ background-color: #292b66;
415
+ border: solid 1px #292b66;
416
+ }
417
+
418
+ .content-card >>> .el-card__body {
419
+ background-color: #f7faff;
420
+ overflow-y: hidden;
421
+ }
422
+
423
+ .content {
424
+ width: 518px;
425
+ flex: 1 1 auto;
426
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
427
+ border: solid 1px #e4e7ed;
428
+ background-color: #ffffff;
429
+ overflow-y: scroll;
430
+ scrollbar-width: thin;
431
+ }
432
+
433
+ .scrollbar::-webkit-scrollbar-track {
434
+ border-radius: 10px;
435
+ background-color: #f5f5f5;
436
+ }
437
+
438
+ .scrollbar::-webkit-scrollbar {
439
+ width: 12px;
440
+ right: -12px;
441
+ background-color: #f5f5f5;
442
+ }
443
+
444
+ .scrollbar::-webkit-scrollbar-thumb {
445
+ border-radius: 4px;
446
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
447
+ background-color: #979797;
448
+ }
449
+
450
+ >>> .el-input__suffix {
451
+ padding-right: 10px;
452
+ }
453
+
454
+ >>> .my-drawer {
455
+ background: rgba(0, 0, 0, 0);
456
+ box-shadow: none;
457
+ }
458
+ </style>