@abi-software/flatmapvuer 1.7.4 → 1.7.5-beta.1
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 +2290 -2223
- package/dist/flatmapvuer.umd.cjs +52 -48
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/FlatmapVuer.vue +131 -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.1",
|
|
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
|
/**
|
|
@@ -1635,6 +1637,7 @@ export default {
|
|
|
1635
1637
|
provenanceTaxonomy: taxons,
|
|
1636
1638
|
}
|
|
1637
1639
|
if (eventType === 'click') {
|
|
1640
|
+
this.setConnectivityDataSource(this.viewingMode, data);
|
|
1638
1641
|
this.featuresAlert = data.alert
|
|
1639
1642
|
//The following will be used to track either a feature is selected
|
|
1640
1643
|
this.statesTracking.activeClick = true
|
|
@@ -1685,6 +1688,23 @@ export default {
|
|
|
1685
1688
|
}
|
|
1686
1689
|
}
|
|
1687
1690
|
},
|
|
1691
|
+
/**
|
|
1692
|
+
* The data for connectivity data source is just a placeholder data
|
|
1693
|
+
* to check which part of the map is clicked, e.g., path or feture or empty area,
|
|
1694
|
+
* based on the viewing mode.
|
|
1695
|
+
* The "connectivity-info-close" event will be emitted based on this data
|
|
1696
|
+
* when there has a click event on map.
|
|
1697
|
+
* @param viewingMode
|
|
1698
|
+
* @param data
|
|
1699
|
+
*/
|
|
1700
|
+
setConnectivityDataSource: function (viewingMode, data) {
|
|
1701
|
+
// for Exploration mode, only path click will be used as data source
|
|
1702
|
+
this.connectivityDataSource = data.source;
|
|
1703
|
+
// for other modes, it can be feature or path
|
|
1704
|
+
if (viewingMode === 'Neuron Connection' || viewingMode === 'Annotation') {
|
|
1705
|
+
this.connectivityDataSource = data.featureId;
|
|
1706
|
+
}
|
|
1707
|
+
},
|
|
1688
1708
|
/**
|
|
1689
1709
|
* @public
|
|
1690
1710
|
* Function triggered by viewing mode change.
|
|
@@ -1832,6 +1852,48 @@ export default {
|
|
|
1832
1852
|
this.mapImp.selectGeoJSONFeatures(allFeaturesToHighlight);
|
|
1833
1853
|
}
|
|
1834
1854
|
},
|
|
1855
|
+
showConnectivitiesByReference: function (resource) {
|
|
1856
|
+
this.searchConnectivitiesByReference(resource).then((featureIds) => {
|
|
1857
|
+
this.mapImp.selectFeatures(featureIds);
|
|
1858
|
+
});
|
|
1859
|
+
},
|
|
1860
|
+
searchConnectivitiesByReference: async function (resource) {
|
|
1861
|
+
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
|
|
1862
|
+
let featureIds = [];
|
|
1863
|
+
|
|
1864
|
+
if (flatmapKnowledge) {
|
|
1865
|
+
featureIds = await this.getReferenceConnectivitiesFromStorage(resource);
|
|
1866
|
+
} else {
|
|
1867
|
+
featureIds = await this.getReferenceConnectivitiesByAPI(resource);
|
|
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
|
+
}
|
|
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
|
+
},
|
|
1835
1897
|
emitConnectivityGraphError: function (errorData) {
|
|
1836
1898
|
this.$emit('connectivity-graph-error', {
|
|
1837
1899
|
data: {
|
|
@@ -1886,6 +1948,8 @@ export default {
|
|
|
1886
1948
|
//require data.resource && data.feature.source
|
|
1887
1949
|
let results =
|
|
1888
1950
|
await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp, data)
|
|
1951
|
+
// load and store knowledge
|
|
1952
|
+
this.loadAndStoreKnowledge(this.mapImp);
|
|
1889
1953
|
// The line below only creates the tooltip if some data was found on the path
|
|
1890
1954
|
// the pubmed URLs are in knowledge response.references
|
|
1891
1955
|
if (
|
|
@@ -1898,6 +1962,58 @@ export default {
|
|
|
1898
1962
|
}
|
|
1899
1963
|
}
|
|
1900
1964
|
},
|
|
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
|
+
},
|
|
1901
2017
|
/**
|
|
1902
2018
|
* A hack to remove flatmap tooltips while popup is open
|
|
1903
2019
|
*/
|
|
@@ -2159,12 +2275,7 @@ export default {
|
|
|
2159
2275
|
}
|
|
2160
2276
|
// Get connectivity knowledge source | SCKAN release
|
|
2161
2277
|
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
|
-
}
|
|
2278
|
+
this.tooltipEntry['knowledge-source'] = this.getKnowledgeSource(this.mapImp);
|
|
2168
2279
|
}
|
|
2169
2280
|
this.$emit('connectivity-info-open', this.tooltipEntry);
|
|
2170
2281
|
}
|
|
@@ -2597,9 +2708,10 @@ export default {
|
|
|
2597
2708
|
} else {
|
|
2598
2709
|
this.statesTracking.activeTerm = ""
|
|
2599
2710
|
}
|
|
2600
|
-
if (this.
|
|
2711
|
+
if (!this.connectivityDataSource) {
|
|
2601
2712
|
this.$emit('connectivity-info-close');
|
|
2602
2713
|
}
|
|
2714
|
+
this.connectivityDataSource = ''; // reset
|
|
2603
2715
|
});
|
|
2604
2716
|
}
|
|
2605
2717
|
},
|
|
@@ -2941,6 +3053,7 @@ export default {
|
|
|
2941
3053
|
loading: false,
|
|
2942
3054
|
flatmapMarker: flatmapMarker,
|
|
2943
3055
|
tooltipEntry: createUnfilledTooltipData(),
|
|
3056
|
+
connectivityDataSource: '',
|
|
2944
3057
|
connectivityTooltipVisible: false,
|
|
2945
3058
|
drawerOpen: false,
|
|
2946
3059
|
featuresAlert: undefined,
|
|
@@ -3005,6 +3118,7 @@ export default {
|
|
|
3005
3118
|
activeClick: false,
|
|
3006
3119
|
activeTerm: "",
|
|
3007
3120
|
}),
|
|
3121
|
+
taxonLeaveDelay: undefined,
|
|
3008
3122
|
}
|
|
3009
3123
|
},
|
|
3010
3124
|
computed: {
|
|
@@ -3159,6 +3273,7 @@ export default {
|
|
|
3159
3273
|
} else if (this.renderAtMounted) {
|
|
3160
3274
|
this.createFlatmap()
|
|
3161
3275
|
}
|
|
3276
|
+
this.refreshCache();
|
|
3162
3277
|
},
|
|
3163
3278
|
}
|
|
3164
3279
|
</script>
|