Skip to content

Commit 552bb59

Browse files
committed
fix: show device point info popup when hovering device history
The Vue 3 migration stopped rendering DeviceHoverMarker, so hovering a device history line no longer showed the point info (date, altitude, battery, accuracy) like in 1.6.0. Render it again from DevicesLayer and make the hover marker interactive so its tooltip opens on hover. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Area52_Nader <86432017+NaderArea52@users.noreply.github.com>
1 parent 19597b5 commit 552bb59

2 files changed

Lines changed: 30 additions & 9 deletions

File tree

‎src/components/map/DeviceHoverMarker.vue‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,25 @@ export default {
7070
7171
watch: {
7272
point: {
73-
handler(newPoint) {
73+
handler(newPoint, oldPoint) {
7474
if (this.marker) {
7575
this.marker.setLatLng([newPoint.lat, newPoint.lng])
76-
this.marker.setIcon(this.icon)
77-
this.marker.setTooltipContent(this.$el) // Force update DOM
76+
// only replace the icon element when needed, replacing it under the mouse breaks hover events
77+
if (!oldPoint || newPoint.color !== oldPoint.color) {
78+
this.marker.setIcon(this.icon)
79+
}
80+
// show the info of the newly hovered point
81+
this.marker.openTooltip()
7882
}
7983
},
8084
deep: true
8185
}
8286
},
8387
8488
mounted() {
85-
this.marker = L.marker([this.point.lat, this.point.lng], {
86-
icon: this.icon,
87-
interactive: false
89+
// interactive (like in 1.6.0) so hovering the point opens its tooltip
90+
this.marker = L.marker([this.point.lat, this.point.lng], {
91+
icon: this.icon,
8892
}).addTo(this.map)
8993
9094
this.marker.bindTooltip(this.$el, this.tooltipOptions)

‎src/components/map/DevicesLayer.vue‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
22
<div style="display: none;">
3+
<DeviceHoverMarker v-if="hoverPoint"
4+
:point="hoverPoint"
5+
:map="map" />
36
<LHeatMap v-if="points.length >= 2500"
47
ref="devicesHeatMap"
58
:map="map"
@@ -14,6 +17,7 @@ import { isComputer } from '../../utils.js'
1417
import { binSearch, isPublic } from '../../utils/common.js'
1518
import moment from '@nextcloud/moment'
1619
import LHeatMap from './LHeatMap.vue'
20+
import DeviceHoverMarker from './DeviceHoverMarker.vue'
1721
import optionsController from '../../optionsController.js'
1822
1923
const DEVICE_MARKER_VIEW_SIZE = 40
@@ -22,6 +26,7 @@ export default {
2226
name: 'DevicesLayer',
2327
components: {
2428
LHeatMap,
29+
DeviceHoverMarker,
2530
},
2631
2732
props: {
@@ -38,6 +43,7 @@ export default {
3843
blur: 10,
3944
gradient: { 0.4: 'blue', 0.65: 'lime', 1: 'red' },
4045
},
46+
hoverPoint: null,
4147
}
4248
},
4349
@@ -50,6 +56,9 @@ export default {
5056
displayedDevices() {
5157
return this.devices.filter(d => d.enabled && d.points && d.points.length > 0);
5258
},
59+
enabledDevices() {
60+
return this.devices.map(d => d.enabled);
61+
},
5362
points() {
5463
return this.devices.reduce((pts, device) => {
5564
if (device.enabled && device.historyEnabled) {
@@ -71,6 +80,9 @@ export default {
7180
7281
watch: {
7382
displayedDevices: { handler: 'renderDevices', deep: true },
83+
enabledDevices() {
84+
this.hoverPoint = null;
85+
},
7486
start: 'renderDevices',
7587
end: 'renderDevices',
7688
},
@@ -131,7 +143,7 @@ export default {
131143
</div>
132144
`, { sticky: true, className: 'leaflet-marker-device-tooltip', direction: 'top', offset: L.point(0, 0) });
133145
134-
marker.on('mouseover', () => this.$emit('point-hover', { ...device.points[device.points.length - 1], color, user_agent: device.user_agent }));
146+
marker.on('mouseover', () => this.onPointHover({ ...device.points[device.points.length - 1], color, user_agent: device.user_agent }));
135147
marker.on('click', () => this.$emit('click', device));
136148
marker.on('contextmenu', (e) => this.showDevicePopup(e, device));
137149
@@ -191,9 +203,14 @@ export default {
191203
}, { minDist: 40000000, hoverPoint: null });
192204
193205
if (closestPoint.hoverPoint) {
194-
this.$emit('point-hover', { ...closestPoint.hoverPoint, color, user_agent: device.user_agent });
206+
this.onPointHover({ ...closestPoint.hoverPoint, color, user_agent: device.user_agent });
195207
}
196-
}
208+
},
209+
210+
onPointHover(point) {
211+
this.hoverPoint = point;
212+
this.$emit('point-hover', point);
213+
},
197214
},
198215
}
199216
</script>

0 commit comments

Comments
 (0)