feat: радиокнопки вместо select для режима/стенда (v1.2.32)

- index.html: radio buttons (🎭/☁️ для режима, DEV/TEST/PROD для стенда)
- main.py: set_mode сохраняет polygon_stand из cookie если не в форме
  (нужно при Облако→Эмуляция — радио стенда нет в DOM)
This commit is contained in:
2026-08-03 09:13:57 +04:00
parent 9a801e6bff
commit 4915d17555
3 changed files with 23 additions and 11 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода. # Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
# Нужна для фильтрации истории (пользователь видит только записи своей версии). # Нужна для фильтрации истории (пользователь видит только записи своей версии).
VERSION = "1.2.31" VERSION = "1.2.32"
# Flask-приложение с Jinja2-шаблонами из папки templates/ # Flask-приложение с Jinja2-шаблонами из папки templates/
app = Flask(__name__, template_folder="templates", static_folder="static") app = Flask(__name__, template_folder="templates", static_folder="static")
+3 -1
View File
@@ -107,7 +107,9 @@ def index():
# Обработка action=set_mode: сохранить режим и стенд в cookie # Обработка action=set_mode: сохранить режим и стенд в cookie
if action == "set_mode": if action == "set_mode":
new_mode = request.form.get("mode", "polygon") new_mode = request.form.get("mode", "polygon")
new_stand = request.form.get("polygon_stand", "test") # polygon_stand: из формы, иначе — сохранить предыдущее значение из cookie
# (нужно при переключении Облако→Эмуляция — радио стенда нет в DOM)
new_stand = request.form.get("polygon_stand") or request.cookies.get("polygon_stand", "test")
resp = make_response(redirect("/")) resp = make_response(redirect("/"))
resp.set_cookie("mode", new_mode, max_age=60*60*24*365, httponly=True, samesite="Strict", secure=True) resp.set_cookie("mode", new_mode, max_age=60*60*24*365, httponly=True, samesite="Strict", secure=True)
resp.set_cookie("polygon_stand", new_stand, max_age=60*60*24*365, httponly=True, samesite="Strict", secure=True) resp.set_cookie("polygon_stand", new_stand, max_age=60*60*24*365, httponly=True, samesite="Strict", secure=True)
+19 -9
View File
@@ -62,16 +62,26 @@
{% if polygon_enabled %} {% if polygon_enabled %}
<form method="post" style="padding:4px 12px 2px;"> <form method="post" style="padding:4px 12px 2px;">
<input type="hidden" name="action" value="set_mode" /> <input type="hidden" name="action" value="set_mode" />
<select name="mode" onchange="this.form.submit()" style="width:100%;height:26px;font-size:11px;padding:0 4px;border:1px solid var(--brand-gray);border-radius:3px;background:#fff;margin-bottom:3px;"> <div style="display:flex;gap:8px;margin-bottom:4px;">
<option value="polygon" {% if mode == 'polygon' %}selected{% endif %}>🎭 Эмуляция</option> <label style="font-size:10px;cursor:pointer;display:flex;align-items:center;gap:2px;color:var(--muted);">
<option value="cloud" {% if mode == 'cloud' %}selected{% endif %}>☁️ Облако</option> <input type="radio" name="mode" value="polygon" onclick="this.form.submit()" {% if mode == 'polygon' %}checked{% endif %} /> 🎭
</select> </label>
<label style="font-size:10px;cursor:pointer;display:flex;align-items:center;gap:2px;color:var(--muted);">
<input type="radio" name="mode" value="cloud" onclick="this.form.submit()" {% if mode == 'cloud' %}checked{% endif %} /> ☁️
</label>
</div>
{% if mode == 'polygon' %} {% if mode == 'polygon' %}
<select name="polygon_stand" onchange="this.form.submit()" style="width:100%;height:26px;font-size:11px;padding:0 4px;border:1px solid var(--brand-gray);border-radius:3px;background:#fff;"> <div style="display:flex;gap:6px;">
<option value="dev" {% if polygon_stand == 'dev' %}selected{% endif %}>DEV</option> <label style="font-size:10px;cursor:pointer;color:var(--muted);">
<option value="test" {% if polygon_stand == 'test' %}selected{% endif %}>TEST</option> <input type="radio" name="polygon_stand" value="dev" onclick="this.form.submit()" {% if polygon_stand == 'dev' %}checked{% endif %} /> DEV
<option value="prod" {% if polygon_stand == 'prod' %}selected{% endif %}>PROD</option> </label>
</select> <label style="font-size:10px;cursor:pointer;color:var(--muted);">
<input type="radio" name="polygon_stand" value="test" onclick="this.form.submit()" {% if polygon_stand == 'test' %}checked{% endif %} /> TEST
</label>
<label style="font-size:10px;cursor:pointer;color:var(--muted);">
<input type="radio" name="polygon_stand" value="prod" onclick="this.form.submit()" {% if polygon_stand == 'prod' %}checked{% endif %} /> PROD
</label>
</div>
{% endif %} {% endif %}
</form> </form>
{% endif %} {% endif %}