wireplanner/templates/_port_list.html

35 lines
1.7 KiB
HTML

{{define "port_list"}}
<div class="ports">
<div class="port-column">
<h5>Front</h5>
{{range .Device.Ports}}{{if eq .Side "front"}}
{{$pid := .ID}}
{{$color := "#333"}}{{$bg := ""}}
{{range $.Connections}}{{if and .Port1 .Port2}}{{if eq .Port1.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{else if eq .Port2.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{end}}{{end}}{{end}}
<span class="port {{if ne $bg ""}}connected{{end}}"
style="{{if ne $bg ""}}border-color:{{$color}};background:{{$color}}22{{end}}"
data-port-id="{{.ID}}"
onclick="if(!connectMode){openModal();htmx.ajax('GET','/connections/{{.ID}}',{target:'#modal-content',swap:'innerHTML'});}else{portClick(this,{{.ID}},event);}"
title="{{.Name}}">
{{.Name}}
</span>
{{end}}{{end}}
</div>
<div class="port-column">
<h5>Back</h5>
{{range .Device.Ports}}{{if eq .Side "back"}}
{{$pid := .ID}}
{{$color := "#333"}}{{$bg := ""}}
{{range $.Connections}}{{if and .Port1 .Port2}}{{if eq .Port1.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{else if eq .Port2.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{end}}{{end}}{{end}}
<span class="port {{if ne $bg ""}}connected{{end}}"
style="{{if ne $bg ""}}border-color:{{$color}};background:{{$color}}22{{end}}"
data-port-id="{{.ID}}"
onclick="if(!connectMode){openModal();htmx.ajax('GET','/connections/{{.ID}}',{target:'#modal-content',swap:'innerHTML'});}else{portClick(this,{{.ID}},event);}"
title="{{.Name}}">
{{.Name}}
</span>
{{end}}{{end}}
</div>
</div>
{{end}}