@abi-software/flatmapvuer 1.8.0 → 1.8.1-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 +449 -432
- package/dist/flatmapvuer.umd.cjs +46 -46
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/FlatmapVuer.vue +88 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "1.8.0",
|
|
3
|
+
"version": "1.8.1-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.4.0",
|
|
47
|
+
"@abi-software/map-utilities": "^1.4.1-beta.0",
|
|
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",
|
|
@@ -139,7 +139,7 @@ Please use `const` to assign meaningful names to them...
|
|
|
139
139
|
</el-icon>
|
|
140
140
|
|
|
141
141
|
<DrawToolbar
|
|
142
|
-
v-if="viewingMode === 'Annotation' &&
|
|
142
|
+
v-if="viewingMode === 'Annotation' && (authorisedUser || offlineAnnotate) && !disableUI"
|
|
143
143
|
:mapCanvas="{
|
|
144
144
|
containerHTML: this.$el,
|
|
145
145
|
class: '.maplibregl-canvas',
|
|
@@ -448,8 +448,11 @@ Please use `const` to assign meaningful names to them...
|
|
|
448
448
|
<el-row class="viewing-mode-description">
|
|
449
449
|
{{ modeDescription }}
|
|
450
450
|
</el-row>
|
|
451
|
+
<el-row v-if="viewingMode === 'Annotation' && offlineAnnotate" class="viewing-mode-description">
|
|
452
|
+
(Offline annotate)
|
|
453
|
+
</el-row>
|
|
451
454
|
</el-row>
|
|
452
|
-
<template v-if="viewingMode === 'Annotation' &&
|
|
455
|
+
<template v-if="viewingMode === 'Annotation' && authorisedUser">
|
|
453
456
|
<el-row class="backgroundText">Annotations From</el-row>
|
|
454
457
|
<el-row class="backgroundControl">
|
|
455
458
|
<el-select
|
|
@@ -791,16 +794,10 @@ export default {
|
|
|
791
794
|
if (this.mapImp) {
|
|
792
795
|
if (value) {
|
|
793
796
|
const numericId = Number(value)
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
} else {
|
|
799
|
-
const drawnFeature = this.existDrawnFeatures.find(
|
|
800
|
-
(feature) => feature.id === value.replace(' ', '')
|
|
801
|
-
)
|
|
802
|
-
payload.feature.feature = drawnFeature
|
|
803
|
-
}
|
|
797
|
+
const featureObject = numericId
|
|
798
|
+
? this.mapImp.featureProperties(numericId)
|
|
799
|
+
: { feature: this.existDrawnFeatures.find(feature => feature.id === value.trim()) };
|
|
800
|
+
let payload = { feature: featureObject }
|
|
804
801
|
this.checkAndCreatePopups(payload)
|
|
805
802
|
} else {
|
|
806
803
|
this.closeTooltip()
|
|
@@ -903,10 +900,7 @@ export default {
|
|
|
903
900
|
* Function to remove all drawn annotations from flatmap annotation layer.
|
|
904
901
|
*/
|
|
905
902
|
clearAnnotationFeature: function () {
|
|
906
|
-
if (
|
|
907
|
-
this.mapImp &&
|
|
908
|
-
this.existDrawnFeatures.length > 0
|
|
909
|
-
) {
|
|
903
|
+
if (this.mapImp) {
|
|
910
904
|
this.mapImp.clearAnnotationFeature()
|
|
911
905
|
}
|
|
912
906
|
},
|
|
@@ -943,23 +937,30 @@ export default {
|
|
|
943
937
|
* @arg {Object} `annotation`
|
|
944
938
|
*/
|
|
945
939
|
commitAnnotationEvent: function (annotation) {
|
|
946
|
-
if (
|
|
947
|
-
this.
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
this.
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
this.
|
|
959
|
-
|
|
960
|
-
|
|
940
|
+
if (this.mapImp) {
|
|
941
|
+
if (this.offlineAnnotate) {
|
|
942
|
+
this.offlineAnnotation = JSON.parse(sessionStorage.getItem('offline-annotation')) || []
|
|
943
|
+
this.offlineAnnotation.push(annotation)
|
|
944
|
+
if (this.annotationEntry.type === 'deleted') {
|
|
945
|
+
this.offlineAnnotation = this.offlineAnnotation.filter((offline) => {
|
|
946
|
+
return offline.resource !== this.serverURL || offline.item.id !== annotation.item.id
|
|
947
|
+
})
|
|
948
|
+
}
|
|
949
|
+
sessionStorage.setItem('offline-annotation', JSON.stringify(this.offlineAnnotation))
|
|
950
|
+
}
|
|
951
|
+
if (['created', 'updated', 'deleted'].includes(this.annotationEntry.type)) {
|
|
952
|
+
this.featureAnnotationSubmitted = true
|
|
953
|
+
this.mapImp.commitAnnotationEvent(this.annotationEntry)
|
|
954
|
+
if (annotation.body.comment === "Position Updated") {
|
|
955
|
+
this.annotationEntry.positionUpdated = false
|
|
956
|
+
} else if (this.annotationEntry.type === 'deleted') {
|
|
957
|
+
if (this.annotationSidebar) this.$emit("annotation-close")
|
|
958
|
+
this.closeTooltip()
|
|
959
|
+
// Only delete need, keep the annotation tooltip/sidebar open if created/updated
|
|
960
|
+
this.annotationEntry = {}
|
|
961
|
+
}
|
|
962
|
+
this.addAnnotationFeature()
|
|
961
963
|
}
|
|
962
|
-
this.addAnnotationFeature()
|
|
963
964
|
}
|
|
964
965
|
},
|
|
965
966
|
/**
|
|
@@ -969,9 +970,17 @@ export default {
|
|
|
969
970
|
* @arg {String} `participated`
|
|
970
971
|
*/
|
|
971
972
|
fetchAnnotatedItemIds: async function (userId = undefined, participated = undefined) {
|
|
972
|
-
let annotatedItemIds
|
|
973
|
-
|
|
974
|
-
|
|
973
|
+
let annotatedItemIds
|
|
974
|
+
if (this.offlineAnnotate) {
|
|
975
|
+
this.offlineAnnotation = JSON.parse(sessionStorage.getItem('offline-annotation')) || []
|
|
976
|
+
annotatedItemIds = this.offlineAnnotation.filter((offline) => {
|
|
977
|
+
return offline.resource === this.serverURL
|
|
978
|
+
}).map(offline => offline.item.id)
|
|
979
|
+
} else {
|
|
980
|
+
annotatedItemIds = await this.annotator.annotatedItemIds(this.userToken, this.serverURL, userId, participated)
|
|
981
|
+
// The annotator has `resource` and `items` fields
|
|
982
|
+
if ('resource' in annotatedItemIds) annotatedItemIds = annotatedItemIds.itemIds
|
|
983
|
+
}
|
|
975
984
|
return annotatedItemIds
|
|
976
985
|
},
|
|
977
986
|
/**
|
|
@@ -993,10 +1002,18 @@ export default {
|
|
|
993
1002
|
* @arg {String} `participated`
|
|
994
1003
|
*/
|
|
995
1004
|
fetchDrawnFeatures: async function (userId, participated) {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1005
|
+
let drawnFeatures
|
|
1006
|
+
if (this.offlineAnnotate) {
|
|
1007
|
+
this.offlineAnnotation = JSON.parse(sessionStorage.getItem('offline-annotation')) || []
|
|
1008
|
+
drawnFeatures = this.offlineAnnotation.filter((offline) => {
|
|
1009
|
+
return offline.feature && offline.resource === this.serverURL
|
|
1010
|
+
}).map(offline => offline.feature)
|
|
1011
|
+
} else {
|
|
1012
|
+
const annotatedItemIds = await this.fetchAnnotatedItemIds(userId, participated)
|
|
1013
|
+
drawnFeatures = await this.annotator.drawnFeatures(this.userToken, this.serverURL, annotatedItemIds)
|
|
1014
|
+
// The annotator has `resource` and `features` fields
|
|
1015
|
+
if ('resource' in drawnFeatures) drawnFeatures = drawnFeatures.features
|
|
1016
|
+
}
|
|
1000
1017
|
return drawnFeatures
|
|
1001
1018
|
},
|
|
1002
1019
|
/**
|
|
@@ -1010,8 +1027,8 @@ export default {
|
|
|
1010
1027
|
this.loading = true
|
|
1011
1028
|
}
|
|
1012
1029
|
const userId = this.annotationFrom === 'Anyone' ?
|
|
1013
|
-
undefined : this.
|
|
1014
|
-
this.
|
|
1030
|
+
undefined : this.authorisedUser.orcid ?
|
|
1031
|
+
this.authorisedUser.orcid : '0000-0000-0000-0000'
|
|
1015
1032
|
const participated = this.annotationFrom === 'Anyone' ?
|
|
1016
1033
|
undefined : this.annotationFrom === 'Me' ?
|
|
1017
1034
|
true : false
|
|
@@ -1902,14 +1919,15 @@ export default {
|
|
|
1902
1919
|
this.annotationEntry = {
|
|
1903
1920
|
...data.feature,
|
|
1904
1921
|
resourceId: this.serverURL,
|
|
1922
|
+
offline: this.offlineAnnotate
|
|
1905
1923
|
}
|
|
1906
1924
|
if (data.feature.featureId && data.feature.models) {
|
|
1907
1925
|
this.displayTooltip(data.feature.models)
|
|
1908
1926
|
} else if (data.feature.feature) {
|
|
1927
|
+
this.annotationEntry.featureId = data.feature.feature.id
|
|
1909
1928
|
// in drawing or edit/delete mode is on or valid drawn
|
|
1910
1929
|
if (this.activeDrawTool || this.activeDrawMode || this.isValidDrawnCreated) {
|
|
1911
1930
|
this.featureAnnotationSubmitted = false
|
|
1912
|
-
this.annotationEntry.featureId = data.feature.feature.id
|
|
1913
1931
|
if (this.activeDrawTool) {
|
|
1914
1932
|
this.createConnectivityBody()
|
|
1915
1933
|
}
|
|
@@ -2390,6 +2408,16 @@ export default {
|
|
|
2390
2408
|
state['colour'] = this.colourRadio
|
|
2391
2409
|
state['outlinesRadio'] = this.outlinesRadio
|
|
2392
2410
|
state['background'] = this.currentBackground
|
|
2411
|
+
if (this.offlineAnnotate) {
|
|
2412
|
+
if (!sessionStorage.getItem('offline-annotation-expiry')) {
|
|
2413
|
+
const expiry = new Date().getTime() + 24 * 60 * 60 * 1000;
|
|
2414
|
+
sessionStorage.setItem('offline-annotation-expiry', expiry);
|
|
2415
|
+
}
|
|
2416
|
+
state['offlineAnnotation'] = {
|
|
2417
|
+
expiry: sessionStorage.getItem('offline-annotation-expiry'),
|
|
2418
|
+
value: sessionStorage.getItem('offline-annotation')
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2393
2421
|
this.getVisibilityState(state)
|
|
2394
2422
|
return state
|
|
2395
2423
|
}
|
|
@@ -2424,6 +2452,11 @@ export default {
|
|
|
2424
2452
|
restoreMapState: function (state) {
|
|
2425
2453
|
if (state) {
|
|
2426
2454
|
if (state.viewport) this.mapImp.setState(state.viewport)
|
|
2455
|
+
if (state.offlineAnnotation) {
|
|
2456
|
+
if (state.offlineAnnotation.expiry > new Date().getTime()) {
|
|
2457
|
+
sessionStorage.setItem('offline-annotation', state.offlineAnnotation.value)
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2427
2460
|
if (state.viewingMode) this.changeViewingMode(state.viewingMode)
|
|
2428
2461
|
//The following three are boolean
|
|
2429
2462
|
if ('flightPath3D' in state) this.setFlightPath3D(state.flightPath3D)
|
|
@@ -2996,6 +3029,8 @@ export default {
|
|
|
2996
3029
|
'Neuron Connection': 'Discover Neuron connections by selecting a neuron and viewing its associated network connections',
|
|
2997
3030
|
'Annotation': ['View feature annotations', 'Add, comment on and view feature annotations']
|
|
2998
3031
|
},
|
|
3032
|
+
offlineAnnotate: false,
|
|
3033
|
+
offlineAnnotation: [],
|
|
2999
3034
|
annotationFrom: 'Anyone',
|
|
3000
3035
|
annotatedSource: ['Anyone', 'Me', 'Others'],
|
|
3001
3036
|
openMapRef: undefined,
|
|
@@ -3009,7 +3044,7 @@ export default {
|
|
|
3009
3044
|
"Connection",
|
|
3010
3045
|
],
|
|
3011
3046
|
annotator: undefined,
|
|
3012
|
-
|
|
3047
|
+
authorisedUser: undefined,
|
|
3013
3048
|
activeDrawMode: undefined,
|
|
3014
3049
|
activeDrawTool: undefined,
|
|
3015
3050
|
featureAnnotationSubmitted: false,
|
|
@@ -3074,7 +3109,7 @@ export default {
|
|
|
3074
3109
|
modeDescription: function () {
|
|
3075
3110
|
let description = this.viewingModes[this.viewingMode]
|
|
3076
3111
|
if (this.viewingMode === 'Annotation') {
|
|
3077
|
-
if (this.
|
|
3112
|
+
if (this.authorisedUser) {
|
|
3078
3113
|
return description[1]
|
|
3079
3114
|
}
|
|
3080
3115
|
return description[0]
|
|
@@ -3114,18 +3149,22 @@ export default {
|
|
|
3114
3149
|
deep: true,
|
|
3115
3150
|
},
|
|
3116
3151
|
viewingMode: function (mode) {
|
|
3152
|
+
this.clearAnnotationFeature()
|
|
3117
3153
|
if (mode === 'Annotation') {
|
|
3118
3154
|
this.loading = true
|
|
3119
3155
|
this.annotator.authenticate(this.userToken).then((userData) => {
|
|
3120
3156
|
if (userData.name && userData.email && userData.canUpdate) {
|
|
3121
|
-
this.
|
|
3122
|
-
this.
|
|
3123
|
-
|
|
3124
|
-
this.
|
|
3157
|
+
this.authorisedUser = userData
|
|
3158
|
+
this.offlineAnnotate = false
|
|
3159
|
+
} else {
|
|
3160
|
+
this.authorisedUser = undefined
|
|
3161
|
+
this.offlineAnnotate = true
|
|
3125
3162
|
}
|
|
3163
|
+
this.setFeatureAnnotated()
|
|
3164
|
+
this.addAnnotationFeature()
|
|
3126
3165
|
this.loading = false
|
|
3127
3166
|
})
|
|
3128
|
-
}
|
|
3167
|
+
}
|
|
3129
3168
|
},
|
|
3130
3169
|
disableUI: function (isUIDisabled) {
|
|
3131
3170
|
if (isUIDisabled) {
|