@abi-software/flatmapvuer 1.7.5-beta.1 → 1.7.5-beta.3
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 +2 -2
- package/src/components/FlatmapVuer.vue +12 -84
- package/src/services/flatmapKnowledge.js +93 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "1.7.5-beta.
|
|
3
|
+
"version": "1.7.5-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/*",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@abi-software/flatmap-viewer": "3.2.13",
|
|
47
|
-
"@abi-software/map-utilities": "^1.3.3-beta.
|
|
47
|
+
"@abi-software/map-utilities": "^1.3.3-beta.5",
|
|
48
48
|
"@abi-software/sparc-annotation": "0.3.2",
|
|
49
49
|
"@abi-software/svg-sprite": "^1.0.1",
|
|
50
50
|
"@element-plus/icons-vue": "^2.3.1",
|
|
@@ -622,6 +622,13 @@ import {
|
|
|
622
622
|
FlatmapQueries,
|
|
623
623
|
findTaxonomyLabels,
|
|
624
624
|
} from '../services/flatmapQueries.js'
|
|
625
|
+
import {
|
|
626
|
+
getReferenceConnectivitiesFromStorage,
|
|
627
|
+
loadAndStoreKnowledge,
|
|
628
|
+
refreshFlatmapKnowledgeCache,
|
|
629
|
+
getKnowledgeSource,
|
|
630
|
+
getReferenceConnectivitiesByAPI,
|
|
631
|
+
} from '../services/flatmapKnowledge.js'
|
|
625
632
|
import { capitalise } from './utilities.js'
|
|
626
633
|
import yellowstar from '../icons/yellowstar'
|
|
627
634
|
import ResizeSensor from 'css-element-queries/src/ResizeSensor'
|
|
@@ -633,7 +640,6 @@ import { DrawToolbar, Tooltip, TreeControls } from '@abi-software/map-utilities'
|
|
|
633
640
|
import '@abi-software/map-utilities/dist/style.css'
|
|
634
641
|
|
|
635
642
|
const ERROR_MESSAGE = 'cannot be found on the map.';
|
|
636
|
-
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
637
643
|
|
|
638
644
|
const centroid = (geometry) => {
|
|
639
645
|
let featureGeometry = { lng: 0, lat: 0, }
|
|
@@ -1862,36 +1868,10 @@ export default {
|
|
|
1862
1868
|
let featureIds = [];
|
|
1863
1869
|
|
|
1864
1870
|
if (flatmapKnowledge) {
|
|
1865
|
-
featureIds = await
|
|
1871
|
+
featureIds = await getReferenceConnectivitiesFromStorage(resource);
|
|
1866
1872
|
} else {
|
|
1867
|
-
featureIds = await this.
|
|
1868
|
-
}
|
|
1869
|
-
return featureIds;
|
|
1870
|
-
},
|
|
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
|
-
}
|
|
1873
|
+
featureIds = await getReferenceConnectivitiesByAPI(this.mapImp, resource, this.flatmapQueries);
|
|
1883
1874
|
}
|
|
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
1875
|
return featureIds;
|
|
1896
1876
|
},
|
|
1897
1877
|
emitConnectivityGraphError: function (errorData) {
|
|
@@ -1949,7 +1929,7 @@ export default {
|
|
|
1949
1929
|
let results =
|
|
1950
1930
|
await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp, data)
|
|
1951
1931
|
// load and store knowledge
|
|
1952
|
-
|
|
1932
|
+
loadAndStoreKnowledge(this.mapImp, this.flatmapQueries);
|
|
1953
1933
|
// The line below only creates the tooltip if some data was found on the path
|
|
1954
1934
|
// the pubmed URLs are in knowledge response.references
|
|
1955
1935
|
if (
|
|
@@ -1962,58 +1942,6 @@ export default {
|
|
|
1962
1942
|
}
|
|
1963
1943
|
}
|
|
1964
1944
|
},
|
|
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
1945
|
/**
|
|
2018
1946
|
* A hack to remove flatmap tooltips while popup is open
|
|
2019
1947
|
*/
|
|
@@ -2275,7 +2203,7 @@ export default {
|
|
|
2275
2203
|
}
|
|
2276
2204
|
// Get connectivity knowledge source | SCKAN release
|
|
2277
2205
|
if (this.mapImp.provenance?.connectivity) {
|
|
2278
|
-
this.tooltipEntry['knowledge-source'] =
|
|
2206
|
+
this.tooltipEntry['knowledge-source'] = getKnowledgeSource(this.mapImp);
|
|
2279
2207
|
}
|
|
2280
2208
|
this.$emit('connectivity-info-open', this.tooltipEntry);
|
|
2281
2209
|
}
|
|
@@ -3273,7 +3201,7 @@ export default {
|
|
|
3273
3201
|
} else if (this.renderAtMounted) {
|
|
3274
3202
|
this.createFlatmap()
|
|
3275
3203
|
}
|
|
3276
|
-
|
|
3204
|
+
refreshFlatmapKnowledgeCache();
|
|
3277
3205
|
},
|
|
3278
3206
|
}
|
|
3279
3207
|
</script>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
async function getReferenceConnectivitiesFromStorage(resource) {
|
|
2
|
+
const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
|
|
3
|
+
|
|
4
|
+
if (flatmapKnowledgeRaw) {
|
|
5
|
+
const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
|
|
6
|
+
const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
|
|
7
|
+
const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
|
|
8
|
+
|
|
9
|
+
if (foundData.length) {
|
|
10
|
+
const featureIds = foundData.map((x) => x.id);
|
|
11
|
+
return featureIds;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function getReferenceConnectivitiesByAPI(mapImp, resource, flatmapQueries) {
|
|
18
|
+
const knowledgeSource = getKnowledgeSource(mapImp);
|
|
19
|
+
const sql = `select knowledge from knowledge
|
|
20
|
+
where source="${knowledgeSource}" and
|
|
21
|
+
knowledge like "%${resource}%" order by source desc`;
|
|
22
|
+
const response = await flatmapQueries.flatmapQuery(sql);
|
|
23
|
+
const mappedData = response.values.map((x) => x[0]);
|
|
24
|
+
const parsedData = mappedData.map((x) => JSON.parse(x));
|
|
25
|
+
const featureIds = parsedData.map((x) => x.id);
|
|
26
|
+
return featureIds;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getKnowledgeSource(mapImp) {
|
|
30
|
+
let mapKnowledgeSource = '';
|
|
31
|
+
if (mapImp.provenance?.connectivity) {
|
|
32
|
+
const sckanProvenance = mapImp.provenance.connectivity;
|
|
33
|
+
if ('knowledge-source' in sckanProvenance) {
|
|
34
|
+
mapKnowledgeSource = sckanProvenance['knowledge-source'];
|
|
35
|
+
} else if ('npo' in sckanProvenance) {
|
|
36
|
+
mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return mapKnowledgeSource;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function loadAndStoreKnowledge(mapImp, flatmapQueries) {
|
|
44
|
+
const knowledgeSource = getKnowledgeSource(mapImp);
|
|
45
|
+
const sql = `select knowledge from knowledge
|
|
46
|
+
where source="${knowledgeSource}"
|
|
47
|
+
order by source desc`;
|
|
48
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
49
|
+
|
|
50
|
+
if (!flatmapKnowledge) {
|
|
51
|
+
flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
52
|
+
const mappedData = response.values.map(x => x[0]);
|
|
53
|
+
const parsedData = mappedData.map(x => JSON.parse(x));
|
|
54
|
+
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
|
|
55
|
+
updateFlatmapKnowledgeCache();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function updateFlatmapKnowledgeCache() {
|
|
61
|
+
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
64
|
+
|
|
65
|
+
sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function removeFlatmapKnowledgeCache() {
|
|
69
|
+
const keys = [
|
|
70
|
+
'flatmap-knowledge',
|
|
71
|
+
'flatmap-knowledge-expiry',
|
|
72
|
+
];
|
|
73
|
+
keys.forEach((key) => {
|
|
74
|
+
sessionStorage.removeItem(key);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function refreshFlatmapKnowledgeCache() {
|
|
79
|
+
const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
|
|
80
|
+
const now = new Date();
|
|
81
|
+
|
|
82
|
+
if (now.getTime() > expiry) {
|
|
83
|
+
removeFlatmapKnowledgeCache();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
getReferenceConnectivitiesFromStorage,
|
|
89
|
+
getReferenceConnectivitiesByAPI,
|
|
90
|
+
loadAndStoreKnowledge,
|
|
91
|
+
getKnowledgeSource,
|
|
92
|
+
refreshFlatmapKnowledgeCache,
|
|
93
|
+
}
|