@abi-software/map-utilities 1.2.2-beta.4 → 1.2.2-beta.6
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/dist/map-utilities.js +2323 -2356
- package/dist/map-utilities.umd.cjs +52 -52
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ConnectivityGraph/graph.js +1 -1
- package/src/components/Tooltip/ExternalResourceCard.vue +130 -178
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="attribute-title-container">
|
|
4
4
|
<div class="attribute-title">References</div>
|
|
5
5
|
</div>
|
|
6
|
-
<div class="citation-tabs">
|
|
6
|
+
<div class="citation-tabs" v-if="referencesWithDOI">
|
|
7
7
|
<el-button
|
|
8
8
|
link
|
|
9
9
|
v-for="citationOption of citationOptions"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
<ul class="citation-list">
|
|
18
18
|
<li
|
|
19
|
-
v-for="reference of
|
|
19
|
+
v-for="reference of pubMedReferences"
|
|
20
20
|
:key="reference.id"
|
|
21
21
|
:class="{'loading': reference.citation && reference.citation[citationType] === ''}"
|
|
22
22
|
>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</li>
|
|
33
33
|
|
|
34
34
|
<li v-for="reference of isbnDBReferences">
|
|
35
|
-
<a :href="reference.url">{{ reference.url }}</a>
|
|
35
|
+
<a :href="reference.url" target="_blank">{{ reference.url }}</a>
|
|
36
36
|
<CopyToClipboard :content="reference.url" />
|
|
37
37
|
</li>
|
|
38
38
|
</ul>
|
|
@@ -73,7 +73,6 @@ export default {
|
|
|
73
73
|
},
|
|
74
74
|
data: function () {
|
|
75
75
|
return {
|
|
76
|
-
references: [],
|
|
77
76
|
pubMedReferences: [],
|
|
78
77
|
openLibReferences: [],
|
|
79
78
|
isbnDBReferences: [],
|
|
@@ -84,7 +83,14 @@ export default {
|
|
|
84
83
|
watch: {
|
|
85
84
|
resources: function (_resources) {
|
|
86
85
|
this.formatReferences([..._resources]);
|
|
87
|
-
|
|
86
|
+
this.getCitationText(CITATION_DEFAULT);
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
computed: {
|
|
90
|
+
referencesWithDOI: function () {
|
|
91
|
+
const withDOI = this.pubMedReferences.filter((reference) => reference.type === 'doi' || reference.doi);
|
|
92
|
+
return withDOI.length;
|
|
93
|
+
},
|
|
88
94
|
},
|
|
89
95
|
mounted: function () {
|
|
90
96
|
this.formatReferences([...this.resources]);
|
|
@@ -101,16 +107,26 @@ export default {
|
|
|
101
107
|
this.extractPublicationIdFromURLString(reference)
|
|
102
108
|
);
|
|
103
109
|
|
|
110
|
+
// pmc to pmid
|
|
111
|
+
this.pubMedReferences.forEach((reference) => {
|
|
112
|
+
if (reference.type === 'pmc') {
|
|
113
|
+
const pmcId = reference.id;
|
|
114
|
+
this.searchPMID(pmcId).then((data) => {
|
|
115
|
+
if (data && data.esearchresult) {
|
|
116
|
+
const idList = data.esearchresult.idlist || [];
|
|
117
|
+
reference.id = idList[0];
|
|
118
|
+
reference.type = 'pmid';
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
104
124
|
this.formatNonPubMedReferences(nonPubMedReferences).then((responses) => {
|
|
105
125
|
this.openLibReferences = responses.filter((response) => response.type === 'openlib');
|
|
106
126
|
this.isbnDBReferences = responses.filter((response) => response.type === 'isbndb');
|
|
107
127
|
|
|
108
128
|
this.formatOpenLibReferences();
|
|
109
129
|
});
|
|
110
|
-
|
|
111
|
-
this.references = [
|
|
112
|
-
...this.pubMedReferences,
|
|
113
|
-
];
|
|
114
130
|
},
|
|
115
131
|
extractNonPubMedReferences: function (references) {
|
|
116
132
|
const extractedReferences = [];
|
|
@@ -141,8 +157,7 @@ export default {
|
|
|
141
157
|
const failedIDs = isbnIDs.slice();
|
|
142
158
|
|
|
143
159
|
const openlibAPI = `https://openlibrary.org/api/books?bibkeys=${isbnIDsKey}&format=json`;
|
|
144
|
-
const
|
|
145
|
-
const data = await response.json();
|
|
160
|
+
const data = await this.fetchData(openlibAPI);
|
|
146
161
|
|
|
147
162
|
for (const key in data) {
|
|
148
163
|
const successKeyIndex = failedIDs.indexOf(key);
|
|
@@ -175,29 +190,6 @@ export default {
|
|
|
175
190
|
|
|
176
191
|
return transformedReferences;
|
|
177
192
|
},
|
|
178
|
-
getURLsForPubMed: function (data) {
|
|
179
|
-
return new Promise((resolve) => {
|
|
180
|
-
const ids = data.map((id) =>
|
|
181
|
-
(typeof id === 'object') ?
|
|
182
|
-
this.extractPublicationIdFromURLString(id[0]) :
|
|
183
|
-
this.extractPublicationIdFromURLString(id)
|
|
184
|
-
)
|
|
185
|
-
this.convertPublicationIds(ids).then((pmids) => {
|
|
186
|
-
if (pmids.length > 0) {
|
|
187
|
-
const transformedIDs = [];
|
|
188
|
-
pmids.forEach(pmid => {
|
|
189
|
-
transformedIDs.push({
|
|
190
|
-
id: pmid,
|
|
191
|
-
link: this.pubmedSearchUrl(pmid),
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
resolve(transformedIDs)
|
|
195
|
-
} else {
|
|
196
|
-
resolve([])
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
})
|
|
200
|
-
},
|
|
201
193
|
extractPublicationIdFromURLString: function (urlStr) {
|
|
202
194
|
if (!urlStr) return
|
|
203
195
|
|
|
@@ -248,79 +240,15 @@ export default {
|
|
|
248
240
|
|
|
249
241
|
return names;
|
|
250
242
|
},
|
|
251
|
-
convertPublicationIds: function (ids) {
|
|
252
|
-
return new Promise((resolve) => {
|
|
253
|
-
const pmids = []
|
|
254
|
-
const toBeConverted = []
|
|
255
|
-
ids.forEach((id) => {
|
|
256
|
-
if (id.type === "pmid") {
|
|
257
|
-
pmids.push(id.id)
|
|
258
|
-
} else if (id.type === "doi" || id.type === "pmc") {
|
|
259
|
-
toBeConverted.push(id.id)
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
this.getPMID(toBeConverted).then((idList) => {
|
|
263
|
-
pmids.push(...idList)
|
|
264
|
-
resolve(pmids)
|
|
265
|
-
})
|
|
266
|
-
.catch(() => {
|
|
267
|
-
resolve(pmids)
|
|
268
|
-
})
|
|
269
|
-
})
|
|
270
|
-
},
|
|
271
|
-
pubmedSearchUrl: function (ids) {
|
|
272
|
-
let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
|
|
273
|
-
let params = new URLSearchParams()
|
|
274
|
-
params.append('term', ids)
|
|
275
|
-
return url + params.toString()
|
|
276
|
-
},
|
|
277
243
|
stripPMIDPrefix: function (pubmedId) {
|
|
278
244
|
return pubmedId.split(':')[1]
|
|
279
245
|
},
|
|
280
|
-
getPMID: function(idsList) {
|
|
281
|
-
return new Promise((resolve) => {
|
|
282
|
-
if (idsList.length > 0) {
|
|
283
|
-
//Muliple term search does not work well,
|
|
284
|
-
//DOIs term get splitted unexpectedly
|
|
285
|
-
//
|
|
286
|
-
const promises = []
|
|
287
|
-
const results = []
|
|
288
|
-
let wrapped = ''
|
|
289
|
-
idsList.forEach((id, i) => {
|
|
290
|
-
wrapped += i > 0 ? 'OR"' + id + '"' : '"' + id + '"'
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
const params = new URLSearchParams({
|
|
294
|
-
db: 'pubmed',
|
|
295
|
-
term: wrapped,
|
|
296
|
-
format: 'json'
|
|
297
|
-
})
|
|
298
|
-
const promise = fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?${params}`, {
|
|
299
|
-
method: 'GET',
|
|
300
|
-
})
|
|
301
|
-
.then((response) => response.json())
|
|
302
|
-
.then((data) => {
|
|
303
|
-
const newIds = data.esearchresult ? data.esearchresult.idlist : []
|
|
304
|
-
results.push(...newIds)
|
|
305
|
-
})
|
|
306
|
-
promises.push(promise)
|
|
307
|
-
|
|
308
|
-
Promise.all(promises).then(() => {
|
|
309
|
-
resolve(results)
|
|
310
|
-
}).catch(() => {
|
|
311
|
-
resolve(results)
|
|
312
|
-
})
|
|
313
|
-
} else {
|
|
314
|
-
resolve([])
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
},
|
|
318
246
|
onCitationFormatChange: function(citationType) {
|
|
319
247
|
this.citationType = citationType;
|
|
320
248
|
this.getCitationText(citationType);
|
|
321
249
|
},
|
|
322
250
|
getCitationText: function(citationType) {
|
|
323
|
-
this.
|
|
251
|
+
this.pubMedReferences.forEach((reference) => {
|
|
324
252
|
const { id, type, doi } = reference;
|
|
325
253
|
|
|
326
254
|
if (
|
|
@@ -331,31 +259,71 @@ export default {
|
|
|
331
259
|
|
|
332
260
|
if (type === 'doi' || doi) {
|
|
333
261
|
const doiID = type === 'doi' ? id : doi;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
.
|
|
337
|
-
|
|
338
|
-
|
|
262
|
+
this.getCitationTextByDOI(doiID).then((text) => {
|
|
263
|
+
const formattedText = this.replaceLinkInText(text);
|
|
264
|
+
reference.citation[citationType] = formattedText;
|
|
265
|
+
this.updateCopyContents();
|
|
266
|
+
});
|
|
339
267
|
} else if (type === 'pmid') {
|
|
340
|
-
this.getDOIFromPubMedID(id)
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
268
|
+
this.getDOIFromPubMedID(id).then((data) => {
|
|
269
|
+
if (data?.result) {
|
|
270
|
+
const resultObj = data.result[id];
|
|
271
|
+
const articleIDs = resultObj?.articleids || [];
|
|
272
|
+
const doiObj = articleIDs.find((item) => item.idtype === 'doi');
|
|
273
|
+
const doiID = doiObj?.value;
|
|
274
|
+
|
|
275
|
+
if (doiID) {
|
|
347
276
|
reference['doi'] = doiID;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
.
|
|
351
|
-
|
|
352
|
-
|
|
277
|
+
this.getCitationTextByDOI(doiID).then((text) => {
|
|
278
|
+
const formattedText = this.replaceLinkInText(text);
|
|
279
|
+
reference.citation[citationType] = formattedText;
|
|
280
|
+
this.updateCopyContents();
|
|
281
|
+
});
|
|
282
|
+
} else {
|
|
283
|
+
// If there has no doi in PubMed
|
|
284
|
+
const { title, pubdate, authors } = resultObj;
|
|
285
|
+
const authorNames = authors ? authors.map((author) => author.name) : [];
|
|
286
|
+
const formattedText = this.formatCopyReference({
|
|
287
|
+
title: title || '',
|
|
288
|
+
date: pubdate || '',
|
|
289
|
+
authors: authorNames,
|
|
290
|
+
url: `https://pubmed.ncbi.nlm.nih.gov/${id}`,
|
|
291
|
+
});
|
|
292
|
+
reference.citation[citationType] = formattedText;
|
|
293
|
+
this.updateCopyContents();
|
|
353
294
|
}
|
|
354
|
-
}
|
|
295
|
+
}
|
|
296
|
+
});
|
|
355
297
|
}
|
|
356
298
|
}
|
|
357
299
|
});
|
|
358
300
|
},
|
|
301
|
+
updateCopyContents: function () {
|
|
302
|
+
const citationTypeObj = this.citationOptions.find((item) => item.value === this.citationType);
|
|
303
|
+
let citationFormatStyle = '';
|
|
304
|
+
const values = [];
|
|
305
|
+
|
|
306
|
+
if (this.referencesWithDOI) {
|
|
307
|
+
citationFormatStyle = citationTypeObj?.label;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this.pubMedReferences.forEach((reference) => {
|
|
311
|
+
values.push(reference.citation[this.citationType]);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
this.openLibReferences.forEach((reference) => {
|
|
315
|
+
values.push(this.formatCopyReference(reference));
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
this.isbnDBReferences.forEach((reference) => {
|
|
319
|
+
values.push(reference.url);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
this.$emit('references-loaded', {
|
|
323
|
+
style: citationFormatStyle,
|
|
324
|
+
list: values
|
|
325
|
+
});
|
|
326
|
+
},
|
|
359
327
|
replaceLinkInText: function (text) {
|
|
360
328
|
const protocol = 'https://';
|
|
361
329
|
let linkBody = text.split(protocol)[1];
|
|
@@ -376,87 +344,55 @@ export default {
|
|
|
376
344
|
|
|
377
345
|
return text;
|
|
378
346
|
},
|
|
347
|
+
searchPMID: async function (term) {
|
|
348
|
+
const esearchAPI = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=${term}&format=json`;
|
|
349
|
+
return await this.fetchData(esearchAPI);
|
|
350
|
+
},
|
|
379
351
|
getCitationTextByDOI: async function (id) {
|
|
380
352
|
const citationAPI = `${CROSSCITE_API_HOST}/format?doi=${id}&style=${this.citationType}&lang=en-US`;
|
|
381
|
-
|
|
382
|
-
const response = await fetch(citationAPI);
|
|
383
|
-
if (!response.ok) {
|
|
384
|
-
throw new Error(`Response status: ${response.status}`);
|
|
385
|
-
}
|
|
386
|
-
const data = await response.text();
|
|
387
|
-
return data;
|
|
388
|
-
} catch (error) {
|
|
389
|
-
console.error(`Fetch citation text error: ${error}`);
|
|
390
|
-
}
|
|
353
|
+
return await this.fetchData(citationAPI, 'text');
|
|
391
354
|
},
|
|
392
355
|
getDOIFromPubMedID: async function (pubmedId) {
|
|
393
356
|
const summaryAPI = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id=${pubmedId}&format=json`;
|
|
394
|
-
|
|
395
|
-
const response = await fetch(summaryAPI);
|
|
396
|
-
if (!response.ok) {
|
|
397
|
-
throw new Error(`Response status: ${response.status}`);
|
|
398
|
-
}
|
|
399
|
-
const data = await response.json();
|
|
400
|
-
return data;
|
|
401
|
-
} catch (error) {
|
|
402
|
-
console.error(`Fetch article summary error: ${error}`);
|
|
403
|
-
}
|
|
357
|
+
return await this.fetchData(summaryAPI);
|
|
404
358
|
},
|
|
405
359
|
formatOpenLibReferences: function () {
|
|
406
360
|
this.openLibReferences.forEach((reference) => {
|
|
407
361
|
const { bookId } = reference;
|
|
408
|
-
this.getBookData(bookId)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
362
|
+
this.getBookData(bookId).then((data) => {
|
|
363
|
+
const { title, authors, publish_date } = data;
|
|
364
|
+
if (title) {
|
|
365
|
+
reference['title'] = title;
|
|
366
|
+
}
|
|
414
367
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
368
|
+
if (publish_date) {
|
|
369
|
+
reference['date'] = publish_date;
|
|
370
|
+
}
|
|
418
371
|
|
|
419
|
-
|
|
420
|
-
|
|
372
|
+
if (authors) {
|
|
373
|
+
reference['authors'] = [];
|
|
421
374
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
});
|
|
375
|
+
authors.forEach((author) => {
|
|
376
|
+
this.getBookAuthor(author.key).then((data) => {
|
|
377
|
+
const { name } = data;
|
|
378
|
+
if (name) {
|
|
379
|
+
reference['authors'].push(name);
|
|
380
|
+
this.updateCopyContents();
|
|
381
|
+
}
|
|
430
382
|
});
|
|
431
|
-
}
|
|
432
|
-
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
this.updateCopyContents();
|
|
386
|
+
});
|
|
433
387
|
});
|
|
434
388
|
},
|
|
435
389
|
getBookData: async function (bookId) {
|
|
436
390
|
const apiURL = `https://openlibrary.org/books/${bookId}.json`;
|
|
437
|
-
|
|
438
|
-
const response = await fetch(apiURL);
|
|
439
|
-
if (!response.ok) {
|
|
440
|
-
throw new Error(`Response status: ${response.status}`);
|
|
441
|
-
}
|
|
442
|
-
const data = await response.json();
|
|
443
|
-
return data;
|
|
444
|
-
} catch (error) {
|
|
445
|
-
console.error(`Fetch book data error: ${error}`);
|
|
446
|
-
}
|
|
391
|
+
return await this.fetchData(apiURL);
|
|
447
392
|
},
|
|
448
393
|
getBookAuthor: async function (key) {
|
|
449
394
|
const apiURL = `https://openlibrary.org${key}.json`;
|
|
450
|
-
|
|
451
|
-
const response = await fetch(apiURL);
|
|
452
|
-
if (!response.ok) {
|
|
453
|
-
throw new Error(`Response status: ${response.status}`);
|
|
454
|
-
}
|
|
455
|
-
const data = await response.json();
|
|
456
|
-
return data;
|
|
457
|
-
} catch (error) {
|
|
458
|
-
console.error(`Fetch book author error: ${error}`);
|
|
459
|
-
}
|
|
395
|
+
return await this.fetchData(apiURL);
|
|
460
396
|
},
|
|
461
397
|
formatCopyReference: function (reference) {
|
|
462
398
|
const copyContents = [];
|
|
@@ -478,6 +414,22 @@ export default {
|
|
|
478
414
|
|
|
479
415
|
return copyContents.join(' ');
|
|
480
416
|
},
|
|
417
|
+
fetchData: async function (apiURL, format) {
|
|
418
|
+
try {
|
|
419
|
+
const response = await fetch(apiURL);
|
|
420
|
+
if (!response.ok) {
|
|
421
|
+
throw new Error(`Response status: ${response.status}`);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (format === 'text') {
|
|
425
|
+
return await response.text();
|
|
426
|
+
} else {
|
|
427
|
+
return await response.json();
|
|
428
|
+
}
|
|
429
|
+
} catch (error) {
|
|
430
|
+
console.error(`Fetch data error: ${error}`);
|
|
431
|
+
}
|
|
432
|
+
},
|
|
481
433
|
},
|
|
482
434
|
}
|
|
483
435
|
</script>
|