add ui to configure how long nodes should show on the map without being updated
This commit is contained in:
@ -864,6 +864,28 @@
|
||||
|
||||
<div class="overflow-y-auto divide-y divide-gray-200">
|
||||
|
||||
<!-- configNodesMaxAgeInSeconds -->
|
||||
<div class="p-2">
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900">Nodes Max Age</label>
|
||||
<select v-model="configNodesMaxAgeInSeconds" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
|
||||
<option :value="null">Show All</option>
|
||||
<option value="900">15 minutes</option>
|
||||
<option value="1800">30 minutes</option>
|
||||
<option value="3600">1 hour</option>
|
||||
<option value="10800">3 hours</option>
|
||||
<option value="21600">6 hours</option>
|
||||
<option value="43200">12 hours</option>
|
||||
<option value="86400">24 hours</option>
|
||||
<option value="172800">2 days</option>
|
||||
<option value="259200">3 days</option>
|
||||
<option value="345600">4 days</option>
|
||||
<option value="432000">5 days</option>
|
||||
<option value="518400">6 days</option>
|
||||
<option value="604800">7 days</option>
|
||||
</select>
|
||||
<div class="text-xs text-gray-600">Nodes not updated within this time are hidden. Reload to update map.</div>
|
||||
</div>
|
||||
|
||||
<!-- configNeighboursMaxDistanceInMeters -->
|
||||
<div class="p-2">
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900">Neighbours Max Distance (meters)</label>
|
||||
@ -891,6 +913,19 @@
|
||||
|
||||
<script>
|
||||
|
||||
function getConfigNodesMaxAgeInSeconds() {
|
||||
const value = localStorage.getItem("config_nodes_max_age_in_seconds");
|
||||
return value != null ? parseInt(value) : null;
|
||||
}
|
||||
|
||||
function setConfigNodesMaxAgeInSeconds(value) {
|
||||
if(value != null){
|
||||
return localStorage.setItem("config_nodes_max_age_in_seconds", value);
|
||||
} else {
|
||||
return localStorage.removeItem("config_nodes_max_age_in_seconds");
|
||||
}
|
||||
}
|
||||
|
||||
function getConfigNeighboursMaxDistanceInMeters() {
|
||||
const value = localStorage.getItem("config_neighbours_max_distance_in_meters");
|
||||
return value != null ? parseInt(value) : null;
|
||||
@ -917,6 +952,7 @@
|
||||
data() {
|
||||
return {
|
||||
|
||||
configNodesMaxAgeInSeconds: window.getConfigNodesMaxAgeInSeconds(),
|
||||
configNeighboursMaxDistanceInMeters: window.getConfigNeighboursMaxDistanceInMeters(),
|
||||
configZoomLevelGoToNode: window.getConfigZoomLevelGoToNode(),
|
||||
|
||||
@ -1294,6 +1330,9 @@
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
configNodesMaxAgeInSeconds() {
|
||||
window.setConfigNodesMaxAgeInSeconds(this.configNodesMaxAgeInSeconds);
|
||||
},
|
||||
configNeighboursMaxDistanceInMeters() {
|
||||
window.setConfigNeighboursMaxDistanceInMeters(this.configNeighboursMaxDistanceInMeters);
|
||||
},
|
||||
@ -1599,6 +1638,16 @@
|
||||
// add nodes
|
||||
for(var node of updatedNodes){
|
||||
|
||||
// skip nodes older than configured node max age
|
||||
const now = moment();
|
||||
const configNodesMaxAgeInSeconds = getConfigNodesMaxAgeInSeconds();
|
||||
if(configNodesMaxAgeInSeconds){
|
||||
const lastUpdatedAgeInMillis = now.diff(moment(node.updated_at));
|
||||
if(lastUpdatedAgeInMillis > configNodesMaxAgeInSeconds * 1000){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// skip nodes without position
|
||||
if(!node.latitude || !node.longitude){
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user