Improve the host list of the application details page

This commit is contained in:
Eduardo Silva
2026-11-22 12:13:27 -03:00
parent 8682dc8ce6
commit 90559a0089
2 changed files with 37 additions and 19 deletions
+4 -4
View File
@@ -158,7 +158,7 @@
<th>{% trans 'Policy Type' %}</th> <th>{% trans 'Policy Type' %}</th>
<th>{% trans 'Groups' %}</th> <th>{% trans 'Groups' %}</th>
<th>{% trans 'Auth Methods' %}</th> <th>{% trans 'Auth Methods' %}</th>
<th>{% trans 'Actions' %}</th> <th class="min-width">{% trans 'Actions' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -168,7 +168,7 @@
<td>{{ policy.get_policy_type_display }}</td> <td>{{ policy.get_policy_type_display }}</td>
<td>{{ policy.groups.count }}</td> <td>{{ policy.groups.count }}</td>
<td>{{ policy.methods.count }}</td> <td>{{ policy.methods.count }}</td>
<td style="width: 15%"> <td class="min-width">
<a href="{% url 'manage_access_policy' %}?uuid={{ policy.uuid }}" <a href="{% url 'manage_access_policy' %}?uuid={{ policy.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}"> class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
@@ -205,7 +205,7 @@
<th>{% trans 'Provider' %}</th> <th>{% trans 'Provider' %}</th>
<th>{% trans 'Delegation domain' %}</th> <th>{% trans 'Delegation domain' %}</th>
<th>{% trans 'Hosts' %}</th> <th>{% trans 'Hosts' %}</th>
<th>{% trans 'Actions' %}</th> <th class="min-width">{% trans 'Actions' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -215,7 +215,7 @@
<td>{{ dns_credential.get_provider_display }}</td> <td>{{ dns_credential.get_provider_display }}</td>
<td>{{ dns_credential.delegation_domain|default:'-' }}</td> <td>{{ dns_credential.delegation_domain|default:'-' }}</td>
<td>{{ dns_credential.hosts.count }}</td> <td>{{ dns_credential.hosts.count }}</td>
<td style="width: 15%"> <td class="min-width">
<a href="{% url 'manage_dns_credential' %}?uuid={{ dns_credential.uuid }}" <a href="{% url 'manage_dns_credential' %}?uuid={{ dns_credential.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}"> class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
+33 -15
View File
@@ -76,7 +76,7 @@
<th>{% trans 'Hostname' %}</th> <th>{% trans 'Hostname' %}</th>
<th>{% trans 'Certificate' %}</th> <th>{% trans 'Certificate' %}</th>
{% if caddy_enabled %}<th>{% trans 'Status' %}</th>{% endif %} {% if caddy_enabled %}<th>{% trans 'Status' %}</th>{% endif %}
<th>{% trans 'Actions' %}</th> <th class="min-width">{% trans 'Actions' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -91,15 +91,14 @@
<i class="fas fa-spinner fa-spin text-muted"></i> <i class="fas fa-spinner fa-spin text-muted"></i>
</td> </td>
{% endif %} {% endif %}
<td style="width: 15%" class="text-nowrap"> <td class="min-width">
{% if host.certificate_type != 'self_signed' %}
<form method="post" action="{% url 'retry_application_host_certificate' %}?uuid={{ host.uuid }}" class="d-inline"> <form method="post" action="{% url 'retry_application_host_certificate' %}?uuid={{ host.uuid }}" class="d-inline">
{% csrf_token %} {% csrf_token %}
<button type="submit" class="btn btn-sm btn-outline-secondary" title="{% trans 'Retry certificate' %}"> <button type="submit" class="btn btn-sm btn-outline-secondary"
title="{% if host.certificate_type == 'self_signed' %}{% trans 'Issue a new self-signed certificate' %}{% else %}{% trans 'Retry certificate' %}{% endif %}">
<i class="fas fa-sync-alt"></i> <i class="fas fa-sync-alt"></i>
</button> </button>
</form> </form>
{% endif %}
{% if is_reserved %} {% if is_reserved %}
<a href="{% url 'manage_application_host' %}?uuid={{ host.uuid }}" <a href="{% url 'manage_application_host' %}?uuid={{ host.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}"> class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
@@ -149,7 +148,7 @@
<th>{% trans 'Path Prefix' %}</th> <th>{% trans 'Path Prefix' %}</th>
<th>{% trans 'Policy' %}</th> <th>{% trans 'Policy' %}</th>
<th>{% trans 'Order' %}</th> <th>{% trans 'Order' %}</th>
<th>{% trans 'Actions' %}</th> <th class="min-width">{% trans 'Actions' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -159,7 +158,7 @@
<td><code>{{ route.path_prefix }}</code></td> <td><code>{{ route.path_prefix }}</code></td>
<td>{{ route.policy }}</td> <td>{{ route.policy }}</td>
<td>{{ route.order }}</td> <td>{{ route.order }}</td>
<td style="width: 15%"> <td class="min-width">
<a href="{% url 'manage_application_route' %}?uuid={{ route.uuid }}" <a href="{% url 'manage_application_route' %}?uuid={{ route.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}"> class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
@@ -206,15 +205,34 @@
var cell = $(this); var cell = $(this);
var serversStatus = data.hosts[cell.data('host-uuid')] || []; var serversStatus = data.hosts[cell.data('host-uuid')] || [];
cell.empty(); cell.empty();
if (!serversStatus.length) {
return;
}
function badge(cssClass, label, title) {
return $('<span class="badge"></span>').addClass('badge-' + cssClass).attr('title', title).text(label);
}
function serverDetail(serverStatus) {
return serverStatus.server ? serverStatus.server + ': ' + serverStatus.detail : serverStatus.detail;
}
// When every server is in the same state, a single badge summarizes them
var first = serversStatus[0];
var sameState = serversStatus.every(function (serverStatus) {
return serverStatus.label === first.label && serverStatus.css_class === first.css_class;
});
if (sameState) {
cell.append(badge(first.css_class, first.label, serversStatus.map(serverDetail).join('\n')));
return;
}
$.each(serversStatus, function (index, serverStatus) { $.each(serversStatus, function (index, serverStatus) {
var title = serverStatus.server ? serverStatus.server + ': ' + serverStatus.detail : serverStatus.detail; if (index) {
var label = serverStatus.server ? serverStatus.server + ': ' + serverStatus.label : serverStatus.label; cell.append('<br>');
cell.append( }
$('<span class="badge mr-1"></span>') cell.append(badge(
.addClass('badge-' + serverStatus.css_class) serverStatus.css_class, serverStatus.server + ': ' + serverStatus.label, serverStatus.detail
.attr('title', title) ));
.text(label)
);
}); });
}); });
}).fail(function () { }).fail(function () {