Add Database Status section to admin panel

- Added table_counts query in /admin route to get record counts for all tables
  * Reference tables (TrnsType, TrnsLkup, Footers, FileStat, Employee, etc.)
  * Core data tables (Rolodex, LegacyPhone, LegacyFile, Ledger, etc.)
  * Specialized tables (PlanInfo, Qdros, Pensions, etc.)
  * Modern models (Client, Phone, Case, Transaction, Payment, Document)

- Created Database Status UI section in admin.html
  * Four-column layout showing all table categories
  * Color-coded badges (green=has data, gray=empty)
  * Check mark icons for populated tables
  * Table row highlighting based on data presence
  * Legend explaining the visual indicators

- Helps users track import progress at a glance
- Shows which tables have been successfully imported
- Distinguishes between legacy and modern model data
This commit is contained in:
HotSwapp
2025-10-08 12:59:35 -05:00
parent 2e7e9693c5
commit fa4e0b9f62
2 changed files with 214 additions and 0 deletions

View File

@@ -137,6 +137,162 @@
</div>
{% endif %}
<!-- Database Status -->
{% if table_counts %}
<div class="card mb-4">
<div class="card-header bg-secondary text-white">
<h5 class="mb-0">
<i class="bi bi-database me-2"></i>Database Status - Imported Data
</h5>
</div>
<div class="card-body">
<p class="mb-3">View record counts for all tables to track import progress:</p>
<div class="row">
<!-- Reference Tables -->
<div class="col-md-3 mb-3">
<h6 class="text-primary"><i class="bi bi-bookmark me-2"></i>Reference Tables</h6>
<div class="table-responsive">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Table</th>
<th class="text-end">Records</th>
</tr>
</thead>
<tbody>
{% for table_name, count in table_counts.reference.items() %}
<tr class="{{ 'table-success' if count > 0 else 'table-light' }}">
<td>
<small>{{ table_name }}</small>
{% if count > 0 %}
<i class="bi bi-check-circle-fill text-success ms-1"></i>
{% endif %}
</td>
<td class="text-end">
<span class="badge {{ 'bg-success' if count > 0 else 'bg-secondary' }}">
{{ "{:,}".format(count) }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<!-- Core Data Tables -->
<div class="col-md-3 mb-3">
<h6 class="text-success"><i class="bi bi-folder me-2"></i>Core Data Tables</h6>
<div class="table-responsive">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Table</th>
<th class="text-end">Records</th>
</tr>
</thead>
<tbody>
{% for table_name, count in table_counts.core.items() %}
<tr class="{{ 'table-success' if count > 0 else 'table-light' }}">
<td>
<small>{{ table_name }}</small>
{% if count > 0 %}
<i class="bi bi-check-circle-fill text-success ms-1"></i>
{% endif %}
</td>
<td class="text-end">
<span class="badge {{ 'bg-success' if count > 0 else 'bg-secondary' }}">
{{ "{:,}".format(count) }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<!-- Specialized Tables -->
<div class="col-md-3 mb-3">
<h6 class="text-info"><i class="bi bi-file-earmark-medical me-2"></i>Specialized Tables</h6>
<div class="table-responsive">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Table</th>
<th class="text-end">Records</th>
</tr>
</thead>
<tbody>
{% for table_name, count in table_counts.specialized.items() %}
<tr class="{{ 'table-success' if count > 0 else 'table-light' }}">
<td>
<small>{{ table_name }}</small>
{% if count > 0 %}
<i class="bi bi-check-circle-fill text-success ms-1"></i>
{% endif %}
</td>
<td class="text-end">
<span class="badge {{ 'bg-success' if count > 0 else 'bg-secondary' }}">
{{ "{:,}".format(count) }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<!-- Modern Models -->
<div class="col-md-3 mb-3">
<h6 class="text-warning"><i class="bi bi-stars me-2"></i>Modern Models</h6>
<div class="table-responsive">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Table</th>
<th class="text-end">Records</th>
</tr>
</thead>
<tbody>
{% for table_name, count in table_counts.modern.items() %}
<tr class="{{ 'table-warning' if count > 0 else 'table-light' }}">
<td>
<small>{{ table_name }}</small>
{% if count > 0 %}
<i class="bi bi-check-circle-fill text-warning ms-1"></i>
{% endif %}
</td>
<td class="text-end">
<span class="badge {{ 'bg-warning text-dark' if count > 0 else 'bg-secondary' }}">
{{ "{:,}".format(count) }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<div class="alert alert-info mb-0">
<i class="bi bi-info-circle me-2"></i>
<strong>Legend:</strong>
<span class="badge bg-success ms-2">Green</span> = Has data imported |
<span class="badge bg-secondary ms-2">Gray</span> = No data yet |
<i class="bi bi-check-circle-fill text-success ms-3 me-1"></i> = Table populated
</div>
</div>
</div>
</div>
</div>
{% endif %}
<!-- Import Order Guide -->
<div class="card mb-4">
<div class="card-header bg-info text-white">