Mini Shell
{# vim: ts=2:sw=2:et:ft=jinja-html #}
{% from "bootstrap_macros.html.jinja" import header_card, header_input_group, checkbox without context %}
{% macro snapshot_radio(radio_name, snapshot_id, checked, date, paths='') %}
<div class="form-check">
<input class="form-check-input" data-date="{{ date }}" value="{{ snapshot_id }}" type="radio" name="{{ radio_name }}" {% if checked %}checked{% endif %} >
<label class="form-check-label">
{{ date }}
{% if paths %}
<span class="text-truncate">{{ paths | join(', ') }}</span>
{% endif %}
</label>
</div>
{% endmacro %}
{% if not backups %}
<div class="alert alert-warning" role="alert">
No completed backups found.
</div>
{% else %}
{% if 'files' in backups %}
<div class="mt-3">
{% call header_card("Files") %}
{% for backup in backups['files'] %}
{{ snapshot_radio("files-snapshot", backup.id, loop.first, backup.datetime.strftime("%d/%m/%y %I%p"), backup.paths) }}
{% endfor %}
{% call header_input_group("Restore Paths", 'Full path(s) in the snapshot to restore. Specify "/" to restore everything the snapshot contains.', group_class="mt-3") %}
<textarea id="files-restore-include" class="form-control">/</textarea>
{% endcall %}
{% call header_input_group("Destination", 'Full root path to restore to. Specify "/" to restore files to their original locations.', group_class="mt-3 mb-3") %}
<input id="files-restore-destination" type="text" value="/" />
{% endcall %}
<div id="files-restore-alert" class="alert d-none" role="alert" style="white-space: pre; overflow: auto"></div>
<button onclick="restore_files()" class="btn btn-primary">Restore</button>
{% endcall %}
</div>
{% endif %}
{% for task, label in (('mysql', 'MySQL'), ('pgsql', 'PgSQL')) %}
{% if task in backups %}
<div class="mt-3">
{% call header_card(label) %}
{% for backup in backups[task] %}
{{ snapshot_radio("{}-snapshot".format(task), backup.id, loop.first, backup.datetime.strftime("%d/%m/%y %I%p")) }}
{% endfor %}
{{ checkbox('{}-compress'.format(task), "gzip compress", checked=False, form_class="mb-3", onclick="compress_changed(this, '{}-restore-destination');".format(task)) }}
{% call header_input_group("Destination", 'Full file path to restore to.', group_class="mt-3 mb-3") %}
<input id="{{ task }}-restore-destination" type="text" value="/root/{{ task }}.sql" />
{% endcall %}
<div id="{{ task }}-restore-alert" class="alert d-none" role="alert" style="white-space: pre; overflow: auto"></div>
<button onclick="restore_db('{{ task }}')" class="btn btn-primary">Restore</button>
{% endcall %}
</div>
{% endif %}
{% endfor %}
{% endif %}
Zerion Mini Shell 1.0