Files
wireguard_webadmin/templates/app_gateway/application_details.html
T

244 lines
11 KiB
HTML
Raw Normal View History

{% extends "base.html" %}
{% load i18n %}
{% block content %}
{% include 'app_gateway/pending_export_alert.html' %}
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">
<i class="fas fa-server"></i> {{ application }}
</h3>
<div class="card-tools">
<a href="{% url 'app_gateway_list' %}" class="btn btn-sm btn-secondary">
<i class="fas fa-arrow-left"></i> {% trans 'Back to List' %}
</a>
{% if is_reserved %}
<a class="btn btn-sm btn-secondary disabled" aria-disabled="true" tabindex="-1" title="{% trans 'This application cannot be modified' %}">
<i class="fas fa-edit"></i> {% trans 'Edit Application' %}
</a>
<a class="btn btn-sm btn-secondary disabled" aria-disabled="true" tabindex="-1" title="{% trans 'This application cannot be deleted' %}">
<i class="fas fa-trash"></i> {% trans 'Delete Application' %}
</a>
{% else %}
<a href="{% url 'manage_application' %}?uuid={{ application.uuid }}" class="btn btn-sm btn-info">
<i class="fas fa-edit"></i> {% trans 'Edit Application' %}
</a>
<a href="{% url 'delete_application' %}?uuid={{ application.uuid }}" class="btn btn-sm btn-danger">
<i class="fas fa-trash"></i> {% trans 'Delete Application' %}
</a>
{% endif %}
</div>
</div>
<div class="card-body">
<div class="row mb-4">
<div class="col-md-6">
<strong>{% trans 'Name' %}:</strong> {{ application }}<br>
<strong>{% trans 'Upstream' %}:</strong> <code>{{ application.upstream }}</code><br>
</div>
<div class="col-md-6">
<strong>{% trans 'Default Policy' %}:</strong>
{% if application.default_policy_config %}
<span>{{ application.default_policy_config.default_policy }}</span>
<a href="{% url 'manage_application_policy' %}?uuid={{ application.default_policy_config.uuid }}"
class="btn btn-sm btn-outline-secondary btn-xs"><i class="fas fa-edit"></i></a>
<a href="{% url 'delete_application_policy' %}?uuid={{ application.default_policy_config.uuid }}"
class="btn btn-sm btn-outline-danger btn-xs"><i class="fas fa-times"></i></a>
{% else %}
<span class="text-muted">{% trans 'Default (Deny)' %}</span>
<a href="{% url 'manage_application_policy' %}?application_uuid={{ application.uuid }}"
class="btn btn-sm btn-outline-primary btn-xs"><i class="fas fa-plus"></i> {% trans 'Set Policy' %}</a>
{% endif %}
</div>
</div>
<hr>
<h4 id="hosts">{% trans 'Application Hosts' %}</h4>
<div class="mb-3">
{% if is_reserved %}
<a class="btn btn-outline-secondary btn-sm disabled" aria-disabled="true" tabindex="-1" title="{% trans 'This application cannot be modified' %}">
<i class="fas fa-plus"></i> {% trans 'Add Host' %}
</a>
{% else %}
<a href="{% url 'manage_application_host' %}?application_uuid={{ application.uuid }}"
class="btn btn-outline-primary btn-sm">
<i class="fas fa-plus"></i> {% trans 'Add Host' %}
</a>
{% endif %}
</div>
{% if hosts %}
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>{% trans 'Hostname' %}</th>
<th>{% trans 'Certificate' %}</th>
{% if caddy_enabled %}<th>{% trans 'Status' %}</th>{% endif %}
<th class="min-width">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody>
{% for host in hosts %}
<tr>
<td>{{ host.hostname }}</td>
<td>
{% include 'app_gateway/host_certificate.html' %}
</td>
{% if caddy_enabled %}
<td class="certificate-status" data-host-uuid="{{ host.uuid }}">
<i class="fas fa-spinner fa-spin text-muted"></i>
</td>
{% endif %}
<td class="min-width">
<form method="post" action="{% url 'retry_application_host_certificate' %}?uuid={{ host.uuid }}" class="d-inline">
{% csrf_token %}
<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>
</button>
</form>
{% if is_reserved %}
<a href="{% url 'manage_application_host' %}?uuid={{ host.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i>
</a>
<a class="btn btn-sm btn-secondary disabled" aria-disabled="true" tabindex="-1" title="{% trans 'This application cannot be modified' %}">
<i class="fas fa-trash"></i>
</a>
{% else %}
<a href="{% url 'manage_application_host' %}?uuid={{ host.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i>
</a>
<a href="{% url 'delete_application_host' %}?uuid={{ host.uuid }}"
class="btn btn-sm btn-danger" title="{% trans 'Delete' %}">
<i class="fas fa-trash"></i>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info">
{% trans 'No Hosts configured for this application.' %}
</div>
{% endif %}
<hr class="mt-4 mb-4">
<h4 id="routes">{% trans 'Application Routes' %}</h4>
<div class="mb-3">
<a href="{% url 'manage_application_route' %}?application_uuid={{ application.uuid }}"
class="btn btn-outline-primary btn-sm">
<i class="fas fa-plus"></i> {% trans 'Add Route' %}
</a>
</div>
{% if routes %}
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>{% trans 'Route Name' %}</th>
<th>{% trans 'Path Prefix' %}</th>
<th>{% trans 'Policy' %}</th>
<th>{% trans 'Order' %}</th>
<th class="min-width">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody>
{% for route in routes %}
<tr>
<td>{{ route }}</td>
<td><code>{{ route.path_prefix }}</code></td>
<td>{{ route.policy }}</td>
<td>{{ route.order }}</td>
<td class="min-width">
<a href="{% url 'manage_application_route' %}?uuid={{ route.uuid }}"
class="btn btn-sm btn-info" title="{% trans 'Edit' %}">
<i class="fas fa-edit"></i>
</a>
<a href="{% url 'delete_application_route' %}?uuid={{ route.uuid }}"
class="btn btn-sm btn-danger" title="{% trans 'Delete' %}">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info">
{% trans 'No Routes configured for this application.' %}
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% block page_custom_head %}
<style>
.tooltip-inner.host-certificate-tooltip {
max-width: 420px;
}
</style>
{% endblock %}
{% block custom_page_scripts %}
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
{% if caddy_enabled and hosts %}
<script>
$(document).ready(function () {
$.getJSON("{% url 'application_certificate_status' %}?uuid={{ application.uuid }}", function (data) {
$('.certificate-status').each(function () {
var cell = $(this);
var serversStatus = data.hosts[cell.data('host-uuid')] || [];
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) {
if (index) {
cell.append('<br>');
}
cell.append(badge(
serverStatus.css_class, serverStatus.server + ': ' + serverStatus.label, serverStatus.detail
));
});
});
}).fail(function () {
$('.certificate-status').html('<span class="text-muted">-</span>');
});
});
</script>
{% endif %}
{% endblock %}