1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00
webvirtcloud/vmbackups/templates/vmbackups/target.html
catborise 4881c3cd3e fix(ui): forms ask one thing at a time, offer the host's pools and say less twice
- A backup schedule asks Which VMs first (a compute's, chosen VMs or a
  tag's) and shows that one field only (policy_scope.js); the other two
  are not read, so a choice left in them is neither saved nor an error.
- A backup target's, a restore's and a disk restore's storage pool
  field offers the chosen compute's active file pools, the ones a
  restore copies into (a target's: directory and NFS only), from
  vmbackups.views.pools, which reads them without a refresh
  (pool_choices.js); a name can still be typed and is checked as before.
- A field's label is no longer repeated inside it as a placeholder, and
  a list's empty choice says Choose… instead of Django's dashes
  (webvirtcloud.bootstrap.FieldRenderer).
- The schedule, target, e-mail OTP and VM delete forms put Cancel and
  their main button at the right, as the other forms do.
2026-11-22 00:25:53 +03:00

78 lines
4.2 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load bootstrap_icons %}
{% load django_bootstrap5 %}
{% load operations %}
{% block title %}{{ target.name }} - {% trans "Backup targets" %}{% endblock %}
{% block page_heading %}<a href="{% url 'vmbackups:targets' %}">{% trans "Backup targets" %}</a> / {{ target.name }}{% endblock page_heading %}
{% block content %}
<div class="d-flex flex-wrap align-items-center gap-2 mb-3">
<span class="text-body-secondary me-auto">{% blocktrans count counter=backup_count %}{{ counter }} backup.{% plural %}{{ counter }} backups.{% endblocktrans %}
{% if target.owners %}{% trans "VM owners with the backup permission may use it." %}{% else %}{% trans "Only superusers use it." %}{% endif %}</span>
<form method="post">
{% csrf_token %}
<button type="submit" name="owners" value="{% if target.owners %}0{% else %}1{% endif %}" class="btn btn-sm btn-outline-secondary">{% if target.owners %}{% trans "Close to VM owners" %}{% else %}{% trans "Open to VM owners" %}{% endif %}</button>
</form>
{% if pools %}
<form method="post">
{% csrf_token %}{% submission_key %}
<button type="submit" name="import" value="1" class="btn btn-sm btn-outline-primary"
title="{% trans "Adds the backups whose manifest is in the target and that the panel does not list, as after its database was lost." %}">{% bs_icon 'download' %} {% trans "Read backups from target" %}</button>
</form>
{% endif %}
</div>
<div class="row row-cols-1 row-cols-md-2 g-3 mb-4">
{% for item in pools %}
<div class="col">
<div class="card h-100">
<div class="card-header d-flex flex-wrap align-items-center gap-2">
<span class="fw-semibold me-auto text-break">{{ item.row.compute.name }}: {{ item.row.pool }}</span>
{% if not backup_count %}
<form method="post">
{% csrf_token %}
<button type="submit" name="remove_pool" value="{{ item.row.id }}" class="btn btn-sm btn-outline-danger"
data-confirm="{% trans "Remove this storage pool from the target? The pool and its files stay on the host." %}">{% trans "Remove" %}</button>
</form>
{% endif %}
</div>
<div class="card-body">
{% if item.error %}
<div class="text-danger small">{% bs_icon 'exclamation-triangle' %} {{ item.error }}</div>
{% else %}
{% include "computes/pool_bar.html" with pool=item.space hide_name=True %}
{% if item.inside %}
<div class="alert alert-warning small mt-2 mb-0">{% blocktrans with pool=item.inside %}The target is inside storage pool {{ pool }}: its backups are lost with that storage.{% endblocktrans %}</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="card mb-4" style="max-width: 40rem;">
<div class="card-header fw-semibold">{% trans "Add a compute's storage pool" %}</div>
<div class="card-body">
<p class="small text-body-secondary">{% trans "The pool must be the same directory as the target's other pools, as an NFS share mounted on each host." %}</p>
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
<button type="submit" name="add_pool" value="1" class="btn btn-primary">{% bs_icon 'plus' %} {% trans "Add" %}</button>
</form>
</div>
</div>
{% if not backup_count %}
<form method="post">
{% csrf_token %}
<button type="submit" name="delete" value="1" class="btn btn-outline-danger"
data-confirm="{% trans "Delete this backup target? Its storage pools stay on the hosts." %}">{% bs_icon 'trash' %} {% trans "Delete target" %}</button>
</form>
{% endif %}
{% endblock %}
{% block script %}<script src="{% static 'vmbackups/pool_choices.js' %}"></script>{% endblock %}