Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile UX: filters, map popups #128

Merged
merged 29 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6258c86
Logs: move filters to the side of tabs
lukarenko May 2, 2024
48d1ecd
Merge branch 'live' into mobile-ux
lukarenko May 2, 2024
9226684
Logs: improve tablet
lukarenko May 2, 2024
3c24e2a
Logs: bring title back
lukarenko May 2, 2024
d4d3c56
Stays: filters in same card as table
lukarenko May 2, 2024
16e5802
Cleanup: use va-xxx-xxx style
lukarenko May 2, 2024
15958b9
Temp workaround for Vuestic date range picker bug
lukarenko May 2, 2024
5aff24c
Stays: better for tablet
lukarenko May 2, 2024
5bf74d7
Stay-Moorage: filters in same card as table
lukarenko May 2, 2024
140a3ec
Moorages: filters in same card as table
lukarenko May 2, 2024
10ff676
Cleanup: remove <div> that is not needed
lukarenko May 2, 2024
ae8118b
Logs/Stays/Moorages: add vesselName to title, fix title text
lukarenko May 2, 2024
e302466
Stays-Moorage, Moorage-Arrivals: fix title
lukarenko May 2, 2024
c3f7438
Simplify
lukarenko May 2, 2024
58fd5b8
LogMap: nicer popup formatting
lukarenko May 2, 2024
c48e8ff
leafletMap: improved popup
lukarenko May 2, 2024
6b7a5de
Apply td style only in popup
lukarenko May 2, 2024
4603b86
Remove 2x miles in popup
lukarenko May 2, 2024
751b7e5
MMSI cleanup
lukarenko May 2, 2024
ce8d103
NM/km/kts for non-english
lukarenko May 2, 2024
6635566
remove warning
lukarenko May 2, 2024
5226cda
Fix mpopup style
lukarenko May 2, 2024
9259105
leafletMap: imrpove formatting multi track popup
lukarenko May 2, 2024
f9f8b74
Moorages Map: add max speed, max wind speed
lukarenko May 2, 2024
f39a2f4
simplify links from popup
lukarenko May 2, 2024
f52eb80
Moorage Map: improve popups
lukarenko May 2, 2024
98cd5a8
Re-add duration i18n
lukarenko May 2, 2024
513792b
Fix log show on click
lukarenko May 2, 2024
a1751c9
Wind Speed Max
lukarenko May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 58 additions & 39 deletions src/components/maps/leafletMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { defaultBaseMapType, baseMaps, overlayMaps, boatMarkerTypes } from './leafletHelpers.js'

import { dateFormatUTC, durationFormatHours } from '../../utils/dateFormatter.js'
import { distanceFormatMiles } from '../../utils/distanceFormatter.js'
import { speedFormatKnots } from '../../utils/speedFormatter.js'
import { awaFormat, angleFormat } from '../../utils/angleFormatter.js'

