portal: consolidate list templates

This commit is contained in:
Iain Learmonth 2022-05-04 13:01:46 +01:00
parent 473152fe19
commit a1aa252bc0
9 changed files with 90 additions and 75 deletions

View file

@ -1,8 +0,0 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import bridgeconfs_table %}
{% block content %}
<h1 class="h2 mt-3">Tor Bridge Configurations</h1>
<a href="{{ url_for("portal.new_bridgeconf") }}" class="btn btn-success">Create new configuration</a>
{{ bridgeconfs_table(bridgeconfs) }}
{% endblock %}

View file

@ -1,7 +0,0 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import bridges_table %}
{% block content %}
<h1 class="h2 mt-3">Tor Bridges</h1>
{{ bridges_table(bridges) }}
{% endblock %}

View file

@ -1,30 +0,0 @@
{% extends "base.html.j2" %}
{% block content %}
<h1 class="h2 mt-3">Groups</h1>
<a href="{{ url_for("portal.new_group") }}" class="btn btn-success">Create new group</a>
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">EOTK</th>
<th scope="col">Sites</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td>{{ group.group_name }}</td>
<td>{{ group.description }}</td>
<td>{% if group.eotk %}✅{% else %}❌{% endif %}</td>
<td>{{ group.origins | length }}</td>
<td><a href="{{ url_for("portal.edit_group", group_id=group.id) }}" class="btn btn-primary btn-sm">View/Edit</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View file

@ -0,0 +1,25 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import bridgeconfs_table, bridges_table,
groups_table, mirrorlists_table, origins_table, proxies_table %}
{% block content %}
<h1 class="h2 mt-3">{{ title }}</h1>
{% if new_link %}
<a href="{{ new_link }}" class="btn btn-success">Create new {{ item }}</a>
{% endif %}
{% if item == "bridge configuration" %}
{{ bridgeconfs_table(items) }}
{% elif item == "bridge" %}
{{ bridges_table(items) }}
{% elif item == "eotk" %}
{{ eotk_table(items) }}
{% elif item == "group" %}
{{ groups_table(items) }}
{% elif item == "mirror list" %}
{{ mirrorlists_table(items) }}
{% elif item == "origin" %}
{{ origins_table(items) }}
{% elif item == "proxy" %}
{{ proxies_table(items) }}
{% endif %}
{% endblock %}

View file

@ -1,8 +0,0 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import mirrorlists_table %}
{% block content %}
<h1 class="h2 mt-3">Mirror Lists</h1>
<a href="{{ url_for("portal.new_mirror_list") }}" class="btn btn-success">Create new mirror list</a>
{{ mirrorlists_table(mirrorlists) }}
{% endblock %}

View file

@ -1,8 +0,0 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import origins_table %}
{% block content %}
<h1 class="h2 mt-3">Origins</h1>
<a href="{{ url_for("portal.new_origin") }}" class="btn btn-success">Create new origin</a>
{{ origins_table(origins) }}
{% endblock %}

View file

@ -1,7 +0,0 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import proxies_table %}
{% block content %}
<h1 class="h2 mt-3">Proxies</h1>
{{ proxies_table(proxies) }}
{% endblock %}

View file

@ -22,6 +22,37 @@
</svg>
{% endmacro %}
{% macro eotk_table(eotks) %}
<div class="alert alert-danger">Not implemented yet.</div>
{% endmacro %}
{% macro groups_table(groups) %}
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">EOTK</th>
<th scope="col">Sites</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td>{{ group.group_name }}</td>
<td>{{ group.description }}</td>
<td>{% if group.eotk %}✅{% else %}❌{% endif %}</td>
<td>{{ group.origins | length }}</td>
<td><a href="{{ url_for("portal.edit_group", group_id=group.id) }}" class="btn btn-primary btn-sm">View/Edit</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro origins_table(origins) %}
<div class="table-responsive">
<table class="table table-striped table-sm">