Files
mikromon/templates/devices/new.html
Mateusz Gruszczyński 7b8a81dc3b changes
2026-03-06 10:06:14 +01:00

99 lines
3.5 KiB
HTML

{% extends "base.html" %}
{% block title %}New device - MikroMon{% endblock %}
{% block content %}
<div class="d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2">
<div>
<h1 class="h3 mb-0">Add device</h1>
<div class="text-muted">Configure RouterOS REST access</div>
</div>
<a class="btn btn-outline-secondary" href="{{ url_for('devices.index') }}"><i class="fa-solid fa-arrow-left me-1"></i>Back</a>
</div>
<div class="row g-3">
<div class="col-12 col-lg-7">
<div class="card shadow-sm">
<div class="card-body">
<form method="post" novalidate>
{{ form.hidden_tag() }}
<div class="row g-3">
<div class="col-12">
<label class="form-label">Name</label>
{{ form.name(class_="form-control", placeholder="e.g. MikroTik RB4011") }}
</div>
<div class="col-12">
<label class="form-label">Host</label>
{{ form.host(class_="form-control", placeholder="192.168.1.1 or router.example.com") }}
</div>
<div class="col-12 col-md-4">
<label class="form-label">Protocol</label>
{{ form.rest_scheme(class_="form-select", id="restScheme") }}
</div>
<div class="col-12 col-md-4">
<label class="form-label">REST port</label>
{{ form.rest_port(class_="form-control", id="restPort") }}
</div>
<div class="col-12 col-md-4">
<label class="form-label">REST base path</label>
{{ form.rest_base_path(class_="form-control", placeholder="/rest") }}
</div>
<div class="col-12 col-md-6">
<label class="form-label">Username</label>
{{ form.username(class_="form-control") }}
</div>
<div class="col-12 col-md-6">
<label class="form-label">Password</label>
{{ form.password(class_="form-control", placeholder="••••••••") }}
</div>
<div class="col-12" id="tlsRow">
<div class="form-check">
{{ form.allow_insecure_tls(class_="form-check-input") }}
<label class="form-check-label">Allow insecure TLS (self-signed)</label>
</div>
</div>
</div>
<hr class="my-3">
<button class="btn btn-primary" type="submit"><i class="fa-solid fa-plus me-1"></i>Save</button>
</form>
</div>
</div>
</div>
<div class="col-12 col-lg-5">
<div class="card shadow-sm">
<div class="card-body">
<div class="fw-semibold mb-2"><i class="fa-solid fa-circle-info me-2"></i>Tips</div>
<ul class="small mb-0">
<li>Use HTTPS for encrypted RouterOS REST.</li>
<li>Use HTTP only for local trusted networks when needed.</li>
<li>Default path is <code>/rest</code>.</li>
</ul>
</div>
</div>
</div>
</div>
<script>
(function(){
const scheme=document.getElementById('restScheme');
const port=document.getElementById('restPort');
const tlsRow=document.getElementById('tlsRow');
function sync(){
const isHttps=(scheme.value||'https')==='https';
tlsRow.style.display=isHttps?'':'none';
if(!port.value || port.dataset.autofill==='1'){
port.value=isHttps?'443':'80';
port.dataset.autofill='1';
}
}
port.addEventListener('input', ()=>{ port.dataset.autofill='0'; });
scheme.addEventListener('change', sync);
sync();
})();
</script>
{% endblock %}