105 lines
2.5 KiB
HTML
105 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>{{ table_name }}</title>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- Top bar: table selector -->
|
|
<form method="get">
|
|
<label>
|
|
Table:
|
|
<select name="table" onchange="this.form.submit()">
|
|
{% for t in tables %}
|
|
<option value="{{ t }}" {% if t == &table_name %}selected{% endif %}>
|
|
{{ t }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</label>
|
|
|
|
<!-- Preserve current view when switching tables -->
|
|
<input type="hidden" name="view" value="{{ view }}">
|
|
</form>
|
|
|
|
<br>
|
|
|
|
<!-- Tabs -->
|
|
<p>
|
|
<a href="/?table={{ table_name }}&view=data">
|
|
{% if view == "data" %}<b>Data</b>{% else %}Data{% endif %}
|
|
</a>
|
|
|
|
|
<a href="/?table={{ table_name }}&view=structure">
|
|
{% if view == "structure" %}<b>Structure</b>{% else %}Structure{% endif %}
|
|
</a>
|
|
</p>
|
|
|
|
<!-- DATA VIEW -->
|
|
{% if view == "data" %}
|
|
|
|
<table border="1" cellspacing="0" cellpadding="4">
|
|
<thead>
|
|
<tr>
|
|
{% for col in columns %}
|
|
<th>{{ col }}</th>
|
|
{% endfor %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for row in rows %}
|
|
<tr>
|
|
{% for cell in row %}
|
|
<td>{{ cell }}</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- STRUCTURE VIEW -->
|
|
{% elif view == "structure" %}
|
|
|
|
<h2>Table: {{ table_name }}</h2>
|
|
|
|
{% if let Some(count) = row_count %}
|
|
<p><b>Rows:</b> {{ count }}</p>
|
|
{% endif %}
|
|
|
|
<!-- Columns -->
|
|
{% if let Some(cols) = columns_info %}
|
|
<details>
|
|
<summary><b>Columns</b></summary>
|
|
|
|
<table border="1" cellspacing="0" cellpadding="4">
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Type</th>
|
|
<th>PK</th>
|
|
</tr>
|
|
{% for c in cols %}
|
|
<tr>
|
|
<td>{{ c.0 }}</td>
|
|
<td>{{ c.1 }}</td>
|
|
<td>{% if c.2 %}✓{% endif %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
</details>
|
|
{% endif %}
|
|
|
|
<br>
|
|
|
|
<!-- Schema -->
|
|
{% if let Some(s) = schema %}
|
|
<details>
|
|
<summary><b>Schema</b></summary>
|
|
<pre>{{ s }}</pre>
|
|
</details>
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</body>
|
|
</html> |