Files
MeshTender/internal/core/templates/edit_repeater.html
T

83 lines
4.3 KiB
HTML

{{define "title"}}Edit {{.Repeater.Name}} · MeshTender{{end}}
{{define "header"}}
<div class="row g-2 align-items-center">
<div class="col">
<div class="page-pretitle">Edit repeater</div>
<h2 class="page-title">{{.Repeater.Name}}</h2>
</div>
</div>
{{end}}
{{define "content"}}
{{if .Error}}<div class="alert alert-danger">{{.Error}}</div>{{end}}
<div class="card">
<div class="card-body">
<p class="text-secondary">The public key identifies the repeater and can't be changed — delete and re-add to change it.</p>
<code class="pk">{{.Repeater.PublicKeyHex}}</code>
<form method="post" action="/repeaters/{{.Repeater.PublicID}}/edit" class="mt-3">
<div class="mb-3">
<label class="form-label" for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" value="{{.Repeater.Name}}" required>
</div>
<div class="mb-3">
<label class="form-label" for="region">Region preset</label>
<select class="form-select" id="region" onchange="applyRegion()">
{{range .Presets}}
<option value="{{.ID}}" data-freq="{{.FreqHz}}" data-bw="{{.BwHz}}" data-sf="{{.SF}}" data-cr="{{.CR}}"{{if eq .ID $.SelectedPreset}} selected{{end}}>{{.Label}}</option>
{{end}}
<option value="custom"{{if eq "custom" $.SelectedPreset}} selected{{end}}>Custom…</option>
</select>
</div>
<div class="row g-2">
<div class="col-6 col-md-3"><label class="form-label" for="radio_freq_hz">Freq (Hz)</label><input type="number" class="form-control" id="radio_freq_hz" name="radio_freq_hz" value="{{.Repeater.RadioFreqHz}}" required></div>
<div class="col-6 col-md-3"><label class="form-label" for="radio_bw_hz">Bandwidth (Hz)</label><input type="number" class="form-control" id="radio_bw_hz" name="radio_bw_hz" value="{{.Repeater.RadioBwHz}}" required></div>
<div class="col-6 col-md-3"><label class="form-label" for="radio_sf">SF</label><input type="number" class="form-control" id="radio_sf" name="radio_sf" value="{{.Repeater.RadioSF}}" min="5" max="12" required></div>
<div class="col-6 col-md-3"><label class="form-label" for="radio_cr">CR</label><input type="number" class="form-control" id="radio_cr" name="radio_cr" value="{{.Repeater.RadioCR}}" min="5" max="8" required></div>
</div>
<label class="form-check mt-3">
<input class="form-check-input" type="checkbox" name="store_location" id="store_location" value="1"{{if .Repeater.StoreLocation}} checked{{end}} onchange="syncPublicMap()">
<span class="form-check-label">Store this repeater's location (lat/lon), fetched during the modem test, so it can appear on
organization maps. Unchecking this also clears any stored coordinates.</span>
</label>
<label class="form-check" id="public_map_row"{{if not .Repeater.StoreLocation}} style="display:none"{{end}}>
<input class="form-check-input" type="checkbox" name="public_map" value="1"{{if .Repeater.PublicMap}} checked{{end}}>
<span class="form-check-label">Also show this repeater on the <strong>public</strong> organization map (visible to anyone, signed in or not).</span>
</label>
<div class="btn-list mt-3">
<button type="submit" class="btn btn-primary">Save changes</button>
<a class="btn" href="/">Cancel</a>
</div>
</form>
{{template "revokedoc" .RevokeCommand}}
</div>
</div>
<script>
function applyRegion() {
var sel = document.getElementById("region");
var opt = sel.options[sel.selectedIndex];
var fields = ["radio_freq_hz", "radio_bw_hz", "radio_sf", "radio_cr"].map(function (id) {
return document.getElementById(id);
});
if (opt.dataset.freq) {
fields[0].value = opt.dataset.freq;
fields[1].value = opt.dataset.bw;
fields[2].value = opt.dataset.sf;
fields[3].value = opt.dataset.cr;
fields.forEach(function (el) { el.readOnly = true; });
} else {
fields.forEach(function (el) { el.readOnly = false; });
}
}
function syncPublicMap() {
var on = document.getElementById("store_location").checked;
document.getElementById("public_map_row").style.display = on ? "" : "none";
if (!on) document.querySelector("#public_map_row input").checked = false;
}
applyRegion();
syncPublicMap();
</script>
{{end}}