Skip to content

Commit

Permalink
chg: [website] Reorganization and improvements to diffenret views tha…
Browse files Browse the repository at this point in the history
…t are dedicated to administrators.
  • Loading branch information
cedricbonhomme committed Jul 30, 2024
1 parent cd7df5d commit 27088c9
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 94 deletions.
19 changes: 19 additions & 0 deletions website/web/templates/admin/bundles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "main.html" %}
{% block title %}Bundles management{% endblock %}
{% block content %}
<div class="container">
<h1>Recent bundles</h1>
{% include "./admin/template_responsive_table_bundles.html" %}
<div class="row">
<div class="col">
{{ pagination.links }}
</div>
</div>
<div class="row">
<div class="col">
{{ pagination.info }}
</div>
</div>
<br />
</div>
{% endblock %}
4 changes: 1 addition & 3 deletions website/web/templates/admin/comments.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends "main.html" %}

{% block title %}Comments{% endblock %}

{% block title %}Comments moderation{% endblock %}
{% block content %}
<div class="container">
<h1>Recent comments</h1>
Expand Down
62 changes: 62 additions & 0 deletions website/web/templates/admin/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% import 'admin/template_responsive_table_users.html' as users_templates with context %}
{% extends "main.html" %}
{% block head %}
{{ super() }}
<script src="{{ url_for('static', filename='js/pretty-print-json.min.js') }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/pretty-print-json.css') }}" />
{% endblock %}
{% block title %}Dasboard{% endblock %}
{% block content %}
<h1>Dashboard</h1>
<div class="row">
<div class="col">
<h2 id="key-figures">Key figures</h2>
<ul class="list-group">
<li class="list-group-item">Number of <a href="{{ url_for('admin_bp.list_users') }}">users</a>: {{ nb_users }}</li>
<li class="list-group-item">Number of <a href="{{ url_for('admin_bp.list_comments') }}">comments</a>: {{ nb_comments }}</li>
<li class="list-group-item">Number of <a href="{{ url_for('bundles_bp.list_bundles') }}">bundles</a>: {{ nb_bundles }}</li>
</ul>
</div>
</div>
<br />
<div class="row">
<div class="col">
<h2 id="instance-status">Instance status</h2>
<ul class="list-group">
<li class="list-group-item">Two-Factor Authentication: <em>{% if config["ENFORCE_2FA"] %}Enforced{% else %}Not enforced{% endif %}</em></li>
<li class="list-group-item">Self-registration: <em>{% if config["SELF_REGISTRATION"] %}Open{% else %}Closed{% endif %}</em></li>
<li class="list-group-item">Comments moderation: <em>{% if config["COMMENTS_MODERATION"] %}On{% else %}Off{% endif %}</em></li>
<li class="list-group-item">Instance UUID: <em>{{ local_instance_uuid }}</em></li>
<li class="list-group-item">Instance name: <em>{{ local_instance_name }}</em></li>
</ul>
</div>
</div>
<br />
<div class="row">
<div class="col">
<h2 id="storage">Storage</h2>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseStorage" aria-expanded="false" aria-controls="collapseStorage">Show JSON</button>
<div class="collapse" id="collapseStorage">
<br />
<div class="card card-body">
<pre id="json-container">{{storage_info|tojson(indent=2)}}</pre>
</div>
<br />
</div>
</div>
</div>
<br />
<div class="row">
<div class="col">
<h2 id="active-users">Active users</h2>
{{ users_templates.table_users(users=users) }}
</div>
</div>
<br />
<script>
document.addEventListener("DOMContentLoaded", function() {
var jsonContainer = document.getElementById("json-container");
jsonContainer.innerHTML = prettyPrintJson.toHtml(JSON.parse(jsonContainer.innerText));
});
</script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2>{{ action | safe }}</h2>
<div class="btn-group" role="group">
<a type="button" id="savebundle" class="btn btn-primary" title="Save" aria-label="Save">Save</a>
<a type="button" class="btn btn-primary" title="View" aria-label="View" href="{{ url_for('bundle_bp.get', bundle_uuid=bundle.uuid) }}">View</a>
<a role="button" class="btn btn-danger" title="Delete" aria-label="Delete" href="{{ url_for('bundle_bp.delete_bundle', bundle_uuid=bundle.uuid) }}" onclick="return confirm('You are going to delete this bundle.');">Delete</a>
<a role="button" class="btn btn-danger" title="Delete" aria-label="Delete" href="{{ url_for('admin_bp.delete_bundle', bundle_uuid=bundle.uuid) }}" onclick="return confirm('You are going to delete this bundle.');">Delete</a>
</div>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions website/web/templates/admin/template_responsive_table_bundles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div class="table-responsive-md">
<table id="table-comments" class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Author</th>
<th>Created at</th>
<th>Updated at</th>
<th>Action</th>

