feat(5.20): US-011 statusbar indicator mediu + toggle conditionat
Statusbar afiseaza mediul RAR default al contului logat (Testare galben / Productie verde, distinct vizual). La >=2 medii disponibile apare butonul Comuta (HTMX POST /_fragments/status/toggle-env, account-scoped, verify_csrf) care alterneaza rar_env_default intre mediile disponibile fara reload; la 1 mediu doar eticheta statica; la 0 medii indicatorul nu apare. _build_status_ctx capata env_default + medii_disponibile + csrf_token (via rar_env_efectiv_cont / medii_disponibile_cont). Retrage badge-env global din header (base.html) pentru utilizatorul logat (F11) — mediul per-cont traieste acum in statusbar; badge-ul global ramane doar pentru vizitatorul nelogat. tests/test_statusbar_env.py: afiseaza env default, toggle doar la 2 medii, toggle schimba default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,43 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# === US-011 (5.20): Indicator mediu RAR activ per cont.
|
||||
La 0 medii: nu afisa (cont fara configuratie RAR).
|
||||
La 1 mediu: eticheta statica (fara toggle).
|
||||
La 2 medii: buton de comutare HTMX (toggle conditionat).
|
||||
#}
|
||||
{% set _medii = medii_disponibile | default([]) %}
|
||||
{% set _env = env_default | default('prod') %}
|
||||
{% set _env_label = "Testare" if _env == "test" else "Productie" %}
|
||||
{% if _medii | length >= 1 %}
|
||||
<div class="env-indicator"
|
||||
style="display:flex; align-items:center; gap:8px; margin-bottom:10px;
|
||||
padding:6px 10px; border-radius:6px; font-size:var(--fs-sm);
|
||||
background:color-mix(in srgb, {% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %} 12%, var(--card));
|
||||
border:1px solid color-mix(in srgb, {% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %} 30%, transparent);">
|
||||
<span style="font-weight:600; color:{% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %};">
|
||||
Mediu RAR: {{ _env_label }}
|
||||
</span>
|
||||
{% if _medii | length >= 2 %}
|
||||
{# Toggle: apare DOAR cand sunt cel putin 2 medii disponibile #}
|
||||
<form method="post" action="/_fragments/status/toggle-env"
|
||||
hx-post="/_fragments/status/toggle-env"
|
||||
hx-target="#status-bar"
|
||||
hx-swap="outerHTML"
|
||||
style="margin:0; padding:0; display:inline;">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token | default('') }}">
|
||||
<button type="submit"
|
||||
style="padding:2px 10px; font-size:var(--fs-xs); border-radius:99px;
|
||||
border:1px solid currentColor; background:transparent; cursor:pointer;
|
||||
color:var(--muted); line-height:1.4;"
|
||||
title="Comuta la {{ 'Productie' if _env == 'test' else 'Testare' }}">
|
||||
Comuta
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# === Navigatie rapida: Trimiteri + Mapari cu badge needs_mapping ===
|
||||
Pastrata exact ca inainte (US-005): tab_activ determina marcajul activ.
|
||||
#}
|
||||
|
||||
@@ -834,7 +834,7 @@
|
||||
Titlul linkeaza la / (Trimiteri) ca si logo-ul. #}
|
||||
<div class="header-center">
|
||||
<a href="/" style="text-decoration:none; color:inherit;">
|
||||
<h1>ROA AUTOPASS<span class="badge-env">{{ rar_env }}</span>{% if is_authenticated|default(false) and tier_label|default('') %}<span class="badge-tier">{{ tier_label }}</span>{% endif %}</h1>
|
||||
<h1>ROA AUTOPASS{% if not is_authenticated|default(false) %}<span class="badge-env">{{ rar_env }}</span>{% endif %}{% if is_authenticated|default(false) and tier_label|default('') %}<span class="badge-tier">{{ tier_label }}</span>{% endif %}</h1>
|
||||
</a>
|
||||
{% if is_authenticated|default(false) and account_name|default('') %}
|
||||
<div class="h-sub">Service auto: <span class="svc">{{ account_name }}</span></div>
|
||||
|
||||
Reference in New Issue
Block a user