Implement CORS-fields in views & HTML, improve list rendering & selection

This commit is contained in:
Josako
2024-05-15 21:27:23 +02:00
parent ea23e8d327
commit 8c6d9bf5ca
13 changed files with 434 additions and 68 deletions

View File

@@ -0,0 +1,24 @@
{% extends 'base.html' %}
{% from "macros.html" import render_field %}
{% block title %}Update Tenant Domain{% endblock %}
{% block content_title %}Update Tenant Domain{% endblock %}
{% block content_description %}Disable a tenant domain{% endblock %}
{% block content %}
<form method="post">
{{ form.hidden_tag() }}
{% set disabled_fields = ['domain'] %}
{% set exclude_fields = [] %}
{% for field in form %}
{{ render_field(field, disabled_fields, exclude_fields) }}
{% endfor %}
<button type="submit" class="btn btn-primary">Update Domain</button>
</form>
{% endblock %}
{% block content_footer %}
{% endblock %}

View File

@@ -1,5 +1,5 @@
{% extends 'base.html' %}
{% from "macros.html" import render_field %}
{% from "macros.html" import render_selectable_table %}
{% block title %}Tenant Selection{% endblock %}
@@ -8,27 +8,38 @@
{% block content %}
<form method="POST" action="{{ url_for('user_bp.handle_tenant_selection') }}">
<table class="table">
<thead>
<tr>
<th>Select</th>
<th>Tenant Name</th>
<th>Tenant ID</th>
</tr>
</thead>
<tbody>
{% for tenant in tenants %}
<tr>
<td><input type="radio" name="tenant_id" value="{{ tenant.id }}" required></td>
<td>{{ tenant.name }}</td>
<td>{{ tenant.id }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" name="action" value="select_tenant" class="btn btn-primary">Set Session Tenant</button>
<button type="submit" name="action" value="view_users" class="btn btn-secondary">View Users</button>
<button type="submit" name="action" value="edit_tenant" class="btn btn-secondary">Edit Tenant</button>
<!-- Add more buttons as needed -->
{{ render_selectable_table(headers=["Tenant ID", "Tenant Name","Website"], rows=tenants, selectable=True, id="tenantsTable") }}
<div class="form-group mt-3">
<button type="submit" name="action" value="select_tenant" class="btn btn-primary">Set Session Tenant</button>
<button type="submit" name="action" value="view_users" class="btn btn-secondary">View Users</button>
<button type="submit" name="action" value="edit_tenant" class="btn btn-secondary">Edit Tenant</button>
<!-- Add more buttons as needed -->
</div>
</form>
{% endblock %}
{% block scripts %}
<script>
$(document).ready(function() {
$('#tenantsTable').DataTable({
'columnDefs': [{
'targets': 0,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'render': function (data, type, full, meta){
return '<input type="radio" name="user_id" value="' + $('<div/>').text(data).html() + '">';
}
},
{
'targets': 1,
'orderable': true
},
{
'targets': 2,
'orderable': true
}],
'order': [[1, 'asc']]
});
});
</script>
{% endblock %}

View File

@@ -0,0 +1,24 @@
{% extends 'base.html' %}
{% from "macros.html" import render_field %}
{% block title %}Tenant Domain Registration{% endblock %}
{% block content_title %}Register Tenant Domain{% endblock %}
{% block content_description %}Make a new tenant domain, which enables the chat client on the specified domain{% endblock %}
{% block content %}
<form method="post">
{{ form.hidden_tag() }}
{% set disabled_fields = [] %}
{% set exclude_fields = [] %}
{% for field in form %}
{{ render_field(field, disabled_fields, exclude_fields) }}
{% endfor %}
<button type="submit" class="btn btn-primary">Register Domain</button>
</form>
{% endblock %}
{% block content_footer %}
{% endblock %}

View File

@@ -0,0 +1,45 @@
{% extends 'base.html' %}
{% from "macros.html" import render_selectable_table %}
{% block title %}View Tenant Domains{% endblock %}
{% block content_title %}Select a domain{% endblock %}
{% block content_description %}Select the domain you'd like to action upon{% endblock %}
{% block content %}
<form action="{{ url_for('user_bp.handle_tenant_domain_action') }}" method="POST">
{{ render_selectable_table(headers=["ID", "Domain Name", "Valid To"], rows=tenant_domains, selectable=True, id="tenantDomainsTable") }}
<div class="form-group mt-3">
<button type="submit" name="action" value="edit_tenant_domain" class="btn btn-primary">Edit Selected Domain</button>
<!-- Additional buttons can be added here for other actions -->
</div>
</form>
{% endblock %}
{% block scripts %}
<script>
$(document).ready(function() {
$('#tenantDomainsTable').DataTable({
'columnDefs': [
{
'targets': 0,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'render': function (data, type, full, meta) {
return '<input type="radio" name="user_id" value="' + $('<div/>').text(data).html() + '">';
}
},
{
'targets': 1,
'orderable': true,
},
{
'targets': 2,
'orderable': true,
},
],
'order': [[1, 'asc']]
});
});
</script>
{% endblock %}

View File

@@ -1,5 +1,5 @@
{% extends 'base.html' %}
{% from "macros.html" import render_field %}
{% from "macros.html" import render_selectable_table %}
{% block title %}View Users{% endblock %}
@@ -7,49 +7,43 @@
{% block content_description %}Select the user you'd like to action upon{% endblock %}
{% block content %}
<h3>Users for Selected Tenant</h3>
<form action="{{ url_for('user_bp.handle_user_action') }}" method="POST">
<table id="usersTable" class="display" style="width:100%">
<thead>
<tr>
<th>Select</th>
<th>User ID</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td><input type="radio" name="user_id" value="{{ user.id }}" required></td>
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ render_selectable_table(headers=["User ID", "User Name", "Email"], rows=users, selectable=True, id="usersTable") }}
<div class="form-group mt-3">
<button type="submit" name="action" value="edit_user" class="btn btn-primary">Edit Selected User</button>
<!-- Additional buttons can be added here for other actions -->
</div>
</form>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
{% endblock %}
{% block scripts %}
<script>
$(document).ready(function() {
$('#usersTable').DataTable({
'columnDefs': [{
'targets': 0,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'render': function (data, type, full, meta){
return '<input type="radio" name="user_id" value="' + $('<div/>').text(data).html() + '">';
'columnDefs': [
{
'targets': 0,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'render': function (data, type, full, meta) {
return '<input type="radio" name="user_id" value="' + $('<div/>').text(data).html() + '">';
}
},
{
'targets': 1,
'orderable': true,
},
{
'targets': 2,
'orderable': true,
},
{
'targets': 3,
'orderable': true,
}
}],
],
'order': [[1, 'asc']]
});
});
</script>
{% endblock %}
{% endblock %}