@abi-software/map-side-bar 1.3.26-staging → 1.3.27

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.
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "1.3.26",
3
+ "version": "1.3.6",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "1.3.26-staging",
3
+ "version": "1.3.27",
4
4
  "main": "./dist/map-side-bar.common.js",
5
5
  "files": [
6
6
  "dist/*",
@@ -79,10 +79,10 @@ export class AlgoliaClient {
79
79
  newResult = { ...res }
80
80
  newResult = {
81
81
  doi: res.item.curie.split(':')[1],
82
- name: res.item.dataset.name,
83
- description: res.item.dataset.description,
84
- updated: res.pennsieve ? res.pennsieve.updatedAt : 'Unkown',
85
- publishDate: res.pennsieve? res.pennsieve.publishDate : 'Uknown',
82
+ name: res.item.name,
83
+ description: res.item.description,
84
+ updated: res.pennsieve.updatedAt,
85
+ publishDate: res.pennsieve.publishDate,
86
86
  datasetId: res.objectID,
87
87
  detailsReady: false
88
88
  }
@@ -133,20 +133,20 @@ export class AlgoliaClient {
133
133
  page: page - 1,
134
134
  filters: filter,
135
135
  attributesToHighlight: [],
136
- // attributesToRetrieve: [
137
- // 'pennsieve.publishDate',
138
- // 'pennsieve.updatedAt',
139
- // 'item.curie',
140
- // 'item.name',
141
- // 'item.description',
142
- // 'objectID',
143
- // ],
136
+ attributesToRetrieve: [
137
+ 'pennsieve.publishDate',
138
+ 'pennsieve.updatedAt',
139
+ 'item.curie',
140
+ 'item.name',
141
+ 'item.description',
142
+ 'objectID',
143
+ ],
144
144
  })
145
145
  .then(response => {
146
146
  let searchData = {
147
147
  items: this._processResultsForCards(response.hits),
148
148
  total: response.nbHits,
149
- discoverIds: response.hits.map(r => r.pennsieve ? r.pennsieve.identifier : undefined),
149
+ discoverIds: response.hits.map(r => r.pennsieve.identifier),
150
150
  dois: response.hits.map(r => r.item.curie.split(':')[1])
151
151
  }
152
152
  resolve(searchData)
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <div class="context-card-container" ref="container">
3
3
  <div v-show="showContextCard">
4
- <div v-show="showDetails" class="hide" @click="showDetails = !showDetails">Hide information<i class="el-icon-arrow-up"></i></div>
5
- <div v-show="!showDetails" class="hide" @click="showDetails = !showDetails">Show information<i class="el-icon-arrow-down"></i></div>
4
+ <div v-show="showDetails" class="hide" @click="showDetails = !showDetails">Hide information panel<i class="el-icon-arrow-up"></i></div>
5
+ <div v-show="!showDetails" class="hide" @click="showDetails = !showDetails">Show information panel<i class="el-icon-arrow-down"></i></div>
6
6
  <el-card v-if="showDetails && Object.keys(contextData).length !== 0" v-loading="loading" class="context-card" >
7
7
  <div class="card-left">
8
- <img :src="entry.banner" class="context-image">
8
+ <img :src="banner" class="context-image">
9
9
  </div>
10
10
  <div class="card-right scrollbar">
11
11
  <div class="title">{{contextData.heading}}</div>
@@ -140,11 +140,8 @@ export default {
140
140
  computed: {
141
141
  samplesUnderViews: function(){
142
142
  if (this.contextData){
143
- if (!this.contextData.views || !this.contextData.samples){
144
- return false
145
- }
146
143
  if (this.contextData.samplesUnderViews){
147
- return this.contextData.samplesUnderViews
144
+ return true
148
145
  } else {
149
146
  let viewId = this.contextData.views.map(v=>v.id)
150
147
  let samplesView = this.contextData.samples.map(s=>s.view)
@@ -161,6 +158,16 @@ export default {
161
158
  }
162
159
  else return false
163
160
  },
161
+ banner: function(){
162
+ if (this.contextData.banner){
163
+ this.getFileFromPath(this.contextData.banner)
164
+ } else if (this.contextData && this.contextData.views) {
165
+ if(this.contextData.views[0].thumbnail){
166
+ return this.getFileFromPath(this.contextData.views[0].thumbnail)
167
+ }
168
+ }
169
+ return this.entry.banner
170
+ }
164
171
  },
165
172
  methods: {
166
173
  samplesMatching: function(viewId){
@@ -4,8 +4,8 @@
4
4
  <div class="seperator-path"></div>
5
5
  <div v-loading="loading" class="card" >
6
6
  <span class="card-left">
7
- <image-gallery v-if="!loading"
8
- :datasetId="String(discoverId)"
7
+ <image-gallery v-if="!loading && discoverId"
8
+ :datasetId="discoverId"
9
9
  :datasetVersion="version"
10
10
  :entry="entry"
11
11
  :envVars="envVars"
@@ -172,11 +172,9 @@ export default {
172
172
  splitDOI: function(doi){
173
173
  return [doi.split('/')[doi.split('/').length-2], doi.split('/')[doi.split('/').length-1]]
174
174
  },
175
- getBanner: function () { // NOTE! This getBanner uses the pennsieve api to retrive the banner. Only use for curation!
176
- if (this.entry.datasetId.length > 4){
177
- this.loading = true
178
- this.getPennsieveBanner()
179
- } else if (this.lastDoi !== this.entry.doi) {
175
+ getBanner: function () {
176
+ // Only load banner if card has changed
177
+ if (this.lastDoi !== this.entry.doi) {
180
178
  this.lastDoi = this.entry.doi
181
179
  this.loading = true
182
180
  let doi = this.splitDOI(this.entry.doi)
@@ -193,7 +191,7 @@ export default {
193
191
  this.discoverId = data.id
194
192
  this.version = data.version
195
193
  this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
196
- if (this.discoverId.length < 5) this.getBiolucidaInfo(this.discoverId)
194
+ this.getBiolucidaInfo(this.discoverId)
197
195
  this.loading = false
198
196
  })
199
197
  .catch(() => {
@@ -202,67 +200,9 @@ export default {
202
200
  this.discoverId = Number(this.entry.datasetId)
203
201
  this.loading = false
204
202
  });
205
- }
206
- },
207
- getPennsieveBanner: function(){
208
- // authenticate with pennsieve
209
- fetch('https://cognito-idp.us-east-1.amazonaws.com/', {
210
- method: 'POST',
211
- headers: {
212
- 'Accept': 'application/json, text/plain, */*',
213
- 'Content-Type': 'application/x-amz-json-1.1',
214
- 'X-Amz-Target': 'AWSCognitoIdentityProviderService.InitiateAuth',
215
- 'X-Amz-User-Agent': 'aws-amplify/0.1.x js',
216
- },
217
- body: JSON.stringify({"AuthFlow":"USER_PASSWORD_AUTH","ClientId":"670mo7si81pcc3sfub7o1914d8","AuthParameters":{"USERNAME":"jessekhorasanee@gmail.com","PASSWORD":"Asameswayhey@666","DEVICE_KEY":"us-east-1_0d4e8de7-6079-470d-bedd-62043ba70f7e"},"ClientMetadata":{}})
218
- }).then(res => res.json())
219
- .then(res => {
220
- console.log(res)
221
- let token = res.AuthenticationResult.AccessToken
222
- let proxy = `${this.envVars.API_LOCATION}proxy/?url=` // set up proxy
223
-
224
- // call pennsieve api via proxy
225
- fetch(`${proxy}https://api.pennsieve.io/datasets/N%3Adataset%3A${this.entry.datasetId}/banner?api_key=${token}`
226
- ).then(res=>res.json()).then(res=>{
227
- console.log('success!')
228
- this.thumbnail = res.banner
229
- this.discoverId = this.entry.datasetId
230
- this.loading = false
231
- })
232
- })
203
+ }
233
204
 
234
205
  },
235
- // getBanner: function () {
236
- // // Only load banner if card has changed
237
- // if (this.lastDoi !== this.entry.doi) {
238
- // this.lastDoi = this.entry.doi
239
- // this.loading = true
240
- // let doi = this.splitDOI(this.entry.doi)
241
- // fetch(`${this.envVars.PENNSIEVE_API_LOCATION}/discover/datasets/doi/${doi[0]}/${doi[1]}`)
242
- // .then((response) =>{
243
- // if (!response.ok){
244
- // throw Error(response.statusText)
245
- // } else {
246
- // return response.json()
247
- // }
248
- // })
249
- // .then((data) => {
250
- // this.thumbnail = data.banner
251
- // this.discoverId = data.id
252
- // this.version = data.version
253
- // this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
254
- // this.getBiolucidaInfo(this.discoverId)
255
- // this.loading = false
256
- // })
257
- // .catch(() => {
258
- // //set defaults if we hit an error
259
- // this.thumbnail = require('@/../assets/missing-image.svg')
260
- // this.discoverId = Number(this.entry.datasetId)
261
- // this.loading = false
262
- // });
263
- // }
264
-
265
- // },
266
206
  lastName: function(fullName){
267
207
  return fullName.split(',')[0]
268
208
  },
@@ -28,7 +28,7 @@ const capitalise = function (string) {
28
28
  return string.replace(/\b\w/g, (v) => v.toUpperCase());
29
29
  };
30
30
 
31
- import GalleryHelper from "../mixins/GalleryHelpers";
31
+ import GalleryHelper from "@abi-software/gallery/src/mixins/GalleryHelpers";
32
32
  import Gallery from "@abi-software/gallery";
33
33
  import "@abi-software/gallery/dist/gallery.css";
34
34
 
@@ -58,8 +58,8 @@ export default {
58
58
  },
59
59
  },
60
60
  datasetId: {
61
- type: String,
62
- default: "",
61
+ type: Number,
62
+ default: -1,
63
63
  },
64
64
  datasetVersion: {
65
65
  type: Number,
@@ -215,6 +215,7 @@ export default {
215
215
  },
216
216
  createScaffoldItems: function () {
217
217
  if (this.entry.scaffolds) {
218
+ window.entry = this.entry
218
219
  let index = 0;
219
220
  this.entry.scaffolds.forEach((scaffold, i) => {
220
221
  const filePath = scaffold.dataset.path;
@@ -228,7 +229,12 @@ export default {
228
229
  let mimetype = '';
229
230
  let thumbnailURL = undefined;
230
231
  if (thumbnail) {
231
- thumbnailURL = `${this.envVars.API_LOCATION}s3-resource/${this.datasetId}/${this.datasetVersion}/files/${filePath}`
232
+ thumbnailURL = this.getImageURLFromS3(this.envVars.API_LOCATION, {
233
+ id,
234
+ datasetId: this.datasetId,
235
+ datasetVersion: this.datasetVersion,
236
+ file_path: thumbnail.dataset.path,
237
+ });
232
238
  mimetype = thumbnail.mimetype.name;
233
239
  }
234
240
  let action = {
@@ -344,7 +350,7 @@ export default {
344
350
  return undefined
345
351
  } else {
346
352
  // The line below checks if there is a context file for each scaffold. If there is not, we use the first context card for each scaffold.
347
- let contextIndex = this.entry.contextualInformation.length == this.entry.scaffolds.length ? scaffoldIndex : 0
353
+ let contextIndex = this.entry['abi-contextual-information'].length == this.entry.scaffolds.length ? scaffoldIndex : 0
348
354
  return `${this.envVars.API_LOCATION}s3-resource/${this.datasetId}/${this.datasetVersion}/files/${this.entry.contextualInformation[contextIndex]}`
349
355
  }
350
356
  }
@@ -311,12 +311,9 @@ export default {
311
311
  }
312
312
  data.results.forEach(element => {
313
313
  // match the scicrunch result with algolia result
314
- let i = this.results.findIndex(res=> (res.datasetId === element.dataset_identifier) || (res.identifier === element.dataset_identifier))
315
- console.log('i: ', i)
316
- let name = this.results[i].name
314
+ let i = this.results.findIndex(res => element.doi ? element.doi.includes(res.doi) : false )
317
315
  // Assign scicrunch results to the object
318
316
  Object.assign(this.results[i], element)
319
- this.results[i].name = name
320
317
  // Assign the attributes that need some processing
321
318
  Object.assign(this.results[i],{
322
319
  numberSamples: element.sampleSize
@@ -325,8 +322,8 @@ export default {
325
322
  numberSubjects: element.subjectSize
326
323
  ? parseInt(element.subjectSize)
327
324
  : 0,
328
- updated: element.updated ? element.updated[0].timestamp.split("T")[0] : undefined,
329
- url: element.uri? element.uri[0] : undefined,
325
+ updated: (element.updated && element.updated.length) > 0 ? element.updated[0].timestamp.split("T")[0] : "",
326
+ url: element.uri[0],
330
327
  datasetId: element.dataset_identifier,
331
328
  datasetRevision: element.dataset_revision,
332
329
  datasetVersion: element.dataset_version,
@@ -1 +0,0 @@
1
- <svg id="logo-sparc-wave-primary" data-name="logo-sparc-wave-primary" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 400 190.5854"><defs><linearGradient id="linear-gradient" y1="96.3505" x2="400" y2="96.3505" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0b00bf"/><stop offset="1" stop-color="#bc00fc"/></linearGradient></defs><title>SPARC Logo</title><path d="M396.6976,128.6248l-146.2735-3.38a6.5358,6.5358,0,0,0-6.1378,3.9236l-.0612.1407-13.673,31.4482L202.9416,9.5333l-.01-.0685a8.9823,8.9823,0,0,0-17.6624-.0114L163.673,125.3819,3.298,129.2886a3.38,3.38,0,0,0,.0269,6.7592L169.34,138.7635a6.5939,6.5939,0,0,0,6.5373-5.1457l.0571-.2546,17.8534-79.5649L221.26,185.1237l.0256.1243A6.7593,6.7593,0,0,0,234.092,186.52L254.9005,138.66l141.7971-3.2762a3.3805,3.3805,0,0,0,0-6.7592Z" style="fill:url(#linear-gradient)"/><path d="M25.6793,0C41.3957,0,51.057,10.0926,51.057,26.0972v9.5162H36.2053V26.0972c0-7.3532-3.8945-11.8219-10.526-11.8219-6.7768,0-10.6691,4.4687-10.6691,11.8219,0,3.8945,1.2982,7.3533,5.4786,11.3908l19.754,18.601C46.5861,62.1441,52.21,68.7778,52.21,79.88c0,16.0047-9.95,26.0973-25.9543,26.0973C10.108,105.9776.1585,95.885.1585,79.88V70.362H15.01V79.88c0,7.3533,4.0375,11.822,11.2455,11.822,7.065,0,11.1025-4.4687,11.1025-11.822,0-4.4709-2.1628-8.6514-6.0551-12.2576L11.1158,48.7357C3.043,41.2372.1585,34.8939.1585,25.666.1585,10.0926,9.82,0,25.6793,0Z" style="fill:#0e0e19"/><path d="M99.7971,69.7856v35.1821H84.9454V1.01h25.3755c16.0047,0,26.0973,10.0926,26.0973,26.0973V43.6883c0,16.15-10.0926,26.0973-26.0973,26.0973Zm10.3808-13.9849c7.2081,0,11.3908-4.3257,11.3908-11.6789V26.6759c0-7.21-4.1827-11.6811-11.3908-11.6811H99.7971V55.8007Z" style="fill:#0e0e19"/><path d="M278.5812,108.147H263.73V4.1893h26.0972c16.0047,0,26.0973,10.0926,26.0973,26.0972v14.13c0,9.95-4.3257,17.7363-11.3908,22.205,4.1827,12.6889,10.0926,29.9917,13.8418,41.5254h-15.14L290.6914,70.3708h-12.11Zm11.1-51.7632c7.21,0,11.3907-4.3257,11.3907-11.5338V29.8553c0-7.21-4.18-11.6812-11.3907-11.6812h-11.1v38.21Z" style="fill:#0e0e19"/><path d="M399.844,73.5414V83.06c0,16.0047-9.9474,26.0973-25.9521,26.0973-16.15,0-26.0972-10.0926-26.0972-26.0973V29.2766c0-16.0046,9.9473-26.0972,26.0972-26.0972,16.0047,0,25.9521,10.0926,25.9521,26.0972v9.5161h-14.85V29.2766c0-7.3532-4.0374-11.822-11.1025-11.822-7.21,0-11.2477,4.4688-11.2477,11.822V83.06c0,7.3533,4.0375,11.822,11.2477,11.822,7.0651,0,11.1025-4.4687,11.1025-11.822V73.5414Z" style="fill:#0e0e19"/></svg>
@@ -1,104 +0,0 @@
1
- import axios from 'axios'
2
-
3
- export default {
4
- //this mixin is not used by this code base but it can be used by other
5
- //projects to get a handle to various resources
6
- data() {
7
- return {
8
- defaultImg: require('../../assets/logo-sparc-wave-primary.svg'),
9
- }
10
- },
11
- methods: {
12
- async getRequest(url, params, timeout) {
13
- return await axios({
14
- method: 'get',
15
- url,
16
- params,
17
- timeout,
18
- })
19
- },
20
- /**
21
- * Returns a file path for S3.
22
- * @param {String} dataset_id dataset id.
23
- * @param {String} dataset_version dataset version.
24
- * @param {String} file_path file path.
25
- * @returns {String} full path to S3 file.
26
- */
27
- getS3FilePath(dataset_id, dataset_version, file_path) {
28
- const encoded_file_path = encodeURIComponent(file_path)
29
- return `${dataset_id}/${dataset_version}/files/${encoded_file_path}`
30
- },
31
- /**
32
- * Find data path in the array that matches the provide path
33
- */
34
- findEntryWithPathInArray(array, path) {
35
- if (path && array) {
36
- for (let i = 0; i < array.length; i++) {
37
- if (path === array[i].dataset.path) return array[i]
38
- }
39
- }
40
- return undefined
41
- },
42
- getThumbnailForPlot(plot, thumbnails) {
43
- if (thumbnails && plot) {
44
- return this.findEntryWithPathInArray(thumbnails, plot.datacite.isSourceOf.path[0])
45
- }
46
- return undefined
47
- },
48
- /**
49
- * Use the scaffoldViews to help with finding the correct thumbnails.
50
- * Use the index if the workflow stated above fails.
51
- */
52
- getThumbnailForScaffold(scaffold, scaffoldViews, thumbnails, index) {
53
- if (thumbnails && thumbnails.length > 0) {
54
- let thumbnail = undefined
55
- if (scaffold && scaffoldViews) {
56
- const view = this.findEntryWithPathInArray(scaffoldViews, scaffold.datacite.isSourceOf.path[0])
57
- if (view) {
58
- thumbnail = this.findEntryWithPathInArray(thumbnails, view.datacite.isSourceOf.path[0])
59
- }
60
- }
61
- if (thumbnail) {
62
- return thumbnail
63
- } else if (index < thumbnails.length) {
64
- return thumbnails[index]
65
- }
66
- }
67
- return undefined
68
- },
69
- getImageURLFromS3(apiEndpoint, info) {
70
- return `${apiEndpoint}/s3-resource/${info.datasetId}/${info.datasetVersion}/files/${info.file_path}?encodeBase64=true`
71
- },
72
- getSegmentationThumbnailURL(apiEndpoint, info) {
73
- let endpoint = `${apiEndpoint}/thumbnail/neurolucida`
74
- endpoint = endpoint + `?datasetId=${info.datasetId}`
75
- endpoint = endpoint + `&version=${info.datasetVersion}`
76
- endpoint = endpoint + `&path=files/${info.segmentationFilePath}`
77
- return endpoint
78
- },
79
- getThumbnailURLFromBiolucida(apiEndpoint, info) {
80
- return `${apiEndpoint}/thumbnail/${info.id}`
81
- },
82
- getImageInfoFromBiolucida(apiEndpoint, items, info) {
83
- const endpoint = `${apiEndpoint}/image/${info.id}`
84
- const params = {}
85
- this.getRequest(endpoint, params, 20000).then(
86
- (response) => {
87
- let item = items.find((x) => x.id === info.id)
88
- const name = response.name
89
- if (name) {
90
- item.title = name
91
- }
92
- },
93
- (reason) => {
94
- if (reason.message.includes('timeout') && reason.message.includes('exceeded') && info.fetchAttempts < 3) {
95
- info.fetchAttempts += 1
96
- this.getImageInfoFromBiolucida(apiEndpoint, items, info)
97
- }
98
-
99
- return Promise.reject('Maximum iterations reached.')
100
- }
101
- )
102
- },
103
- },
104
- }