Expand Down Expand Up @@ -103,51 +104,57 @@
//console.log(`popup`, feature.properties)
let status = feature.properties.status || ''
let time = dateFormatUTC(feature.properties.time)
let speed = speedFormatKnots(feature.properties.speedoverground) || 0
let cog = angleFormat(feature.properties.courseovergroundtrue) || 0
let awa = awaFormat(feature.properties.truewinddirection, feature.properties.courseovergroundtrue) || 0
let wind = speedFormatKnots(feature.properties.windspeedapparent) || 0
let winddir = angleFormat(feature.properties.truewinddirection) || 0
let latitude = parseFloat(feature.properties.latitude).toFixed(5)
let longitude = parseFloat(feature.properties.longitude).toFixed(5)
let text = `<div class='center'><h4>${vesselName}: ${status}</h4></div><br/>
Time: ${time}<br/>
Boat Speed: ${speed}<br/>
Course Over Ground: ${cog}<br/>
Apparent Wind Angle: ${awa}<br/>
Wind Speed: ${wind}<br/>
Wind Direction: ${winddir}<br/>
Latitude: ${latitude}<br/>
Longitude: ${longitude}<br/>`
let sog = speedFormatKnots(feature.properties.speedoverground)
let cog = angleFormat(feature.properties.courseovergroundtrue)
let twd = angleFormat(feature.properties.truewinddirection)
let aws = speedFormatKnots(feature.properties.windspeedapparent)
let awa = awaFormat(feature.properties.truewinddirection, feature.properties.courseovergroundtrue)
let latitude = parseFloat(feature.properties.latitude).toFixed(3)
let longitude = parseFloat(feature.properties.longitude).toFixed(3)
let text = `<div class='mpopup' id='${time}'><h4>${vesselName}: ${status}</h4><br/>
<table class='data'><tbody>
<tr><td>Time</td><td>${time}</td></tr>
<tr><td>Position</td><td>${latitude} ${longitude}</td></tr>`
if (feature.properties.speedoverground) {
text += `<tr><td>Speed</td><td>${sog}`
if (feature.properties.courseovergroundtrue) {
text += ` / ${cog}`
}
text += `</td></tr>`
}
if (feature.properties.windspeedapparent) {
text += `<tr><td>Wind</td><td>${aws}`
if (feature.properties.truewinddirection) {
text += ` / ${twd}`
}
text += `</td></tr>`
}
if (feature.properties.truewinddirection && feature.properties.courseovergroundtrue) {
text += `<tr><td>AWA</td><td>${awa}</td></tr>`
}
text += `</tbody></table></div>`
popupContent = text
}
// If geo linestring click
if (feature.properties && feature.properties._from_time) {
//console.log(`popup`, feature.properties)
let time = dateFormatUTC(feature.properties._from_time)
let duration = durationFormatHours(feature.properties.duration)
let distance = distanceFormatMiles(feature.properties.distance)
let avg_speed = speedFormatKnots(feature.properties.avg_speed)
let duration = durationFormatHours(feature.properties.duration) + ' H'
let distance = parseFloat(feature.properties.distance).toFixed(5) + ' NM'
let text = `<div class='center'><h4><a id="logLink" style="cursor: pointer;" onclick="logLink(${feature.properties.id})">${feature.properties.name}</a></h4></div><br/>
Time: ${time}<br/>
Average Speed: ${avg_speed}<br/>
Duration: ${duration}<br/>
Distance: ${distance}<br/>
<a id="timelapseLink" style="cursor: pointer;" onclick="timelapseLink(${feature.properties.id})">Play timelapse</a>`
let max_speed = speedFormatKnots(feature.properties.max_speed)
let max_wind = speedFormatKnots(feature.properties.max_wind_speed)
let text = `<div class='mpopup'>
<h4><a href="/logmap/${feature.properties.id}">${feature.properties.name}</a></h4><br/>
<table class='data'><tbody>
<tr><td>Time</td><td>${time}</td></tr>
<tr><td>Distance</td><td>${distance}</td></tr>
<tr><td>Duration</td><td>${duration} hours</td></tr>
<tr><td>Speed Ave/Max</td><td>${avg_speed} / ${max_speed}</td></tr>
<tr><td>Wind Speed Max</td><td>${max_wind}</td></tr>
</tbody></table></br>
<a href="/timelapse/${feature.properties.id}">Replay</a>
</div>`
popupContent = text

// Go to logbook details page
window.logLink = async function (log_id) {
let tripLink = document.getElementById('logLink')
tripLink.href = `/logmap/${log_id}`
return
}
// Go to timelapse page
window.timelapseLink = async function (log_id) {
let link = document.getElementById('timelapseLink')
link.href = `/timelapse/${log_id}`
return
}
}
layer.bindPopup(popupContent)
}
Expand Down Expand Up @@ -215,7 +222,19 @@
}
</script>

