@abi-software/map-side-bar 1.3.37 → 1.3.38

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,7 +1,11 @@
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" :envVars="envVars"/>
4
+ <context-card
5
+ v-if="contextCardEntry && contextCardEnabled"
6
+ :entry="contextCardEntry"
7
+ :envVars="envVars"
8
+ />
5
9
  <el-input
6
10
  class="search-input"
7
11
  placeholder="Search"
@@ -23,12 +27,15 @@
23
27
  @cascaderReady="cascaderReady"
24
28
  ></SearchFilters>
25
29
  <div class="content scrollbar" v-loading="loadingCards" ref="content">
26
- <div
27
- class="error-feedback"
28
- v-if="results.length === 0 && !loadingCards"
29
- >No results found - Please change your search / filter criteria.</div>
30
+ <div class="error-feedback" v-if="results.length === 0 && !loadingCards">
31
+ No results found - Please change your search / filter criteria.
32
+ </div>
30
33
  <div v-for="result in results" :key="result.doi" class="step-item">
31
- <DatasetCard :entry="result" :envVars="envVars" @contextUpdate="contextCardUpdate"></DatasetCard>
34
+ <DatasetCard
35
+ :entry="result"
36
+ :envVars="envVars"
37
+ @contextUpdate="contextCardUpdate"
38
+ ></DatasetCard>
32
39
  </div>
33
40
  <el-pagination
34
41
  class="pagination"
@@ -55,17 +62,17 @@ import {
55
62
  Icon,
56
63
  Input,
57
64
  Loading,
58
- Pagination
65
+ Pagination,
59
66
  } from "element-ui";
60
67
  import lang from "element-ui/lib/locale/lang/en";
61
68
  import locale from "element-ui/lib/locale";
62
69
  import SearchFilters from "./SearchFilters";
63
70
  import DatasetCard from "./DatasetCard";
64
71
  import ContextCard from "./ContextCard.vue";
65
- import EventBus from "./EventBus"
72
+ import EventBus from "./EventBus";
66
73
 
67
- import {AlgoliaClient} from "../algolia/algolia.js";
68
- import {getFilters} from "../algolia/utils.js"
74
+ import { AlgoliaClient } from "../algolia/algolia.js";
75
+ import { getFilters } from "../algolia/utils.js";
69
76
 
70
77
  locale.use(lang);
71
78
  Vue.use(Button);
@@ -78,7 +85,7 @@ Vue.use(Pagination);
78
85
 
79
86
  // handleErrors: A custom fetch error handler to recieve messages from the server
80
87
  // even when an error is found
