232 lines
		
	
	
	
		
			9.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			232 lines
		
	
	
	
		
			9.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by templ - DO NOT EDIT.
 | |
| 
 | |
| // templ: version: v0.2.543
 | |
| package templates
 | |
| 
 | |
| //lint:file-ignore SA4006 This context is only used if a nested component is present.
 | |
| 
 | |
| import "github.com/a-h/templ"
 | |
| import "context"
 | |
| import "io"
 | |
| import "bytes"
 | |
| 
 | |
| import "git.jmbit.de/jmb/goipam/utils"
 | |
| import "git.jmbit.de/jmb/goipam/db"
 | |
| import "fmt"
 | |
| 
 | |
| func SubnetsPage(metaContent utils.MetaContent, subnets []db.Subnet, err error) templ.Component {
 | |
| 	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 | |
| 		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			templ_7745c5c3_Buffer = templ.GetBuffer()
 | |
| 			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 | |
| 		}
 | |
| 		ctx = templ.InitializeContext(ctx)
 | |
| 		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
 | |
| 		if templ_7745c5c3_Var1 == nil {
 | |
| 			templ_7745c5c3_Var1 = templ.NopComponent
 | |
| 		}
 | |
| 		ctx = templ.ClearChildren(ctx)
 | |
| 		templ_7745c5c3_Var2 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 | |
| 			templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 | |
| 			if !templ_7745c5c3_IsBuffer {
 | |
| 				templ_7745c5c3_Buffer = templ.GetBuffer()
 | |
| 				defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"section is-centered\"><div class=\"container\">")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			templ_7745c5c3_Err = subnetsTable(subnets).Render(ctx, templ_7745c5c3_Buffer)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			if !templ_7745c5c3_IsBuffer {
 | |
| 				_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
 | |
| 			}
 | |
| 			return templ_7745c5c3_Err
 | |
| 		})
 | |
| 		templ_7745c5c3_Err = wrapBase(metaContent, "Subnets", err).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
 | |
| 		if templ_7745c5c3_Err != nil {
 | |
| 			return templ_7745c5c3_Err
 | |
| 		}
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
 | |
| 		}
 | |
| 		return templ_7745c5c3_Err
 | |
| 	})
 | |
| }
 | |
| 
 | |
| func subnetsTable(subnets []db.Subnet) templ.Component {
 | |
| 	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 | |
| 		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			templ_7745c5c3_Buffer = templ.GetBuffer()
 | |
| 			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 | |
| 		}
 | |
| 		ctx = templ.InitializeContext(ctx)
 | |
| 		templ_7745c5c3_Var3 := templ.GetChildren(ctx)
 | |
| 		if templ_7745c5c3_Var3 == nil {
 | |
| 			templ_7745c5c3_Var3 = templ.NopComponent
 | |
| 		}
 | |
| 		ctx = templ.ClearChildren(ctx)
 | |
| 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<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>")
 | |
| 		if templ_7745c5c3_Err != nil {
 | |
| 			return templ_7745c5c3_Err
 | |
| 		}
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
 | |
| 		}
 | |
| 		return templ_7745c5c3_Err
 | |
| 	})
 | |
| }
 | |
| 
 | |
| func subnetsTableRows(subnets []db.Subnet) templ.Component {
 | |
| 	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 | |
| 		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			templ_7745c5c3_Buffer = templ.GetBuffer()
 | |
| 			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 | |
| 		}
 | |
| 		ctx = templ.InitializeContext(ctx)
 | |
| 		templ_7745c5c3_Var4 := templ.GetChildren(ctx)
 | |
| 		if templ_7745c5c3_Var4 == nil {
 | |
| 			templ_7745c5c3_Var4 = templ.NopComponent
 | |
| 		}
 | |
| 		ctx = templ.ClearChildren(ctx)
 | |
| 		for _, subnet := range subnets {
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr hx-get=\"")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("/subnets/details/%d", subnet.ID)))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var5 string
 | |
| 			templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.ID))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 42, Col: 30}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var6 string
 | |
| 			templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Name)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 43, Col: 20}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var7 string
 | |
| 			templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.DisplayName)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 44, Col: 27}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var8 string
 | |
| 			templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.VLAN))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 45, Col: 32}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var9 string
 | |
| 			templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv4Net)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 46, Col: 23}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var10 string
 | |
| 			templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv6Net)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 47, Col: 23}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td hx-get=\"")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("/locations/details/%d", subnet.LocationID)))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var11 string
 | |
| 			templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Location().Name)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 48, Col: 98}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			var templ_7745c5c3_Var12 string
 | |
| 			templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Comment)
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 49, Col: 23}
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr>")
 | |
| 			if templ_7745c5c3_Err != nil {
 | |
| 				return templ_7745c5c3_Err
 | |
| 			}
 | |
| 		}
 | |
| 		if !templ_7745c5c3_IsBuffer {
 | |
| 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
 | |
| 		}
 | |
| 		return templ_7745c5c3_Err
 | |
| 	})
 | |
| }
 |