routeros_update/templates/settings.html
Mateusz Gruszczyński 04c1e6d49a new options
2025-02-24 10:18:52 +01:00

107 lines
5.2 KiB
HTML

{% extends "base.html" %}
{% block title %}Ustawienia - RouterOS Update{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-8">
<h2 class="mb-4">Ustawienia powiadomień i systemu</h2>
<!-- Główny formularz ustawień -->
<form method="POST">
<fieldset class="border p-3 mb-3">
<legend class="w-auto">Pushover</legend>
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input" name="pushover_enabled" id="pushover_enabled" {% if settings.pushover_enabled %}checked{% endif %}>
<label class="form-check-label" for="pushover_enabled">Włącz powiadomienia Pushover</label>
</div>
<div class="mb-3">
<label for="pushover_user_key" class="form-label">Pushover User Key</label>
<input type="text" class="form-control" name="pushover_user_key" id="pushover_user_key" value="{{ settings.pushover_user_key or '' }}">
</div>
<div class="mb-3">
<label for="pushover_token" class="form-label">Pushover Token</label>
<input type="text" class="form-control" name="pushover_token" id="pushover_token" value="{{ settings.pushover_token or '' }}">
</div>
</fieldset>
<fieldset class="border p-3 mb-3">
<legend class="w-auto">SMTP (E-mail)</legend>
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input" name="email_notifications_enabled" id="email_notifications_enabled" {% if settings.email_notifications_enabled %}checked{% endif %}>
<label class="form-check-label" for="email_notifications_enabled">Włącz powiadomienia e-mail</label>
</div>
<div class="mb-3">
<label for="smtp_server" class="form-label">SMTP Server</label>
<input type="text" class="form-control" name="smtp_server" id="smtp_server" value="{{ settings.smtp_server or '' }}">
</div>
<div class="mb-3">
<label for="smtp_port" class="form-label">SMTP Port</label>
<input type="number" class="form-control" name="smtp_port" id="smtp_port" value="{{ settings.smtp_port or '' }}">
</div>
<div class="mb-3">
<label for="smtp_username" class="form-label">SMTP Username</label>
<input type="text" class="form-control" name="smtp_username" id="smtp_username" value="{{ settings.smtp_username or '' }}">
</div>
<div class="mb-3">
<label for="smtp_password" class="form-label">SMTP Password</label>
<input type="password" class="form-control" name="smtp_password" id="smtp_password" value="{{ settings.smtp_password or '' }}">
</div>
</fieldset>
<fieldset class="border p-3 mb-3">
<legend class="w-auto">E-mail odbiorcy powiadomień</legend>
<div class="mb-3">
<label for="recipient_email" class="form-label">Adres e-mail do otrzymywania powiadomień</label>
<input type="email" class="form-control" name="recipient_email" id="recipient_email" value="{{ settings.recipient_email or '' }}">
</div>
</fieldset>
<fieldset class="border p-3 mb-3">
<legend class="w-auto">Interwał sprawdzania</legend>
<div class="mb-3">
<label for="check_interval" class="form-label">Interwał (sekundy) <code>21600 = 6 godzin</code></label>
<input type="number" class="form-control" name="check_interval" id="check_interval" value="{{ settings.check_interval or 21600 }}">
</div>
<div class="mb-3">
<label for="time_input" class="form-label">Czas (HH:MM:SS)</label>
<input type="text" class="form-control" id="time_input" placeholder="np. 01:30:00">
<button type="button" class="btn btn-secondary mt-2" onclick="convertTime()">Konwertuj na sekundy</button>
</div>
</fieldset>
<fieldset class="border p-3 mb-3">
<legend class="w-auto">Retencja logów</legend>
<div class="mb-3">
<label for="log_retention_days" class="form-label">Przechowywać logi przez (dni)</label>
<input type="number" class="form-control" name="log_retention_days" id="log_retention_days" value="{{ settings.log_retention_days or 30 }}">
</div>
</fieldset>
<button type="submit" class="btn btn-primary">Zapisz ustawienia</button>
</form>
<!-- Przyciski testowe w osobnym bloku, ułożone w jednej linii po prawej stronie -->
<div class="mt-4">
<div class="d-flex justify-content-end">
<form method="POST" action="{{ url_for('test_pushover') }}" class="d-inline me-2">
<button type="submit" class="btn btn-secondary">Test Pushover</button>
</form>
<form method="POST" action="{{ url_for('test_email') }}" class="d-inline">
<button type="submit" class="btn btn-secondary">Test E-mail</button>
</form>
</div>
</div>
</div>
</div>
<script>
function convertTime() {
var timeStr = document.getElementById("time_input").value;
var parts = timeStr.split(':');
if (parts.length !== 3) {
alert("Podaj czas w formacie HH:MM:SS");
return;
}
var seconds = parseInt(parts[0]) * 3600 + parseInt(parts[1]) * 60 + parseInt(parts[2]);
document.getElementById("check_interval").value = seconds;
}
</script>
{% endblock %}