@abi-software/map-side-bar 2.4.0-isan-2 → 2.4.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.
@@ -34,29 +34,18 @@
34
34
  ref="searchHistory"
35
35
  @search="searchHistorySearch"
36
36
  ></SearchHistory>
37
- pmr hits: {{ pmrNumberOfHits }}
38
37
  <div class="content scrollbar" v-loading="loadingCards" ref="content">
39
38
  <div class="error-feedback" v-if="results.length === 0 && !loadingCards">
40
39
  No results found - Please change your search / filter criteria.
41
40
  </div>
42
- <div v-for="(result, i) in results" :key="result.doi || i" class="step-item">
41
+ <div v-for="result in results" :key="result.doi" class="step-item">
43
42
  <DatasetCard
44
- v-if="result.dataSource === 'SPARC'"
45
43
  class="dataset-card"
46
44
  :entry="result"
47
45
  :envVars="envVars"
48
46
  @mouseenter="hoverChanged(result)"
49
47
  @mouseleave="hoverChanged(undefined)"
50
- ></DatasetCard>
51
- <PMRDatasetCard
52
- v-else-if="result.dataSource === 'PMR'"
53
- class="dataset-card"
54
- :entry="result"
55
- :envVars="envVars"
56
- @pmr-action-click="onPmrActionClick"
57
- @mouseenter="hoverChanged(result)"
58
- @mouseleave="hoverChanged(undefined)"
59
- ></PMRDatasetCard>
48
+ />
60
49
  </div>
61
50
  <el-pagination
62
51
  class="pagination"
@@ -84,17 +73,12 @@ import {
84
73
  } from 'element-plus'
85
74
  import SearchFilters from './SearchFilters.vue'
86
75
  import SearchHistory from './SearchHistory.vue'
76
+ import DatasetCard from './DatasetCard.vue'
87
77
  import EventBus from './EventBus.js'
88
78
 
89
- import DatasetCard from "./DatasetCard.vue";
90
- import PMRDatasetCard from "./PMRDatasetCard.vue";
91
-
92
79
  import { AlgoliaClient } from '../algolia/algolia.js'
93
80
  import { getFilters, facetPropPathMapping } from '../algolia/utils.js'
94
- import FlatmapQueries from '../flatmapQueries/flatmapQueries.js'
95
- import mixedPageCalculation from '../mixins/mixedPageCalculation.vue'
96
-
97
- const RatioOfPMRResults = 0.2; // Ratio of PMR results to Sparc results
81
+ import { markRaw } from 'vue'
98
82
 
99
83
  // handleErrors: A custom fetch error handler to recieve messages from the server
100
84
  // even when an error is found
@@ -114,27 +98,21 @@ var initial_state = {
114
98
  searchInput: '',
115
99
  lastSearch: '',
116
100
  results: [],
117
- pmrNumberOfHits: 0,
118
- sparcNumberOfHits: 0,
101
+ numberOfHits: 0,
119
102
  filter: [],
120
103
  loadingCards: false,
121
104
  numberPerPage: 10,
122
105
  page: 1,
123
- pmrResultsOnlyFlag: false,
124
- noPMRResultsFlag: false,
106
+ pageModel: 1,
107
+ start: 0,
125
108
  hasSearched: false,
126
109
  contextCardEnabled: false,
127
- pmrResults: [],
128
- RatioOfPMRResults: RatioOfPMRResults,
129
- };
130
-
131
-
110
+ }
132
111
 
