goipam/web/templates/subnets.templ

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-02-23 11:22:28 +01:00
package templates
import "git.jmbit.de/jmb/goipam/db"
import "fmt"
templ SubnetsPage(metaContent MetaContent, subnets []db.Subnet, err error) {
2024-02-23 11:22:28 +01:00
@wrapBase(metaContent, "Subnets", err) {
<div class="section is-centered">
<div class="container">
@subnetsTable(subnets)
</div>
</div>
}
}
templ subnetsTable(subnets []db.Subnet) {
<div class="section is-centered">
<h2 class="title">Subnets</h2>
<div class="table-container">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Display Name</th>
<th><abbr title="Virtual LAN ID">VLAN</abbr></th>
<th><abbr title="IPv4 Address">IPv4</abbr></th>
<th><abbr title="IPv6 Address">IPv6</abbr></th>
<th>Location</th>
<th>Comment</th>
</tr>
</thead>
<tbody id="search-results"></tbody>
</table>
</div>
</div>
}
templ subnetsTableRows(subnets []db.Subnet) {
for _, subnet := range subnets {
<tr hx-get={ fmt.Sprintf("/subnets/details/%d", subnet.ID) }>
<td>{ fmt.Sprint(subnet.ID) }</td>
<td>{ subnet.Name }</td>
<td>{ subnet.DisplayName }</td>
<td>{ fmt.Sprint(subnet.VLAN) }</td>
<td>{ subnet.IPv4Net }</td>
<td>{ subnet.IPv6Net }</td>
<td hx-get={ fmt.Sprintf("/locations/details/%d", subnet.LocationID) }>{ subnet.Location().Name }</td>
<td>{ subnet.Comment }</td>
</tr>
}
}