@abi-software/flatmapvuer 1.8.1-beta.0 → 1.8.1-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "1.8.1-beta.0",
3
+ "version": "1.8.1-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.4.1-beta.0",
47
+ "@abi-software/map-utilities": "^1.4.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' && (authorisedUser || offlineAnnotate) && !disableUI"
142
+ v-if="viewingMode === 'Annotation' && userInformation && !disableUI"
143
143
  :mapCanvas="{
144
144
  containerHTML: this.$el,
145
145
  class: '.maplibregl-canvas',
@@ -448,11 +448,8 @@ 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>
454
451
  </el-row>
455
- <template v-if="viewingMode === 'Annotation' && authorisedUser">
452
+ <template v-if="viewingMode === 'Annotation' && userInformation">
456
453
  <el-row class="backgroundText">Annotations From</el-row>
457
454
  <el-row class="backgroundControl">
458
455
  <el-select
@@ -794,10 +791,16 @@ export default {
794
791
  if (this.mapImp) {
795
792
  if (value) {
796
793
  const numericId = Number(value)
797
- const featureObject = numericId
798
- ? this.mapImp.featureProperties(numericId)
799
- : { feature: this.existDrawnFeatures.find(feature => feature.id === value.trim()) };
800
- let payload = { feature: featureObject }
794
+ let payload = { feature: {} }
795
+ if (numericId) {
796
+ const data = this.mapImp.featureProperties(numericId)
797
+ payload.feature = data
798
+ } else {
799
+ const drawnFeature = this.existDrawnFeatures.find(
800
+ (feature) => feature.id === value.replace(' ', '')
801
+ )
802
+ payload.feature.feature = drawnFeature
803
+ }
801
804
  this.checkAndCreatePopups(payload)
802
805
  } else {
803
806
  this.closeTooltip()
@@ -900,7 +903,10 @@ export default {
900
903
  * Function to remove all drawn annotations from flatmap annotation layer.
901
904
  */
902
905
  clearAnnotationFeature: function () {
903
- if (this.mapImp) {
906
+ if (
907
+ this.mapImp &&
908
+ this.existDrawnFeatures.length > 0
909
+ ) {
904
910
  this.mapImp.clearAnnotationFeature()
905
911
  }
906
912
  },
@@ -937,30 +943,23 @@ export default {
937
943
  * @arg {Object} `annotation`
938
944
  */
939
945
  commitAnnotationEvent: function (annotation) {
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()
946
+ if (
947
+ this.mapImp &&
948
+ ['created', 'updated', 'deleted'].includes(this.annotationEntry.type) &&
949
+ // Only when annotation comments stored successfully
950
+ annotation
951
+ ) {
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 = {}
963
961
  }
962
+ this.addAnnotationFeature()
964
963
  }
965
964
  },
966
965
  /**
@@ -970,17 +969,9 @@ export default {
970
969
  * @arg {String} `participated`
971
970
  */
972
971
  fetchAnnotatedItemIds: async function (userId = undefined, participated = undefined) {
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
- }
972
+ let annotatedItemIds = await this.annotator.annotatedItemIds(this.userToken, this.serverURL, userId, participated)
973
+ // The annotator has `resource` and `items` fields
974
+ if ('resource' in annotatedItemIds) annotatedItemIds = annotatedItemIds.itemIds
984
975
  return annotatedItemIds
985
976
  },
986
977
  /**
@@ -1002,18 +993,10 @@ export default {
1002
993
  * @arg {String} `participated`
1003
994
  */
1004
995
  fetchDrawnFeatures: async function (userId, participated) {
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
- }
996
+ const annotatedItemIds = await this.fetchAnnotatedItemIds(userId, participated)
997
+ let drawnFeatures = await this.annotator.drawnFeatures(this.userToken, this.serverURL, annotatedItemIds)
998
+ // The annotator has `resource` and `features` fields
999
+ if ('resource' in drawnFeatures) drawnFeatures = drawnFeatures.features
1017
1000
  return drawnFeatures
1018
1001
  },
1019
1002
  /**
@@ -1027,8 +1010,8 @@ export default {
1027
1010
  this.loading = true
1028
1011
  }
1029
1012
  const userId = this.annotationFrom === 'Anyone' ?
1030
- undefined : this.authorisedUser.orcid ?
1031
- this.authorisedUser.orcid : '0000-0000-0000-0000'
1013
+ undefined : this.userInformation.orcid ?
1014
+ this.userInformation.orcid : '0000-0000-0000-0000'
1032
1015
  const participated = this.annotationFrom === 'Anyone' ?
1033
1016
  undefined : this.annotationFrom === 'Me' ?
1034
1017
  true : false
@@ -1284,52 +1267,74 @@ export default {
1284
1267
  )
1285
1268
  }
1286
1269
  },
1270
+ /**
1271
+ * Function to highlight paths and features
1272
+ * @param data
1273
+ */
1274
+ zoomToFeatures: function (data) {
1275
+ if (this.mapImp) {
1276
+ this.mapImp.zoomToFeatures(data)
1277
+ }
1278
+ },
1287
1279
  /**
1288
1280
  * @public
1289
1281
  * Function to highlight the connected paths
1290
- * by providing path model identifier, ``pathId``.
1291
- * @arg {String} `pathId`
1282
+ * by providing path model identifier, ``pathId`` or ``anatomicalId``.
1283
+ * @arg {string | string[]} `pathId` (string) or `anatomicalId` (array)
1292
1284
  */
1293
- highlightConnectedPaths: async function (payload) {
1285
+ retrieveConnectedPaths: async function (payload, options = {}) {
1294
1286
  if (this.mapImp) {
1295
- let paths = [...this.mapImp.pathModelNodes(payload)]
1296
-
1297
- // The line below is to get the path features from the geojson ids
1298
- let pathFeatures = paths.map((p) => this.mapImp.featureProperties(p))
1299
-
1300
- // Query the flatmap knowledge graph for connectivity, we use this to grab the origins
1301
- let connectivity = await this.flatmapQueries.queryForConnectivityNew(this.mapImp, payload)
1302
-
1303
- // Check and flatten the origins node graph
1304
- let originsFlat = connectivity?.ids?.dendrites?.flat().flat()
1305
-
1306
- let toHighlight = []
1307
- let highlight = false
1308
-
1309
- // Loop through the path features and check if we have origin nodes
1310
- pathFeatures.forEach((p) => {
1311
-
1312
- // Get the nodes from each path feature
1313
- this.mapImp.nodePathModels(p.featureId).forEach((f) => {
1314
- highlight = true
1315
- // s2 here is the second level paths
1316
- let s2 = this.mapImp.pathModelNodes(f)
1317
- s2.forEach((s) => {
1318
- let s2Feature = this.mapImp.featureProperties([s]) // get the feature properties for s2
1319
- if (originsFlat.includes(s2Feature.models)) {
1320
- highlight = false // if we have an origin node, we don't want to highlight the path
1321
- return
1322
- }
1323
- })
1324
-
1325
- if (highlight) {
1326
- toHighlight.push(f)
1327
- }
1328
- })
1329
- })
1330
-
1331
- // display connected paths
1332
- this.mapImp.zoomToFeatures(toHighlight, { noZoomIn: true })
1287
+ let connectedPaths = [];
1288
+ let connectedTarget = options.target?.length ? options.target : [];
1289
+ if (typeof payload === 'string') {
1290
+ // The line below is to get the path features from the geojson ids
1291
+ const nodeFeatureIds = [...this.mapImp.pathModelNodes(payload)];
1292
+ if (!connectedTarget.length) {
1293
+ const connectedType = options.type?.length ? options.type : ["all"];
1294
+ const connectivity = await this.flatmapQueries.queryForConnectivityNew(this.mapImp, [payload]);
1295
+ const originsFlat = connectivity?.ids?.dendrites.flat(Infinity);
1296
+ const componentsFlat = connectivity?.ids?.components.flat(Infinity);
1297
+ const destinationsFlat = connectivity?.ids?.axons.flat(Infinity);
1298
+ let connected = [];
1299
+ if (connectedType.includes("origins")) connected.push(...originsFlat);
1300
+ if (connectedType.includes("components")) connected.push(...componentsFlat);
1301
+ if (connectedType.includes("destinations")) connected.push(...destinationsFlat);
1302
+ if (connectedType.includes("all")) connected.push(...originsFlat, ...componentsFlat, ...destinationsFlat);
1303
+ connectedTarget = [...new Set(connected)];
1304
+ }
1305
+ // Loop through the node features and check if we have certain nodes
1306
+ nodeFeatureIds.forEach((featureId) => {
1307
+ // Get the paths from each node feature
1308
+ const pathsL2 = this.mapImp.nodePathModels(featureId);
1309
+ pathsL2.forEach((path) => {
1310
+ // nodes of the second level path
1311
+ const nodeFeatureIdsL2 = this.mapImp.pathModelNodes(path);
1312
+ const nodeModelsL2 = nodeFeatureIdsL2.map((featureIdL2) => {
1313
+ return this.mapImp.featureProperties(featureIdL2).models;
1314
+ });
1315
+ const intersection = connectedTarget.filter(element => nodeModelsL2.includes(element));
1316
+ if (intersection.length && !connectedPaths.includes(path)) connectedPaths.push(path);
1317
+ });
1318
+ });
1319
+ connectedPaths = [...connectedPaths, payload];
1320
+ } else if (Array.isArray(payload)) {
1321
+ const pathsOfEntities = await this.mapImp.queryPathsForFeatures(payload);
1322
+ if (connectedTarget.length) {
1323
+ pathsOfEntities.forEach((path) => {
1324
+ const nodeFeatureIds = this.mapImp.pathModelNodes(path);
1325
+ const nodeModels = nodeFeatureIds.map((featureId) => {
1326
+ return this.mapImp.featureProperties(featureId).models;
1327
+ });
1328
+ const intersection = connectedTarget.filter(element => nodeModels.includes(element));
1329
+ if (intersection.length && !connectedPaths.includes(path)) connectedPaths.push(path);
1330
+ });
1331
+ } else {
1332
+ connectedPaths = pathsOfEntities;
1333
+ }
1334
+ connectedPaths = [...connectedPaths, ...payload];
1335
+ }
1336
+ connectedPaths = [...new Set(connectedPaths)];
1337
+ return connectedPaths;
1333
1338
  }
1334
1339
  },
1335
1340
  resetMapFilter: function() {
@@ -1660,13 +1665,11 @@ export default {
1660
1665
  provenanceTaxonomy: taxons,
1661
1666
  }
1662
1667
  if (eventType === 'click') {
1663
- this.setConnectivityDataSource(this.viewingMode, data);
1664
1668
  this.featuresAlert = data.alert
1665
- //The following will be used to track either a feature is selected
1666
- this.statesTracking.activeClick = true
1667
- this.statesTracking.activeTerm = data?.models
1668
1669
  if (this.viewingMode === 'Neuron Connection') {
1669
- this.highlightConnectedPaths([data.models])
1670
+ this.retrieveConnectedPaths([data.models]).then((paths) => {
1671
+ this.zoomToFeatures(paths)
1672
+ })
1670
1673
  } else {
1671
1674
  this.currentActive = data.models ? data.models : ''
1672
1675
  // Drawing connectivity between features
@@ -1711,23 +1714,6 @@ export default {
1711
1714
  }
1712
1715
  }
1713
1716
  },
1714
- /**
1715
- * The data for connectivity data source is just a placeholder data
1716
- * to check which part of the map is clicked, e.g., path or feture or empty area,
1717
- * based on the viewing mode.
1718
- * The "connectivity-info-close" event will be emitted based on this data
1719
- * when there has a click event on map.
1720
- * @param viewingMode
1721
- * @param data
1722
- */
1723
- setConnectivityDataSource: function (viewingMode, data) {
1724
- // for Exploration mode, only path click will be used as data source
1725
- this.connectivityDataSource = data.source;
1726
- // for other modes, it can be feature or path
1727
- if (viewingMode === 'Neuron Connection' || viewingMode === 'Annotation') {
1728
- this.connectivityDataSource = data.featureId;
1729
- }
1730
- },
1731
1717
  /**
1732
1718
  * @public
1733
1719
  * Function triggered by viewing mode change.
@@ -1919,15 +1905,14 @@ export default {
1919
1905
  this.annotationEntry = {
1920
1906
  ...data.feature,
1921
1907
  resourceId: this.serverURL,
1922
- offline: this.offlineAnnotate
1923
1908
  }
1924
1909
  if (data.feature.featureId && data.feature.models) {
1925
1910
  this.displayTooltip(data.feature.models)
1926
1911
  } else if (data.feature.feature) {
1927
- this.annotationEntry.featureId = data.feature.feature.id
1928
1912
  // in drawing or edit/delete mode is on or valid drawn
1929
1913
  if (this.activeDrawTool || this.activeDrawMode || this.isValidDrawnCreated) {
1930
1914
  this.featureAnnotationSubmitted = false
1915
+ this.annotationEntry.featureId = data.feature.feature.id
1931
1916
  if (this.activeDrawTool) {
1932
1917
  this.createConnectivityBody()
1933
1918
  }
@@ -2403,21 +2388,11 @@ export default {
2403
2388
  state['biologicalSex'] = identifier.biologicalSex
2404
2389
  if (identifier && identifier.uuid) state['uuid'] = identifier.uuid
2405
2390
  state['viewingMode'] = this.viewingMode
2406
- state['searchTerm'] = this.statesTracking.activeTerm
2391
+ state['searchTerm'] = this.searchTerm
2407
2392
  state['flightPath3D'] = this.flightPath3DRadio
2408
2393
  state['colour'] = this.colourRadio
2409
- state['outlinesRadio'] = this.outlinesRadio
2394
+ state['outlines'] = this.outlinesRadio
2410
2395
  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
- }
2421
2396
  this.getVisibilityState(state)
2422
2397
  return state
2423
2398
  }
@@ -2452,11 +2427,6 @@ export default {
2452
2427
  restoreMapState: function (state) {
2453
2428
  if (state) {
2454
2429
  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
- }
2460
2430
  if (state.viewingMode) this.changeViewingMode(state.viewingMode)
2461
2431
  //The following three are boolean
2462
2432
  if ('flightPath3D' in state) this.setFlightPath3D(state.flightPath3D)
@@ -2466,7 +2436,9 @@ export default {
2466
2436
  if (state.searchTerm) {
2467
2437
  const searchTerm = state.searchTerm
2468
2438
  if (state.viewingMode === "Neuron Connection") {
2469
- this.highlightConnectedPaths([searchTerm])
2439
+ this.retrieveConnectedPaths([searchTerm]).then((paths) => {
2440
+ this.zoomToFeatures(paths)
2441
+ })
2470
2442
  } else {
2471
2443
  this.searchAndShowResult(searchTerm, true)
2472
2444
  }
@@ -2619,7 +2591,6 @@ export default {
2619
2591
  if (this.mapImp.options?.style === 'functional') {
2620
2592
  this.isFC = true
2621
2593
  }
2622
- console.log(this.mapImp)
2623
2594
  this.mapImp.setBackgroundOpacity(1)
2624
2595
  this.backgroundChangeCallback(this.currentBackground)
2625
2596
  this.pathways = this.mapImp.pathTypes()
@@ -2633,7 +2604,6 @@ export default {
2633
2604
  this.loading = false
2634
2605
  this.computePathControlsMaximumHeight()
2635
2606
  this.mapResize()
2636
- this.handleMapClick();
2637
2607
  this.setInitMapState();
2638
2608
  /**
2639
2609
  * This is ``onFlatmapReady`` event.
@@ -2641,29 +2611,6 @@ export default {
2641
2611
  */
2642
2612
  this.$emit('ready', this)
2643
2613
  },
2644
- /**
2645
- * @public
2646
- * Function to handle mouse click on map area
2647
- * after the map is loaded.
2648
- */
2649
- handleMapClick: function () {
2650
- const _map = this.mapImp._map;
2651
- if (_map) {
2652
- _map.on('click', (e) => {
2653
- //A little logic to make sure we are keeping track
2654
- //of selected term
2655
- if (this.statesTracking.activeClick) {
2656
- this.statesTracking.activeClick = false
2657
- } else {
2658
- this.statesTracking.activeTerm = ""
2659
- }
2660
- if (!this.connectivityDataSource) {
2661
- this.$emit('connectivity-info-close');
2662
- }
2663
- this.connectivityDataSource = ''; // reset
2664
- });
2665
- }
2666
- },
2667
2614
  /**
2668
2615
  * @public
2669
2616
  * Function to show or hide the minimap
@@ -2698,12 +2645,11 @@ export default {
2698
2645
  } else if (this.viewingMode === "Annotation") {
2699
2646
  this.manualAbortedOnClose()
2700
2647
  }
2701
- this.statesTracking.activeTerm = ""
2648
+ this.searchTerm = ""
2702
2649
  return true
2703
2650
  } else {
2704
2651
  const searchResults = this.mapImp.search(term)
2705
2652
  if (searchResults?.results?.length) {
2706
- this.statesTracking.activeTerm = term
2707
2653
  this.mapImp.showSearchResults(searchResults)
2708
2654
  if (displayInfo) {
2709
2655
  let featureId = undefined;
@@ -2723,9 +2669,9 @@ export default {
2723
2669
  if (this.viewingMode === "Exploration" || this.viewingMode === "Annotation") {
2724
2670
  this.checkAndCreatePopups(data)
2725
2671
  } else if (this.viewingMode === 'Neuron Connection') {
2726
- setTimeout(() => {
2727
- this.highlightConnectedPaths(data.resource)
2728
- }, 1000)
2672
+ this.retrieveConnectedPaths(data.resource).then((paths) => {
2673
+ this.zoomToFeatures(paths)
2674
+ })
2729
2675
  }
2730
2676
  this.mapImp.showPopup(featureId, capitalise(feature.label), {
2731
2677
  className: 'custom-popup',
@@ -2734,6 +2680,7 @@ export default {
2734
2680
  })
2735
2681
  }
2736
2682
  }
2683
+ this.searchTerm = term
2737
2684
  return true
2738
2685
  } else this.mapImp.clearSearchResults()
2739
2686
  }
@@ -3029,8 +2976,6 @@ export default {
3029
2976
  'Neuron Connection': 'Discover Neuron connections by selecting a neuron and viewing its associated network connections',
3030
2977
  'Annotation': ['View feature annotations', 'Add, comment on and view feature annotations']
3031
2978
  },
3032
- offlineAnnotate: false,
3033
- offlineAnnotation: [],
3034
2979
  annotationFrom: 'Anyone',
3035
2980
  annotatedSource: ['Anyone', 'Me', 'Others'],
3036
2981
  openMapRef: undefined,
@@ -3044,7 +2989,7 @@ export default {
3044
2989
  "Connection",
3045
2990
  ],
3046
2991
  annotator: undefined,
3047
- authorisedUser: undefined,
2992
+ userInformation: undefined,
3048
2993
  activeDrawMode: undefined,
3049
2994
  activeDrawTool: undefined,
3050
2995
  featureAnnotationSubmitted: false,
@@ -3073,10 +3018,7 @@ export default {
3073
3018
  without: true,
3074
3019
  }
3075
3020
  }),
3076
- statesTracking: markRaw({
3077
- activeClick: false,
3078
- activeTerm: "",
3079
- }),
3021
+ searchTerm: "",
3080
3022
  taxonLeaveDelay: undefined,
3081
3023
  }
3082
3024
  },
@@ -3109,7 +3051,7 @@ export default {
3109
3051
  modeDescription: function () {
3110
3052
  let description = this.viewingModes[this.viewingMode]
3111
3053
  if (this.viewingMode === 'Annotation') {
3112
- if (this.authorisedUser) {
3054
+ if (this.userInformation) {
3113
3055
  return description[1]
3114
3056
  }
3115
3057
  return description[0]
@@ -3149,22 +3091,18 @@ export default {
3149
3091
  deep: true,
3150
3092
  },
3151
3093
  viewingMode: function (mode) {
3152
- this.clearAnnotationFeature()
3153
3094
  if (mode === 'Annotation') {
3154
3095
  this.loading = true
3155
3096
  this.annotator.authenticate(this.userToken).then((userData) => {
3156
3097
  if (userData.name && userData.email && userData.canUpdate) {
3157
- this.authorisedUser = userData
3158
- this.offlineAnnotate = false
3159
- } else {
3160
- this.authorisedUser = undefined
3161
- this.offlineAnnotate = true
3098
+ this.showAnnotator(true)
3099
+ this.userInformation = userData
3100
+ this.setFeatureAnnotated()
3101
+ this.addAnnotationFeature()
3162
3102
  }
3163
- this.setFeatureAnnotated()
3164
- this.addAnnotationFeature()
3165
3103
  this.loading = false
3166
3104
  })
3167
- }
3105
+ } else this.showAnnotator(false)
3168
3106
  },
3169
3107
  disableUI: function (isUIDisabled) {
3170
3108
  if (isUIDisabled) {
@@ -8,6 +8,7 @@ export {}
8
8
  declare module 'vue' {
9
9
  export interface GlobalComponents {
10
10
  DynamicLegends: typeof import('./components/legends/DynamicLegends.vue')['default']
11
+ ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
11
12
  ElButton: typeof import('element-plus/es')['ElButton']
12
13
  ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
13
14
  ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
@@ -23,6 +24,7 @@ declare module 'vue' {
23
24
  ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
24
25
  ElRow: typeof import('element-plus/es')['ElRow']
25
26
  ElSelect: typeof import('element-plus/es')['ElSelect']
27
+ ElSwitch: typeof import('element-plus/es')['ElSwitch']
26
28
  FlatmapVuer: typeof import('./components/FlatmapVuer.vue')['default']
27
29
  MultiFlatmapVuer: typeof import('./components/MultiFlatmapVuer.vue')['default']
28
30
  SelectionsGroup: typeof import('./components/SelectionsGroup.vue')['default']
@@ -36,25 +36,29 @@ function getKnowledgeSource(mapImp) {
36
36
  mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
37
37
  }
38
38
  }
39
-
40
39
  return mapKnowledgeSource;
41
40
  }
42
41
 
43
- function loadAndStoreKnowledge(mapImp, flatmapQueries) {
42
+ async function loadAndStoreKnowledge(mapImp, flatmapQueries) {
44
43
  const knowledgeSource = getKnowledgeSource(mapImp);
45
44
  const sql = `select knowledge from knowledge
46
- where source="${knowledgeSource}"
47
- order by source desc`;
45
+ where source="${knowledgeSource}"
46
+ order by source desc`;
47
+
48
+ refreshFlatmapKnowledgeCache()
48
49
  const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
49
50
 
50
51
  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
- });
52
+ const response = await flatmapQueries.flatmapQuery(sql);
53
+ const mappedData = response.values.map(x => x[0]);
54
+ const parsedData = mappedData.map(x => JSON.parse(x));
55
+
56
+ sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
57
+ updateFlatmapKnowledgeCache();
58
+
59
+ return parsedData;
57
60
  }
61
+ return JSON.parse(flatmapKnowledge);
58
62
  }
59
63
 
60
64
  function updateFlatmapKnowledgeCache() {
@@ -70,6 +74,7 @@ function removeFlatmapKnowledgeCache() {
70
74
  'flatmap-knowledge',
71
75
  'flatmap-knowledge-expiry',
72
76
  ];
77
+
73
78
  keys.forEach((key) => {
74
79
  sessionStorage.removeItem(key);
75
80
  });