zakladka ustawien
This commit is contained in:
17
app.py
17
app.py
@@ -4115,33 +4115,28 @@ def admin_settings():
|
||||
categories = Category.query.order_by(Category.name.asc()).all()
|
||||
|
||||
if request.method == "POST":
|
||||
# OCR
|
||||
ocr_raw = (request.form.get("ocr_keywords") or "").strip()
|
||||
set_setting("ocr_keywords", ocr_raw)
|
||||
|
||||
# OCR sensitivity
|
||||
ocr_sens = (request.form.get("ocr_sensitivity") or "").strip()
|
||||
set_setting("ocr_sensitivity", ocr_sens)
|
||||
|
||||
# Bezpieczeństwo – limit błędnych prób (system_auth)
|
||||
max_attempts = (request.form.get("max_login_attempts") or "").strip()
|
||||
set_setting("max_login_attempts", max_attempts)
|
||||
|
||||
# (opcjonalnie) okno blokady
|
||||
login_window = (request.form.get("login_window_seconds") or "").strip()
|
||||
if login_window: # pole możesz ukryć w UI – zostawiam jako opcję
|
||||
if login_window:
|
||||
set_setting("login_window_seconds", login_window)
|
||||
|
||||
# Kolory kategorii
|
||||
for c in categories:
|
||||
field = f"color_{c.id}"
|
||||
val = (request.form.get(field) or "").strip()
|
||||
vals = request.form.getlist(field)
|
||||
val = (vals[-1] if vals else "").strip()
|
||||
|
||||
existing = CategoryColorOverride.query.filter_by(category_id=c.id).first()
|
||||
if val and re.fullmatch(r"^#[0-9A-Fa-f]{6}$", val):
|
||||
if not existing:
|
||||
db.session.add(
|
||||
CategoryColorOverride(category_id=c.id, color_hex=val)
|
||||
)
|
||||
db.session.add(CategoryColorOverride(category_id=c.id, color_hex=val))
|
||||
else:
|
||||
existing.color_hex = val
|
||||
else:
|
||||
@@ -4152,7 +4147,6 @@ def admin_settings():
|
||||
flash("Zapisano ustawienia.", "success")
|
||||
return redirect(url_for("admin_settings"))
|
||||
|
||||
# --- GET ---
|
||||
override_rows = CategoryColorOverride.query.filter(
|
||||
CategoryColorOverride.category_id.in_([c.id for c in categories])
|
||||
).all()
|
||||
@@ -4164,7 +4158,6 @@ def admin_settings():
|
||||
|
||||
current_ocr = get_setting("ocr_keywords", "")
|
||||
|
||||
# nowe pola do szablonu
|
||||
ocr_sensitivity = get_int_setting("ocr_sensitivity", 5)
|
||||
max_login_attempts = get_int_setting("max_login_attempts", 10)
|
||||
login_window_seconds = get_int_setting("login_window_seconds", 3600)
|
||||
|
@@ -31,10 +31,16 @@
|
||||
if (barEff) barEff.style.backgroundColor = effHex;
|
||||
if (hexEffEl) hexEffEl.textContent = effHex;
|
||||
|
||||
if (!raw) ensureHiddenClear(input); else removeHiddenClear(input);
|
||||
if (!raw) {
|
||||
ensureHiddenClear(input);
|
||||
input.disabled = true;
|
||||
} else {
|
||||
removeHiddenClear(input);
|
||||
input.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
form.querySelectorAll(".reset-one").forEach(btn => {
|
||||
form.querySelectorAll(".use-default").forEach(btn => {
|
||||
btn.addEventListener("click", () => {
|
||||
const name = btn.getAttribute("data-target");
|
||||
const input = form.querySelector(`input[name="${name}"]`);
|
||||
@@ -43,6 +49,7 @@
|
||||
updatePreview(input);
|
||||
});
|
||||
});
|
||||
|
||||
resetAllBtn?.addEventListener("click", () => {
|
||||
form.querySelectorAll('input[type="color"].category-color').forEach(input => {
|
||||
input.value = "";
|
||||
|
@@ -78,6 +78,11 @@
|
||||
<button type="button" class="btn btn-outline-light btn-sm reset-one" data-target="color_{{ c.id }}">
|
||||
🔄 Reset
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-outline-light btn-sm use-default ms-2"
|
||||
data-target="color_{{ c.id }}">
|
||||
🎯 Przywróć domyślny
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="color-indicators mt-2">
|
||||
|
Reference in New Issue
Block a user