Feature: Wetter-Verbesserung im Tagebuch — Auto-Wetter, Chip-Fix, Detail-Fix (SW by-v695)

- diary.js: Weather-Chip in der Liste nutzt jetzt temp_c (korrekter Feldname)
- diary.js: Detail-View zeigt "emoji temp · X km/h Wind · Y% Regen" (precip_prob statt Luftfeuchtigkeit)
- diary.js: Bei neuem Eintrag ohne GPS → Wetter wird via GPS-API vorgeholt und als weather_json mitgesendet
- diary.py: DiaryCreate-Modell um weather_json-Feld erweitert; client-geliefertes Wetter wird gespeichert wenn kein GPS-basiertes Wetter verfügbar
- SW by-v695, APP_VER 695
This commit is contained in:
rene 2026-05-04 20:30:06 +02:00
parent 6152d6bf0e
commit b1d9fb4f54
4 changed files with 43 additions and 16 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '694'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '695'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VERSION = '1.3.0'; // ← semantische Version, wird bei make release gesetzt
const IS_STAGING = location.hostname === 'staging.banyaro.app';

View file

@ -868,9 +868,9 @@ window.Page_diary = (() => {
if (e.weather_json) {
try {
const w = typeof e.weather_json === 'string' ? JSON.parse(e.weather_json) : e.weather_json;
const temp = w?.temperature_2m ?? w?.temp_c;
const temp = w?.temp_c ?? w?.temperature_2m;
if (temp != null) {
metaParts.push(`<span>${_weatherEmoji(w.weather_code ?? w.weathercode, w.is_day)} ${Math.round(temp)}°</span>`);
metaParts.push(`<span class="diary-meta-weather">${_weatherEmoji(w.weathercode ?? w.weather_code, w.is_day)} ${Math.round(temp)}°</span>`);
}
} catch (_) {}
}
@ -1073,15 +1073,14 @@ window.Page_diary = (() => {
if (entry.weather_json) {
try {
const w = typeof entry.weather_json === 'string' ? JSON.parse(entry.weather_json) : entry.weather_json;
const temp = w?.temperature_2m ?? w?.temp_c;
const temp = w?.temp_c ?? w?.temperature_2m;
if (w && temp != null) {
const feels = w.apparent_temperature ?? w.feels_like_c;
const wind = w.wind_speed_10m ?? w.wind_kmh;
const wind = w.wind_kmh ?? w.wind_speed_10m;
const precip = w.precip_prob;
const parts = [
`${_weatherEmoji(w.weather_code ?? w.weathercode, w.is_day)} ${Math.round(temp)}°C`,
feels != null ? `gefühlt ${Math.round(feels)}°` : null,
wind != null ? `💨 ${Math.round(wind)} km/h` : null,
w.relative_humidity_2m != null ? `💧 ${w.relative_humidity_2m}%` : null,
`${_weatherEmoji(w.weathercode ?? w.weather_code, w.is_day)} ${Math.round(temp)}°C`,
wind != null ? `${Math.round(wind)} km/h Wind` : null,
precip != null ? `${precip}% Regen` : null,
].filter(Boolean).join(' · ');
metaItems.push(`<span class="diary-detail-meta-item">${parts}</span>`);
}
@ -1728,6 +1727,16 @@ window.Page_diary = (() => {
});
await UI.asyncButton(submitBtn, async () => {
// Auto-Wetter: nur bei neuem Eintrag ohne GPS-Standort
let _clientWeather = null;
if (!isEdit && _locLat == null) {
try {
const pos = await API.getLocation();
const wd = await API.weather.get(pos.lat, pos.lon);
if (wd && wd.temp_c != null) _clientWeather = JSON.stringify(wd);
} catch (_) { /* GPS oder Wetter nicht verfügbar → kein Problem */ }
}
const payload = {
datum: fd.datum || null,
typ: fd.typ,
@ -1739,6 +1748,7 @@ window.Page_diary = (() => {
gps_lon: _locLon,
location_name: _locName,
client_time: API.clientNow(),
weather_json: _clientWeather,
};
async function _uploadNewFiles(entryId) {

View file

@ -3,7 +3,7 @@
Offline-Cache + Push Notifications + Tile-Cache
============================================================ */
const CACHE_VERSION = 'by-v694';
const CACHE_VERSION = 'by-v695';
const CACHE_STATIC = `${CACHE_VERSION}-static`;
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache