Three features: device dropdown filter, charge log history, unassign-all

- Device dropdowns (quick-assign, bulk install, assign page) now only show
  devices with free slots; full devices are excluded entirely
- New ChargeLog model tracks charge dates with optional cycle increment;
  battery detail page gets a Charge History card with add/delete rows
- Device list page gets per-device Unassign All button (with confirmation)
  via new POST /device/<id>/unassign-all route
This commit is contained in:
2026-04-13 08:12:23 -05:00
parent 6597fcd4ac
commit b1bc02e963
6 changed files with 167 additions and 25 deletions
+60
View File
@@ -148,6 +148,66 @@
</form>
</div>
<!-- Charge History -->
<div class="card">
<h2>Charge History</h2>
{% if charge_logs %}
<div class="table-wrap">
<table class="responsive-table">
<thead>
<tr>
<th>Date</th>
<th>+Cycle</th>
<th>Notes</th>
<th></th>
</tr>
</thead>
<tbody>
{% for log in charge_logs %}
<tr>
<td data-label="Date">{{ log.charged_date }}</td>
<td data-label="+Cycle">{{ '✓' if log.increment_cycles else '—' }}</td>
<td data-label="Notes" class="text-muted">{{ log.notes or '—' }}</td>
<td data-label="">
<form class="inline" method="post"
action="{{ url_for('battery_charge_log_delete', battery_id=battery.id, log_id=log.id) }}"
onsubmit="return confirm('Delete this charge log entry?')">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="text-muted" style="margin-bottom:0.75rem;">No charge log entries yet.</p>
{% endif %}
<h3 style="font-size:1rem;margin:1rem 0 0.5rem;color:var(--text-h2);">Add Charge Entry</h3>
<form method="post" action="{{ url_for('battery_charge_log_add', battery_id=battery.id) }}"
style="display:flex;gap:0.5rem;flex-wrap:wrap;align-items:flex-end;">
<div class="form-group" style="margin:0;flex:1;min-width:140px;">
<label>Date</label>
<input type="date" name="charged_date" required>
</div>
<div class="form-group" style="margin:0;align-self:flex-end;padding-bottom:1rem;">
<label style="display:flex;align-items:center;gap:0.4rem;font-weight:normal;cursor:pointer;">
<input type="checkbox" name="increment_cycles" value="1" checked>
Increment charge cycles
</label>
</div>
<div class="form-group" style="margin:0;flex:2;min-width:160px;">
<label>Notes (optional)</label>
<input type="text" name="notes" placeholder="e.g. trickle charge overnight">
</div>
<div style="padding-bottom:1rem;">
<button class="btn btn-primary" type="submit">Add</button>
</div>
</form>
</div>
<!-- Edit Details -->
<div class="card">
<h2>Edit Details</h2>