<style scoped>
<style lang="scss">
.mpopup {
td:nth-child(1) {
text-align: right;
padding-right: 5px;
}
td:nth-child(2) {
font-weight: bold;
}
a {
cursor: pointer;
}
}
#mapContainer {
z-index: 0;
}
Expand Down
54 changes: 36 additions & 18 deletions src/components/maps/leafletMapMoorages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* TODO
* Add boat name
* Add motorboat icon
* Add Emodnet bathymetry
*/
import 'leaflet/dist/leaflet.css'
import * as L from 'leaflet'
Expand All @@ -26,6 +25,7 @@

import { dateFormatUTC, durationFormatHours } from '../../utils/dateFormatter.js'
import { distanceFormatMiles } from '../../utils/distanceFormatter.js'
import { speedFormatKnots } from '../../utils/speedFormatter.js'

const isBusy = ref(false),
apiError = ref(null),
Expand Down Expand Up @@ -149,17 +149,14 @@
var popupContent =
'<p>I started out as a GeoJSON ' + feature.geometry.type + ", but now I'm a Leaflet vector!</p>"
if (feature.properties && feature.properties.id) {
console.log('popup onEachMoorageFeaturePopup')
let text = `<div class='center'><h5><a href="/moorage/${feature.properties.id}">${feature.properties.name}</a></h5><br/>
<a href="/stay/${feature.properties.id}">${feature.properties.total_stay}<a/> day(s) stay<br/></div>`
// Should be done using i18n
let text = `<div class='mpopup'>
<h4><a href="/moorage/${feature.properties.id}">${feature.properties.name}</a></h4><br/>
<a href="/stays/moorage/${feature.properties.id}">${feature.properties.total_stay} day(s) stay</a>
</div>`
popupContent = text
}
layer.bindPopup(popupContent)
//bind click
layer.on({
click: whenClicked,
})
layer.on({ click: whenClicked })
}

