Files
battery-tracker-app/templates/device_list.html
T
iterminate 6ea3eae981 Initial commit: Flask battery tracker app
- Flask + SQLAlchemy (MariaDB-compatible schema) battery tracking web app
- 40 pre-seeded batteries (Eneloop, BONAI, Energizer NiMH) across 5 devices
- Business rules: block retired assignment, brand-mix warnings, capacity checks
- Mobile-friendly Jinja2 templates with inline CSS
- waitress WSGI server via systemd user service (sbin/install-service.sh)
- SQLite → MariaDB migration script (migrate_to_mariadb.py)
- 26 passing acceptance tests (pytest + Flask test client)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 22:38:16 -05:00

59 lines
2.0 KiB
HTML

{% extends "base.html" %}
{% block title %}Devices — Battery Tracker{% endblock %}
{% block content %}
<h1>Devices</h1>
<div class="card">
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Name</th>
<th>Slots</th>
<th>Installed</th>
<th>Brands</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for d in devices %}
<tr>
<td><a href="{{ url_for('device_detail', device_id=d.id) }}"><strong>{{ d.name }}</strong></a></td>
<td>{{ d.battery_slots }}</td>
<td>
{{ d.installed_count() }} / {{ d.battery_slots }}
{% if d.installed_count() >= d.battery_slots %}
<span class="badge badge-retired">Full</span>
{% endif %}
</td>
<td>
{% set brands = d.installed_brands() %}
{% if brands %}
{{ brands|join(', ') }}
{% if d.has_mixed_brands() %}
<span class="badge badge-warning">⚠ mixed</span>
{% endif %}
{% else %}
<span class="text-muted"></span>
{% endif %}
</td>
<td style="white-space:nowrap;">
<a class="btn btn-sm btn-secondary" href="{{ url_for('device_detail', device_id=d.id) }}">View</a>
<form class="inline" method="post" action="{{ url_for('device_delete', device_id=d.id) }}"
onsubmit="return confirm('Delete {{ d.name }}? All installed batteries will be unassigned.');">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="5" class="text-muted" style="text-align:center;padding:1rem;">No devices yet. <a href="{{ url_for('device_add') }}">Add one.</a></td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<a class="btn btn-primary" href="{{ url_for('device_add') }}">+ Add Device</a>
{% endblock %}