133
112
  export default {
134
113
  components: {
135
114
  SearchFilters,
136
115
  DatasetCard,
137
- PMRDatasetCard,
138
116
  SearchHistory,
139
117
  Button,
140
118
  Card,
@@ -144,7 +122,6 @@ export default {
144
122
  Pagination
145
123
  },
146
124
  name: 'SideBarContent',
147
- mixins: [mixedPageCalculation],
148
125
  props: {
149
126
  visible: {
150
127
  type: Boolean,
@@ -158,13 +135,6 @@ export default {
158
135
  type: Object,
159
136
  default: () => initial_state,
160
137
  },
161
- initFilters: {
162
- type: Object,
163
- default: {
164
- filter: [],
165
- searchInput: '',
166
- }
167
- },
168
138
  envVars: {
169
139
  type: Object,
170
140
  default: () => {},
@@ -173,7 +143,7 @@ export default {
173
143
  data: function () {
174
144
  return {
175
145
  ...this.entry,
176
- ...this.initFilters,
146
+ algoliaClient: undefined,
177
147
  bodyStyle: {
178
148
  flex: '1 1 auto',
179
149
  'flex-flow': 'column',
@@ -190,69 +160,21 @@ export default {
190
160
  filterFacets: this.filter,
191
161
  }
192
162
  },
193
- // npp_SPARC: Number per page for SPARC datasets
194
- npp_SPARC: function () {
195
- return Math.round(this.numberPerPage * (1 - RatioOfPMRResults))
196
- },
197
- // npp_PMR: Number per page for PMR datasets
198
- npp_PMR: function () {
199
- return Math.round(this.numberPerPage * RatioOfPMRResults)
200
- },
201
- numberOfHits: function () {
202
- return this.sparcNumberOfHits + this.pmrNumberOfHits
203
- },
204
-
205
163
  },
206
164
  methods: {
207
165
  hoverChanged: function (data) {
208
166
  this.$emit('hover-changed', data)
209
167
  },
210
- onPmrActionClick: function (data) {
211
- this.$emit('pmr-action-click', data);
212
- },
213
- // resetSearch: Resets the results, and page, and variable results ratio
214
- // Does not: reset filters, search input, or search history
215
168
  resetSearch: function () {
216
- this.pmrNumberOfHits = 0
217
- this.sparcNumberOfHits = 0
218
- this.page = 1
219
- this.calculateVariableRatio()
169
+ this.numberOfHits = 0
220
170
  this.discoverIds = []
221
171
  this._dois = []
222
172
  this.results = []
223
173
  this.loadingCards = false
224
174
  },
225
- // openSearch: Resets the results, populates dataset cards and filters. Will use Algolia and SciCrunch data uness pmr mode is set
226
- openSearch: function(filter, search = '', resetSearch = true) {
227
- this.updatePMROnlyFlag(filter);
228
-
229
- if (resetSearch) {
230
- this.resetSearch();
231
- this.openFilterSearch(filter, search);
232
- } else {
233
- this.searchAlgolia(filter, search);
234
- this.openPMRSearch(filter, search);
235
- }
236
- },
237
-
238
- // openPMRSearch: Resets the results, populates dataset cards and filters with PMR data.
239
- openPMRSearch: function (filter, search = '') {
240
- this.loadingCards = true;
241
- this.flatmapQueries.updateOffset(this.calculatePMROffest())
242
- this.flatmapQueries.updateLimit(this.PMRLimit(this.pmrResultsOnlyFlag))
243
- this.flatmapQueries.pmrSearch(filter, search).then((data) => {
244
- data.forEach((result) => {
245
- this.results.push(result)
246
- })
247
- this.pmrNumberOfHits = this.flatmapQueries.numberOfHits
248
- this.loadingCards = false;
249
- })
250
- },
251
-
252
- // previously openAlgoliaSearch:
253
- // Resets the results, populates dataset cards and filters with Algloia and SciCrunch data.
254
- openFilterSearch: function (filter, search = '') {
175
+ openSearch: function (filter, search = '') {
255
176
  this.searchInput = search
177
+ this.resetPageNavigation()
256
178
  //Proceed normally if cascader is ready
257
179
  if (this.cascaderIsReady) {
258
180
  this.filter =
@@ -269,14 +191,7 @@ export default {
269
191
  this.$refs.filtersRef.checkShowAllBoxes()
270
192
  this.resetSearch()
271
193
  } else if (this.filter) {
272
- if (this.pmrResultsOnlyFlag) {
273
- this.openPMRSearch(this.filter, search);
274
- } else if (this.noPMRResultsFlag) {
275
- this.searchAlgolia(this.filter, search);
276
- } else {
277
- this.searchAlgolia(this.filter, search);
278
- this.openPMRSearch(this.filter, search);
279
- }
194
+ this.searchAlgolia(this.filter, search)
280
195
  this.$refs.filtersRef.setCascader(this.filter)
281
196
  }
282
197
  } else {
@@ -284,20 +199,13 @@ export default {
284
199
  //otherwise waith for cascader to be ready
285
200
  this.filter = filter
286
201
  if (!filter || filter.length == 0) {
287
- if (this.pmrResultsOnlyFlag) {
288
- this.openPMRSearch(this.filter, search);
289
- } else if (this.noPMRResultsFlag) {
290
- this.searchAlgolia(this.filter, search);
291
- } else {
292
- this.searchAlgolia(this.filter, search);
293
- this.openPMRSearch(this.filter, search);
294
- }
202
+ this.searchAlgolia(this.filter, search)
295
203
  }
296
204
  }
297
205
  },
298
206
  addFilter: function (filter) {
299
207
  if (this.cascaderIsReady) {
300
- this.resetSearch()
208
+ this.resetPageNavigation()
301
209
  if (filter) {
302
210
  if (this.$refs.filtersRef.addFilter(filter))
303
211
  this.$refs.filtersRef.initiateSearch()
@@ -316,66 +224,31 @@ export default {
316
224
  },
317
225
  clearSearchClicked: function () {
318
226
  this.searchInput = ''
319
- this.resetSearch()
320
- this.openSearch(this.filter, this.searchInput)
227
+ this.resetPageNavigation()
228
+ this.searchAlgolia(this.filters, this.searchInput)
321
229
  this.$refs.searchHistory.selectValue = 'Full search history'
322
230
  },
323
231
  searchEvent: function (event = false) {
324
232
  if (event.keyCode === 13 || event instanceof MouseEvent) {
325
- this.openSearch(this.filter, this.searchInput)
233
+ this.resetPageNavigation()
234
+ this.searchAlgolia(this.filters, this.searchInput)
326
235
  this.$refs.searchHistory.selectValue = 'Full search history'
327
236
  this.$refs.searchHistory.addSearchToHistory(
328
- this.filter,
237
+ this.filters,
329
238
  this.searchInput
330
239
  )
331
240
  }
332
241
  },
333
- updatePMROnlyFlag: function (filters) {
334
- const dataTypeFilters = filters.filter((item) => item.facetPropPath === 'item.types.name');
335
- const pmrFilter = dataTypeFilters.filter((item) => item.facet === 'PMR');
336
- const showAllFilter = dataTypeFilters.filter((item) => item.facet === 'Show all');
337
-
338
- this.pmrResultsOnlyFlag = false;
339
- this.noPMRResultsFlag = false;
340
-
341
- if (dataTypeFilters.length === 1 && pmrFilter.length === 1) {
342
- this.pmrResultsOnlyFlag = true;
343
- }
344
-
345
- if (dataTypeFilters.length > 0 && pmrFilter.length === 0 && showAllFilter.length === 0) {
346
- this.noPMRResultsFlag = true;
347
- }
348
- },
349
242
  filterUpdate: function (filters) {
350
- this.filter = [...filters]
351
-
352
- // Check if PMR is in the filters
353
- this.updatePMROnlyFlag(filters)
354
-
355
- // Note that we cannot use the openSearch function as that modifies filters
356
- this.resetSearch()
357
- if (this.pmrResultsOnlyFlag) {
358
- this.openPMRSearch(filters, this.searchInput)
359
- } else if (this.noPMRResultsFlag) {
360
- this.searchAlgolia(filters, this.searchInput)
361
- } else {
362
- this.searchAlgolia(filters, this.searchInput)
363
- this.openPMRSearch(filters, this.searchInput)
364
- }
365
-
243
+ this.filters = [...filters]
244
+ this.resetPageNavigation()
245
+ this.searchAlgolia(filters, this.searchInput)
366
246
  this.$emit('search-changed', {
367
247
  value: filters,
368
248
  type: 'filter-update',
369
249
  })
370
250
  },
371
251
  searchAlgolia(filters, query = '') {
372
-
373
- // Remove loading if we dont expect any results
374
- if (this.SPARCLimit() === 0) {
375
- this.loadingCards = false
376
- return
377
- }
378
-
379
252
  // Algolia search
380
253
 
381
254
  this.loadingCards = true
@@ -387,17 +260,12 @@ export default {
387
260
  EventBus.emit('number-of-datasets-for-anatomies', r.forScaffold)
388
261
  })
389
262
  this.algoliaClient
390
- .search(getFilters(filters), query, this.calculateSPARCOffest(), this.SPARCLimit(this.pmrResultsOnlyFlag) )
263
+ .search(getFilters(filters), query, this.numberPerPage, this.page)
391
264
  .then((searchData) => {
392
- this.sparcNumberOfHits = searchData.total
265
+ this.numberOfHits = searchData.total
393
266
  this.discoverIds = searchData.discoverIds
394
267
  this._dois = searchData.dois
395
- searchData.items.forEach((item) => {
396
- item.detailsReady = false
397
- this.results.push(item)
398
- })
399
- // add the items to the results
400
- this.results.concat(searchData.items)
268
+ this.results = searchData.items
401
269
  this.loadingCards = false
402
270
  this.scrollToTop()
403
271
  this.$emit('search-changed', {
@@ -419,10 +287,14 @@ export default {
419
287
  this.pageChange(1)
420
288
  },
421
289
  pageChange: function (page) {
290
+ this.start = (page - 1) * this.numberPerPage
422
291
  this.page = page
423
- this.results = []
424
- this.calculateVariableRatio()
425
- this.openSearch(this.filter, this.searchInput, false)
292
+ this.searchAlgolia(
293
+ this.filters,
294
+ this.searchInput,
295
+ this.numberPerPage,
296
+ this.page
297
+ )
426
298
  },
427
299
  handleMissingData: function (doi) {
428
300
  let i = this.results.findIndex((res) => res.doi === doi)
@@ -464,6 +336,7 @@ export default {
464
336
  }
465
337
  },
466
338
  resetPageNavigation: function () {
339
+ this.start = 0
467
340
  this.page = 1
468
341
  },
469
342
  resultsProcessing: function (data) {
@@ -571,19 +444,13 @@ export default {
571
444
  },
572
445
  mounted: function () {
573
446
  // initialise algolia
574
- this.algoliaClient = new AlgoliaClient(
447
+ this.algoliaClient = markRaw(new AlgoliaClient(
575
448
  this.envVars.ALGOLIA_ID,
576
449
  this.envVars.ALGOLIA_KEY,
577
450
  this.envVars.PENNSIEVE_API_LOCATION
578
- )
451
+ ))
579
452
  this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX)
580
-
581
- // initialise flatmap queries
582
- this.flatmapQueries = new FlatmapQueries()
583
- this.flatmapQueries.initialise(this.envVars.FLATMAP_API_LOCATION)
584
-
585
- // open search
586
- this.openSearch(this.filter, this.searchInput, this.mode )
453
+ this.openSearch(this.filter, this.searchInput)
587
454
  },
588
455
  created: function () {
589
456
  //Create non-reactive local variables
@@ -622,17 +489,6 @@ export default {
622
489
  display: flex;
623
490
  }
624
491
 
625
- .data-type-select {
626
- width: 90px;
627
- margin-left: 10px;
628
- }
629
-
630
- .button {
631
- background-color: $app-primary-color;
632
- border: $app-primary-color;
633
- color: white;
634
- }
635
-
636
492
  .step-item {
637
493
  font-size: 14px;
638
494
  margin-bottom: 18px;
@@ -27,7 +27,6 @@ declare module 'vue' {
27
27
  ElTag: typeof import('element-plus/es')['ElTag']
28
28
  ExternalResourceCard: typeof import('./components/ExternalResourceCard.vue')['default']
29
29
  ImageGallery: typeof import('./components/ImageGallery.vue')['default']
30
- PMRDatasetCard: typeof import('./components/PMRDatasetCard.vue')['default']
31
30
  SearchFilters: typeof import('./components/SearchFilters.vue')['default']
32
31
  SearchHistory: typeof import('./components/SearchHistory.vue')['default']
33
32
  SideBar: typeof import('./components/SideBar.vue')['default']
@@ -1,317 +0,0 @@
1
- <template>
2
- <div class="dataset-card-container" ref="container">
3
- <div class="dataset-card" ref="card">
4
- <div class="seperator-path"></div>
5
- <div v-loading="loading" class="card" >
6
- <span class="card-left">
7
- <a class="card-image-container" :href="entry.exposure" target="_blank">
8
- <img
9
- class="card-image"
10
- :src="thumbnail"
11
- width="210"
12
- height="210"
13
- :alt="entry.title"
14
- loading="lazy"
15
- />
16
- </a>
17
- </span>
18
- <div class="card-right">
19
- <el-tag type="primary" class="source-tag">PMR</el-tag>
20
- <div>
21
- <h4 class="title">{{ entry.title }}</h4>
22
- <div class="details">
23
- {{ entry.authors }}
24
- </div>
25
- </div>
26
- <div class="details" v-if="entry.description">
27
- {{ entry.description }}
28
- </div>
29
- <div class="buttons-group">
30
- <a
31
- :href="entry.exposure"
32
- target="_blank"
33
- class="el-button el-button--small button"
34
- >
35
- Exposure
36
- </a>
37
- <a
38
- v-if="entry.omex"
39
- :href="entry.omex"
40
- target="_blank"
41
- class="el-button el-button--small button"
42
- >
43
- OMEX archive
44
- </a>
45
- <el-button v-if="entry.flatmap"
46
- size="small"
47
- class="button"
48
- @click="onFlatmapClick(entry.flatmap)"
49
- >
50
- Flatmap
51
- </el-button>
52
- <el-button v-if="entry.simulation"
53
- size="small"
54
- class="button"
55
- @click="onSimulationClick(entry.simulation)"
56
- >
57
- Simulation
58
- </el-button>
59
- </div>
60
- </div>
61
- </div>
62
- </div>
63
- </div>
64
- </template>
65
-
66
-
67
- <script>
68
- /* eslint-disable no-alert, no-console */
69
- import {
70
- ElButton,
71
- ElIcon,
72
- ElTag
73
- } from 'element-plus'
74
-
75
- /**
76
- * Entry Object - Data types
77
- * ---------------------------------------
78
- "exposure"
79
- type: String
80
- description: The exposure URL
81
-
82
- "title"
83
- type: String
84
- description: The title
85
-
86
- "sha"
87
- type: String
88
- description:
89
-
90
- "workspace"
91
- type: String
92
- description: The workspace URL
93
-
94
- "omex"
95
- type: String
96
- description:
97
-
98
- "image"
99
- type: String
100
- description: The image URL
101
-
102
- "authors"
103
- type: String
104
- description: Comma separated values if more than one
105
-
106
- "description"
107
- type: String
108
- description: The description
109
-
110
- "flatmap"
111
- type: String
112
- descriptin: (Optional) to link to flatmap
113
-
114
- "simulation"
115
- type: String
116
- descriptin: (Optional) simulation resource
117
- * ---------------------------------------
118
- */
119
-
120
- const placeholderThumbnail = 'assets/missing-image.svg';
121
-
122
- export default {
123
- name: "PMRDatasetCard",
124
- components: {
125
- ElButton,
126
- ElIcon,
127
- ElTag
128
- },
129
- props: {
130
- /**
131
- * Object containing information for
132
- * the required viewing.
133
- */
134
- entry: {
135
- type: Object,
136
- default: () => {}
137
- },
138
- envVars: {
139
- type: Object,
140
- default: () => {}
141
- },
142
- },
143
- data: function () {
144
- return {
145
- thumbnail: this.entry.image || placeholderThumbnail,
146
- loading: false,
147
- };
148
- },
149
- methods: {
150
- onFlatmapClick: function (data) {
151
- this.emitPMRActionClick({
152
- type: 'Flatmap',
153
- resource: data
154
- });
155
- },
156
- onSimulationClick: function (data) {
157
- this.emitPMRActionClick({
158
- type: 'Simulation',
159
- resource: data,
160
- });
161
- },
162
- emitPMRActionClick: function (data) {
163
- const payload = {
164
- ...data,
165
- name: this.entry.title,
166
- description: this.entry.description,
167
- apiLocation: this.envVars.API_LOCATION,
168
- };
169
- this.$emit('pmr-action-click', payload);
170
- },
171
- }
172
- };
173
- </script>
174
-
175
- <!-- Add "scoped" attribute to limit CSS to this component only -->
176
- <style scoped lang="scss">
177
-
178
- .dataset-card-container {
179
- padding: 0 1rem;
180
- }
181
-
182
- .dataset-card {
183
- position: relative;
184
- min-height:17rem;
185
- }
186
-
187
- .title {
188
- padding-bottom: 0.75rem;
189
- font-family: Asap;
190
- font-size: 14px;
191
- font-weight: bold;
192
- font-stretch: normal;
193
- font-style: normal;
194
- line-height: 1.5;
195
- letter-spacing: 1.05px;
196
- color: #484848;
197
- }
198
- .card {
199
- font-family: Asap;
200
- padding-top: 18px;
201
- position: relative;
202
- display: flex;
203
-
204
- h4,
205
- p {
206
- margin: 0;
207
- }
208
- }
209
-
210
- .card-left{
211
- flex: 1;
212
- }
213
-
214
- .card-right {
215
- flex: 1.3;
216
- display: flex;
217
- flex-direction: column;
218
- gap: 1rem;
219
- min-height: 17rem;
220
- }
221
-
222
- .details {
223
- font-family: Asap;
224
- font-size: 14px;
225
- font-weight: normal;
226
- font-stretch: normal;
227
- font-style: normal;
228
- line-height: 1.5;
229
- letter-spacing: 1.05px;
230
- color: #484848;
231
- }
232
-
233
- .el-button {
234
- font-family: Asap;
235
- font-size: 14px;
236
- font-weight: normal;
237
- font-stretch: normal;
238
- font-style: normal;
239
- line-height: normal;
240
- letter-spacing: normal;
241
- text-decoration: none;
242
- }
243
-
244
- .button {
245
- background-color: $app-primary-color;
246
- border: $app-primary-color;
247
- color: white;
248
- transition: all 0.3s ease;
249
-
250
- &:hover,
251
- &:focus {
252
- color: white;
253
- background-color: $app-primary-color;
254
- outline: none;
255
- }
256
- }
257
-
258
- .card-image-container {
259
- display: block;
260
- width: 244px; // gallery image full-size width
261
- }
262
-
263
- .card-image {
264
- max-width: 100%;
265
- height: auto;
266
- object-fit: cover;
267
- }
268
-
269
- .buttons-group {
270
- display: flex;
271
- flex-direction: row;
272
- flex-wrap: wrap;
273
- gap: 0.75rem;
274
-
275
- .el-button {
276
- border-radius: 4px!important;
277
- font-size: 0.75rem!important;
278
- padding: 0.2rem 0.2rem!important;
279
- background: #f9f2fc!important;
280
- border: 1px solid $app-primary-color!important;
281
- color: $app-primary-color!important;
282
-
283
- &.active {
284
- background: $app-primary-color!important;
285
- border: 1px solid $app-primary-color!important;
286
- color: #fff!important;
287
- }
288
- }
289
-
290
- .el-button + .el-button {
291
- margin: 0;
292
- }
293
- }
294
-
295
- .source-tag {
296
- margin-bottom: 0.75rem;
297
- margin-right: 2rem;
298
- position: absolute;
299
- bottom: 0;
300
- right: 0;
301
- }
302
-
303
- .loading-icon {
304
- z-index: 20;
305
- width: 40px;
306
- height: 40px;
307
- left: 80px;
308
- }
309
-
310
- .loading-icon ::v-deep(.el-loading-mask) {
311
- background-color: rgba(117, 190, 218, 0.0) !important;
312
- }
313
-
314
- .loading-icon ::v-deep(.el-loading-spinner .path) {
315
- stroke: $app-primary-color;
316
- }
317
- </style>