many updates
This commit is contained in:
180
web/layouts/organized_carpool/_partials/booking_map.html
Normal file
180
web/layouts/organized_carpool/_partials/booking_map.html
Normal file
@@ -0,0 +1,180 @@
|
||||
{{ define "organized_carpool_map" }}
|
||||
<div id="map" class="w-full h-full min-h-96"></div>
|
||||
<script>
|
||||
let protocol = new pmtiles.Protocol();
|
||||
maplibregl.addProtocol("pmtiles",protocol.tile);
|
||||
var map = new maplibregl.Map({
|
||||
container: 'map', // container id
|
||||
style: "/public/maps/protomaps-light/style.json",
|
||||
});
|
||||
|
||||
const geojsonPoints = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [{{ .booking.PassengerPickupLng }}, {{ .booking.PassengerPickupLat }}]
|
||||
},
|
||||
"properties": {
|
||||
"label": "{{ .booking.PassengerPickupAddress }}",
|
||||
"type": "pickup"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [{{ .booking.PassengerDropLng }}, {{ .booking.PassengerDropLat }}]
|
||||
},
|
||||
"properties": {
|
||||
"label": "{{ .booking.PassengerDropAddress }}",
|
||||
"type": "drop"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
map.on('load', async () => {
|
||||
// Add route polyline if available
|
||||
// Add driver route if available
|
||||
{{if .booking.DriverRoute}}
|
||||
console.log("DriverRoute found");
|
||||
try {
|
||||
const driverRoute = JSON.parse(`{{ .booking.DriverRoute.Serialized }}`);
|
||||
console.log("Parsed driverRoute:", driverRoute);
|
||||
console.log("DriverRoute type:", driverRoute.type);
|
||||
console.log("DriverRoute features:", driverRoute.features);
|
||||
console.log("DriverRoute features count:", driverRoute.features ? driverRoute.features.length : 0);
|
||||
console.log("DriverRoute keys:", Object.keys(driverRoute));
|
||||
if (driverRoute.features && driverRoute.features.length > 0) {
|
||||
console.log("First feature:", driverRoute.features[0]);
|
||||
console.log("LineString features:", driverRoute.features.filter(f => f.geometry && f.geometry.type === 'LineString'));
|
||||
} else {
|
||||
console.log("No features found, checking alternative structure");
|
||||
console.log("All driverRoute properties:", driverRoute);
|
||||
}
|
||||
|
||||
map.addSource('driver_route', {
|
||||
type: "geojson",
|
||||
data: driverRoute
|
||||
});
|
||||
|
||||
map.addLayer({
|
||||
'id': 'driver_route',
|
||||
'type': 'line',
|
||||
'source': 'driver_route',
|
||||
'filter': ['==', ['geometry-type'], 'LineString'], // Only show LineString geometries
|
||||
'layout': {
|
||||
'line-join': 'round',
|
||||
'line-cap': 'round',
|
||||
},
|
||||
'paint': {
|
||||
'line-color': '#243887', // Blue - main application color
|
||||
'line-width': 3
|
||||
},
|
||||
});
|
||||
console.log("Driver route layer added successfully");
|
||||
} catch (error) {
|
||||
console.error("Error adding driver route:", error);
|
||||
}
|
||||
{{else}}
|
||||
console.log("No DriverRoute available");
|
||||
{{end}}
|
||||
|
||||
// Add passenger route if available
|
||||
{{if .booking.PassengerRoute}}
|
||||
console.log("PassengerRoute found");
|
||||
try {
|
||||
const passengerRoute = JSON.parse(`{{ .booking.PassengerRoute.Serialized }}`);
|
||||
console.log("Parsed passengerRoute:", passengerRoute);
|
||||
console.log("PassengerRoute type:", passengerRoute.type);
|
||||
console.log("PassengerRoute features count:", passengerRoute.features ? passengerRoute.features.length : 0);
|
||||
|
||||
map.addSource('passenger_route', {
|
||||
type: "geojson",
|
||||
data: passengerRoute
|
||||
});
|
||||
|
||||
map.addLayer({
|
||||
'id': 'passenger_route',
|
||||
'type': 'line',
|
||||
'source': 'passenger_route',
|
||||
'filter': ['==', ['geometry-type'], 'LineString'], // Only show LineString geometries
|
||||
'layout': {
|
||||
'line-join': 'round',
|
||||
'line-cap': 'round',
|
||||
},
|
||||
'paint': {
|
||||
'line-color': '#243887', // Blue - main application color
|
||||
'line-width': 3
|
||||
},
|
||||
});
|
||||
console.log("Passenger route layer added successfully");
|
||||
} catch (error) {
|
||||
console.error("Error adding passenger route:", error);
|
||||
}
|
||||
{{else}}
|
||||
console.log("No PassengerRoute available");
|
||||
{{end}}
|
||||
|
||||
map.addSource('carpool_points', {
|
||||
type: "geojson",
|
||||
data: geojsonPoints
|
||||
})
|
||||
|
||||
// Add pickup point
|
||||
map.addLayer({
|
||||
'id': 'pickup_point',
|
||||
'type': 'circle',
|
||||
'source': 'carpool_points',
|
||||
'filter': ['==', ['get', 'type'], 'pickup'],
|
||||
'paint': {
|
||||
'circle-color': '#243887', // Blue - main application color
|
||||
'circle-radius': 8,
|
||||
'circle-stroke-color': '#fff',
|
||||
'circle-stroke-width': 2
|
||||
},
|
||||
});
|
||||
|
||||
// Add drop point
|
||||
map.addLayer({
|
||||
'id': 'drop_point',
|
||||
'type': 'circle',
|
||||
'source': 'carpool_points',
|
||||
'filter': ['==', ['get', 'type'], 'drop'],
|
||||
'paint': {
|
||||
'circle-color': '#243887', // Blue - main application color
|
||||
'circle-radius': 8,
|
||||
'circle-stroke-color': '#fff',
|
||||
'circle-stroke-width': 2
|
||||
},
|
||||
});
|
||||
|
||||
// Add popup on click
|
||||
map.on('click', 'pickup_point', (e) => {
|
||||
new maplibregl.Popup()
|
||||
.setLngLat(e.lngLat)
|
||||
.setHTML(`<strong>Point de départ</strong><br>${e.features[0].properties.label}`)
|
||||
.addTo(map);
|
||||
});
|
||||
|
||||
map.on('click', 'drop_point', (e) => {
|
||||
new maplibregl.Popup()
|
||||
.setLngLat(e.lngLat)
|
||||
.setHTML(`<strong>Destination</strong><br>${e.features[0].properties.label}`)
|
||||
.addTo(map);
|
||||
});
|
||||
|
||||
// Change cursor on hover
|
||||
map.on('mouseenter', 'pickup_point', () => map.getCanvas().style.cursor = 'pointer');
|
||||
map.on('mouseleave', 'pickup_point', () => map.getCanvas().style.cursor = '');
|
||||
map.on('mouseenter', 'drop_point', () => map.getCanvas().style.cursor = 'pointer');
|
||||
map.on('mouseleave', 'drop_point', () => map.getCanvas().style.cursor = '');
|
||||
|
||||
var bbox = turf.bbox(geojsonPoints)
|
||||
map.fitBounds(bbox, { padding: 50 })
|
||||
})
|
||||
</script>
|
||||
{{ end }}
|
||||
@@ -40,32 +40,32 @@
|
||||
{{range .ViewState.bookings}}
|
||||
<tr>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
<a class="text-co-blue" href="/app/organized-carpool/drivers/{{.DriverId}}">
|
||||
{{ (index $.ViewState.drivers_map .DriverId).Data.first_name }}
|
||||
{{ (index $.ViewState.drivers_map .DriverId).Data.last_name }}
|
||||
<a class="text-co-blue" href="/app/organized-carpool/drivers/{{.Driver.Id}}">
|
||||
{{ (index $.ViewState.drivers_map .Driver.Id).Data.first_name }}
|
||||
{{ (index $.ViewState.drivers_map .Driver.Id).Data.last_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
<a class="text-co-blue" href="/app/beneficiaries/{{.PassengerId}}">
|
||||
{{ (index $.ViewState.passengers_map .PassengerId).Data.first_name }}
|
||||
{{ (index $.ViewState.passengers_map .PassengerId).Data.last_name }}
|
||||
<a class="text-co-blue" href="/app/beneficiaries/{{.Passenger.Id}}">
|
||||
{{ (index $.ViewState.passengers_map .Passenger.Id).Data.first_name }}
|
||||
{{ (index $.ViewState.passengers_map .Passenger.Id).Data.last_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ .Journey.PassengerPickup.Properties.label }}
|
||||
<td class="py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ .PassengerPickupAddress }}
|
||||
</td>
|
||||
<td class="py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ .PassengerDropAddress }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ .Journey.PassengerDrop.Properties.label }}
|
||||
{{ timeFormat .PassengerPickupDate.AsTime "02/01/2006 15:04" }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ .Journey.PassengerPickupDate.Format "02/01/2006 15:04" }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||
{{ if eq .Status "WAITING_CONFIRMATION"}}
|
||||
{{ if eq .Status.String "WAITING_DRIVER_CONFIRMATION"}}
|
||||
<span class="p-1 text-xs bg-gray-300 rounded-xl">Attente confirmation</span>
|
||||
{{ else if eq .Status "VALIDATED"}}
|
||||
{{ else if eq .Status.String "VALIDATED"}}
|
||||
<span class="p-1 text-xs bg-co-green rounded-xl">Validé</span>
|
||||
{{ else if eq .Status "CANCELLED"}}
|
||||
{{ else if eq .Status.String "CANCELLED"}}
|
||||
<span class="p-1 text-xs bg-co-red text-white rounded-xl">Annulé</span>
|
||||
{{ end }}
|
||||
</td>
|
||||
|
||||
@@ -12,11 +12,23 @@
|
||||
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
|
||||
<div class="sm:col-span-1">
|
||||
<dt class="text-sm font-medium text-gray-500">Départ passager</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{(index .journey.Features 0).Properties.MustString "label"}}</dd>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
{{ if .journey.ExtraMembers.passenger_pickup }}
|
||||
{{ .journey.ExtraMembers.passenger_pickup.properties.label }}
|
||||
{{ else }}
|
||||
Adresse non disponible
|
||||
{{ end }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="sm:col-span-1">
|
||||
<dt class="text-sm font-medium text-gray-500">Destination passager</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{(index .journey.Features 1).Properties.MustString "label"}}</dd>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
{{ if .journey.ExtraMembers.passenger_drop }}
|
||||
{{ .journey.ExtraMembers.passenger_drop.properties.label }}
|
||||
{{ else }}
|
||||
Adresse non disponible
|
||||
{{ end }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="sm:col-span-1">
|
||||
<dt class="text-sm font-medium text-gray-500">Départ conducteur</dt>
|
||||
|
||||
Reference in New Issue
Block a user