1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(appsettings): the Settings page groups its settings and saves a group at once

The page listed 37 settings by name, each its own form saved as soon as
its list or field changed, with the description only in a tooltip. It
now shows them in groups (New VM defaults, Disks, Clones, Console, VM
access and owners, Snapshots and jobs, Login, Lists and pages) with each
description under its field and the label tied to it. A group's Save
button saves its changed settings, or none when one is refused, and
says which were saved; number settings are number fields with their
range. Language and theme are under Appearance with their own buttons.
A setting in no group shows under Other.
This commit is contained in:
catborise 2026-10-25 21:50:27 +03:00
parent 0e3708d182
commit 3fa2ca4b70
3 changed files with 157 additions and 76 deletions

View file

@ -6,60 +6,70 @@
{% block page_heading %}{% trans "Edit Settings" %}{% endblock page_heading %}
{% block content %}
<div class="">
<div class="col-lg-12">
<h3 class="page-header">{% trans "App Settings" %}</h3>
<form action="{% url 'set_language' %}" method="post" style="display:inline" aria-label="Edit language.name_local settings form">{% csrf_token %}
<div class="row mb-1">
<input name="next" type="hidden" value="{{ redirect_to }}">
<label class="col-sm-3 col-form-label" for="language">{% trans "Language" %}</label>
<section class="card mb-3" aria-labelledby="appearance-heading">
<div class="card-body">
<h2 class="h5 card-title" id="appearance-heading">{% trans "Appearance" %}</h2>
<form action="{% url 'set_language' %}" method="post" class="row g-2 mb-3 align-items-start">{% csrf_token %}
<label class="col-sm-4 col-form-label" for="language">{% trans "Language" %}</label>
<div class="col-sm-6">
<select id="language" name="language" class="form-select" aria-describedby="language-help">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>{{ language.name_local }} ({{ language.code }})</option>
{% endfor %}
</select>
<div id="language-help" class="form-text">{% trans "Yours only, in this browser" %}</div>
</div>
<div class="col-sm-2"><button type="submit" class="btn btn-outline-primary w-100">{% trans "Change" %}</button></div>
</form>
<form method="post" class="row g-2 align-items-start">{% csrf_token %}
<label class="col-sm-4 col-form-label" for="theme">{% trans bootstrap_theme.name %}</label>
<div class="col-sm-6">
<select id="theme" class="form-select" name="{{ bootstrap_theme.key }}" aria-describedby="theme-help">
{% for theme in themes_list %}
<option value="{{ theme }}"{% if bootstrap_theme.value == theme %} selected{% endif %}>{{ theme }}</option>
{% endfor %}
</select>
<div id="theme-help" class="form-text">{% trans "For every user" %}</div>
</div>
<div class="col-sm-2"><button type="submit" class="btn btn-outline-primary w-100">{% trans "Change" %}</button></div>
</form>
</div>
</section>
{% for title, settings in groups %}
<section class="card mb-3" aria-labelledby="group-{{ forloop.counter }}">
<div class="card-body">
<form method="post">{% csrf_token %}
<h2 class="h5 card-title mb-3" id="group-{{ forloop.counter }}">{% trans title %}</h2>
{% for setting in settings %}
<div class="row g-2 mb-3">
<label class="col-sm-4 col-form-label" for="setting-{{ setting.key }}">{% trans setting.name %}</label>
<div class="col-sm-6">
<select id="language" name="language" class="form-control" onchange="this.form.submit()">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% if setting.choices %}
<select id="setting-{{ setting.key }}" class="form-select" name="{{ setting.key }}" aria-describedby="help-{{ setting.key }}">
{% for choice in setting.choices_as_list %}
<option value="{{ choice }}"{% if setting.value == choice %} selected{% endif %}>{% trans choice %}</option>
{% endfor %}
</select>
{% elif setting.bounds %}
<input id="setting-{{ setting.key }}" class="form-control" type="number" name="{{ setting.key }}" value="{{ setting.value }}"
min="{{ setting.bounds.0 }}" max="{{ setting.bounds.1 }}" step="1" required aria-describedby="help-{{ setting.key }}">
{% else %}
<input id="setting-{{ setting.key }}" class="form-control" type="text" name="{{ setting.key }}" value="{{ setting.value }}"
maxlength="25" aria-describedby="help-{{ setting.key }}">
{% endif %}
<div id="help-{{ setting.key }}" class="form-text">{% trans setting.description %}</div>
</div>
</div>
</form>
{% if request.user.is_superuser %}
<form method="post" action="" role="form" aria-label="Edit theme settings form">{% csrf_token %}
<div class="row mb-1">
<label class="col-sm-3 col-form-label">{% trans bootstrap_theme.name %}</label>
<div class="col-sm-6">
<select class="form-select" name="{{ bootstrap_theme.key }}" onchange="this.form.submit()" title="{% trans bootstrap_theme.description %}">
{% for theme in themes_list %}
<option {% if bootstrap_theme.value == theme %}selected{% endif %} value="{{ theme }}">{{ theme }}</option>
{% endfor %}
</select>
</div>
{% endfor %}
<div class="text-end">
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
</div>
</form>
{% endif %}
<h3 class="page-header">{% trans "Other Settings" %}</h3>
{% for setting in appsettings %}
<form method="post" action="" role="form" aria-label="{{setting.name}} form">{% csrf_token %}
<div class="row mb-1">
<label class="col-sm-3 col-form-label">{% trans setting.name %}</label>
<div class="col-sm-6">
{% if setting.choices %}
<select class="form-select" name="{{ setting.key }}" onchange="this.form.submit()" title="{% trans setting.description %}">
{% for choice in setting.choices_as_list %}
<option {% if setting.value == choice %} selected {% endif %} value="{{ choice }}">{% trans choice %}</option>
{% endfor %}
</select>
{% else %}
<input class="form-control" name="{{ setting.key }}" value="{{ setting.value }}" title="{% trans setting.description %}" onchange="this.form.submit()"/>
{% endif%}
</div>
</div>
</form>
{% endfor %}
</div>
</div>
</section>
{% endfor %}
{% endblock %}