goipam/web/templates/subnetDetails.templ

73 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

package templates
import "git.jmbit.de/jmb/goipam/db"
import "fmt"
templ SubnetDetails(metaContent MetaContent, title string, subnet *db.Subnet) {
@wrapBase(metaContent, title) {
@subnetMain(subnet)
}
}
templ subnetMain(subnet *db.Subnet) {
<div class="section is-medium">
<div class="container">
@SubnetStatic(subnet)
</div>
</div>
}
templ SubnetStatic(subnet *db.Subnet) {
<div hx-target="this" hx-swap="outerHTML">
<div class="field">
<label class="label">Subnet Name</label> { subnet.Name }
</div>
<div class="field">
<label class="label">Display Name</label> { subnet.DisplayName }
</div>
<div class="field">
<label class="label">VLAN</label> { fmt.Sprint(subnet.VLAN) }
</div>
<div class="field">
<label class="label">IPv4 Network Address</label> { subnet.IPv4Net }
</div>
<div class="field">
<label class="label">IPv6 Network Address</label> { subnet.IPv6Net }
</div>
<div class="field">
<label class="label">Location</label>
<a href={ templ.URL(fmt.Sprint("/locations/details/", subnet.LocationID)) }>
{ subnet.Location().Name }
</a>
</div>
<div class="field">
<label class="label">Comment</label> { fmt.Sprint(subnet.VLAN) }
</div>
<button hx-get={ fmt.Sprintf("/subnets/details/%d/edit.html", subnet.ID) } class="button is-primary">
Click To Edit
</button>
</div>
}
templ SubnetForm(subnet *db.Subnet) {
<form hx-post="/subnet/edit" hx-swap="outerHTML">
@formField("Name", "text", "name", subnet.Name)
@formField("Display Name", "text", "display-name", subnet.DisplayName)
@formField("VLAN", "number", "vlan", fmt.Sprint(subnet.VLAN))
@formField("IPv4 Network Address", "text", "ipv4", subnet.IPv4Net)
@formField("IPv6 Network Address", "text", "ipv6", subnet.IPv6Net)
<div class="field">
<label class="label">Location</label>
<a href={ templ.URL(fmt.Sprint("/locations/details/", subnet.LocationID)) }>
{ subnet.Location().Name }
</a>
</div>
@formField("Comment", "text", "comment", subnet.Comment)
<button class="button is-primary">Submit</button>
<button class="button is-light" hx-get={ fmt.Sprintf("/subnets/details/%d/edit.html", subnet.ID) }>Cancel</button>
</form>
}