This commit is contained in:
@@ -2069,32 +2069,6 @@ def tablets_speichern(tablet_id):
|
||||
name = (request.form.get("name") or "").strip()[:60]
|
||||
ziel_typ = request.form.get("ziel_typ") or ""
|
||||
maschine_id = request.form.get("maschine_id", type=int)
|
||||
ersetzt_id = request.form.get("ersetzt_id", type=int)
|
||||
|
||||
if ersetzt_id and ersetzt_id != tablet_id:
|
||||
# Neues Gerät (z.B. nach gelöschten Browserdaten) übernimmt Name und
|
||||
# Zuordnung eines alten Eintrags; der alte Eintrag wird entfernt.
|
||||
with db.get_cursor() as cur:
|
||||
cur.execute('SELECT * FROM "Tablets" WHERE id = %s', (ersetzt_id,))
|
||||
alt = cur.fetchone()
|
||||
cur.execute('SELECT * FROM "Tablets" WHERE id = %s', (tablet_id,))
|
||||
neu = cur.fetchone()
|
||||
if not alt or not neu:
|
||||
abort(404)
|
||||
cur.execute(
|
||||
'UPDATE "Tablets" SET name = %s, ziel_typ = %s, maschine_id = %s WHERE id = %s RETURNING *',
|
||||
(alt["name"], alt["ziel_typ"], alt["maschine_id"], tablet_id),
|
||||
)
|
||||
neu = cur.fetchone()
|
||||
ziel = _ziel_text(cur, alt["ziel_typ"], alt["maschine_id"])
|
||||
tablet_log(
|
||||
cur, "Eintrag ersetzt",
|
||||
f"Übernimmt Name \"{alt['name']}\" und Zuordnung ({ziel}) von Tablet {_tablet_kurzkennung(alt['kennung'])}",
|
||||
neu,
|
||||
)
|
||||
tablet_log(cur, "Entfernt", f"Ersetzt durch Tablet {_tablet_kurzkennung(neu['kennung'])} (\"{neu['name']}\")", alt)
|
||||
cur.execute('DELETE FROM "Tablets" WHERE id = %s', (ersetzt_id,))
|
||||
return _zur_tablet_zeile(tablet_id)
|
||||
|
||||
if ziel_typ and ziel_typ not in TABLET_ZIELE:
|
||||
return _tablets_seite(error="Ungültiges Ziel.", fehler_id=tablet_id), 400
|
||||
|
||||
@@ -575,9 +575,13 @@ table.data-table td.col-actions { white-space: nowrap; }
|
||||
.tablet-legend { display: inline-block; width: 5px; height: 1em; background: var(--amber); vertical-align: middle; margin-right: 4px; }
|
||||
#lernmodus, #tablet-liste { scroll-margin-top: 16px; }
|
||||
.dash-body .tablet-id-badge { color: #ffffff; background: var(--d-panel); border-color: var(--d-border); opacity: 1; }
|
||||
.learn-form { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
|
||||
.learn-form .big-btn { width: auto; min-width: 240px; }
|
||||
.card.learn-on { border-color: var(--amber); }
|
||||
.learn-bar { margin: 10px 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); font-size: 0.92em; }
|
||||
.learn-bar.learn-on { border-color: var(--amber); }
|
||||
.learn-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
|
||||
.learn-form .icon-btn { padding: 4px 12px; }
|
||||
.learn-help[open] { flex-basis: 100%; }
|
||||
.learn-help summary { cursor: pointer; color: var(--text-dim); }
|
||||
.learn-help p { margin: 6px 0 2px; }
|
||||
|
||||
/* Import: auffälliger gelber Hinweis, wenn etwas nicht automatisch geht */
|
||||
.attention-banner {
|
||||
|
||||
@@ -14,19 +14,21 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="card {{ 'learn-on' if lernmodus else '' }}" id="lernmodus">
|
||||
<div class="learn-bar {{ 'learn-on' if lernmodus else '' }}" id="lernmodus">
|
||||
<form method="post" action="{{ url_for('tablets_lernmodus') }}" class="learn-form">
|
||||
<div>
|
||||
<strong>Lernmodus: {{ 'AN' if lernmodus else 'AUS' }}</strong><br>
|
||||
<span class="hint">
|
||||
Solange er an ist, werden Geräte, die noch über einen einzelnen Link (<code>/m<N></code> oder
|
||||
<code>/m<N>_show</code>) kommen, automatisch gespeichert und genau dieser Seite zugeordnet.
|
||||
Beim nächsten Besuch über <code>/tablet</code> werden sie erkannt. Nach der Umstellung bitte ausschalten,
|
||||
sonst wird auch z. B. ein PC registriert, der eine Maschinenseite öffnet.
|
||||
</span>
|
||||
</div>
|
||||
<span class="learn-state">Lernmodus: <strong>{{ 'AN' if lernmodus else 'AUS' }}</strong></span>
|
||||
<input type="hidden" name="an" value="{{ '0' if lernmodus else '1' }}">
|
||||
<button type="submit" class="big-btn small {{ 'neutral' if lernmodus else 'primary' }}">{{ 'Lernmodus ausschalten' if lernmodus else 'Lernmodus einschalten' }}</button>
|
||||
<button type="submit" class="icon-btn">{{ 'Ausschalten' if lernmodus else 'Einschalten' }}</button>
|
||||
<details class="learn-help">
|
||||
<summary>Was ist das?</summary>
|
||||
<p class="hint">
|
||||
Solange der Lernmodus an ist, werden Geräte, die noch über einen einzelnen Link (<code>/m<N></code> oder
|
||||
<code>/m<N>_show</code>) kommen, automatisch gespeichert und genau dieser Seite zugeordnet.
|
||||
Beim nächsten Besuch über <code>/tablet</code> werden sie erkannt. Nach der Umstellung ausschalten,
|
||||
sonst wird auch z. B. ein PC registriert, der eine Maschinenseite öffnet.
|
||||
Neue Tablets ohne Lernen werden von Hand zugeordnet.
|
||||
</p>
|
||||
</details>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -63,14 +65,6 @@
|
||||
<option value="{{ m.id }}" {% if t.maschine_id == m.id %}selected{% endif %}>{{ m.name or ('Maschine ' ~ m.id) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if not t.ziel_typ and tablets|length > 1 %}
|
||||
<select name="ersetzt_id" aria-label="Zuordnung übernehmen von" title="Ersetzt dieses Tablet ein altes (z. B. nach gelöschten Browserdaten)? Dann dessen Zuordnung übernehmen.">
|
||||
<option value="">Ersetzt Tablet … (optional)</option>
|
||||
{% for o in tablets if o.id != t.id and not o.online %}
|
||||
<option value="{{ o.id }}">{{ o.name }} ({{ o.kurz }})</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% if fehler_id == t.id and zeilenfehler %}<div class="tablet-row-error">{{ zeilenfehler }}</div>{% endif %}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user