refractored MetaContent from utils to Templates
parent
8ee5b3d8e6
commit
db0d541b74
|
@ -20,13 +20,6 @@ func (subnet *Subnet) Delete() error {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (subnet *Subnet) Get() *Subnet {
|
|
||||||
if err := conn.First(subnet).Error; err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return subnet
|
|
||||||
|
|
||||||
}
|
|
||||||
func CountSubnets() int {
|
func CountSubnets() int {
|
||||||
var count int64
|
var count int64
|
||||||
err := conn.Model(&Subnet{}).Count(&count)
|
err := conn.Model(&Subnet{}).Count(&count)
|
||||||
|
@ -38,6 +31,7 @@ func CountSubnets() int {
|
||||||
return int(count)
|
return int(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Location() allows accessing the associated Location from the Subnet object
|
||||||
func (subnet *Subnet) Location() Location {
|
func (subnet *Subnet) Location() Location {
|
||||||
var location Location
|
var location Location
|
||||||
|
|
||||||
|
@ -55,3 +49,9 @@ func SubnetsList(filter *Subnet, limit int, offset int, order string) []Subnet {
|
||||||
|
|
||||||
return subnets
|
return subnets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SubnetByID(id uint) Subnet {
|
||||||
|
var subnet Subnet
|
||||||
|
conn.First(&subnet, id)
|
||||||
|
return subnet
|
||||||
|
}
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-contrib/sessions"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MetaContent struct {
|
|
||||||
Username string
|
|
||||||
IsLoggedIn bool
|
|
||||||
IsAdmin bool
|
|
||||||
Timestamp string
|
|
||||||
ErrorTitle string
|
|
||||||
ErrorText string
|
|
||||||
}
|
|
||||||
|
|
||||||
// MetaContent collects all the values needed to render the templates that aren't specific to the view
|
|
||||||
// and combines them into a structure expected by the template
|
|
||||||
func GenMetaContent(c *gin.Context) MetaContent {
|
|
||||||
session := sessions.Default(c)
|
|
||||||
sessionUserName := session.Get("username")
|
|
||||||
sessionIsLoggedIn := session.Get("isLoggedIn")
|
|
||||||
sessionIsAdmin := session.Get("isAdmin")
|
|
||||||
var username string
|
|
||||||
var isLoggedIn bool
|
|
||||||
var isAdmin bool
|
|
||||||
|
|
||||||
// Validate Types
|
|
||||||
if sessionUserName != nil {
|
|
||||||
username, _ = sessionUserName.(string)
|
|
||||||
} else {
|
|
||||||
username = ""
|
|
||||||
}
|
|
||||||
if sessionIsLoggedIn != nil {
|
|
||||||
isLoggedIn, _ = sessionIsLoggedIn.(bool)
|
|
||||||
} else {
|
|
||||||
isLoggedIn = false
|
|
||||||
}
|
|
||||||
if sessionIsAdmin != nil {
|
|
||||||
isAdmin, _ = sessionIsAdmin.(bool)
|
|
||||||
} else {
|
|
||||||
isAdmin = false
|
|
||||||
}
|
|
||||||
|
|
||||||
return MetaContent{
|
|
||||||
Username: username,
|
|
||||||
IsLoggedIn: isLoggedIn,
|
|
||||||
IsAdmin: isAdmin,
|
|
||||||
Timestamp: fmt.Sprintf("%d", time.Now().Year()),
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,8 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
templ Index(metaContent utils.MetaContent, counters IndexCounts, err error) {
|
templ Index(metaContent MetaContent, counters IndexCounts, err error) {
|
||||||
@wrapBase(metaContent, "GoIPAM", err) {
|
@wrapBase(metaContent, "GoIPAM", err) {
|
||||||
<div class="section is-centered">
|
<div class="section is-centered">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -11,9 +11,8 @@ import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
func Index(metaContent utils.MetaContent, counters IndexCounts, err error) templ.Component {
|
func Index(metaContent MetaContent, counters IndexCounts, err error) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
@ -80,7 +79,7 @@ func indexStats(counters IndexCounts) templ.Component {
|
||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.SubnetCount))
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.SubnetCount))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 20, Col: 55}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 19, Col: 55}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -93,7 +92,7 @@ func indexStats(counters IndexCounts) templ.Component {
|
||||||
var templ_7745c5c3_Var5 string
|
var templ_7745c5c3_Var5 string
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.AddressCount))
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.AddressCount))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 26, Col: 56}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 25, Col: 56}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -106,7 +105,7 @@ func indexStats(counters IndexCounts) templ.Component {
|
||||||
var templ_7745c5c3_Var6 string
|
var templ_7745c5c3_Var6 string
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.DeviceCount))
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.DeviceCount))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 32, Col: 55}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 31, Col: 55}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -119,7 +118,7 @@ func indexStats(counters IndexCounts) templ.Component {
|
||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.LocationCount))
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.LocationCount))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 38, Col: 57}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 37, Col: 57}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
templ Login(metaContent MetaContent, title string, err error) {
|
||||||
|
|
||||||
templ Login(metaContent utils.MetaContent, title string, err error) {
|
|
||||||
@wrapBase(metaContent, title, err) {
|
@wrapBase(metaContent, title, err) {
|
||||||
<div class="section is-medium">
|
<div class="section is-medium">
|
||||||
<div class="columns is-centered">
|
<div class="columns is-centered">
|
||||||
|
|
|
@ -10,9 +10,7 @@ import "context"
|
||||||
import "io"
|
import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
func Login(metaContent MetaContent, title string, err error) templ.Component {
|
||||||
|
|
||||||
func Login(metaContent utils.MetaContent, title string, err error) templ.Component {
|
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
templ head(title string) {
|
templ head(title string) {
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
|
@ -95,7 +93,7 @@ templ ErrorMessage(title string, content string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapBase handles the basics of HTML
|
// wrapBase handles the basics of HTML
|
||||||
templ wrapBase(metaContent utils.MetaContent, title string, err error) {
|
templ wrapBase(metaContent MetaContent, title string, err error) {
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
@head(title)
|
@head(title)
|
||||||
|
|
|
@ -10,8 +10,6 @@ import "context"
|
||||||
import "io"
|
import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
func head(title string) templ.Component {
|
func head(title string) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
|
@ -32,7 +30,7 @@ func head(title string) templ.Component {
|
||||||
var templ_7745c5c3_Var2 string
|
var templ_7745c5c3_Var2 string
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 10, Col: 16}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 8, Col: 16}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -69,7 +67,7 @@ func footer(timestamp string) templ.Component {
|
||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(timestamp)
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(timestamp)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 18, Col: 100}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 16, Col: 100}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -169,7 +167,7 @@ func ErrorMessage(title string, content string) templ.Component {
|
||||||
var templ_7745c5c3_Var8 string
|
var templ_7745c5c3_Var8 string
|
||||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 80, Col: 13}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 78, Col: 13}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -182,7 +180,7 @@ func ErrorMessage(title string, content string) templ.Component {
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var9 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(content)
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(content)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 91, Col: 12}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 89, Col: 12}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -200,7 +198,7 @@ func ErrorMessage(title string, content string) templ.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapBase handles the basics of HTML
|
// wrapBase handles the basics of HTML
|
||||||
func wrapBase(metaContent utils.MetaContent, title string, err error) templ.Component {
|
func wrapBase(metaContent MetaContent, title string, err error) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/db"
|
import "git.jmbit.de/jmb/goipam/db"
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
templ ProfilePage(metaContent utils.MetaContent, title string, user *db.User, err error) {
|
templ ProfilePage(metaContent MetaContent, title string, user *db.User, err error) {
|
||||||
@wrapBase(metaContent, title, err) {
|
@wrapBase(metaContent, title, err) {
|
||||||
@profileMain(user)
|
@profileMain(user)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,8 @@ import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/db"
|
import "git.jmbit.de/jmb/goipam/db"
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
|
|
||||||
func ProfilePage(metaContent utils.MetaContent, title string, user *db.User, err error) templ.Component {
|
func ProfilePage(metaContent MetaContent, title string, user *db.User, err error) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
@ -104,7 +103,7 @@ func ProfileStatic(user *db.User) templ.Component {
|
||||||
var templ_7745c5c3_Var5 string
|
var templ_7745c5c3_Var5 string
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 23, Col: 52}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 22, Col: 52}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -117,7 +116,7 @@ func ProfileStatic(user *db.User) templ.Component {
|
||||||
var templ_7745c5c3_Var6 string
|
var templ_7745c5c3_Var6 string
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.DisplayName)
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.DisplayName)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 26, Col: 63}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 25, Col: 63}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -130,7 +129,7 @@ func ProfileStatic(user *db.User) templ.Component {
|
||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 29, Col: 50}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 28, Col: 50}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -167,7 +166,7 @@ func ProfileForm(user *db.User) templ.Component {
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var9 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 40, Col: 52}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 39, Col: 52}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
|
|
@ -1,8 +1,61 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/sessions"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
type IndexCounts struct {
|
type IndexCounts struct {
|
||||||
SubnetCount int
|
SubnetCount int
|
||||||
AddressCount int
|
AddressCount int
|
||||||
DeviceCount int
|
DeviceCount int
|
||||||
LocationCount int
|
LocationCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MetaContent struct {
|
||||||
|
Username string
|
||||||
|
IsLoggedIn bool
|
||||||
|
IsAdmin bool
|
||||||
|
Timestamp string
|
||||||
|
ErrorTitle string
|
||||||
|
ErrorText string
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetaContent collects all the values needed to render the templates that aren't specific to the view
|
||||||
|
// and combines them into a structure expected by the template
|
||||||
|
func GenMetaContent(c *gin.Context) MetaContent {
|
||||||
|
session := sessions.Default(c)
|
||||||
|
sessionUserName := session.Get("username")
|
||||||
|
sessionIsLoggedIn := session.Get("isLoggedIn")
|
||||||
|
sessionIsAdmin := session.Get("isAdmin")
|
||||||
|
var username string
|
||||||
|
var isLoggedIn bool
|
||||||
|
var isAdmin bool
|
||||||
|
|
||||||
|
// Validate Types
|
||||||
|
if sessionUserName != nil {
|
||||||
|
username, _ = sessionUserName.(string)
|
||||||
|
} else {
|
||||||
|
username = ""
|
||||||
|
}
|
||||||
|
if sessionIsLoggedIn != nil {
|
||||||
|
isLoggedIn, _ = sessionIsLoggedIn.(bool)
|
||||||
|
} else {
|
||||||
|
isLoggedIn = false
|
||||||
|
}
|
||||||
|
if sessionIsAdmin != nil {
|
||||||
|
isAdmin, _ = sessionIsAdmin.(bool)
|
||||||
|
} else {
|
||||||
|
isAdmin = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return MetaContent{
|
||||||
|
Username: username,
|
||||||
|
IsLoggedIn: isLoggedIn,
|
||||||
|
IsAdmin: isAdmin,
|
||||||
|
Timestamp: fmt.Sprintf("%d", time.Now().Year()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
import "git.jmbit.de/jmb/goipam/db"
|
import "git.jmbit.de/jmb/goipam/db"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
templ SubnetsPage(metaContent utils.MetaContent, subnets []db.Subnet, err error) {
|
templ SubnetsPage(metaContent MetaContent, subnets []db.Subnet, err error) {
|
||||||
@wrapBase(metaContent, "Subnets", err) {
|
@wrapBase(metaContent, "Subnets", err) {
|
||||||
<div class="section is-centered">
|
<div class="section is-centered">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -10,11 +10,10 @@ import "context"
|
||||||
import "io"
|
import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import "git.jmbit.de/jmb/goipam/utils"
|
|
||||||
import "git.jmbit.de/jmb/goipam/db"
|
import "git.jmbit.de/jmb/goipam/db"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func SubnetsPage(metaContent utils.MetaContent, subnets []db.Subnet, err error) templ.Component {
|
func SubnetsPage(metaContent MetaContent, subnets []db.Subnet, err error) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
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)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
@ -114,7 +113,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var5 string
|
var templ_7745c5c3_Var5 string
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.ID))
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.ID))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 42, Col: 30}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 41, Col: 30}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -127,7 +126,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var6 string
|
var templ_7745c5c3_Var6 string
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Name)
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 43, Col: 20}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 42, Col: 20}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -140,7 +139,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.DisplayName)
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.DisplayName)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 44, Col: 27}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 43, Col: 27}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -153,7 +152,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var8 string
|
var templ_7745c5c3_Var8 string
|
||||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.VLAN))
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(subnet.VLAN))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 45, Col: 32}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 44, Col: 32}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -166,7 +165,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var9 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv4Net)
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv4Net)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 46, Col: 23}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 45, Col: 23}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -179,7 +178,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var10 string
|
var templ_7745c5c3_Var10 string
|
||||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv6Net)
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.IPv6Net)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 47, Col: 23}
|
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_Var10))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -200,7 +199,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var11 string
|
var templ_7745c5c3_Var11 string
|
||||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Location().Name)
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Location().Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 48, Col: 98}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 47, Col: 98}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
@ -213,7 +212,7 @@ func subnetsTableRows(subnets []db.Subnet) templ.Component {
|
||||||
var templ_7745c5c3_Var12 string
|
var templ_7745c5c3_Var12 string
|
||||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Comment)
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(subnet.Comment)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 49, Col: 23}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/subnets.templ`, Line: 48, Col: 23}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"git.jmbit.de/jmb/goipam/db"
|
"git.jmbit.de/jmb/goipam/db"
|
||||||
"git.jmbit.de/jmb/goipam/utils"
|
|
||||||
"git.jmbit.de/jmb/goipam/web/templates"
|
"git.jmbit.de/jmb/goipam/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ func index(c *gin.Context) {
|
||||||
LocationCount: db.CountLocations(),
|
LocationCount: db.CountLocations(),
|
||||||
}
|
}
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "", templates.Index(utils.GenMetaContent(c), counters, nil))
|
c.HTML(http.StatusOK, "", templates.Index(templates.GenMetaContent(c), counters, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEmpty(c *gin.Context) {
|
func getEmpty(c *gin.Context) {
|
||||||
|
|
|
@ -7,13 +7,12 @@ import (
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"git.jmbit.de/jmb/goipam/utils"
|
|
||||||
"git.jmbit.de/jmb/goipam/web/auth"
|
"git.jmbit.de/jmb/goipam/web/auth"
|
||||||
"git.jmbit.de/jmb/goipam/web/templates"
|
"git.jmbit.de/jmb/goipam/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getLogin(c *gin.Context) {
|
func getLogin(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "", templates.Login(utils.GenMetaContent(c), "Login", nil))
|
c.HTML(http.StatusOK, "", templates.Login(templates.GenMetaContent(c), "Login", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func postLogin(c *gin.Context) {
|
func postLogin(c *gin.Context) {
|
||||||
|
@ -22,7 +21,7 @@ func postLogin(c *gin.Context) {
|
||||||
password := c.PostForm("password")
|
password := c.PostForm("password")
|
||||||
err := auth.CheckPassword(username, password, session)
|
err := auth.CheckPassword(username, password, session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metaContent := utils.GenMetaContent(c)
|
metaContent := templates.GenMetaContent(c)
|
||||||
metaContent.ErrorTitle = "Error"
|
metaContent.ErrorTitle = "Error"
|
||||||
metaContent.ErrorText = err.Error()
|
metaContent.ErrorText = err.Error()
|
||||||
c.HTML(http.StatusUnauthorized, "", templates.Login(metaContent, "Login", err))
|
c.HTML(http.StatusUnauthorized, "", templates.Login(metaContent, "Login", err))
|
||||||
|
|
|
@ -22,17 +22,17 @@ func getProfile(c *gin.Context) {
|
||||||
c.HTML(
|
c.HTML(
|
||||||
http.StatusInternalServerError,
|
http.StatusInternalServerError,
|
||||||
"",
|
"",
|
||||||
templates.ProfilePage(utils.GenMetaContent(c), "User Profile", &user, err),
|
templates.ProfilePage(templates.GenMetaContent(c), "User Profile", &user, err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.HTML(
|
c.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
"",
|
"",
|
||||||
templates.ProfilePage(utils.GenMetaContent(c), "User Profile", &user, nil),
|
templates.ProfilePage(templates.GenMetaContent(c), "User Profile", &user, nil),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
c.HTML(http.StatusNotFound, "", templates.ProfilePage(utils.GenMetaContent(c), "User Profile", &user, nil))
|
c.HTML(http.StatusNotFound, "", templates.ProfilePage(templates.GenMetaContent(c), "User Profile", &user, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,23 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"git.jmbit.de/jmb/goipam/db"
|
"git.jmbit.de/jmb/goipam/db"
|
||||||
"git.jmbit.de/jmb/goipam/utils"
|
|
||||||
"git.jmbit.de/jmb/goipam/web/templates"
|
"git.jmbit.de/jmb/goipam/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getSubnetsPage(c *gin.Context) {
|
func getSubnetsPage(c *gin.Context) {
|
||||||
subnets := db.SubnetsList(&db.Subnet{}, -1, -1, "")
|
subnets := db.SubnetsList(&db.Subnet{}, -1, -1, "")
|
||||||
c.HTML(http.StatusOK, "", templates.SubnetsPage(utils.GenMetaContent(c), subnets, nil))
|
c.HTML(http.StatusOK, "", templates.SubnetsPage(templates.GenMetaContent(c), subnets, nil))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSubnetDetails(c *gin.Context) {
|
func getSubnetDetails(c *gin.Context) {
|
||||||
subnetID := c.Param("id")
|
subnetID, err := strconv.Atoi(c.Param("id"))
|
||||||
subnet := &db.Subnet{ID: subnetID}.Get()
|
c.Errors = append(c.Errors, &gin.Error{Err: err, Type: gin.ErrorTypeAny})
|
||||||
|
|
||||||
|
subnet := db.SubnetByID(subnetID)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue