mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-01-01 14:16:18 +00:00
Cluster settings update
This commit is contained in:
@@ -10,7 +10,7 @@ from .models import ClusterSettings, Worker
|
|||||||
class WorkerForm(forms.ModelForm):
|
class WorkerForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Worker
|
model = Worker
|
||||||
fields = ['name', 'enabled', 'ip_lock', 'ip_address', 'country', 'city', 'hostname']
|
fields = ['name', 'enabled', 'ip_lock', 'ip_address', 'country', 'city', 'hostname', 'token']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@@ -21,6 +21,7 @@ class WorkerForm(forms.ModelForm):
|
|||||||
self.fields['country'].label = _("Country")
|
self.fields['country'].label = _("Country")
|
||||||
self.fields['city'].label = _("City")
|
self.fields['city'].label = _("City")
|
||||||
self.fields['hostname'].label = _("Hostname")
|
self.fields['hostname'].label = _("Hostname")
|
||||||
|
self.fields['token'].label = _("Token")
|
||||||
|
|
||||||
back_label = _("Back")
|
back_label = _("Back")
|
||||||
delete_label = _("Delete")
|
delete_label = _("Delete")
|
||||||
@@ -35,18 +36,29 @@ class WorkerForm(forms.ModelForm):
|
|||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
Row(
|
Row(
|
||||||
Column('name', css_class='form-group col-md-6 mb-0'),
|
Column('name', css_class='form-group col-md-6 mb-0'),
|
||||||
Column('enabled', css_class='form-group col-md-6 mb-0'),
|
Column('hostname', css_class='form-group col-md-6 mb-0'),
|
||||||
css_class='form-row'
|
css_class='form-row'
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
Column('ip_lock', css_class='form-group col-md-6 mb-0'),
|
Column('country', css_class='form-group col-md-6 mb-0'),
|
||||||
|
Column('city', css_class='form-group col-md-6 mb-0'),
|
||||||
|
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
|
||||||
|
Column('token', css_class='form-group col-md-12 mb-0'),
|
||||||
|
css_class='form-row'
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Column(css_class='form-group col-md-6 mb-0'),
|
||||||
Column('ip_address', css_class='form-group col-md-6 mb-0'),
|
Column('ip_address', css_class='form-group col-md-6 mb-0'),
|
||||||
css_class='form-row'
|
css_class='form-row'
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
Column('country', css_class='form-group col-md-4 mb-0'),
|
|
||||||
Column('city', css_class='form-group col-md-4 mb-0'),
|
Column('enabled', css_class='form-group col-md-6 mb-0'),
|
||||||
Column('hostname', css_class='form-group col-md-4 mb-0'),
|
Column('ip_lock', css_class='form-group col-md-6 mb-0'),
|
||||||
|
|
||||||
css_class='form-row'
|
css_class='form-row'
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@@ -130,10 +142,10 @@ class ClusterSettingsForm(forms.ModelForm):
|
|||||||
stats_sync_interval = cleaned_data.get('stats_sync_interval')
|
stats_sync_interval = cleaned_data.get('stats_sync_interval')
|
||||||
stats_cache_interval = cleaned_data.get('stats_cache_interval')
|
stats_cache_interval = cleaned_data.get('stats_cache_interval')
|
||||||
|
|
||||||
if stats_sync_interval and stats_sync_interval < 10:
|
if stats_sync_interval and stats_sync_interval < 60:
|
||||||
raise ValidationError(_("Stats sync interval must be at least 10 seconds."))
|
raise ValidationError(_("Stats sync interval must be at least 60 seconds."))
|
||||||
|
|
||||||
if stats_cache_interval and stats_cache_interval < 10:
|
if stats_cache_interval and stats_cache_interval < 60:
|
||||||
raise ValidationError(_("Stats cache interval must be at least 10 seconds."))
|
raise ValidationError(_("Stats cache interval must be at least 60 seconds."))
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
20
cluster/migrations/0005_alter_worker_token.py
Normal file
20
cluster/migrations/0005_alter_worker_token.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 5.2.9 on 2025-12-29 20:59
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cluster', '0004_alter_clustersettings_cluster_mode'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='worker',
|
||||||
|
name='token',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, unique=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -30,7 +30,7 @@ class ClusterSettings(models.Model):
|
|||||||
class Worker(models.Model):
|
class Worker(models.Model):
|
||||||
name = models.CharField(max_length=100, unique=True)
|
name = models.CharField(max_length=100, unique=True)
|
||||||
enabled = models.BooleanField(default=True)
|
enabled = models.BooleanField(default=True)
|
||||||
token = models.UUIDField(default=uuid.uuid4)
|
token = models.UUIDField(default=uuid.uuid4, unique=True)
|
||||||
ip_lock = models.BooleanField(default=False)
|
ip_lock = models.BooleanField(default=False)
|
||||||
ip_address = models.GenericIPAddressField(blank=True, null=True)
|
ip_address = models.GenericIPAddressField(blank=True, null=True)
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
<th>{% trans 'Name' %}</th>
|
<th>{% trans 'Name' %}</th>
|
||||||
<th>{% trans 'Status' %}</th>
|
<th>{% trans 'Status' %}</th>
|
||||||
<th>{% trans 'IP Address' %}</th>
|
<th>{% trans 'IP Address' %}</th>
|
||||||
<th>{% trans 'Location' %}</th>
|
<th><i class="fas fa-map-marker-alt" title="{% trans 'Location' %}"></i></th>
|
||||||
<th>{% trans 'Last Seen' %}</th>
|
<th><i class="far fa-clock" title="{% trans 'Last Seen' %}"></i></th>
|
||||||
<th>{% trans 'Config Version' %}</th>
|
<th><i class="fas fa-cogs" title="{% trans 'Config Version' %}"></i></th>
|
||||||
<th colspan="2">{% trans 'Options' %}</th>
|
|
||||||
<th><i class="far fa-edit"></i></th>
|
<th><i class="far fa-edit"></i></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
<td>{{ worker.name }}</td>
|
<td>{{ worker.name }}</td>
|
||||||
<td style="width: 1%; white-space: nowrap;">
|
<td style="width: 1%; white-space: nowrap;">
|
||||||
{% if worker.enabled %}
|
{% if worker.enabled %}
|
||||||
<span class="badge badge-success">{% trans 'Enabled' %}</span>
|
<i class="fas fa-check text-green"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge badge-secondary">{% trans 'Disabled' %}</span>
|
<i class="fas fa-times text-gray"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -57,26 +57,20 @@
|
|||||||
<i class="fas fa-clock text-warning" title="{% trans 'Config Pending' %}"></i>
|
<i class="fas fa-clock text-warning" title="{% trans 'Config Pending' %}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-muted">0</span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td style="width: 1%; white-space: nowrap;">
|
<td style="width: 1%; white-space: nowrap;">
|
||||||
{% if worker.force_reload %}
|
|
||||||
<i class="fas fa-sync-alt text-info" title="{% trans 'Force Reload' %}"></i>
|
<i class="fas fa-sync-alt text-info" title="{% trans 'Force Reload' %}"></i>
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td style="width: 1%; white-space: nowrap;">
|
|
||||||
{% if worker.force_restart %}
|
|
||||||
<i class="fas fa-power-off text-danger" title="{% trans 'Force Restart' %}"></i>
|
<i class="fas fa-power-off text-danger" title="{% trans 'Force Restart' %}"></i>
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td style="width: 1%; white-space: nowrap;">
|
|
||||||
<a href="/cluster/worker/manage/?uuid={{ worker.uuid }}" title="{% trans 'Edit' %}"><i class="far fa-edit"></i></a>
|
<a href="/cluster/worker/manage/?uuid={{ worker.uuid }}" title="{% trans 'Edit' %}"><i class="far fa-edit"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="9" class="text-center text-muted">{% trans 'No workers configured' %}</td>
|
<td colspan="8" class="text-center text-muted">{% trans 'No workers configured' %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user