const layer = L.geoJSON(geojson, {
Expand All @@ -174,18 +171,26 @@
}

// TODO Zoom and fit on click
// TODO convert _from_time to date
// TODO convert _duration to hours
const onEachLineStringFeaturePopup = function (feature, layer) {
var popupContent = '<p>I started out as a GeoJSON ' + feature.geometry.type + ", but now I'm a Leaflet vector!</p>"
if (feature.properties && feature.properties.id) {
console.log('popup onEachLineStringFeaturePopup')
let date = dateFormatUTC(feature.properties._from_time)
if (feature.properties && feature.properties._from_time) {
let time = dateFormatUTC(feature.properties._from_time)
let duration = durationFormatHours(feature.properties.duration)
let distance = distanceFormatMiles(feature.properties.distance)
let text = `<div class='center'><h6><a href="/log/${feature.properties.id}">From ${feature.properties.name}</a></h6><br/>
${date}, ${distance} miles, ${duration} hours<br/></div>`
// TODO should be done using i18n
let avg_speed = speedFormatKnots(feature.properties.avg_speed)
let max_speed = speedFormatKnots(feature.properties.max_speed)
let max_wind = speedFormatKnots(feature.properties.max_wind_speed)
let text = `<div class='mpopup'>
<h4><a href="/logmap/${feature.properties.id}">${feature.properties.name}</a></h4><br/>
<table class='data'><tbody>
<tr><td>Time</td><td>${time}</td></tr>
<tr><td>Distance</td><td>${distance}</td></tr>
<tr><td>Duration</td><td>${duration} hours</td></tr>
<tr><td>Speed Ave/Max</td><td>${avg_speed} / ${max_speed}</td></tr>
<tr><td>Wind Speed Max</td><td>${max_wind}</td></tr>
</tbody></table></br>
<a href="/timelapse/${feature.properties.id}">Replay</a>
</div>`
popupContent = text
}
layer.bindPopup(popupContent)
Expand Down Expand Up @@ -278,4 +283,17 @@
})
</script>

<style lang="scss" scoped></style>
<style lang="scss">
.mpopup {
td:nth-child(1) {
text-align: right;
padding-right: 5px;
}
td:nth-child(2) {
font-weight: bold;
}
a {
cursor: pointer;
}
}
</style>
22 changes: 14 additions & 8 deletions src/i18n/locales/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
"logs": {
"list": {
"title": "Logs list",
"title": "Logs - Log Book for",
"filter": {
"title": "Search for log",
"name": "Name",
Expand Down Expand Up @@ -159,7 +159,7 @@
},
"stays": {
"list": {
"title": "Stays list",
"title": "Stays - Moorage History of",
"filter": {
"title": "Search for stay",
"name": "Name",
Expand All @@ -178,19 +178,22 @@
"departed": "Departed",
"arrived": "Arrived",
"stayed_at": "Fiquei em",
"duration": "Duração",
"duration_d": "Duração [d]",
"note": "Note | Notes"
},
"moorage": {
"title": "Stays at Moorage",
"arrived": "Chegou",
"departed": "Partiu",
"stayed_at": "Fiquei em",
"duration": "Duração",
"duration_d": "Duração [d]"
}
},
"moorages": {
"list": {
"title": "Moorages list",
"title": "Moorages of",
"filter": {
"title": "Search for moorage",
"name": "Name",
Expand All @@ -202,10 +205,14 @@
"total_stay": "Total Stay [d]",
"arrivals": "Arrivals & Departures"
},
"arrivals-departures": {
"title": "Arrivals and Departures for Moorage"
},
"details": {
"title": "Moorage's details"
},
"moorage": {
"title": "Stays at Moorage",
"moorage": "Preferred Name",
"departed": "Default Stay Type",
"home": "Home",
Expand Down Expand Up @@ -247,15 +254,14 @@
},
"boat": {
"name": "Name | Names",
"mmsi": "MMSI (opcional)",
"mmsi": "MMSI",
"first_contact": "Primeiro contato",
"last_contact": "Último contato",
"created_at": "Creado en",
"token_modal": {
"button": "Get token",
"title": "Boat's token",
"token": "Token",
//"message": "WARNING, This access token will only be displayed once. It will not be stored and cannot be retrieved. Please be sure to save it now."
"message": "Copy paste this token into your postgsail plugin instance of signalk."
},
"beam": "Beam",
Expand Down Expand Up @@ -417,11 +423,11 @@
},
"units": {
"distance": {
"miles": "NM",
"kilometres": "km"
"miles": "{n} NM",
"kilometres": "{n} km"
},
"speed": {
"knots": "kts"
"knots": "{n} kts"
},
"time": {
"days": "{n} days | {n} day | {n} days",
Expand Down
11 changes: 6 additions & 5 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@
"departed": "Abgereist",
"arrived": "Angekommen",
"stayed_at": "Verbleib",
"duration": "Dauer",
"duration_d": "Dauer [t]",
"note": "Notiz | Notizen"
},
"moorage": {
"arrived": "Arrived",
"departed": "Departed",
"stayed_at": "Stayed at",
"duration": "Dauer",
"duration_d": "Dauer [t]"
}
},
Expand Down Expand Up @@ -251,7 +253,7 @@
},
"boat": {
"name": "Name | Namen",
"mmsi": "MMSI (fakultativ)",
"mmsi": "MMSI",
"first_contact": "First Kontakt",
"last_contact": "Letzter Kontakt",
"created_at": "Erstellt am",
Expand All @@ -260,7 +262,6 @@
"button": "Token erhalten",
"title": "Token des Bootes",
"token": "Token",
//"message": "WARNUNG, Dieser Zugriffstoken wird nur einmal angezeigt. Er wird nicht gespeichert und kann nicht wieder abgerufen werden. Bitte speichern Sie ihn jetzt.",
"message": "Kopieren Sie diesen Token in Ihre PostgSail-Plugin-Instanz von Signalk."
},
"beam": "Breite",
Expand Down Expand Up @@ -423,11 +424,11 @@
},
"units": {
"distance": {
"miles": "NM",
"kilometres": "km"
"miles": "{n} NM",
"kilometres": "{n} km"
},
"speed": {
"knots": "kts"
"knots": "{n} kts"
},
"time": {
"days": "{n} Tage | {n} Tag | {n} Tage",
Expand Down
Loading