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:
+1
-1
@@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
|
||||
|
||||
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
||||
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
||||
VERSION = "1.2.31"
|
||||
VERSION = "1.2.32"
|
||||
|
||||
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||
|
||||
+3
-1
@@ -107,7 +107,9 @@ def index():
|
||||
# Обработка action=set_mode: сохранить режим и стенд в cookie
|
||||
if action == "set_mode":
|
||||
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.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)
|
||||
|
||||
@@ -62,16 +62,26 @@
|
||||
{% if polygon_enabled %}
|
||||
<form method="post" style="padding:4px 12px 2px;">
|
||||
<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;">
|
||||
<option value="polygon" {% if mode == 'polygon' %}selected{% endif %}>🎭 Эмуляция</option>
|
||||
<option value="cloud" {% if mode == 'cloud' %}selected{% endif %}>☁️ Облако</option>
|
||||
</select>
|
||||
<div style="display:flex;gap:8px;margin-bottom:4px;">
|
||||
<label style="font-size:10px;cursor:pointer;display:flex;align-items:center;gap:2px;color:var(--muted);">
|
||||
<input type="radio" name="mode" value="polygon" onclick="this.form.submit()" {% if mode == 'polygon' %}checked{% endif %} /> 🎭
|
||||
</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' %}
|
||||
<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;">
|
||||
<option value="dev" {% if polygon_stand == 'dev' %}selected{% endif %}>DEV</option>
|
||||
<option value="test" {% if polygon_stand == 'test' %}selected{% endif %}>TEST</option>
|
||||
<option value="prod" {% if polygon_stand == 'prod' %}selected{% endif %}>PROD</option>
|
||||
</select>
|
||||
<div style="display:flex;gap:6px;">
|
||||
<label style="font-size:10px;cursor:pointer;color:var(--muted);">
|
||||
<input type="radio" name="polygon_stand" value="dev" onclick="this.form.submit()" {% if polygon_stand == 'dev' %}checked{% endif %} /> DEV
|
||||
</label>
|
||||
<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 %}
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user