@abi-software/flatmapvuer 1.7.4-beta.2 → 1.7.4-beta.5
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 +21602 -24341
- package/dist/flatmapvuer.umd.cjs +104 -100
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/src/components/FlatmapVuer.vue +95 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "1.7.4-beta.
|
|
3
|
+
"version": "1.7.4-beta.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/*",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"./src/*": "./src/*"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@abi-software/flatmap-viewer": "3.2.
|
|
47
|
-
"@abi-software/map-utilities": "^1.3.3-beta.
|
|
46
|
+
"@abi-software/flatmap-viewer": "3.2.13",
|
|
47
|
+
"@abi-software/map-utilities": "^1.3.3-beta.4",
|
|
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",
|
|
@@ -633,6 +633,7 @@ import { DrawToolbar, Tooltip, TreeControls } from '@abi-software/map-utilities'
|
|
|
633
633
|
import '@abi-software/map-utilities/dist/style.css'
|
|
634
634
|
|
|
635
635
|
const ERROR_MESSAGE = 'cannot be found on the map.';
|
|
636
|
+
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
636
637
|
|
|
637
638
|
const centroid = (geometry) => {
|
|
638
639
|
let featureGeometry = { lng: 0, lat: 0, }
|
|
@@ -1832,6 +1833,44 @@ export default {
|
|
|
1832
1833
|
this.mapImp.selectGeoJSONFeatures(allFeaturesToHighlight);
|
|
1833
1834
|
}
|
|
1834
1835
|
},
|
|
1836
|
+
showConnectivitiesByReference: function (resource) {
|
|
1837
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1838
|
+
|
|
1839
|
+
if (!flatmapKnowledge) {
|
|
1840
|
+
this.highlightReferenceConnectivitiesByAPI(resource);
|
|
1841
|
+
} else {
|
|
1842
|
+
this.highlightReferenceConnectivitiesFromStorage(resource);
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
// Store in storage and highlight
|
|
1846
|
+
highlightReferenceConnectivitiesFromStorage: function (resource) {
|
|
1847
|
+
const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
|
|
1848
|
+
|
|
1849
|
+
if (flatmapKnowledgeRaw) {
|
|
1850
|
+
const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
|
|
1851
|
+
const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
|
|
1852
|
+
const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
|
|
1853
|
+
|
|
1854
|
+
if (foundData.length) {
|
|
1855
|
+
const featureIds = foundData.map((x) => x.id);
|
|
1856
|
+
this.mapImp.selectFeatures(featureIds);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
// Directly load from API and highlight
|
|
1861
|
+
highlightReferenceConnectivitiesByAPI: function (resource) {
|
|
1862
|
+
const knowledgeSource = this.getKnowledgeSource(this.mapImp);
|
|
1863
|
+
const sql = `select knowledge from knowledge
|
|
1864
|
+
where source="${knowledgeSource}" and
|
|
1865
|
+
knowledge like "%${resource}%" order by source desc`;
|
|
1866
|
+
|
|
1867
|
+
this.flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
1868
|
+
const mappedData = response.values.map((x) => x[0]);
|
|
1869
|
+
const parsedData = mappedData.map((x) => JSON.parse(x));
|
|
1870
|
+
const featureIds = parsedData.map((x) => x.id);
|
|
1871
|
+
this.mapImp.selectFeatures(featureIds);
|
|
1872
|
+
});
|
|
1873
|
+
},
|
|
1835
1874
|
emitConnectivityGraphError: function (errorData) {
|
|
1836
1875
|
this.$emit('connectivity-graph-error', {
|
|
1837
1876
|
data: {
|
|
@@ -1886,6 +1925,8 @@ export default {
|
|
|
1886
1925
|
//require data.resource && data.feature.source
|
|
1887
1926
|
let results =
|
|
1888
1927
|
await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp, data)
|
|
1928
|
+
// load and store knowledge
|
|
1929
|
+
this.loadAndStoreKnowledge(this.mapImp);
|
|
1889
1930
|
// The line below only creates the tooltip if some data was found on the path
|
|
1890
1931
|
// the pubmed URLs are in knowledge response.references
|
|
1891
1932
|
if (
|
|
@@ -1898,6 +1939,58 @@ export default {
|
|
|
1898
1939
|
}
|
|
1899
1940
|
}
|
|
1900
1941
|
},
|
|
1942
|
+
removeAllCacheData: function () {
|
|
1943
|
+
const keys = [
|
|
1944
|
+
'flatmap-knowledge',
|
|
1945
|
+
'flatmap-knowledge-expiry',
|
|
1946
|
+
];
|
|
1947
|
+
keys.forEach((key) => {
|
|
1948
|
+
sessionStorage.removeItem(key);
|
|
1949
|
+
});
|
|
1950
|
+
},
|
|
1951
|
+
refreshCache: function () {
|
|
1952
|
+
const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
|
|
1953
|
+
const now = new Date();
|
|
1954
|
+
|
|
1955
|
+
if (now.getTime() > expiry) {
|
|
1956
|
+
this.removeAllCacheData();
|
|
1957
|
+
}
|
|
1958
|
+
},
|
|
1959
|
+
updateCacheExpiry: function () {
|
|
1960
|
+
const now = new Date();
|
|
1961
|
+
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
1962
|
+
|
|
1963
|
+
sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
|
|
1964
|
+
},
|
|
1965
|
+
loadAndStoreKnowledge: function (mapImp) {
|
|
1966
|
+
const knowledgeSource = this.getKnowledgeSource(mapImp);
|
|
1967
|
+
const sql = `select knowledge from knowledge
|
|
1968
|
+
where source="${knowledgeSource}"
|
|
1969
|
+
order by source desc`;
|
|
1970
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1971
|
+
|
|
1972
|
+
if (!flatmapKnowledge) {
|
|
1973
|
+
this.flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
1974
|
+
const mappedData = response.values.map(x => x[0]);
|
|
1975
|
+
const parsedData = mappedData.map(x => JSON.parse(x));
|
|
1976
|
+
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
|
|
1977
|
+
this.updateCacheExpiry();
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
},
|
|
1981
|
+
getKnowledgeSource: function (mapImp) {
|
|
1982
|
+
let mapKnowledgeSource = '';
|
|
1983
|
+
if (mapImp.provenance?.connectivity) {
|
|
1984
|
+
const sckanProvenance = mapImp.provenance.connectivity;
|
|
1985
|
+
if ('knowledge-source' in sckanProvenance) {
|
|
1986
|
+
mapKnowledgeSource = sckanProvenance['knowledge-source'];
|
|
1987
|
+
} else if ('npo' in sckanProvenance) {
|
|
1988
|
+
mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
return mapKnowledgeSource;
|
|
1993
|
+
},
|
|
1901
1994
|
/**
|
|
1902
1995
|
* A hack to remove flatmap tooltips while popup is open
|
|
1903
1996
|
*/
|
|
@@ -2159,12 +2252,7 @@ export default {
|
|
|
2159
2252
|
}
|
|
2160
2253
|
// Get connectivity knowledge source | SCKAN release
|
|
2161
2254
|
if (this.mapImp.provenance?.connectivity) {
|
|
2162
|
-
|
|
2163
|
-
if ('knowledge-source' in sckanProvenance) {
|
|
2164
|
-
this.tooltipEntry['knowledge-source'] = sckanProvenance['knowledge-source'];
|
|
2165
|
-
} else if ('npo' in sckanProvenance) {
|
|
2166
|
-
this.tooltipEntry['knowledge-source'] = `${sckanProvenance.npo.release}-npo`;
|
|
2167
|
-
}
|
|
2255
|
+
this.tooltipEntry['knowledge-source'] = this.getKnowledgeSource(this.mapImp);
|
|
2168
2256
|
}
|
|
2169
2257
|
this.$emit('connectivity-info-open', this.tooltipEntry);
|
|
2170
2258
|
}
|
|
@@ -3159,6 +3247,7 @@ export default {
|
|
|
3159
3247
|
} else if (this.renderAtMounted) {
|
|
3160
3248
|
this.createFlatmap()
|
|
3161
3249
|
}
|
|
3250
|
+
this.refreshCache();
|
|
3162
3251
|
},
|
|
3163
3252
|
}
|
|
3164
3253
|
</script>
|