81
- var handleErrors = async function(response) {
88
+ var handleErrors = async function (response) {
82
89
  if (!response.ok) {
83
90
  let parse = await response.json();
84
91
  if (parse) {
@@ -112,53 +119,53 @@ export default {
112
119
  props: {
113
120
  visible: {
114
121
  type: Boolean,
115
- default: false
122
+ default: false,
116
123
  },
117
124
  isDrawer: {
118
125
  type: Boolean,
119
- default: true
126
+ default: true,
120
127
  },
121
128
  entry: {
122
129
  type: Object,
123
- default: () => initial_state
130
+ default: () => initial_state,
124
131
  },
125
132
  envVars: {
126
133
  type: Object,
127
- default: () => {}
134
+ default: () => {},
128
135
  },
129
136
  },
130
- data: function() {
137
+ data: function () {
131
138
  return {
132
139
  ...this.entry,
133
140
  bodyStyle: {
134
141
  flex: "1 1 auto",
135
142
  "flex-flow": "column",
136
- display: "flex"
143
+ display: "flex",
137
144
  },
138
145
  cascaderIsReady: false,
139
146
  };
140
147
  },
141
148
  computed: {
142
149
  // This computed property populates filter data's entry object with $data from this sidebar
143
- filterEntry: function() {
150
+ filterEntry: function () {
144
151
  return {
145
152
  numberOfHits: this.numberOfHits,
146
- filterFacets: this.filter
153
+ filterFacets: this.filter,
147
154
  };
148
- }
155
+ },
149
156
  },
150
157
  methods: {
151
- contextCardUpdate: function(val){
152
- this.contextCardEntry = val
158
+ contextCardUpdate: function (val) {
159
+ this.contextCardEntry = val;
153
160
  },
154
- resetSearch: function() {
155
- this.numberOfHits = 0
156
- this.discoverIds = []
157
- this._dois = []
158
- this.results = []
159
- this.loadingCards = false
161
+ resetSearch: function () {
162
+ this.numberOfHits = 0;
163
+ this.discoverIds = [];
164
+ this._dois = [];
165
+ this.results = [];
166
+ this.loadingCards = false;
160
167
  },
161
- openSearch: function(filter, search='') {
168
+ openSearch: function (filter, search = "") {
162
169
  this.searchInput = search;
163
170
  this.resetPageNavigation();
164
171
  //Proceed normally if cascader is ready
@@ -167,8 +174,12 @@ export default {
167
174
  //Facets provided but cannot find at least one valid
168
175
  //facet. Tell the users the search is invalid and reset
169
176
  //facets check boxes.
170
- if ((filter && filter.length > 0) &&
171
- (this.filter && this.filter.length === 0)) {
177
+ if (
178
+ filter &&
179
+ filter.length > 0 &&
180
+ this.filter &&
181
+ this.filter.length === 0
182
+ ) {
172
183
  this.$refs.filtersRef.checkShowAllBoxes();
173
184
  this.resetSearch();
174
185
  } else if (this.filter) {
@@ -184,7 +195,7 @@ export default {
184
195
  }
185
196
  }
186
197
  },
187
- addFilter: function(filter) {
198
+ addFilter: function (filter) {
188
199
  if (this.cascaderIsReady) {
189
200
  this.resetPageNavigation();
190
201
  if (filter) {
@@ -199,70 +210,80 @@ export default {
199
210
  }
200
211
  }
201
212
  },
202
- cascaderReady: function() {
213
+ cascaderReady: function () {
203
214
  this.cascaderIsReady = true;
204
215
  this.openSearch(this.filter, this.searchInput);
205
216
  },
206
- clearSearchClicked: function() {
217
+ clearSearchClicked: function () {
207
218
  this.searchInput = "";
208
219
  this.resetPageNavigation();
209
220
  this.searchAlgolia(this.filters, this.searchInput);
210
221
  },
211
- searchEvent: function(event = false) {
222
+ searchEvent: function (event = false) {
212
223
  if (event.keyCode === 13 || event instanceof MouseEvent) {
213
224
  this.resetPageNavigation();
214
225
  this.searchAlgolia(this.filters, this.searchInput);
215
226
  }
216
227
  },
217
- filterUpdate: function(filters) {
218
- this.filters = [...filters]
219
- this.resetPageNavigation()
220
- this.searchAlgolia(filters, this.searchInput)
228
+ filterUpdate: function (filters) {
229
+ this.filters = [...filters];
230
+ this.resetPageNavigation();
231
+ this.searchAlgolia(filters, this.searchInput);
221
232
  this.$emit("search-changed", {
222
233
  value: filters,
223
- type: "filter-update"
234
+ type: "filter-update",
224
235
  });
225
236
  },
226
- searchAlgolia(filters, query=''){
237
+ searchAlgolia(filters, query = "") {
227
238
  // Algolia search
228
- this.loadingCards = true
229
- this.algoliaClient.anatomyInSearch(getFilters(filters), query).then(anatomy => {
230
- EventBus.$emit("anatomyFound", anatomy)
231
- })
232
- this.algoliaClient.search(getFilters(filters), query, this.numberPerPage, this.page).then(searchData => {
233
- this.numberOfHits = searchData.total
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" })
240
- if (this._abortController)
241
- this._abortController.abort()
242
- this._abortController = new AbortController()
243
- const signal = this._abortController.signal
244
- //Search ongoing, let the current flow progress
245
- this.perItemSearch(signal, { count: 0 })
246
- })
239
+ this.loadingCards = true;
240
+ this.algoliaClient
241
+ .anatomyInSearch(getFilters(filters), query)
242
+ .then((anatomy) => {
243
+ EventBus.$emit("anatomyFound", anatomy);
244
+ });
245
+ this.algoliaClient
246
+ .search(getFilters(filters), query, this.numberPerPage, this.page)
247
+ .then((searchData) => {
248
+ this.numberOfHits = searchData.total;
249
+ this.discoverIds = searchData.discoverIds;
250
+ this._dois = searchData.dois;
251
+ this.results = searchData.items;
252
+ this.loadingCards = false;
253
+ this.scrollToTop();
254
+ this.$emit("search-changed", {
255
+ value: this.searchInput,
256
+ type: "query-update",
257
+ });
258
+ if (this._abortController) this._abortController.abort();
259
+ this._abortController = new AbortController();
260
+ const signal = this._abortController.signal;
261
+ //Search ongoing, let the current flow progress
262
+ this.perItemSearch(signal, { count: 0 });
263
+ });
247
264
  },
248
265
  filtersLoading: function (val) {
249
266
  this.loadingCards = val;
250
267
  },
251
- numberPerPageUpdate: function(val) {
268
+ numberPerPageUpdate: function (val) {
252
269
  this.numberPerPage = val;
253
270
  this.pageChange(1);
254
271
  },
255
- pageChange: function(page) {
272
+ pageChange: function (page) {
256
273
  this.start = (page - 1) * this.numberPerPage;
257
- this.page = page
258
- this.searchAlgolia(this.filters, this.searchInput, this.numberPerPage, this.page)
274
+ this.page = page;
275
+ this.searchAlgolia(
276
+ this.filters,
277
+ this.searchInput,
278
+ this.numberPerPage,
279
+ this.page
280
+ );
259
281
  },
260
- handleMissingData: function(doi) {
261
- let i = this.results.findIndex(res=> res.doi === doi)
262
- if (this.results[i])
263
- this.results[i].detailsReady = true;
282
+ handleMissingData: function (doi) {
283
+ let i = this.results.findIndex((res) => res.doi === doi);
284
+ if (this.results[i]) this.results[i].detailsReady = true;
264
285
  },
265
- perItemSearch: function(signal, data) {
286
+ perItemSearch: function (signal, data) {
266
287
  //Maximum 10 downloads at once to prevent long waiting time
267
288
  //between unfinished search and new search
268
289
  const maxDownloads = 10;
@@ -270,92 +291,105 @@ export default {
270
291
  const doi = this._dois.shift();
271
292
  if (doi) {
272
293
  data.count++;
273
- this.callSciCrunch(this.envVars.API_LOCATION, {'dois': [doi]}, signal)
274
- .then(result => {
275
- if (result.numberOfHits === 0)
276
- this.handleMissingData(doi);
277
- else
278
- this.resultsProcessing(result);
294
+ this.callSciCrunch(this.envVars.API_LOCATION, { dois: [doi] }, signal)
295
+ .then((result) => {
296
+ if (result.numberOfHits === 0) this.handleMissingData(doi);
297
+ else this.resultsProcessing(result);
279
298
  this.$refs.content.style["overflow-y"] = "scroll";
280
299
  data.count--;
281
300
  //Async::Download finished, get the next one
282
301
  this.perItemSearch(signal, data);
283
302
  })
284
- .catch(result => {
285
- if (result.name !== 'AbortError') {
303
+ .catch((result) => {
304
+ if (result.name !== "AbortError") {
286
305
  this.handleMissingData(doi);
287
306
  data.count--;
288
307
  //Async::Download not aborted, get the next one
289
308
  this.perItemSearch(signal, data);
290
309
  }
291
310
  });
292
- //Check and make another request until it gets to max downloads
293
- this.perItemSearch(signal, data);
311
+ //Check and make another request until it gets to max downloads
312
+ this.perItemSearch(signal, data);
294
313
  }
295
314
  }
296
315
  },
297
- scrollToTop: function() {
316
+ scrollToTop: function () {
298
317
  if (this.$refs.content) {
299
318
  this.$refs.content.scroll({ top: 0, behavior: "smooth" });
300
319
  }
301
320
  },
302
- resetPageNavigation: function() {
321
+ resetPageNavigation: function () {
303
322
  this.start = 0;
304
323
  this.page = 1;
305
324
  },
306
- resultsProcessing: function(data) {
325
+ resultsProcessing: function (data) {
307
326
  this.lastSearch = this.searchInput;
308
327
 
309
328
  if (data.results.length === 0) {
310
329
  return;
311
330
  }
312
- data.results.forEach(element => {
331
+ data.results.forEach((element) => {
313
332
  // match the scicrunch result with algolia result
314
- let i = this.results.findIndex(res => element.doi ? element.doi.includes(res.doi) : false )
333
+ let i = this.results.findIndex((res) =>
334
+ element.doi ? element.doi.includes(res.doi) : false
335
+ );
315
336
  // Assign scicrunch results to the object
316
- Object.assign(this.results[i], element)
337
+ Object.assign(this.results[i], element);
317
338
  // Assign the attributes that need some processing
318
- Object.assign(this.results[i],{
319
- numberSamples: element.sampleSize
320
- ? parseInt(element.sampleSize)
321
- : 0,
339
+ Object.assign(this.results[i], {
340
+ numberSamples: element.sampleSize ? parseInt(element.sampleSize) : 0,
322
341
  numberSubjects: element.subjectSize
323
342
  ? parseInt(element.subjectSize)
324
343
  : 0,
325
- updated: (element.updated && element.updated.length) > 0 ? element.updated[0].timestamp.split("T")[0] : "",
344
+ updated:
345
+ (element.updated && element.updated.length) > 0
346
+ ? element.updated[0].timestamp.split("T")[0]
347
+ : "",
326
348
  url: element.uri[0],
327
349
  datasetId: element.dataset_identifier,
328
350
  datasetRevision: element.dataset_revision,
329
351
  datasetVersion: element.dataset_version,
330
- organs: (element.organs && element.organs.length > 0)
331
- ? [...new Set(element.organs.map(v => v.name))]
352
+ organs:
353
+ element.organs && element.organs.length > 0
354
+ ? [...new Set(element.organs.map((v) => v.name))]
332
355
  : undefined,
333
356
  species: element.organisms
334
357
  ? element.organisms[0].species
335
- ? [...new Set(element.organisms.map((v) =>v.species ? v.species.name : null))]
358
+ ? [
359
+ ...new Set(
360
+ element.organisms.map((v) =>
361
+ v.species ? v.species.name : null
362
+ )
363
+ ),
364
+ ]
336
365
  : undefined
337
366
  : undefined, // This processing only includes each gender once into 'sexes'
338
- scaffolds: element['abi-scaffold-metadata-file'],
339
- thumbnails: element['abi-thumbnail'] ? element['abi-thumbnail']: element['abi-scaffold-thumbnail'],
340
- scaffoldViews: element['abi-scaffold-view-file'],
367
+ scaffolds: element["abi-scaffold-metadata-file"],
368
+ thumbnails: element["abi-thumbnail"]
369
+ ? element["abi-thumbnail"]
370
+ : element["abi-scaffold-thumbnail"],
371
+ scaffoldViews: element["abi-scaffold-view-file"],
341
372
  videos: element.video,
342
- plots: element['abi-plot'],
343
- images: element['common-images'],
344
- contextualInformation: element['abi-contextual-information'].length > 0 ? element['abi-contextual-information'] : undefined,
345
- segmentation: element['mbf-segmentation'],
346
- simulation: element['abi-simulation-file'],
373
+ plots: element["abi-plot"],
374
+ images: element["common-images"],
375
+ contextualInformation:
376
+ element["abi-contextual-information"].length > 0
377
+ ? element["abi-contextual-information"]
378
+ : undefined,
379
+ segmentation: element["mbf-segmentation"],
380
+ simulation: element["abi-simulation-file"],
347
381
  additionalLinks: element.additionalLinks,
348
382
  detailsReady: true,
349
- })
350
- Vue.set(this.results, i, this.results[i])
383
+ });
384
+ Vue.set(this.results, i, this.results[i]);
351
385
  });
352
386
  },
353
- createfilterParams: function(params) {
387
+ createfilterParams: function (params) {
354
388
  let p = new URLSearchParams();
355
389
  //Check if field is array or value
356
390
  for (const key in params) {
357
391
  if (Array.isArray(params[key])) {
358
- params[key].forEach(e => {
392
+ params[key].forEach((e) => {
359
393
  p.append(key, e);
360
394
  });
361
395
  } else {
@@ -364,33 +398,49 @@ export default {
364
398
  }
365
399
  return p.toString();
366
400
  },
367
- callSciCrunch: function(apiLocation, params = {}, signal) {
401
+ callSciCrunch: function (apiLocation, params = {}, signal) {
368
402
  return new Promise((resolve, reject) => {
369
403
  // Add parameters if we are sent them
370
- let fullEndpoint = this.envVars.API_LOCATION + this.searchEndpoint + "?" + this.createfilterParams(params);
371
- fetch(fullEndpoint, {signal})
404
+ let fullEndpoint =
405
+ this.envVars.API_LOCATION +
406
+ this.searchEndpoint +
407
+ "?" +
408
+ this.createfilterParams(params);
409
+ fetch(fullEndpoint, { signal })
372
410
  .then(handleErrors)
373
- .then(response => response.json())
374
- .then(data => resolve(data))
375
- .catch(data => reject(data));
411
+ .then((response) => response.json())
412
+ .then((data) => resolve(data))
413
+ .catch((data) => reject(data));
376
414
  });
377
415
  },
378
416
  },
379
- mounted: function() {
417
+ mounted: function () {
380
418
  // initialise algolia
381
- this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
419
+ this.algoliaClient = new AlgoliaClient(
420
+ this.envVars.ALGOLIA_ID,
421
+ this.envVars.ALGOLIA_KEY,
422
+ this.envVars.PENNSIEVE_API_LOCATION
423
+ );
382
424
  this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
383
425
  this.openSearch(this.filter, this.searchInput);
384
426
  },
385
- created: function() {
427
+ created: function () {
386
428
  //Create non-reactive local variables
387
429
  this.searchEndpoint = "dataset_info/using_multiple_dois/";
388
- }
430
+ },
389
431
  };
390
432
  </script>
391
433
 
392
434
  <!-- Add "scoped" attribute to limit CSS to this component only -->
393
- <style scoped>
435
+ <style scoped lang="scss">
436
+ @import "~element-ui/packages/theme-chalk/src/button";
437
+ @import "~element-ui/packages/theme-chalk/src/card";
438
+ @import "~element-ui/packages/theme-chalk/src/drawer";
439
+ @import "~element-ui/packages/theme-chalk/src/icon";
440
+ @import "~element-ui/packages/theme-chalk/src/input";
441
+ @import "~element-ui/packages/theme-chalk/src/loading";
442
+ @import "~element-ui/packages/theme-chalk/src/pagination";
443
+
394
444
  .content-card {
395
445
  height: 100%;
396
446
  flex-flow: column;
@@ -398,8 +448,8 @@ export default {
398
448
  }
399
449
 
400
450
  .button {
401
- background-color: #8300bf;
402
- border: #8300bf;
451
+ background-color: $app-primary-color;
452
+ border: $app-primary-color;
403
453
  color: white;
404
454
  }
405
455
 
@@ -428,14 +478,14 @@ export default {
428
478
  text-align: center;
429
479
  }
430
480
 
431
- .pagination >>> button {
481
+ .pagination ::v-deep button {
432
482
  background-color: white !important;
433
483
  }
434
- .pagination >>> li {
484
+ .pagination ::v-deep li {
435
485
  background-color: white !important;
436
486
  }
437
- .pagination >>> li.active {
438
- color: #8300bf;
487
+ .pagination ::v-deep li.active {
488
+ color: $app-primary-color;
439
489
  }
440
490
 
441
491
  .error-feedback {
@@ -445,12 +495,12 @@ export default {
445
495
  padding-top: 15px;
446
496
  }
447
497
 
448
- .content-card >>> .el-card__header {
498
+ .content-card ::v-deep .el-card__header {
449
499
  background-color: #292b66;
450
500
  border: solid 1px #292b66;
451
501
  }
452
502
 
453
- .content-card >>> .el-card__body {
503
+ .content-card ::v-deep .el-card__body {
454
504
  background-color: #f7faff;
455
505
  overflow-y: hidden;
456
506
  }
@@ -465,15 +515,15 @@ export default {
465
515
  scrollbar-width: thin;
466
516
  }
467
517
 
468
- .content >>> .el-loading-spinner .path {
469
- stroke: #8300bf;
518
+ .content ::v-deep .el-loading-spinner .path {
519
+ stroke: $app-primary-color;
470
520
  }
471
521
 
472
- .content >>> .step-item:first-child .seperator-path{
473
- display: none;
522
+ .content ::v-deep .step-item:first-child .seperator-path {
523
+ display: none;
474
524
  }
475
525
 
476
- .content >>> .step-item:not(:first-child) .seperator-path{
526
+ .content ::v-deep .step-item:not(:first-child) .seperator-path {
477
527
  width: 486px;
478
528
  height: 0px;
479
529
  border: solid 1px #e4e7ed;
@@ -497,11 +547,11 @@ export default {
497
547
  background-color: #979797;
498
548
  }
499
549
 
500
- >>> .el-input__suffix {
550
+ ::v-deep .el-input__suffix {
501
551
  padding-right: 10px;
502
552
  }
503
553
 
504
- >>> .my-drawer {
554
+ ::v-deep .my-drawer {
505
555
  background: rgba(0, 0, 0, 0);
506
556
  box-shadow: none;
507
557
  }
@@ -35,7 +35,7 @@ export default {
35
35
  </script>
36
36
 
37
37
  <!-- Add "scoped" attribute to limit CSS to this component only -->
38
- <style scoped>
38
+ <style scoped lang="scss">
39
39
 
40
40
  .tab-container{
41
41
  height: 28px;
@@ -44,7 +44,7 @@ export default {
44
44
  .title {
45
45
  width: 101px;
46
46
  height: 28px;
47
- border: solid 1px #dcdfe6;
47
+ border: solid 1px $lineColor1;
48
48
  border-bottom: none;
49
49
  background-color: white;
50
50
  display:inline-block;
@@ -68,11 +68,11 @@ export default {
68
68
  }
69
69
 
70
70
  .parent-dialog:hover .title-text {
71
- color:#8300bf;
71
+ color:$app-primary-color;
72
72
  }
73
73
 
74
74
  .highlightText {
75
- color:#8300bf;
75
+ color:$app-primary-color;
76
76
  }
77
77
 
78
78
  </style>
package/vue.config.js CHANGED
@@ -8,4 +8,14 @@ module.exports = {
8
8
  config.externals = [ nodeExternals({allowlist: [/^marked/]}) ];
9
9
  }
10
10
  },
11
+ css: {
12
+ sourceMap: process.env.NODE_ENV === 'wc',
13
+ extract: process.env.NODE_ENV !== 'wc',
14
+ //Import variables into all stylesheets.
15
+ loaderOptions: {
16
+ sass: {
17
+ prependData: `@import '@/assets/styles';`
18
+ }
19
+ }
20
+ }
11
21
  }