@abi-software/map-side-bar 2.4.0-isan-1 → 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,26 +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,
106
+ pageModel: 1,
107
+ start: 0,
124
108
  hasSearched: false,
125
109
  contextCardEnabled: false,
126
- pmrResults: [],
127
- RatioOfPMRResults: RatioOfPMRResults,
128
- };
129
-
130
-
110
+ }
131
111
 
132
112
  export default {
133
113
  components: {
134
114
  SearchFilters,
135
115
  DatasetCard,
136
- PMRDatasetCard,
137
116
  SearchHistory,
138
117
  Button,
139
118
  Card,
@@ -143,7 +122,6 @@ export default {
143
122
  Pagination
144
123
  },
145
124
  name: 'SideBarContent',
146
- mixins: [mixedPageCalculation],
147
125
  props: {
148
126
  visible: {
149
127
  type: Boolean,
@@ -165,6 +143,7 @@ export default {
165
143
  data: function () {
166
144
  return {
167
145
  ...this.entry,
146
+ algoliaClient: undefined,
168
147
  bodyStyle: {
169
148
  flex: '1 1 auto',
170
149
  'flex-flow': 'column',
@@ -181,64 +160,21 @@ export default {
181
160
  filterFacets: this.filter,
182
161
  }
183
162
  },
184
- // npp_SPARC: Number per page for SPARC datasets
185
- npp_SPARC: function () {
186
- return Math.round(this.numberPerPage * (1 - RatioOfPMRResults))
187
- },
188
- // npp_PMR: Number per page for PMR datasets
189
- npp_PMR: function () {
190
- return Math.round(this.numberPerPage * RatioOfPMRResults)
191
- },
192
- numberOfHits: function () {
193
- return this.sparcNumberOfHits + this.pmrNumberOfHits
194
- },
195
-
196
163
  },
197
164
  methods: {
198
165
  hoverChanged: function (data) {
199
166
  this.$emit('hover-changed', data)
200
167
  },
201
- onPmrActionClick: function (data) {
202
- this.$emit('pmr-action-click', data);
203
- },
204
- // resetSearch: Resets the results, and page, and variable results ratio
205
- // Does not: reset filters, search input, or search history
206
168
  resetSearch: function () {
207
- this.pmrNumberOfHits = 0
208
- this.sparcNumberOfHits = 0
209
- this.page = 1
210
- this.calculateVariableRatio()
169
+ this.numberOfHits = 0
211
170
  this.discoverIds = []
212
171
  this._dois = []
213
172
  this.results = []
214
173
  this.loadingCards = false
215
174
  },
216
- // openSearch: Resets the results, populates dataset cards and filters. Will use Algolia and SciCrunch data uness pmr mode is set
217
- openSearch: function(filter, search = '', resetSearch = true) {
218
- if (resetSearch) {
219
- this.resetSearch();
220
- this.openAlgoliaSearch(filter, search);
221
- } else {
222
- this.searchAlgolia(filter, search);
223
- }
224
- this.openPMRSearch(filter, search)
225
- },
226
-
227
- // openPMRSearch: Resets the results, populates dataset cards and filters with PMR data.
228
- openPMRSearch: function (filter, search = '') {
229
- this.flatmapQueries.updateOffset(this.calculatePMROffest())
230
- this.flatmapQueries.updateLimit(this.PMRLimit(this.pmrResultsOnlyFlag))
231
- this.flatmapQueries.pmrSearch(filter, search).then((data) => {
232
- data.forEach((result) => {
233
- this.results.push(result)
234
- })
235
- this.pmrNumberOfHits = this.flatmapQueries.numberOfHits
236
- })
237
- },
238
-
239
- // openAlgoliaSearch: Resets the results, populates dataset cards and filters with Algloia and SciCrunch data.
240
- openAlgoliaSearch: function (filter, search = '') {
175
+ openSearch: function (filter, search = '') {
241
176
  this.searchInput = search
177
+ this.resetPageNavigation()
242
178
  //Proceed normally if cascader is ready
243
179
  if (this.cascaderIsReady) {
244
180
  this.filter =
@@ -269,7 +205,7 @@ export default {
269
205
  },
270
206
  addFilter: function (filter) {
271
207
  if (this.cascaderIsReady) {
272
- this.resetSearch()
208
+ this.resetPageNavigation()
273
209
  if (filter) {
274
210
  if (this.$refs.filtersRef.addFilter(filter))
275
211
  this.$refs.filtersRef.initiateSearch()
@@ -288,51 +224,31 @@ export default {
288
224
  },
289
225
  clearSearchClicked: function () {
290
226
  this.searchInput = ''
291
- this.resetSearch()
292
- this.openSearch(this.filter, this.searchInput)
227
+ this.resetPageNavigation()
228
+ this.searchAlgolia(this.filters, this.searchInput)
293
229
  this.$refs.searchHistory.selectValue = 'Full search history'
294
230
  },
295
231
  searchEvent: function (event = false) {
296
232
  if (event.keyCode === 13 || event instanceof MouseEvent) {
297
- this.openSearch(this.filter, this.searchInput)
233
+ this.resetPageNavigation()
234
+ this.searchAlgolia(this.filters, this.searchInput)
298
235
  this.$refs.searchHistory.selectValue = 'Full search history'
299
236
  this.$refs.searchHistory.addSearchToHistory(
300
- this.filter,
237
+ this.filters,
301
238
  this.searchInput
302
239
  )
303
240
  }
304
241
  },
305
- updatePMROnlyFlag: function (filters) {
306
- const pmrSearchObject = filters.find((tmp) => tmp.facet === 'PMR');
307
- if (pmrSearchObject) {
308
- this.pmrResultsOnlyFlag = true
309
- } else {
310
- this.pmrResultsOnlyFlag = false
311
- }
312
- },
313
242
  filterUpdate: function (filters) {
314
- this.filter = [...filters]
315
-
316
- // Check if PMR is in the filters
317
- this.updatePMROnlyFlag(filters)
318
-
319
- // Note that we cannot use the openSearch function as that modifies filters
320
- this.resetSearch()
243
+ this.filters = [...filters]
244
+ this.resetPageNavigation()
321
245
  this.searchAlgolia(filters, this.searchInput)
322
- this.openPMRSearch(filters, this.searchInput)
323
246
  this.$emit('search-changed', {
324
247
  value: filters,
325
248
  type: 'filter-update',
326
249
  })
327
250
  },
328
251
  searchAlgolia(filters, query = '') {
329
-
330
- // Remove loading if we dont expect any results
331
- if (this.SPARCLimit() === 0) {
332
- this.loadingCards = false
333
- return
334
- }
335
-
336
252
  // Algolia search
337
253
 
338
254
  this.loadingCards = true
@@ -344,17 +260,12 @@ export default {
344
260
  EventBus.emit('number-of-datasets-for-anatomies', r.forScaffold)
345
261
  })
346
262
  this.algoliaClient
347
- .search(getFilters(filters), query, this.calculateSPARCOffest(), this.SPARCLimit(this.pmrResultsOnlyFlag) )
263
+ .search(getFilters(filters), query, this.numberPerPage, this.page)
348
264
  .then((searchData) => {
349
- this.sparcNumberOfHits = searchData.total
265
+ this.numberOfHits = searchData.total
350
266
  this.discoverIds = searchData.discoverIds
351
267
  this._dois = searchData.dois
352
- searchData.items.forEach((item) => {
353
- item.detailsReady = false
354
- this.results.push(item)
355
- })
356
- // add the items to the results
357
- this.results.concat(searchData.items)
268
+ this.results = searchData.items
358
269
  this.loadingCards = false
359
270
  this.scrollToTop()
360
271
  this.$emit('search-changed', {
@@ -376,10 +287,14 @@ export default {
376
287
  this.pageChange(1)
377
288
  },
378
289
  pageChange: function (page) {
290
+ this.start = (page - 1) * this.numberPerPage
379
291
  this.page = page
380
- this.results = []
381
- this.calculateVariableRatio()
382
- this.openSearch(this.filter, this.searchInput, false)
292
+ this.searchAlgolia(
293
+ this.filters,
294
+ this.searchInput,
295
+ this.numberPerPage,
296
+ this.page
297
+ )
383
298
  },
384
299
  handleMissingData: function (doi) {
385
300
  let i = this.results.findIndex((res) => res.doi === doi)
@@ -421,6 +336,7 @@ export default {
421
336
  }
422
337
  },
423
338
  resetPageNavigation: function () {
339
+ this.start = 0
424
340
  this.page = 1
425
341
  },
426
342
  resultsProcessing: function (data) {
@@ -528,19 +444,13 @@ export default {
528
444
  },
529
445
  mounted: function () {
530
446
  // initialise algolia
531
- this.algoliaClient = new AlgoliaClient(
447
+ this.algoliaClient = markRaw(new AlgoliaClient(
532
448
  this.envVars.ALGOLIA_ID,
533
449
  this.envVars.ALGOLIA_KEY,
534
450
  this.envVars.PENNSIEVE_API_LOCATION
535
- )
451
+ ))
536
452
  this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX)
537
-
538
- // initialise flatmap queries
539
- this.flatmapQueries = new FlatmapQueries()
540
- this.flatmapQueries.initialise(this.envVars.FLATMAP_API_LOCATION)
541
-
542
- // open search
543
- this.openSearch(this.filter, this.searchInput, this.mode )
453
+ this.openSearch(this.filter, this.searchInput)
544
454
  },
545
455
  created: function () {
546
456
  //Create non-reactive local variables
@@ -579,17 +489,6 @@ export default {
579
489
  display: flex;
580
490
  }
581
491
 
582
- .data-type-select {
583
- width: 90px;
584
- margin-left: 10px;
585
- }
586
-
587
- .button {
588
- background-color: $app-primary-color;
589
- border: $app-primary-color;
590
- color: white;
591
- }
592
-
593
492
  .step-item {
594
493
  font-size: 14px;
595
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>