@abi-software/flatmapvuer 1.7.4 → 1.7.5-beta.0
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 +2277 -2222
- package/dist/flatmapvuer.umd.cjs +52 -48
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/FlatmapVuer.vue +114 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5-beta.0",
|
|
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.
|
|
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, }
|
|
@@ -1471,16 +1472,19 @@ export default {
|
|
|
1471
1472
|
taxonMouseEnterEmitted: function (payload) {
|
|
1472
1473
|
if (this.mapImp) {
|
|
1473
1474
|
if (payload.value) {
|
|
1475
|
+
clearTimeout(this.taxonLeaveDelay)
|
|
1474
1476
|
let gid = this.mapImp.taxonFeatureIds(payload.key)
|
|
1475
1477
|
this.mapImp.enableConnectivityByTaxonIds(payload.key, payload.value) // make sure path is visible
|
|
1476
1478
|
this.mapImp.zoomToGeoJSONFeatures(gid, {noZoomIn: true})
|
|
1477
1479
|
} else {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1480
|
+
this.taxonLeaveDelay = setTimeout(() => {
|
|
1481
|
+
// reset visibility of paths
|
|
1482
|
+
this.mapImp.unselectGeoJSONFeatures()
|
|
1483
|
+
payload.selections.forEach((item) => {
|
|
1484
|
+
let show = payload.checked.includes(item.taxon)
|
|
1485
|
+
this.mapImp.enableConnectivityByTaxonIds(item.taxon, show)
|
|
1486
|
+
})
|
|
1487
|
+
}, 1000);
|
|
1484
1488
|
}
|
|
1485
1489
|
}
|
|
1486
1490
|
},
|
|
@@ -1492,9 +1496,7 @@ export default {
|
|
|
1492
1496
|
*/
|
|
1493
1497
|
checkAllTaxons: function (payload) {
|
|
1494
1498
|
if (this.mapImp) {
|
|
1495
|
-
payload.keys.
|
|
1496
|
-
this.mapImp.enableConnectivityByTaxonIds(key, payload.value)
|
|
1497
|
-
)
|
|
1499
|
+
this.mapImp.enableConnectivityByTaxonIds(payload.keys, payload.value)
|
|
1498
1500
|
}
|
|
1499
1501
|
},
|
|
1500
1502
|
/**
|
|
@@ -1676,6 +1678,7 @@ export default {
|
|
|
1676
1678
|
// Disable popup when drawing
|
|
1677
1679
|
!this.activeDrawTool
|
|
1678
1680
|
) {
|
|
1681
|
+
this.connectivityDataSource = data.source;
|
|
1679
1682
|
this.checkAndCreatePopups(payload)
|
|
1680
1683
|
}
|
|
1681
1684
|
this.$emit('resource-selected', payload)
|
|
@@ -1832,6 +1835,48 @@ export default {
|
|
|
1832
1835
|
this.mapImp.selectGeoJSONFeatures(allFeaturesToHighlight);
|
|
1833
1836
|
}
|
|
1834
1837
|
},
|
|
1838
|
+
showConnectivitiesByReference: function (resource) {
|
|
1839
|
+
this.searchConnectivitiesByReference(resource).then((featureIds) => {
|
|
1840
|
+
this.mapImp.selectFeatures(featureIds);
|
|
1841
|
+
});
|
|
1842
|
+
},
|
|
1843
|
+
searchConnectivitiesByReference: async function (resource) {
|
|
1844
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1845
|
+
let featureIds = [];
|
|
1846
|
+
|
|
1847
|
+
if (flatmapKnowledge) {
|
|
1848
|
+
featureIds = await this.getReferenceConnectivitiesFromStorage(resource);
|
|
1849
|
+
} else {
|
|
1850
|
+
featureIds = await this.getReferenceConnectivitiesByAPI(resource);
|
|
1851
|
+
}
|
|
1852
|
+
return featureIds;
|
|
1853
|
+
},
|
|
1854
|
+
getReferenceConnectivitiesFromStorage: async function (resource) {
|
|
1855
|
+
const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
|
|
1856
|
+
|
|
1857
|
+
if (flatmapKnowledgeRaw) {
|
|
1858
|
+
const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
|
|
1859
|
+
const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
|
|
1860
|
+
const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
|
|
1861
|
+
|
|
1862
|
+
if (foundData.length) {
|
|
1863
|
+
const featureIds = foundData.map((x) => x.id);
|
|
1864
|
+
return featureIds;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return [];
|
|
1868
|
+
},
|
|
1869
|
+
getReferenceConnectivitiesByAPI: async function (resource) {
|
|
1870
|
+
const knowledgeSource = this.getKnowledgeSource(this.mapImp);
|
|
1871
|
+
const sql = `select knowledge from knowledge
|
|
1872
|
+
where source="${knowledgeSource}" and
|
|
1873
|
+
knowledge like "%${resource}%" order by source desc`;
|
|
1874
|
+
const response = await this.flatmapQueries.flatmapQuery(sql);
|
|
1875
|
+
const mappedData = response.values.map((x) => x[0]);
|
|
1876
|
+
const parsedData = mappedData.map((x) => JSON.parse(x));
|
|
1877
|
+
const featureIds = parsedData.map((x) => x.id);
|
|
1878
|
+
return featureIds;
|
|
1879
|
+
},
|
|
1835
1880
|
emitConnectivityGraphError: function (errorData) {
|
|
1836
1881
|
this.$emit('connectivity-graph-error', {
|
|
1837
1882
|
data: {
|
|
@@ -1886,6 +1931,8 @@ export default {
|
|
|
1886
1931
|
//require data.resource && data.feature.source
|
|
1887
1932
|
let results =
|
|
1888
1933
|
await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp, data)
|
|
1934
|
+
// load and store knowledge
|
|
1935
|
+
this.loadAndStoreKnowledge(this.mapImp);
|
|
1889
1936
|
// The line below only creates the tooltip if some data was found on the path
|
|
1890
1937
|
// the pubmed URLs are in knowledge response.references
|
|
1891
1938
|
if (
|
|
@@ -1898,6 +1945,58 @@ export default {
|
|
|
1898
1945
|
}
|
|
1899
1946
|
}
|
|
1900
1947
|
},
|
|
1948
|
+
removeAllCacheData: function () {
|
|
1949
|
+
const keys = [
|
|
1950
|
+
'flatmap-knowledge',
|
|
1951
|
+
'flatmap-knowledge-expiry',
|
|
1952
|
+
];
|
|
1953
|
+
keys.forEach((key) => {
|
|
1954
|
+
sessionStorage.removeItem(key);
|
|
1955
|
+
});
|
|
1956
|
+
},
|
|
1957
|
+
refreshCache: function () {
|
|
1958
|
+
const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
|
|
1959
|
+
const now = new Date();
|
|
1960
|
+
|
|
1961
|
+
if (now.getTime() > expiry) {
|
|
1962
|
+
this.removeAllCacheData();
|
|
1963
|
+
}
|
|
1964
|
+
},
|
|
1965
|
+
updateCacheExpiry: function () {
|
|
1966
|
+
const now = new Date();
|
|
1967
|
+
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
1968
|
+
|
|
1969
|
+
sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
|
|
1970
|
+
},
|
|
1971
|
+
loadAndStoreKnowledge: function (mapImp) {
|
|
1972
|
+
const knowledgeSource = this.getKnowledgeSource(mapImp);
|
|
1973
|
+
const sql = `select knowledge from knowledge
|
|
1974
|
+
where source="${knowledgeSource}"
|
|
1975
|
+
order by source desc`;
|
|
1976
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1977
|
+
|
|
1978
|
+
if (!flatmapKnowledge) {
|
|
1979
|
+
this.flatmapQueries.flatmapQuery(sql).then((response) => {
|
|
1980
|
+
const mappedData = response.values.map(x => x[0]);
|
|
1981
|
+
const parsedData = mappedData.map(x => JSON.parse(x));
|
|
1982
|
+
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
|
|
1983
|
+
this.updateCacheExpiry();
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
getKnowledgeSource: function (mapImp) {
|
|
1988
|
+
let mapKnowledgeSource = '';
|
|
1989
|
+
if (mapImp.provenance?.connectivity) {
|
|
1990
|
+
const sckanProvenance = mapImp.provenance.connectivity;
|
|
1991
|
+
if ('knowledge-source' in sckanProvenance) {
|
|
1992
|
+
mapKnowledgeSource = sckanProvenance['knowledge-source'];
|
|
1993
|
+
} else if ('npo' in sckanProvenance) {
|
|
1994
|
+
mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
return mapKnowledgeSource;
|
|
1999
|
+
},
|
|
1901
2000
|
/**
|
|
1902
2001
|
* A hack to remove flatmap tooltips while popup is open
|
|
1903
2002
|
*/
|
|
@@ -2159,12 +2258,7 @@ export default {
|
|
|
2159
2258
|
}
|
|
2160
2259
|
// Get connectivity knowledge source | SCKAN release
|
|
2161
2260
|
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
|
-
}
|
|
2261
|
+
this.tooltipEntry['knowledge-source'] = this.getKnowledgeSource(this.mapImp);
|
|
2168
2262
|
}
|
|
2169
2263
|
this.$emit('connectivity-info-open', this.tooltipEntry);
|
|
2170
2264
|
}
|
|
@@ -2597,9 +2691,10 @@ export default {
|
|
|
2597
2691
|
} else {
|
|
2598
2692
|
this.statesTracking.activeTerm = ""
|
|
2599
2693
|
}
|
|
2600
|
-
if (this.
|
|
2694
|
+
if (!this.connectivityDataSource) {
|
|
2601
2695
|
this.$emit('connectivity-info-close');
|
|
2602
2696
|
}
|
|
2697
|
+
this.connectivityDataSource = ''; // reset
|
|
2603
2698
|
});
|
|
2604
2699
|
}
|
|
2605
2700
|
},
|
|
@@ -2941,6 +3036,7 @@ export default {
|
|
|
2941
3036
|
loading: false,
|
|
2942
3037
|
flatmapMarker: flatmapMarker,
|
|
2943
3038
|
tooltipEntry: createUnfilledTooltipData(),
|
|
3039
|
+
connectivityDataSource: '',
|
|
2944
3040
|
connectivityTooltipVisible: false,
|
|
2945
3041
|
drawerOpen: false,
|
|
2946
3042
|
featuresAlert: undefined,
|
|
@@ -3005,6 +3101,7 @@ export default {
|
|
|
3005
3101
|
activeClick: false,
|
|
3006
3102
|
activeTerm: "",
|
|
3007
3103
|
}),
|
|
3104
|
+
taxonLeaveDelay: undefined,
|
|
3008
3105
|
}
|
|
3009
3106
|
},
|
|
3010
3107
|
computed: {
|
|
@@ -3159,6 +3256,7 @@ export default {
|
|
|
3159
3256
|
} else if (this.renderAtMounted) {
|
|
3160
3257
|
this.createFlatmap()
|
|
3161
3258
|
}
|
|
3259
|
+
this.refreshCache();
|
|
3162
3260
|
},
|
|
3163
3261
|
}
|
|
3164
3262
|
</script>
|