</tr>
</thead>
<tbody>
{% for bundle in bundles %}
<tr>
<td>{{ bundle.name }}</td>
<td><a href="{{ url_for('admin_bp.form_user', user_id=bundle.author.id) }}">{{ bundle.author.login }}</a></td>
<td class="date">{{ bundle.creation_timestamp | datetimeformat }}</td>
<td class="date">{{ bundle.timestamp | datetimeformat }}</td>
<td>
<a class="icon-link" href="{{ url_for('admin_bp.form_bundle', bundle_uuid=bundle.uuid) }}">{{ render_icon('pen', title='Edit the bundle') }}</a>
<a class="icon-link" href="{{ url_for('admin_bp.delete_bundle', bundle_uuid=bundle.uuid) }}" onclick="return confirm('You are going to delete this bundle.');">{{ render_icon('trash') }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
4 changes: 2 additions & 2 deletions website/web/templates/admin/users.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% import 'admin/template_responsive_table_users.html' as users_templates with context %}
{% extends "main.html" %}
{% block title %}Users{% endblock %}
{% block title %}Users management{% endblock %}
{% block content %}
<h2>Status</h2>
<ul class="list-group">
Expand Down Expand Up @@ -36,6 +36,6 @@ <h2>Users</h2>
</div>
<br />
<p>Removing a user will not impact any of the contributions they have previously made.</p>
<a class="btn btn-primary" href="{{ url_for('admin_bp.form_user') }}">Add a new user</a>
<a class="btn btn-primary" href="{{ url_for('admin_bp.form_user') }}">Create a new user</a>
<br /><br />
{% endblock %}
4 changes: 2 additions & 2 deletions website/web/templates/bundles/bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ <h2>Author</h2>
</ul>
</div>
{% if current_user.is_authenticated and current_user.is_admin %}
<a type="button" class="btn btn-primary" title="Edit" aria-label="Edit" href="{{ url_for('bundle_bp.form', bundle_uuid=bundle.uuid) }}">Edit</a>
<a role="button" class="btn btn-danger" title="Delete" aria-label="Delete" href="{{ url_for('bundle_bp.delete_bundle', bundle_uuid=bundle.uuid) }}" onclick="return confirm('You are going to delete this bundle.');">Delete</a>
<a type="button" class="btn btn-primary" title="Edit" aria-label="Edit" href="{{ url_for('admin_bp.form_bundle', bundle_uuid=bundle.uuid) }}">Edit</a>
<a role="button" class="btn btn-danger" title="Delete" aria-label="Delete" href="{{ url_for('admin_bp.delete_bundle', bundle_uuid=bundle.uuid) }}" onclick="return confirm('You are going to delete this bundle.');">Delete</a>
{% endif %}
</div>
<br /><br />
Expand Down
2 changes: 1 addition & 1 deletion website/web/templates/bundles/bundles.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1>Recent bundles</h1>
<div class="row">
<div class="col">
{% if current_user.is_authenticated and current_user.is_admin %}
<a id="buttonNewBundle" class="btn btn-primary" aria-expanded="false" href="{{ url_for('bundle_bp.form') }}">New bundle</a>
<a id="buttonNewBundle" class="btn btn-primary" aria-expanded="false" href="{{ url_for('admin_bp.form_bundle') }}">New bundle</a>
{% endif %}
</div>
<div class="col text-end">
Expand Down
9 changes: 8 additions & 1 deletion website/web/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@
Admin
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownAdmin">
<a class="dropdown-item" href="{{ url_for('admin_bp.dashboard') }}" title="Dashboard">Dashboard</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ url_for('admin_bp.list_users') }}" title="Users">Users</a>
<a class="dropdown-item" href="{{ url_for('admin_bp.list_comments') }}" title="Comments">Comments</a>
<a class="dropdown-item" href="{{ url_for('admin_bp.form_user') }}" title="Users">Create a new user</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ url_for('admin_bp.list_comments') }}" title="Comments">Comments moderation</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ url_for('admin_bp.list_bundles') }}" title="Comments">Bundles</a>
<a class="dropdown-item" href="{{ url_for('admin_bp.form_bundle') }}" title="Users">Create a new bundle</a>
</ul>
</li>
{% endif %}
Expand Down
48 changes: 23 additions & 25 deletions website/web/templates/user/setup-2fa.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
{% extends "main.html" %}
{% block title %}Set up Two-Factor Authentication{% endblock %}

{% block title %}Setup Two-Factor Authentication{% endblock %}
{% block content %}

<div class="row">
<div class="col-md-6">
<main class="form-signin w-100 m-auto">
<h5>Instructions</h5>
<ul>
<li>Install an authenticator application on your mobile.</li>
<li>Scan the QRCode or copy the secret token.</li>
<li>Once you have scanned the QRCode, click <a href="{{ url_for('user_bp.verify_two_factor_auth') }}">here</a>.</li>
</ul>
<div class="text-center">
<img src="data:image/png;base64, {{ qr_image }}" alt="Secret Token" style="width:200px;height:200px"/>
</div>
<div class="form-group">
<label for="secret">Secret Token</label>
<input type="text" class="form-control" id="secret" value="{{ secret }}" readonly>
</div>
<div class="mt-3 mb-3">
<button class='btn btn-primary' id='copySecret'>Copy Secret</button>
</div>
</main>
</div>
<div class="col-md-6"></div>
<div class="col-md-6">
<main class="form-signin w-100 m-auto">
<h5>Instructions</h5>
<ul>
<li>Install an authenticator application on your mobile.</li>
<li>Scan the QRCode or copy the secret token.</li>
<li>Once you have scanned the QRCode, click <a href="{{ url_for('user_bp.verify_two_factor_auth') }}">here</a>.</li>
</ul>
<div class="text-center">
<img src="data:image/png;base64, {{ qr_image }}" alt="Secret Token" style="width:200px;height:200px"/>
</div>
<div class="form-group">
<label for="secret">Secret Token</label>
<input type="text" class="form-control" id="secret" value="{{ secret }}" readonly>
</div>
<div class="mt-3 mb-3">
<button class='btn btn-primary' id='copySecret'>Copy Secret</button>
</div>
</main>
</div>
{% block js %}
<div class="col-md-6"></div>
</div>
{% block js %}
<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("copySecret").onclick = function(event) {
Expand Down
Loading

0 comments on commit 27088c9

Please sign in to comment.