Files
battery-tracker-app/templates/base.html
T
iterminate 3bc897c1e5 Add device_type field, mobile-friendly improvements, and device filtering
- Device model: add device_type column (String 50, nullable)
- Device add/edit: type select with presets + custom entry
- Device detail: show type in info card; new Edit Device form
- Device list: Type column + client-side filter bar (type + text search)
- Mobile: card-style responsive tables on dashboard and device list,
  form-grid-2col collapse, larger tap targets, stacked form-actions,
  column picker viewport fix, filter bar full-width controls
- Assign page: larger radio touch targets (min-height 44px)
- 3 new acceptance tests for device_type (45 total)
2026-04-12 22:02:29 -05:00

188 lines
7.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Battery Tracker{% endblock %}</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; font-size: 15px; background: #f5f5f5; color: #222; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
/* Nav */
nav {
background: #1e40af;
color: #fff;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
padding: 0.75rem 1rem;
}
nav .brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; color: #fff; }
nav a { color: #bfdbfe; font-size: 0.9rem; padding: 0.25rem 0.5rem; border-radius: 4px; }
nav a:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
/* Layout */
.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }
/* Flash messages */
.flash { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash.warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
/* Cards / boxes */
.card { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 1.25rem; margin-bottom: 1rem; }
/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.5rem 0.75rem; background: #f1f5f9; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; border-bottom: 2px solid #e2e8f0; }
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
/* Status badges */
.badge { display: inline-block; padding: 0.2em 0.55em; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-available { background: #dcfce7; color: #166534; }
.badge-installed { background: #dbeafe; color: #1e40af; }
.badge-retired { background: #f1f5f9; color: #64748b; }
.badge-warning { background: #fef9c3; color: #854d0e; }
/* Buttons */
.btn { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 4px; border: none; cursor: pointer; font-size: 0.875rem; font-family: inherit; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.3rem; color: #374151; }
input[type=text], input[type=number], select, textarea {
width: 100%; padding: 0.45rem 0.65rem; border: 1px solid #d1d5db;
border-radius: 4px; font-size: 0.9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }
textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 1.25rem; }
/* Headings */
h1 { font-size: 1.5rem; margin-bottom: 1rem; color: #1e293b; }
h2 { font-size: 1.15rem; margin-bottom: 0.75rem; color: #334155; }
/* Inline form (for POST buttons in tables) */
form.inline { display: inline; }
/* Warning text */
.text-warning { color: #b45309; font-size: 0.8rem; }
.text-danger { color: #dc2626; }
.text-muted { color: #6b7280; font-size: 0.85rem; }
/* ─── Mobile responsive ─────────────────────────────────── */
@media (max-width: 640px) {
/* Tap targets */
.btn { padding: 0.5rem 0.9rem; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.825rem; }
/* Collapse 2-col form grids */
.form-grid-2col { grid-template-columns: 1fr !important; }
/* Card-style table rows */
.responsive-table thead { display: none; }
.responsive-table tr {
display: block;
border: 1px solid #e2e8f0;
border-radius: 6px;
margin-bottom: 0.75rem;
padding: 0.25rem 0;
background: #fff;
}
.responsive-table tr:hover td { background: transparent; }
.responsive-table td {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.4rem 0.75rem;
border-bottom: 1px solid #f1f5f9;
border-top: none;
font-size: 0.875rem;
}
.responsive-table td:last-child { border-bottom: none; }
.responsive-table td:empty { display: none; }
.responsive-table td::before {
content: attr(data-label);
font-weight: 600;
color: #64748b;
font-size: 0.8rem;
flex-shrink: 0;
margin-right: 0.75rem;
white-space: nowrap;
}
/* Checkbox column: no label prefix, left-aligned */
.responsive-table td[data-label=""] {
justify-content: flex-start;
border-bottom: none;
padding-bottom: 0;
}
/* Actions column: allow wrapping, override nowrap */
.responsive-table td[data-label="Actions"] {
flex-wrap: wrap;
gap: 0.35rem;
white-space: normal !important;
}
.responsive-table td[data-label="Actions"] select {
width: 100%;
max-width: 100% !important;
}
/* Filter bar: full-width controls with larger tap targets */
#filter-bar select,
#filter-bar input[type=text] { flex: 1 1 100%; width: 100% !important; padding: 0.5rem 0.65rem !important; font-size: 0.9rem !important; }
/* Bulk toolbar: prevent text inputs overflowing */
#bulk-toolbar input[type=text] { width: 100% !important; }
/* Install grid on device_detail */
#install-grid { grid-template-columns: 1fr !important; max-width: 100% !important; }
/* Column picker: keep panel inside viewport */
#col-picker-panel { left: 0; right: auto !important; max-width: calc(100vw - 2rem); }
/* form-actions: stack buttons full-width */
.form-actions { flex-direction: column; align-items: stretch; }
.form-actions .btn,
.form-actions button { width: 100%; text-align: center; }
}
</style>
</head>
<body>
<nav>
<span class="brand">Battery Tracker</span>
<a href="{{ url_for('dashboard') }}">Dashboard</a>
<a href="{{ url_for('device_list') }}">Devices</a>
<a href="{{ url_for('battery_add') }}">+ Battery</a>
<a href="{{ url_for('device_add') }}">+ Device</a>
</nav>
<div class="container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
<div class="flash {{ category }}">{{ message }}</div>
{% endfor %}
{% endwith %}
{% block content %}{% endblock %}
</div>
</body>
</html>