@abi-software/map-side-bar 1.1.17 → 1.2.0-beta.2

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,443 +1,459 @@
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: false
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
- let id = 0;
250
- if (data.results.length === 0) {
251
- return;
252
- }
253
- data.results.forEach(element => {
254
- // this.results.push(element) below should be once backend is ready
255
- this.results.push({
256
- name: element.name,
257
- description: element.description,
258
- contributors: element.contributors,
259
- numberSamples: element.sampleSize
260
- ? parseInt(element.sampleSize)
261
- : 0,
262
- numberSubjects: element.subjectSize
263
- ? parseInt(element.subjectSize)
264
- : 0,
265
- updated: element.updated[0].timestamp.split("T")[0],
266
- url: element.uri[0],
267
- datasetId: element.identifier,
268
- organs: (element.organs && element.organs.length > 0)
269
- ? [...new Set(element.organs.map(v => v.name))]
270
- : undefined,
271
- species: element.organisms
272
- ? element.organisms[0].species
273
- ? [...new Set(element.organisms.map((v) =>v.species ? v.species.name : null))]
274
- : undefined
275
- : undefined, // This processing only includes each gender once into 'sexes'
276
- csvFiles: element.csvFiles,
277
- id: id,
278
- doi: element.doi,
279
- publishDate: element.publishDate,
280
- scaffolds: element['abi-scaffold-metadata-file'] ? element['abi-scaffold-metadata-file'] : undefined,
281
- contextualInformation: element['abi-contextual-information'].length > 0 ? element['abi-contextual-information'] : undefined,
282
- additionalLinks: element.additionalLinks,
283
- simulation: element.additionalLinks
284
- ? element.additionalLinks[0].description == 'Repository'
285
- : false,
286
- s3uri: element.s3uri
287
- });
288
- id++;
289
- });
290
- },
291
- createfilterParams: function(params) {
292
- let p = new URLSearchParams();
293
- //Check if field is array or value
294
- for (const key in params) {
295
- if (Array.isArray(params[key])) {
296
- params[key].forEach(e => {
297
- p.append(key, e);
298
- });
299
- } else {
300
- p.append(key, params[key]);
301
- }
302
- }
303
- return p.toString();
304
- },
305
- callSciCrunch: function(apiLocation, params = {}) {
306
- return new Promise((resolve, reject) => {
307
- // the following controller will abort current search
308
- // if a new one has been started
309
- if (this._controller) this._controller.abort();
310
- this._controller = new AbortController();
311
- let signal = this._controller.signal;
312
- // Add parameters if we are sent them
313
- let fullEndpoint = this.envVars.API_LOCATION + this.searchEndpoint + "?" + this.createfilterParams(params);
314
- fetch(fullEndpoint, { signal })
315
- .then(handleErrors)
316
- .then(response => response.json())
317
- .then(data => resolve(data))
318
- .catch(data => reject(data));
319
- });
320
- }
321
- },
322
- mounted: function() {
323
- // initialise algolia
324
- this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
325
- this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
326
- console.log('Algolia initialised in sidebar')
327
-
328
- // temporarily disable flatmap search since there are no datasets
329
- if (this.firstSearch === "Flatmap" || this.firstSearch === "flatmap") {
330
- this.openSearch(undefined, '')
331
- } else {
332
- this.openSearch(undefined, '');
333
- }
334
- },
335
- created: function() {
336
- //Create non-reactive local variables
337
- this.searchEndpoint = "dataset_info/using_multiple_dois/";
338
- }
339
- };
340
- </script>
341
-
342
- <!-- Add "scoped" attribute to limit CSS to this component only -->
343
- <style scoped>
344
- .content-card {
345
- height: 100%;
346
- flex-flow: column;
347
- display: flex;
348
- }
349
-
350
- .button {
351
- background-color: #8300bf;
352
- border: #8300bf;
353
- color: white;
354
- }
355
-
356
- .step-item {
357
- font-size: 14px;
358
- margin-bottom: 18px;
359
- text-align: left;
360
- }
361
-
362
- .search-input {
363
- width: 298px !important;
364
- height: 40px;
365
- padding-right: 14px;
366
- align-items: left;
367
- }
368
-
369
- .header {
370
- border: solid 1px #292b66;
371
- background-color: #292b66;
372
- text-align: left;
373
- }
374
-
375
- .pagination {
376
- padding-bottom: 16px;
377
- background-color: white;
378
- text-align: center;
379
- }
380
-
381
- .pagination >>> button {
382
- background-color: white !important;
383
- }
384
- .pagination >>> li {
385
- background-color: white !important;
386
- }
387
- .pagination >>> li.active {
388
- color: #8300bf;
389
- }
390
-
391
- .error-feedback {
392
- font-family: Asap;
393
- font-size: 14px;
394
- font-style: italic;
395
- padding-top: 15px;
396
- }
397
-
398
- .content-card >>> .el-card__header {
399
- background-color: #292b66;
400
- border: solid 1px #292b66;
401
- }
402
-
403
- .content-card >>> .el-card__body {
404
- background-color: #f7faff;
405
- overflow-y: hidden;
406
- }
407
-
408
- .content {
409
- width: 518px;
410
- flex: 1 1 auto;
411
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
412
- border: solid 1px #e4e7ed;
413
- background-color: #ffffff;
414
- overflow-y: scroll;
415
- scrollbar-width: thin;
416
- }
417
-
418
- .scrollbar::-webkit-scrollbar-track {
419
- border-radius: 10px;
420
- background-color: #f5f5f5;
421
- }
422
-
423
- .scrollbar::-webkit-scrollbar {
424
- width: 12px;
425
- right: -12px;
426
- background-color: #f5f5f5;
427
- }
428
-
429
- .scrollbar::-webkit-scrollbar-thumb {
430
- border-radius: 4px;
431
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
432
- background-color: #979797;
433
- }
434
-
435
- >>> .el-input__suffix {
436
- padding-right: 10px;
437
- }
438
-
439
- >>> .my-drawer {
440
- background: rgba(0, 0, 0, 0);
441
- box-shadow: none;
442
- }
443
- </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
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: false
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
+ 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
+ .pagination >>> button {
387
+ background-color: white !important;
388
+ }
389
+ .pagination >>> li {
390
+ background-color: white !important;
391
+ }
392
+ .pagination >>> li.active {
393
+ color: #8300bf;
394
+ }
395
+
396
+ .error-feedback {
397
+ font-family: Asap;
398
+ font-size: 14px;
399
+ font-style: italic;
400
+ padding-top: 15px;
401
+ }
402
+
403
+ .content-card >>> .el-card__header {
404
+ background-color: #292b66;
405
+ border: solid 1px #292b66;
406
+ }
407
+
408
+ .content-card >>> .el-card__body {
409
+ background-color: #f7faff;
410
+ overflow-y: hidden;
411
+ }
412
+
413
+ .content {
414
+ width: 518px;
415
+ flex: 1 1 auto;
416
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
417
+ border: solid 1px #e4e7ed;
418
+ background-color: #ffffff;
419
+ overflow-y: scroll;
420
+ scrollbar-width: thin;
421
+ }
422
+
423
+ .content >>> .step-item:first-child .seperator-path{
424
+ display: none;
425
+ }
426
+
427
+ .content >>> .step-item:not(:first-child) .seperator-path{
428
+ width: 486px;
429
+ height: 0px;
430
+ border: solid 1px #e4e7ed;
431
+ background-color: #e4e7ed;
432
+ }
433
+
434
+ .scrollbar::-webkit-scrollbar-track {
435
+ border-radius: 10px;
436
+ background-color: #f5f5f5;
437
+ }
438
+
439
+ .scrollbar::-webkit-scrollbar {
440
+ width: 12px;
441
+ right: -12px;
442
+ background-color: #f5f5f5;
443
+ }
444
+
445
+ .scrollbar::-webkit-scrollbar-thumb {
446
+ border-radius: 4px;
447
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
448
+ background-color: #979797;
449
+ }
450
+
451
+ >>> .el-input__suffix {
452
+ padding-right: 10px;
453
+ }
454
+
455
+ >>> .my-drawer {
456
+ background: rgba(0, 0, 0, 0);
457
+ box-shadow: none;
458
+ }
459
+ </style>