From 46775bbec86de1fc641b32e85e235d4834ca6580 Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <fabio@manganiello.tech>
Date: Mon, 24 Feb 2025 01:59:36 +0100
Subject: [PATCH] Set start/end date in filter by clicking on the map info.

---
 frontend/src/components/Map.vue | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/frontend/src/components/Map.vue b/frontend/src/components/Map.vue
index 55aa6c8..3f14c4f 100644
--- a/frontend/src/components/Map.vue
+++ b/frontend/src/components/Map.vue
@@ -6,11 +6,19 @@
         <div class="time-range" v-if="gpsPoints?.length">
           <div class="row">
             <div class="key">From</div>
-            <div class="value">{{ displayedDate(oldestPoint?.timestamp) }}</div>
+            <div class="value">
+              <a href="#" @click.prevent.stop="onStartDateClick">
+                {{ displayedDate(oldestPoint?.timestamp) }}
+              </a>
+            </div>
           </div>
           <div class="row">
             <div class="key">To</div>
-            <div class="value">{{ displayedDate(newestPoint?.timestamp) }}</div>
+            <div class="value">
+              <a href="#" @click.prevent.stop="onEndDateClick">
+                {{ displayedDate(newestPoint?.timestamp) }}
+              </a>
+            </div>
           </div>
 
           <div class="row">
@@ -190,6 +198,18 @@ export default {
 
       return new Date(date).toString().replace(/GMT.*/, '')
     },
+
+    onStartDateClick() {
+      this.locationQuery.startDate = this.oldestPoint?.timestamp
+      this.locationQuery.minId = undefined
+      this.locationQuery.maxId = undefined
+    },
+
+    onEndDateClick() {
+      this.locationQuery.endDate = this.newestPoint?.timestamp
+      this.locationQuery.minId = undefined
+      this.locationQuery.maxId = undefined
+    },
   },
 
   watch: {