Add frontend route history tracking
This commit is contained in:
@@ -53,7 +53,7 @@ class FleetVehicle(models.Model):
|
||||
|
||||
# === Otonom GPS / Takip Cihazı (Faz 9) ===
|
||||
tracker_device_id = fields.Char(string="Takip Uygulaması ID", help="Traccar veya OwnTracks uygulamasındaki benzersiz kimlik (Device ID).")
|
||||
google_maps_name = fields.Char(string="Google Konum Görünen Adı", help="Şoförün Google Haritalar üzerinde görünen tam adı (Örn: Ahmet Yılmaz).")
|
||||
google_maps_name = fields.Char(string="Google Konum Görünen Adı", help="Şoförün Google Haritalar Konum Paylaşımı'ndaki görünen adı (Örn: Ahmet Yılmaz)")
|
||||
|
||||
# 3 Para Birimli Amortisman Maliyet Alanları ve Ortalama Değer
|
||||
depreciation_cost_try = fields.Float(string="Amortisman Maliyeti (Ana Döviz)", default=0.0)
|
||||
|
||||
@@ -339,6 +339,33 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
var offlineCount = 0;
|
||||
|
||||
vehiclesData.forEach(function(v, idx) {
|
||||
// === Tarayıcı Tabanlı Rota Çizgisi Geçmişi (Frontend History) ===
|
||||
var historyKey = 'mymach_route_' + v.id;
|
||||
var history = [];
|
||||
try {
|
||||
history = JSON.parse(localStorage.getItem(historyKey) || '[]');
|
||||
} catch(e) {}
|
||||
|
||||
if (v.green_route && v.green_route.length > 0) {
|
||||
var currentLat = v.green_route[0][0];
|
||||
var currentLon = v.green_route[0][1];
|
||||
|
||||
var addPoint = true;
|
||||
if (history.length > 0) {
|
||||
var lastPt = history[history.length - 1];
|
||||
// Eğer son konumla aynıysa (veya çok yakınsa) ekleme (yaklaşık 10 metre)
|
||||
if (Math.abs(lastPt[0] - currentLat) < 0.0001 && Math.abs(lastPt[1] - currentLon) < 0.0001) {
|
||||
addPoint = false;
|
||||
}
|
||||
}
|
||||
if (addPoint) {
|
||||
history.push([currentLat, currentLon]);
|
||||
if (history.length > 300) history = history.slice(-300); // 300 noktayı hafızada tut
|
||||
localStorage.setItem(historyKey, JSON.stringify(history));
|
||||
}
|
||||
v.green_route = history;
|
||||
}
|
||||
|
||||
// Basit bir kural: Hızı 0'dan büyük olanlar HAREKETLİ, 0 olanlar PARK, veri olmayanlar ÇEVRİMDIŞI.
|
||||
var speedStr = "0 km/s";
|
||||
if (v.gps_speed !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user