This commit is contained in:
root
2025-02-22 22:33:36 +01:00
commit 7807157052
23 changed files with 2510 additions and 0 deletions

View File

@ -0,0 +1,114 @@
{% extends "base.html" %}
{% block content %}
<div class="container mt-5">
<div class="card shadow-sm">
<div class="card-header">
<h2 class="mb-0">Zaawansowane ustawienia harmonogramu</h2>
</div>
<div class="card-body">
<form action="{{ url_for('advanced_schedule') }}" method="POST">
<div class="mb-3">
<label for="retention_cron" class="form-label">Harmonogram retencji (cron)</label>
<div class="input-group">
<input type="text" class="form-control" id="retention_cron" name="retention_cron" value="{{ settings.retention_cron }}">
<button type="button" class="btn btn-outline-secondary" onclick="openCronModal('retention_cron')">Generuj cron</button>
</div>
<div class="form-text">Np. <code>0 */12 * * *</code> co 12 godzin</div>
</div>
<div class="mb-3">
<label for="binary_cron" class="form-label">Harmonogram kopii zapasowych binarnych (cron)</label>
<div class="input-group">
<input type="text" class="form-control" id="binary_cron" name="binary_cron" value="{{ settings.binary_cron|default('') }}">
<button type="button" class="btn btn-outline-secondary" onclick="openCronModal('binary_cron')">Generuj cron</button>
</div>
<div class="form-text">Np. <code>15 2 * * *</code> codziennie o 2:15</div>
</div>
<div class="mb-3">
<label for="export_cron" class="form-label">Harmonogram eksportów (cron)</label>
<div class="input-group">
<input type="text" class="form-control" id="export_cron" name="export_cron" value="{{ settings.export_cron }}">
<button type="button" class="btn btn-outline-secondary" onclick="openCronModal('export_cron')">Generuj cron</button>
</div>
<div class="form-text">Np. <code>0 */12 * * *</code> co 12 godzin</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="enable_auto_export" name="enable_auto_export" {% if settings.enable_auto_export %}checked{% endif %}>
<label class="form-check-label" for="enable_auto_export">Włącz automatyczny eksport</label>
</div>
<button type="submit" class="btn btn-primary">Zapisz ustawienia</button>
</form>
</div>
</div>
</div>
<!-- Modal do generowania wyrażenia CRON -->
<div class="modal fade" id="cronModal" tabindex="-1" aria-labelledby="cronModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="cronModalLabel">Generuj wyrażenie CRON</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Zamknij"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="cron_minute" class="form-label">Minuta</label>
<input type="text" class="form-control" id="cron_minute" placeholder="0-59">
</div>
<div class="mb-3">
<label for="cron_hour" class="form-label">Godzina</label>
<input type="text" class="form-control" id="cron_hour" placeholder="0-23">
</div>
<div class="mb-3">
<label for="cron_day" class="form-label">Dzień miesiąca</label>
<input type="text" class="form-control" id="cron_day" placeholder="1-31 lub *">
</div>
<div class="mb-3">
<label for="cron_month" class="form-label">Miesiąc</label>
<input type="text" class="form-control" id="cron_month" placeholder="1-12 lub *">
</div>
<div class="mb-3">
<label for="cron_dow" class="form-label">Dzień tygodnia</label>
<input type="text" class="form-control" id="cron_dow" placeholder="0-6 (0 = niedziela) lub *">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Anuluj</button>
<button type="button" class="btn btn-primary" onclick="generateCronExpression()">Generuj</button>
</div>
</div>
</div>
</div>
<script>
// Zmienna przechowująca ID pola, do którego ma być wpisane wyrażenie cron
var targetCronField = '';
function openCronModal(fieldId) {
targetCronField = fieldId;
// Wyzeruj wartości w modalu
document.getElementById('cron_minute').value = '*';
document.getElementById('cron_hour').value = '*';
document.getElementById('cron_day').value = '*';
document.getElementById('cron_month').value = '*';
document.getElementById('cron_dow').value = '*';
// Otwórz modal (przy użyciu Bootstrap 5)
var cronModal = new bootstrap.Modal(document.getElementById('cronModal'));
cronModal.show();
}
function generateCronExpression() {
var minute = document.getElementById('cron_minute').value || '*';
var hour = document.getElementById('cron_hour').value || '*';
var day = document.getElementById('cron_day').value || '*';
var month = document.getElementById('cron_month').value || '*';
var dow = document.getElementById('cron_dow').value || '*';
var cronExpr = minute + ' ' + hour + ' ' + day + ' ' + month + ' ' + dow;
document.getElementById(targetCronField).value = cronExpr;
// Zamknij modal
var modalEl = document.getElementById('cronModal');
var modalInstance = bootstrap.Modal.getInstance(modalEl);
modalInstance.hide();
}
</script>
{% endblock %}