Files
MeshTender/internal/web/templates/org_config.html
T
2026-07-02 11:23:03 -04:00

97 lines
4.2 KiB
HTML

{{define "title"}}Configuration · {{.Org.Name}} · MeshTender{{end}}
{{define "header"}}
<div class="row g-2 align-items-center">
<div class="col">
<div class="page-pretitle">{{.Org.Name}}</div>
<h2 class="page-title">Recommended Configuration</h2>
</div>
{{if .CanEdit}}
<div class="col-auto ms-auto d-print-none">
<a class="btn" href="/orgs/{{.Org.Slug}}/config/edit">{{template "icon-pencil" "me-1"}}Edit</a>
</div>
{{end}}
</div>
{{end}}
{{define "content"}}
{{template "org-tabs" .Nav}}
{{if not .Config.HasConfig}}
<div class="card"><div class="card-body text-secondary">
This organization hasn't defined any configuration yet.{{if .CanEdit}} Use <strong>Edit</strong> to add a profile or region.{{end}}
</div></div>
{{else}}
<div class="row row-cards">
<!-- Main: selected profile's base settings + regions (only what's defined) -->
<div class="col-lg-8">
{{if .Config.Profiles}}
<div class="card">
<div class="card-header"><h3 class="card-title">{{.Config.Selected}} · base settings</h3></div>
<div class="card-body">{{template "step-list" .Config.SelectedSteps}}</div>
</div>
{{end}}
{{if .Config.PreviewActive}}
<div class="card{{if .Config.Profiles}} mt-3{{end}}">
<div class="card-header"><h3 class="card-title">Regions</h3></div>
{{if .Config.RegionDef}}
<div class="card-body"><pre class="mb-0"><code>{{range .Config.RegionDef}}{{.}}
{{end}}</code></pre></div>
{{else}}
<div class="card-body text-secondary">No regions cover this location.</div>
{{end}}
</div>
{{end}}
</div>
<!-- Sidebar: profile selector (if profiles) + a click-to-preview location map -->
<div class="col-lg-4">
{{if .Config.Profiles}}
<div class="card">
<div class="card-header"><h3 class="card-title">Profile</h3></div>
<div class="card-body">
<form method="get" action="/orgs/{{.Org.Slug}}/config">
<select class="form-select" name="profile" aria-label="Choose a configuration profile" data-autosubmit>
{{range .Config.Profiles}}<option value="{{.Name}}"{{if eq .Name $.Config.Selected}} selected{{end}}>{{.Name}}</option>{{end}}
</select>
{{if .PreviewLat}}<input type="hidden" name="lat" value="{{.PreviewLat}}">{{end}}
{{if .PreviewLon}}<input type="hidden" name="lon" value="{{.PreviewLon}}">{{end}}
</form>
<p class="text-secondary small mt-2 mb-0">
Pick the profile matching your hardware to see its base settings.{{if .Config.HasRegions}} A repeater's regions are assigned separately, by location.{{end}}
</p>
</div>
</div>
{{end}}
{{if .Config.HasRegionShapes}}
<div class="card{{if .Config.Profiles}} mt-3{{end}}">
<div class="card-header"><h3 class="card-title">Preview a location</h3></div>
<div class="card-body p-2">
<link rel="stylesheet" href="/static/leaflet.css">
<div id="region-map" style="height:240px" role="region" aria-label="Click the map to preview a repeater's region config"></div>
<script src="/static/leaflet.js"></script>
<script src="/static/regionmap.js"></script>
<script nonce="{{.Nonce}}">
regionMapView('region-map', {
pickURL: '/orgs/{{.Org.Slug}}/config?{{if .Config.Profiles}}profile={{.Config.Selected | urlquery}}&{{end}}',
{{if .Config.PreviewActive}}preview: {lat: {{.PreviewLat}}, lon: {{.PreviewLon}}},{{end}}
{{if .Config.MapBounds}}bounds: [[{{index .Config.MapBounds 0}}, {{index .Config.MapBounds 1}}], [{{index .Config.MapBounds 2}}, {{index .Config.MapBounds 3}}]]{{end}}
});
</script>
{{if .Config.PreviewActive}}
<div class="text-secondary small mt-2 text-center">{{template "icon-map-pin" "me-1"}}<span class="font-monospace">{{.PreviewLat}}, {{.PreviewLon}}</span></div>
{{end}}
</div>
</div>
{{end}}
</div>
</div>
{{end}}
{{end}}
{{/* step-list renders a sequence of ConfigStep as a copy-pasteable block. */}}
{{define "step-list"}}
{{if .}}<pre class="mb-0"><code>{{range .}}{{if .IsComment}}# {{.Comment}}{{else}}{{.CommandLine}}{{end}}
{{end}}</code></pre>{{else}}<div class="text-secondary">No steps.</div>{{end}}
{{end}}