@abi-software/flatmapvuer 1.7.5-beta.1 → 1.7.5-beta.2
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/flatmapvuer.js +6953 -6953
- package/dist/flatmapvuer.umd.cjs +94 -94
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/FlatmapVuer.vue +10 -84
- package/src/services/flatmapQueries.js +96 -1
package/package.json
CHANGED
|
@@ -621,6 +621,11 @@ import flatmapMarker from '../icons/flatmap-marker'
|
|
|
621
621
|
import {
|
|
622
622
|
FlatmapQueries,
|
|
623
623
|
findTaxonomyLabels,
|
|
624
|
+
getKnowledgeSource,
|
|
625
|
+
getReferenceConnectivitiesByAPI,
|
|
626
|
+
getReferenceConnectivitiesFromStorage,
|
|
627
|
+
loadAndStoreKnowledge,
|
|
628
|
+
refreshFlatmapKnowledgeCache,
|
|
624
629
|
} from '../services/flatmapQueries.js'
|
|
625
630
|
import { capitalise } from './utilities.js'
|
|
626
631
|
import yellowstar from '../icons/yellowstar'
|
|
@@ -633,7 +638,6 @@ import { DrawToolbar, Tooltip, TreeControls } from '@abi-software/map-utilities'
|
|
|
633
638
|
import '@abi-software/map-utilities/dist/style.css'
|
|
634
639
|
|
|
635
640
|
const ERROR_MESSAGE = 'cannot be found on the map.';
|
|
636
|
-
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
637
641
|
|
|
638
642
|
const centroid = (geometry) => {
|
|
639
643
|
let featureGeometry = { lng: 0, lat: 0, }
|
|
@@ -1862,38 +1866,12 @@ export default {
|
|
|
1862
1866
|
let featureIds = [];
|
|
1863
1867
|
|
|
1864
1868
|
if (flatmapKnowledge) {
|
|
1865
|
-
featureIds = await
|
|
1869
|
+
featureIds = await getReferenceConnectivitiesFromStorage(resource);
|
|
1866
1870
|
} else {
|
|
1867
|
-
featureIds = await this.
|
|
1871
|
+
featureIds = await getReferenceConnectivitiesByAPI(this.mapImp, resource, this.flatmapQueries);
|
|
1868
1872
|
}
|
|
1869
1873
|
return featureIds;
|
|
1870
1874
|
},
|
|
1871
|
-
getReferenceConnectivitiesFromStorage: async function (resource) {
|
|
1872
|
-
const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
|
|
1873
|
-
|
|
1874
|
-
if (flatmapKnowledgeRaw) {
|
|
1875
|
-
const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
|
|
1876
|
-
const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
|
|
1877
|
-
const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
|
|
1878
|
-
|
|
1879
|
-
if (foundData.length) {
|
|
1880
|
-
const featureIds = foundData.map((x) => x.id);
|
|
1881
|
-
return featureIds;
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
return [];
|
|
1885
|
-
},
|
|
1886
|
-
getReferenceConnectivitiesByAPI: async function (resource) {
|
|
1887
|
-
const knowledgeSource = this.getKnowledgeSource(this.mapImp);
|
|
1888
|
-
const sql = `select knowledge from knowledge
|
|
1889
|
-
where source="${knowledgeSource}" and
|
|
1890
|
-
knowledge like "%${resource}%" order by source desc`;
|
|
1891
|
-
const response = await this.flatmapQueries.flatmapQuery(sql);
|
|
1892
|
-
const mappedData = response.values.map((x) => x[0]);
|
|
1893
|
-
const parsedData = mappedData.map((x) => JSON.parse(x));
|
|
1894
|
-
const featureIds = parsedData.map((x) => x.id);
|
|
1895
|
-
return featureIds;
|
|
1896
|
-
},
|
|
1897
1875
|
emitConnectivityGraphError: function (errorData) {
|
|
1898
1876
|
this.$emit('connectivity-graph-error', {
|
|
1899
1877
|
data: {
|
|
@@ -1949,7 +1927,7 @@ export default {
|
|
|
1949
1927
|
let results =
|
|
1950
1928
|
await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp, data)
|
|
1951
1929
|
// load and store knowledge
|
|
1952
|
-
|
|
1930
|
+
loadAndStoreKnowledge(this.mapImp, this.flatmapQueries);
|
|
1953
1931
|
// The line below only creates the tooltip if some data was found on the path
|
|
1954
1932
|
// the pubmed URLs are in knowledge response.references
|
|
1955
1933
|
if (
|
|
@@ -1962,58 +1940,6 @@ export default {
|
|
|
1962
1940
|
}
|
|
1963
1941
|
}
|
|
1964
1942
|
},
|
|
1965
|
-
removeAllCacheData: function () {
|
|
1966
|
-
const keys = [
|
|
1967
|
-
'flatmap-knowledge',
|
|
1968
|
-
'flatmap-knowledge-expiry',
|
|
1969
|
-
];
|
|
1970
|
-
keys.forEach((key) => {
|
|
1971
|
-
sessionStorage.removeItem(key);
|
|
1972
|
-
});
|
|
1973
|
-
},
|
|
1974
|
-
refreshCache: function () {
|
|
1975
|
-
const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
|
|
1976
|
-
const now = new Date();
|
|
1977
|
-
|
|
1978
|
-
if (now.getTime() > expiry) {
|
|
1979
|
-
this.removeAllCacheData();
|
|
1980
|
-
}
|
|
1981
|
-
},
|
|
1982
|
-
updateCacheExpiry: function () {
|
|
1983
|
-
const now = new Date();
|
|
1984
|
-
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
1985
|
-
|
|
1986
|
-
sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
|
|
1987
|
-
},
|
|
1988
|
-
loadAndStoreKnowledge: function (mapImp) {
|
|
1989
|
-
const knowledgeSource = this.getKnowledgeSource(mapImp);
|
|
1990
|
-
const sql = `select knowledge from knowledge
|
|
1991
|
-
where source="${knowledgeSource}"
|
|
1992
|
-
order by source desc`;
|
|
1993
|
-
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1994
|
-
|
|
1995
|
-
if (!flatmapKnowledge) {
|
|
1996
|
-
this.flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
1997
|
-
const mappedData = response.values.map(x => x[0]);
|
|
1998
|
-
const parsedData = mappedData.map(x => JSON.parse(x));
|
|
1999
|
-
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
|
|
2000
|
-
this.updateCacheExpiry();
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
},
|
|
2004
|
-
getKnowledgeSource: function (mapImp) {
|
|
2005
|
-
let mapKnowledgeSource = '';
|
|
2006
|
-
if (mapImp.provenance?.connectivity) {
|
|
2007
|
-
const sckanProvenance = mapImp.provenance.connectivity;
|
|
2008
|
-
if ('knowledge-source' in sckanProvenance) {
|
|
2009
|
-
mapKnowledgeSource = sckanProvenance['knowledge-source'];
|
|
2010
|
-
} else if ('npo' in sckanProvenance) {
|
|
2011
|
-
mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
return mapKnowledgeSource;
|
|
2016
|
-
},
|
|
2017
1943
|
/**
|
|
2018
1944
|
* A hack to remove flatmap tooltips while popup is open
|
|
2019
1945
|
*/
|
|
@@ -2275,7 +2201,7 @@ export default {
|
|
|
2275
2201
|
}
|
|
2276
2202
|
// Get connectivity knowledge source | SCKAN release
|
|
2277
2203
|
if (this.mapImp.provenance?.connectivity) {
|
|
2278
|
-
this.tooltipEntry['knowledge-source'] =
|
|
2204
|
+
this.tooltipEntry['knowledge-source'] = getKnowledgeSource(this.mapImp);
|
|
2279
2205
|
}
|
|
2280
2206
|
this.$emit('connectivity-info-open', this.tooltipEntry);
|
|
2281
2207
|
}
|
|
@@ -3273,7 +3199,7 @@ export default {
|
|
|
3273
3199
|
} else if (this.renderAtMounted) {
|
|
3274
3200
|
this.createFlatmap()
|
|
3275
3201
|
}
|
|
3276
|
-
|
|
3202
|
+
refreshFlatmapKnowledgeCache();
|
|
3277
3203
|
},
|
|
3278
3204
|
}
|
|
3279
3205
|
</script>
|
|
@@ -495,4 +495,99 @@ let FlatmapQueries = function () {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
|
|
498
|
+
async function getReferenceConnectivitiesFromStorage(resource) {
|
|
499
|
+
const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
|
|
500
|
+
|
|
501
|
+
if (flatmapKnowledgeRaw) {
|
|
502
|
+
const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
|
|
503
|
+
const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
|
|
504
|
+
const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
|
|
505
|
+
|
|
506
|
+
if (foundData.length) {
|
|
507
|
+
const featureIds = foundData.map((x) => x.id);
|
|
508
|
+
return featureIds;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return [];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
async function getReferenceConnectivitiesByAPI(mapImp, resource, flatmapQueries) {
|
|
515
|
+
const knowledgeSource = getKnowledgeSource(mapImp);
|
|
516
|
+
const sql = `select knowledge from knowledge
|
|
517
|
+
where source="${knowledgeSource}" and
|
|
518
|
+
knowledge like "%${resource}%" order by source desc`;
|
|
519
|
+
const response = await flatmapQueries.flatmapQuery(sql);
|
|
520
|
+
const mappedData = response.values.map((x) => x[0]);
|
|
521
|
+
const parsedData = mappedData.map((x) => JSON.parse(x));
|
|
522
|
+
const featureIds = parsedData.map((x) => x.id);
|
|
523
|
+
return featureIds;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function getKnowledgeSource(mapImp) {
|
|
527
|
+
let mapKnowledgeSource = '';
|
|
528
|
+
if (mapImp.provenance?.connectivity) {
|
|
529
|
+
const sckanProvenance = mapImp.provenance.connectivity;
|
|
530
|
+
if ('knowledge-source' in sckanProvenance) {
|
|
531
|
+
mapKnowledgeSource = sckanProvenance['knowledge-source'];
|
|
532
|
+
} else if ('npo' in sckanProvenance) {
|
|
533
|
+
mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return mapKnowledgeSource;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function loadAndStoreKnowledge(mapImp, flatmapQueries) {
|
|
541
|
+
const knowledgeSource = getKnowledgeSource(mapImp);
|
|
542
|
+
const sql = `select knowledge from knowledge
|
|
543
|
+
where source="${knowledgeSource}"
|
|
544
|
+
order by source desc`;
|
|
545
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
546
|
+
|
|
547
|
+
if (!flatmapKnowledge) {
|
|
548
|
+
flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
549
|
+
const mappedData = response.values.map(x => x[0]);
|
|
550
|
+
const parsedData = mappedData.map(x => JSON.parse(x));
|
|
551
|
+
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
|
|
552
|
+
updateFlatmapKnowledgeCache();
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function updateFlatmapKnowledgeCache() {
|
|
558
|
+
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
559
|
+
const now = new Date();
|
|
560
|
+
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
561
|
+
|
|
562
|
+
sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function removeFlatmapKnowledgeCache() {
|
|
566
|
+
const keys = [
|
|
567
|
+
'flatmap-knowledge',
|
|
568
|
+
'flatmap-knowledge-expiry',
|
|
569
|
+
];
|
|
570
|
+
keys.forEach((key) => {
|
|
571
|
+
sessionStorage.removeItem(key);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function refreshFlatmapKnowledgeCache() {
|
|
576
|
+
const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
|
|
577
|
+
const now = new Date();
|
|
578
|
+
|
|
579
|
+
if (now.getTime() > expiry) {
|
|
580
|
+
removeFlatmapKnowledgeCache();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export {
|
|
585
|
+
FlatmapQueries,
|
|
586
|
+
findTaxonomyLabel,
|
|
587
|
+
findTaxonomyLabels,
|
|
588
|
+
getReferenceConnectivitiesFromStorage,
|
|
589
|
+
getReferenceConnectivitiesByAPI,
|
|
590
|
+
loadAndStoreKnowledge,
|
|
591
|
+
getKnowledgeSource,
|
|
592
|
+
refreshFlatmapKnowledgeCache,
|
|
593
|
+
}
|