mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-22 04:43:18 +01:00
233 lines
13 KiB
HTML
233 lines
13 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block content %}
|
|
{% if not cluster_settings.enabled %}
|
|
<div class="alert alert-warning">
|
|
<i class="icon fas fa-exclamation-triangle"></i>
|
|
{% trans 'The cluster is disabled. Workers are refused and App Gateway applications are only published by this primary server.' %}
|
|
<a href="{% url 'cluster_settings' %}" class="alert-link">{% trans 'Cluster Settings' %}</a>
|
|
</div>
|
|
{% endif %}
|
|
{% if stopped_instances %}
|
|
<div class="alert alert-danger">
|
|
<i class="icon fas fa-exclamation-circle"></i>
|
|
{% trans 'These WireGuard instances are offline because their worker is disabled:' %}
|
|
{% for instance in stopped_instances %}<strong>wg{{ instance.instance_id }}</strong> ({{ instance.worker }}){% if not forloop.last %}, {% endif %}{% endfor %}.
|
|
{% trans 'Enable the worker or move the instances to another server.' %}
|
|
</div>
|
|
{% endif %}
|
|
{% if not cache_enabled %}
|
|
<div class="alert alert-danger">
|
|
<i class="icon fas fa-exclamation-circle"></i>
|
|
{% trans 'The cluster requires the WireGuard status cache. Enable WIREGUARD_STATUS_CACHE_ENABLED in the .env file.' %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div id="cluster-live">
|
|
<div class="row">
|
|
<div class="col-md-3 col-sm-6">
|
|
<div class="info-box">
|
|
<span class="info-box-icon {% if summary.online == summary.enabled %}bg-success{% else %}bg-danger{% endif %}"><i class="fas fa-server"></i></span>
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">{% trans 'Workers online' %}</span>
|
|
<span class="info-box-number">{{ summary.online }} / {{ summary.enabled }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 col-sm-6">
|
|
<div class="info-box">
|
|
<span class="info-box-icon {% if summary.synced == summary.enabled %}bg-success{% else %}bg-info{% endif %}"><i class="fas fa-sync"></i></span>
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">{% trans 'Synchronized' %}</span>
|
|
<span class="info-box-number">{{ summary.synced }} / {{ summary.enabled }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 col-sm-6">
|
|
<div class="info-box">
|
|
<span class="info-box-icon {% if summary.attention %}bg-warning{% else %}bg-success{% endif %}"><i class="fas fa-exclamation-triangle"></i></span>
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">{% trans 'Need attention' %}</span>
|
|
<span class="info-box-number">{{ summary.attention }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 col-sm-6">
|
|
<div class="info-box">
|
|
<span class="info-box-icon {% if cluster_settings.primary_enable_wireguard %}bg-success{% else %}bg-secondary{% endif %}"><i class="fas fa-network-wired"></i></span>
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">{% trans 'Primary WireGuard' %}</span>
|
|
<span class="info-box-number">{% if cluster_settings.primary_enable_wireguard %}{% trans 'Enabled' %}{% else %}{% trans 'Disabled' %}{% endif %}</span>
|
|
{% if distributed %}
|
|
<span class="text-muted text-sm" title="{% trans 'WireGuard instances on the primary server' %}">
|
|
{% for instance in primary_instances %}wg{{ instance.instance_id }}{% if not forloop.last %}, {% endif %}{% empty %}{% trans 'No WireGuard instances' %}{% endfor %}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card card-primary card-outline">
|
|
<div class="card-header">
|
|
<h3 class="card-title"><i class="fas fa-server"></i> {% trans 'Workers' %}</h3>
|
|
<div class="card-tools">
|
|
<a href="{% url 'worker_manage' %}" class="btn btn-sm btn-primary"><i class="fas fa-plus"></i> {% trans 'Add Worker' %}</a>
|
|
<a href="{% url 'cluster_settings' %}" class="btn btn-sm btn-secondary"><i class="fas fa-cog"></i> {% trans 'Cluster Settings' %}</a>
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
{% if workers %}
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans 'Worker' %}</th>
|
|
<th>{% trans 'Status' %}</th>
|
|
<th>{% trans 'Synchronization' %}</th>
|
|
<th>{% trans 'Services' %}</th>
|
|
<th>{% trans 'Version' %}</th>
|
|
<th class="text-right">{% trans 'Actions' %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for worker in workers %}
|
|
<tr>
|
|
<td>
|
|
<a href="{% url 'worker_details' %}?uuid={{ worker.uuid }}"><strong>{{ worker.name }}</strong></a>
|
|
<br><small class="text-muted">
|
|
{{ worker.hostname|default:worker.ip_address|default:'-' }}
|
|
{% if worker.ip_lock %}<i class="fas fa-lock text-warning" title="{% trans 'IP Lock Enabled' %}"></i>{% endif %}
|
|
{% if worker.city or worker.country %} · {{ worker.city|default:'' }}{% if worker.city and worker.country %}, {% endif %}{{ worker.country|default:'' }}{% endif %}
|
|
</small>
|
|
{% if distributed %}
|
|
<br><small>
|
|
{% for instance in worker.hosted_instances %}
|
|
<span class="badge badge-info" title="{% trans 'WireGuard instance' %}">wg{{ instance.instance_id }}{% if instance.name %} · {{ instance.name }}{% endif %}</span>
|
|
{% empty %}
|
|
<span class="text-muted">{% trans 'No WireGuard instances' %}</span>
|
|
{% endfor %}
|
|
</small>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-nowrap">
|
|
{% if not worker.enabled %}
|
|
<span class="badge badge-secondary">{% trans 'Disabled' %}</span>
|
|
{% elif worker.error_status %}
|
|
<span class="badge badge-danger" title="{{ worker.get_error_status_display }}">{% trans 'Refused' %}</span>
|
|
{% elif worker.is_online %}
|
|
<span class="badge badge-success">{% trans 'Online' %}</span>
|
|
{% else %}
|
|
<span class="badge badge-danger">{% trans 'Offline' %}</span>
|
|
{% endif %}
|
|
<br><small class="text-muted" title="{% trans 'Last Seen' %}">
|
|
{% if worker.status %}{{ worker.status.last_seen|date:"SHORT_DATETIME_FORMAT" }}{% else %}{% trans 'Never' %}{% endif %}
|
|
</small>
|
|
</td>
|
|
<td>
|
|
{% if not worker.enabled %}
|
|
<span class="text-muted">-</span>
|
|
{% elif not worker.operational %}
|
|
<span class="badge badge-secondary" title="{% trans 'The worker is not receiving updates.' %}">{% trans 'Unknown' %}</span>
|
|
{% elif worker.sync_state.state == 'synced' %}
|
|
<span class="badge badge-success">{% trans 'Synchronized' %}</span>
|
|
{% elif worker.sync_state.state == 'error' %}
|
|
<span class="badge badge-danger" title="{{ worker.error_messages|join:' / ' }}">{% trans 'Error' %}</span>
|
|
<br><small class="text-muted">{{ worker.unsynced_sections|join:', ' }}</small>
|
|
{% else %}
|
|
<span class="badge badge-secondary">{% trans 'Pending' %}</span>
|
|
<br><small class="text-muted">{{ worker.unsynced_sections|join:', ' }}</small>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% for service, state in worker.services %}
|
|
{% if worker.operational %}
|
|
<span class="badge {% if state == 'running' %}badge-success{% else %}badge-danger{% endif %}">{{ service }}</span>
|
|
{% else %}
|
|
<span class="badge badge-secondary" title="{% trans 'Last reported state' %}: {{ state }}">{{ service }}</span>
|
|
{% endif %}
|
|
{% empty %}
|
|
<span class="text-muted">-</span>
|
|
{% endfor %}
|
|
{% if worker.operational and worker.warnings.certificate_issues %}
|
|
<br><small class="text-warning" title="{{ worker.warnings.certificate_issues|join:', ' }}">
|
|
<i class="fas fa-certificate"></i> {% trans 'Certificates unavailable or expiring soon' %}
|
|
</small>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-nowrap">
|
|
{% if worker.status %}
|
|
<span class="badge {% if worker.outdated %}badge-warning{% else %}badge-light{% endif %}"
|
|
{% if worker.outdated %}title="{% trans 'The worker is outdated. Please update it to the latest version.' %}"{% endif %}>
|
|
v{{ worker.status.worker_version }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-muted">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-right text-nowrap">
|
|
<a href="{% url 'worker_details' %}?uuid={{ worker.uuid }}" class="btn btn-sm btn-outline-info" title="{% trans 'Details' %}"><i class="fas fa-eye"></i></a>
|
|
<a href="{% url 'worker_manage' %}?uuid={{ worker.uuid }}" class="btn btn-sm btn-outline-secondary" title="{% trans 'Edit' %}"><i class="fas fa-edit"></i></a>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="p-4 text-center text-muted">
|
|
<p>{% trans 'No workers configured' %}</p>
|
|
<a href="{% url 'worker_manage' %}" class="btn btn-primary"><i class="fas fa-plus"></i> {% trans 'Add Worker' %}</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card card-secondary card-outline collapsed-card">
|
|
<div class="card-header">
|
|
<h3 class="card-title"><i class="fas fa-stethoscope"></i> {% trans 'Diagnostics' %}</h3>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-plus"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<dl class="row mb-0">
|
|
<dt class="col-sm-4">{% trans 'Cluster Mode' %}</dt>
|
|
<dd class="col-sm-8">{{ cluster_settings.get_cluster_mode_display }}</dd>
|
|
<dt class="col-sm-4">{% trans 'Worker Display' %}</dt>
|
|
<dd class="col-sm-8">{{ cluster_settings.get_worker_display_display }}</dd>
|
|
<dt class="col-sm-4">{% trans 'Current worker version' %}</dt>
|
|
<dd class="col-sm-8">v{{ current_worker_version }}</dd>
|
|
<dt class="col-sm-4">{% trans 'Stats Cache Refresh Interval' %}</dt>
|
|
<dd class="col-sm-8">{{ cache_refresh_interval }}s</dd>
|
|
<dt class="col-sm-4">{% trans 'Cache Web Load Previous Count' %}</dt>
|
|
<dd class="col-sm-8">{{ cache_web_load_previous_count }}</dd>
|
|
<dt class="col-sm-4">{% trans 'Master Cache Processing Time' %}</dt>
|
|
<dd class="col-sm-8"><small>{{ master_cache_times|default:'-' }}</small></dd>
|
|
<dt class="col-sm-4">{% trans 'Cluster Cache Processing Time' %}</dt>
|
|
<dd class="col-sm-8"><small>{{ cluster_cache_times|default:'-' }}</small></dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block custom_page_scripts %}
|
|
<script>
|
|
$(document).ready(function () {
|
|
// Refresh the summary and the worker list every 30 seconds while the page is visible
|
|
setInterval(function () {
|
|
if (document.visibilityState === 'visible') {
|
|
$.get(window.location.href, function (data) {
|
|
var content = $('<div>').append($.parseHTML(data)).find('#cluster-live');
|
|
if (content.length) {
|
|
$('#cluster-live').html(content.html());
|
|
}
|
|
});
|
|
}
|
|
}, 30000);
|
|
});
|
|
</script>
|
|
{% endblock %}
|