diff --git a/app/main.py b/app/main.py index 9011a8d..5f25623 100644 --- a/app/main.py +++ b/app/main.py @@ -278,9 +278,20 @@ def prometheus_metrics() -> Response: return metrics_response() +class _NoCacheStatic(StaticFiles): + """Dashboard SPA: no-cache header — deploy/değişiklik sonrası tarayıcı ESKİ asset + sunmaz (ETag korunur → değişmeyen dosyada 304 hızlı, ama her zaman revalidate). + Önceki davranış: ETag var ama Cache-Control yok → tarayıcı heuristik cache'liyor.""" + + async def get_response(self, path, scope): + resp = await super().get_response(path, scope) + resp.headers["Cache-Control"] = "no-cache, must-revalidate" + return resp + + _dashboard_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "frontend") if os.path.isdir(_dashboard_dir): - app.mount("/dashboard", StaticFiles(directory=_dashboard_dir, html=True), name="dashboard") + app.mount("/dashboard", _NoCacheStatic(directory=_dashboard_dir, html=True), name="dashboard") # Bitki sağlığı görsel upload'ları (plants.py içinde URL üretiliyor) _plant_uploads_dir = os.path.join(os.path.dirname(__file__), "ml", "plant_uploads") diff --git a/frontend/index.html b/frontend/index.html index 62d5f3e..a7389bd 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -873,7 +873,7 @@

Dashboard

- + @@ -884,7 +884,7 @@

Dashboard

- + diff --git a/frontend/src/lib/pages/account.js b/frontend/src/lib/pages/account.js index 2736a4f..dfc6d22 100644 --- a/frontend/src/lib/pages/account.js +++ b/frontend/src/lib/pages/account.js @@ -9,7 +9,7 @@ import { _fmtDate, _escAttr, showToast } from "../utils.js"; import { getAuthToken, setAuthToken, clearAuthToken, apiAuth, API_BASE } from "../api.js"; import { _skeletonBlock, _setBusy } from "../skeleton.js"; -import { setCurrentUser } from "../session.js"; +import { setCurrentUser, getCurrentUser } from "../session.js"; import { navigate } from "../nav.js"; import { refreshBell, _hideBell } from "./alerts.js"; @@ -317,11 +317,13 @@ export async function loadUsers() { .map(r => ``).join(''); let html = '' + ''; + const me = getCurrentUser(); for (const u of list) { + const isSelf = me && u.id === me.id; html += ` - +
Kullanıcı listesi
AdE-postaRolÇiftlikKayıtİşlem
${_escAttr(u.name)} ${_escAttr(u.email)} ${u.owned_farms_count ?? 0} ${_fmtDate(u.created_at)}