started working on subnet list
parent
a4b26485ba
commit
8b2ca3707f
|
@ -30,6 +30,7 @@ type Subnet struct {
|
|||
IPv4Net string
|
||||
IPv6Net string
|
||||
LocationID uint
|
||||
Comment string
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
|
|
19
db/setup.go
19
db/setup.go
|
@ -31,7 +31,7 @@ func SetupDB() {
|
|||
} else {
|
||||
log.Println("Admin PW is:", adminPW)
|
||||
}
|
||||
adminPWHash, err := utils.RandomString(32)
|
||||
adminPWHash, err := utils.HashPassword(adminPW)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not generate admin PW: %v", err)
|
||||
} else {
|
||||
|
@ -49,4 +49,21 @@ func SetupDB() {
|
|||
if result.Error != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
result = nil
|
||||
result = conn.Create(&Location{
|
||||
Name: "Example",
|
||||
Comment: "This is an example Location",
|
||||
Subnets: []Subnet{
|
||||
{
|
||||
Name: "VLAN1337",
|
||||
DisplayName: "Example Subnet",
|
||||
IPv4Net: "1.3.3.7/32",
|
||||
IPv6Net: "dead:beef:ca1f/64",
|
||||
},
|
||||
},
|
||||
})
|
||||
if result.Error != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,14 @@ func (subnet *Subnet) Delete() error {
|
|||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (subnet *Subnet) Get() *Subnet {
|
||||
if err := conn.First(subnet).Error; err != nil {
|
||||
return nil
|
||||
}
|
||||
return subnet
|
||||
|
||||
}
|
||||
func CountSubnets() int {
|
||||
var count int64
|
||||
|
@ -29,3 +37,21 @@ func CountSubnets() int {
|
|||
|
||||
return int(count)
|
||||
}
|
||||
|
||||
func (subnet *Subnet) Location() Location {
|
||||
var location Location
|
||||
|
||||
conn.First(&location, subnet.LocationID)
|
||||
return location
|
||||
}
|
||||
|
||||
func SubnetsList(filter *Subnet, limit int, offset int, order string) []Subnet {
|
||||
var subnets []Subnet
|
||||
if order == "" {
|
||||
order = "id desc"
|
||||
}
|
||||
|
||||
conn.Where(filter).Limit(limit).Offset(offset).Order(order).Find(&subnets)
|
||||
|
||||
return subnets
|
||||
}
|
||||
|
|
|
@ -21,5 +21,9 @@ func DoPasswordsMatch(hashedPassword, currPassword string) bool {
|
|||
err := bcrypt.CompareHashAndPassword(
|
||||
[]byte(hashedPassword), []byte(currPassword))
|
||||
|
||||
return err == nil
|
||||
if err == nil {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
|
||||
"git.jmbit.de/jmb/goipam/db"
|
||||
|
@ -31,7 +33,10 @@ func CheckPassword(username string, password string, session sessions.Session) e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Println("Logged in ", user.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
log.Println("Login error for ", username)
|
||||
return &utils.CustomError{Message: "Passwords do not match"}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package templates
|
||||
|
||||
import "fmt"
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
templ Index(metaContent utils.MetaContent, counters IndexCounts, err error) {
|
||||
@wrapBase(metaContent, "GoIPAM", err) {
|
||||
|
@ -15,28 +16,28 @@ templ Index(metaContent utils.MetaContent, counters IndexCounts, err error) {
|
|||
templ indexStats(counters IndexCounts) {
|
||||
<div class="level mt-5 box">
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<a href="/subnets/">
|
||||
<p class="heading">Subnets</p>
|
||||
<p class="title">{ fmt.Sprint(counters.SubnetCount) }</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<a href="/addresses/">
|
||||
<p class="heading">Addresses</p>
|
||||
<p class="title">{ fmt.Sprint(counters.AddressCount) }</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<a href="/devices/">
|
||||
<p class="heading">Devices</p>
|
||||
<p class="title">{ fmt.Sprint(counters.DeviceCount) }</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<a href="/locations/">
|
||||
<p class="heading">Locations</p>
|
||||
<p class="title">{ fmt.Sprint(counters.LocationCount) }</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import "io"
|
|||
import "bytes"
|
||||
|
||||
import "fmt"
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
func Index(metaContent utils.MetaContent, counters IndexCounts, err error) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
|
@ -72,59 +73,59 @@ func indexStats(counters IndexCounts) templ.Component {
|
|||
templ_7745c5c3_Var3 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"level mt-5 box\"><div class=\"level-item has-text-centered\"><div><p class=\"heading\">Subnets</p><p class=\"title\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"level mt-5 box\"><div class=\"level-item has-text-centered\"><a href=\"/subnets/\"><p class=\"heading\">Subnets</p><p class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.SubnetCount))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 19, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 20, Col: 55}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div></div><div class=\"level-item has-text-centered\"><div><p class=\"heading\">Addresses</p><p class=\"title\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></a></div><div class=\"level-item has-text-centered\"><a href=\"/addresses/\"><p class=\"heading\">Addresses</p><p class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.AddressCount))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 25, Col: 56}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 26, Col: 56}
|
||||
}
|
||||
_, 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("</p></div></div><div class=\"level-item has-text-centered\"><div><p class=\"heading\">Devices</p><p class=\"title\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></a></div><div class=\"level-item has-text-centered\"><a href=\"/devices/\"><p class=\"heading\">Devices</p><p class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.DeviceCount))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 31, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 32, Col: 55}
|
||||
}
|
||||
_, 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("</p></div></div><div class=\"level-item has-text-centered\"><div><p class=\"heading\">Locations</p><p class=\"title\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></a></div><div class=\"level-item has-text-centered\"><a href=\"/locations/\"><p class=\"heading\">Locations</p><p class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(counters.LocationCount))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 37, Col: 57}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/index.templ`, Line: 38, Col: 57}
|
||||
}
|
||||
_, 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("</p></div></div></div>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></a></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package templates
|
||||
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
templ Login(metaContent utils.MetaContent, title string, err error) {
|
||||
@wrapBase(metaContent, title, err) {
|
||||
<div class="section is-medium">
|
||||
|
|
|
@ -10,6 +10,8 @@ import "context"
|
|||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
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) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package templates
|
||||
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
templ head(title string) {
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
|
@ -25,7 +27,7 @@ templ footer(timestamp string) {
|
|||
}
|
||||
|
||||
templ navbar(loggedIn bool) {
|
||||
<nav id="navbarTop" class="navbar is-transparent is-fixed-top pb-3" role="navigation" aria-label="main navigation">
|
||||
<nav id="navbarTop" class="navbar is-transparent is-fixed-top mb-5" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item has-text-centered" href="/">
|
||||
<p class="title">GoIPAM</p>
|
||||
|
@ -74,10 +76,17 @@ templ loginButton(loggedIn bool) {
|
|||
}
|
||||
|
||||
templ ErrorMessage(title string, content string) {
|
||||
<article class="message container">
|
||||
<article class="message container is-warning" id="errorMessage">
|
||||
<div class="message-header">
|
||||
<p>{ title }</p>
|
||||
<button class="delete" aria-label="delete"></button>
|
||||
<button
|
||||
class="delete"
|
||||
aria-label="delete"
|
||||
hx-get="/empty.html"
|
||||
hx-trigger="click"
|
||||
hx-target="#errorMessage"
|
||||
hx-swap="outerHTML"
|
||||
></button>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
{ content }
|
||||
|
|
|
@ -10,6 +10,8 @@ import "context"
|
|||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
|
||||
func head(title string) 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)
|
||||
|
@ -30,7 +32,7 @@ func head(title string) templ.Component {
|
|||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 8, Col: 16}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 10, Col: 16}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
@ -67,7 +69,7 @@ func footer(timestamp string) templ.Component {
|
|||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(timestamp)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 16, Col: 100}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 18, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
@ -97,7 +99,7 @@ func navbar(loggedIn bool) templ.Component {
|
|||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<nav id=\"navbarTop\" class=\"navbar is-transparent is-fixed-top pb-3\" role=\"navigation\" aria-label=\"main navigation\"><div class=\"navbar-brand\"><a class=\"navbar-item has-text-centered\" href=\"/\"><p class=\"title\">GoIPAM</p></a> <a role=\"button\" class=\"navbar-burger\" aria-label=\"menu\" aria-expanded=\"false\" data-target=\"navbarTop\"><span aria-hidden=\"true\"></span> <span aria-hidden=\"true\"></span> <span aria-hidden=\"true\"></span></a></div><div id=\"navbar\" class=\"navbar-menu\"><div class=\"navbar-start\"><a class=\"navbar-item\" href=\"/index.html\">Home</a> <a class=\"navbar-item\">Page</a></div><div class=\"navbar-end\"><div class=\"navbar-item\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<nav id=\"navbarTop\" class=\"navbar is-transparent is-fixed-top mb-5\" role=\"navigation\" aria-label=\"main navigation\"><div class=\"navbar-brand\"><a class=\"navbar-item has-text-centered\" href=\"/\"><p class=\"title\">GoIPAM</p></a> <a role=\"button\" class=\"navbar-burger\" aria-label=\"menu\" aria-expanded=\"false\" data-target=\"navbarTop\"><span aria-hidden=\"true\"></span> <span aria-hidden=\"true\"></span> <span aria-hidden=\"true\"></span></a></div><div id=\"navbar\" class=\"navbar-menu\"><div class=\"navbar-start\"><a class=\"navbar-item\" href=\"/index.html\">Home</a> <a class=\"navbar-item\">Page</a></div><div class=\"navbar-end\"><div class=\"navbar-item\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -160,27 +162,27 @@ func ErrorMessage(title string, content string) templ.Component {
|
|||
templ_7745c5c3_Var7 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article class=\"message container\"><div class=\"message-header\"><p>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article class=\"message container is-warning\" id=\"errorMessage\"><div class=\"message-header\"><p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 78, Col: 13}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 80, Col: 13}
|
||||
}
|
||||
_, 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("</p><button class=\"delete\" aria-label=\"delete\"></button></div><div class=\"message-body\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><button class=\"delete\" aria-label=\"delete\" hx-get=\"/empty.html\" hx-trigger=\"click\" hx-target=\"#errorMessage\" hx-swap=\"outerHTML\"></button></div><div class=\"message-body\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(content)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 82, Col: 12}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/mainComponents.templ`, Line: 91, Col: 12}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
|
@ -20,10 +20,16 @@ templ profileMain(user *db.User) {
|
|||
|
||||
templ ProfileStatic(user *db.User) {
|
||||
<div hx-target="this" hx-swap="outerHTML">
|
||||
<div class="field"><label>Username</label>: { user.Name }</div>
|
||||
<div class="field"><label>Display Name</label>: { user.DisplayName }</div>
|
||||
<div class="field"><label>Email</label>: { user.Email }</div>
|
||||
<button hx-get="/profile/edit.html" class="button button-primary">
|
||||
<div class="field">
|
||||
<label class="label">Username</label> { user.Name }
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Display Name</label> { user.DisplayName }
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Email</label> { user.Email }
|
||||
</div>
|
||||
<button hx-get="/profile/edit.html" class="button is-primary">
|
||||
Click To Edit
|
||||
</button>
|
||||
</div>
|
||||
|
@ -31,22 +37,32 @@ templ ProfileStatic(user *db.User) {
|
|||
|
||||
templ ProfileForm(user *db.User) {
|
||||
<form hx-post="/profile/edit" hx-swap="outerHTML">
|
||||
<div>
|
||||
<label>Username</label>
|
||||
<input type="text" name="username" value={ user.Name }/>
|
||||
<div class="field">
|
||||
<label class="label">Username</label> { user.Name }
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Display Name</label>
|
||||
<input type="text" name="displayname" value={ user.DisplayName }/>
|
||||
<div class="field">
|
||||
<label class="label">Display Name</label>
|
||||
<input class="input" type="text" name="displayname" value={ user.DisplayName }/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Email Address</label>
|
||||
<input type="email" name="email" value={ user.Email }/>
|
||||
<div class="field">
|
||||
<label class="label">Email Address</label>
|
||||
<input class="input" type="email" name="email" value={ user.Email }/>
|
||||
</div>
|
||||
<button class="button button-primary">Submit</button>
|
||||
<button class="button button-primary" hx-get="/profile/static.html">Cancel</button>
|
||||
<button class="button is-primary">Submit</button>
|
||||
<button class="button is-light" hx-get="/profile/static.html">Cancel</button>
|
||||
</form>
|
||||
}
|
||||
|
||||
templ PasswordForm(result string) {
|
||||
templ PasswordForm(success bool, message string) {
|
||||
<form hx-post="/profile/password.html" hx-swap="outerHTML">
|
||||
<div class="field">
|
||||
<label class="label">Password</label>
|
||||
<input class="input" type="password" name="password" placeholder="************" required/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Confirm Password</label>
|
||||
<input class="input" type="password" name="confirm" placeholder="************" required/>
|
||||
</div>
|
||||
<button class="button button-primary">Submit</button>
|
||||
</form>
|
||||
}
|
||||
|
|
|
@ -97,46 +97,46 @@ func ProfileStatic(user *db.User) templ.Component {
|
|||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div hx-target=\"this\" hx-swap=\"outerHTML\"><div class=\"field\"><label>Username</label>: ")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div hx-target=\"this\" hx-swap=\"outerHTML\"><div class=\"field\"><label class=\"label\">Username</label> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 22, Col: 57}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 23, Col: 52}
|
||||
}
|
||||
_, 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("</div><div class=\"field\"><label>Display Name</label>: ")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"field\"><label class=\"label\">Display Name</label> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.DisplayName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 23, Col: 68}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 26, Col: 63}
|
||||
}
|
||||
_, 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("</div><div class=\"field\"><label>Email</label>: ")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"field\"><label class=\"label\">Email</label> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 24, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 29, Col: 50}
|
||||
}
|
||||
_, 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("</div><button hx-get=\"/profile/edit.html\" class=\"button button-primary\">Click To Edit</button></div>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><button hx-get=\"/profile/edit.html\" class=\"button is-primary\">Click To Edit</button></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -160,15 +160,20 @@ func ProfileForm(user *db.User) templ.Component {
|
|||
templ_7745c5c3_Var8 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-post=\"/profile/edit\" hx-swap=\"outerHTML\"><div><label>Username</label> <input type=\"text\" name=\"username\" value=\"")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-post=\"/profile/edit\" hx-swap=\"outerHTML\"><div class=\"field\"><label class=\"label\">Username</label> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(user.Name))
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/profile.templ`, Line: 40, Col: 52}
|
||||
}
|
||||
_, 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("\"></div><div class=\"form-group\"><label>Display Name</label> <input type=\"text\" name=\"displayname\" value=\"")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"field\"><label class=\"label\">Display Name</label> <input class=\"input\" type=\"text\" name=\"displayname\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -176,7 +181,7 @@ func ProfileForm(user *db.User) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><div class=\"form-group\"><label>Email Address</label> <input type=\"email\" name=\"email\" value=\"")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><div class=\"field\"><label class=\"label\">Email Address</label> <input class=\"input\" type=\"email\" name=\"email\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -184,7 +189,7 @@ func ProfileForm(user *db.User) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><button class=\"button button-primary\">Submit</button> <button class=\"button button-primary\" hx-get=\"/profile/static.html\">Cancel</button></form>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><button class=\"button is-primary\">Submit</button> <button class=\"button is-light\" hx-get=\"/profile/static.html\">Cancel</button></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -195,7 +200,7 @@ func ProfileForm(user *db.User) templ.Component {
|
|||
})
|
||||
}
|
||||
|
||||
func PasswordForm(result string) templ.Component {
|
||||
func PasswordForm(success bool, message string) 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 {
|
||||
|
@ -203,11 +208,15 @@ func PasswordForm(result string) templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var9 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var9 == nil {
|
||||
templ_7745c5c3_Var9 = templ.NopComponent
|
||||
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var10 == nil {
|
||||
templ_7745c5c3_Var10 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-post=\"/profile/password.html\" hx-swap=\"outerHTML\"><div class=\"field\"><label class=\"label\">Password</label> <input class=\"input\" type=\"password\" name=\"password\" placeholder=\"************\" required></div><div class=\"field\"><label class=\"label\">Confirm Password</label> <input class=\"input\" type=\"password\" name=\"confirm\" placeholder=\"************\" required></div><button class=\"button button-primary\">Submit</button></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package templates
|
||||
|
||||
import "git.jmbit.de/jmb/goipam/utils"
|
||||
import "git.jmbit.de/jmb/goipam/db"
|
||||
import "fmt"
|
||||
|
||||
templ SubnetsPage(metaContent utils.MetaContent, subnets []db.Subnet, err error) {
|
||||
@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>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
// 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
|
||||
})
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package ui
|
|
@ -0,0 +1 @@
|
|||
package ui
|
|
@ -20,3 +20,7 @@ func index(c *gin.Context) {
|
|||
|
||||
c.HTML(http.StatusOK, "", templates.Index(utils.GenMetaContent(c), counters, nil))
|
||||
}
|
||||
|
||||
func getEmpty(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "", templates.Empty())
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
package ui
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.jmbit.de/jmb/goipam/db"
|
||||
"git.jmbit.de/jmb/goipam/utils"
|
||||
"git.jmbit.de/jmb/goipam/web/auth"
|
||||
"git.jmbit.de/jmb/goipam/web/templates"
|
||||
|
@ -30,17 +29,6 @@ func postLogin(c *gin.Context) {
|
|||
log.Println(err)
|
||||
return
|
||||
} else {
|
||||
user, err := db.GetUserByName(username)
|
||||
if err != nil {
|
||||
log.Printf("Could not retrieve User Object for User with name %s", username)
|
||||
}
|
||||
session.Set("username", username)
|
||||
session.Set("isLoggedIn", true)
|
||||
session.Set("isAdmin", user.Admin)
|
||||
err = session.Save()
|
||||
if err != nil {
|
||||
log.Println("[ERRO] Could not save Session")
|
||||
}
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/")
|
||||
}
|
||||
|
||||
|
@ -50,6 +38,7 @@ func getLogout(c *gin.Context) {
|
|||
session := sessions.Default(c)
|
||||
username := session.Get("username")
|
||||
session.Clear()
|
||||
session.Save()
|
||||
log.Printf("[INFO] Logged out %s", username)
|
||||
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/login.html")
|
||||
|
|
|
@ -22,7 +22,7 @@ func getProfile(c *gin.Context) {
|
|||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.ProfilePage(utils.GenMetaContent(c), "User Profile", &user, nil),
|
||||
templates.ProfilePage(utils.GenMetaContent(c), "User Profile", &user, err),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -36,3 +36,102 @@ func getProfile(c *gin.Context) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func getProfileEdit(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
sessionUserName := session.Get("username")
|
||||
var user db.User
|
||||
if username, ok := sessionUserName.(string); ok {
|
||||
|
||||
user, err := db.GetUserByName(username)
|
||||
if err != nil {
|
||||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.ProfileStatic(&user),
|
||||
)
|
||||
}
|
||||
|
||||
c.HTML(
|
||||
http.StatusOK,
|
||||
"",
|
||||
|
||||
templates.ProfileStatic(&user),
|
||||
)
|
||||
} else {
|
||||
c.HTML(http.StatusNotFound, "", templates.ProfileStatic(&user))
|
||||
}
|
||||
}
|
||||
|
||||
func postProfileEdit(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
sessionUserName := session.Get("username")
|
||||
var user db.User
|
||||
if username, ok := sessionUserName.(string); ok {
|
||||
|
||||
user, err := db.GetUserByName(username)
|
||||
if err != nil {
|
||||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.ProfileStatic(&user),
|
||||
)
|
||||
}
|
||||
|
||||
c.HTML(
|
||||
http.StatusOK,
|
||||
"",
|
||||
|
||||
templates.ProfileStatic(&user),
|
||||
)
|
||||
} else {
|
||||
c.HTML(http.StatusNotFound, "", templates.ProfileStatic(&user))
|
||||
}
|
||||
}
|
||||
|
||||
func postPassword(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
password := c.PostForm("password")
|
||||
confirm := c.PostForm("confirm")
|
||||
if password != confirm {
|
||||
|
||||
c.HTML(http.StatusConflict, "", templates.PasswordForm(false, "Passwords do not match"))
|
||||
}
|
||||
sessionUserName := session.Get("username")
|
||||
if username, ok := sessionUserName.(string); ok {
|
||||
|
||||
user, err := db.GetUserByName(username)
|
||||
if err != nil {
|
||||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.PasswordForm(false, err.Error()),
|
||||
)
|
||||
}
|
||||
passHash, err := utils.HashPassword(password)
|
||||
if err != nil {
|
||||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.PasswordForm(false, err.Error()),
|
||||
)
|
||||
}
|
||||
db.SetUserPassHash(user, passHash)
|
||||
if err != nil {
|
||||
c.HTML(
|
||||
http.StatusInternalServerError,
|
||||
"",
|
||||
templates.PasswordForm(false, err.Error()),
|
||||
)
|
||||
}
|
||||
|
||||
c.HTML(
|
||||
http.StatusOK,
|
||||
"",
|
||||
|
||||
templates.PasswordForm(true, "Password changed"),
|
||||
)
|
||||
} else {
|
||||
c.HTML(http.StatusNotFound, "", templates.PasswordForm(false, "User Not Found"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@ func GroupWeb(router *gin.Engine) *gin.Engine {
|
|||
router.GET("/", index)
|
||||
router.POST("/", index)
|
||||
router.GET("/login.html", getLogin)
|
||||
router.GET("/logout.html", getLogout)
|
||||
router.POST("/login.html", postLogin)
|
||||
router.GET("/profile/", getProfile)
|
||||
router.GET("/empty.html", getEmpty)
|
||||
|
||||
return router
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.jmbit.de/jmb/goipam/db"
|
||||
"git.jmbit.de/jmb/goipam/utils"
|
||||
"git.jmbit.de/jmb/goipam/web/templates"
|
||||
)
|
||||
|
||||
func getSubnetsPage(c *gin.Context) {
|
||||
subnets := db.SubnetsList(&db.Subnet{}, -1, -1, "")
|
||||
c.HTML(http.StatusOK, "", templates.SubnetsPage(utils.GenMetaContent(c), subnets, nil))
|
||||
|
||||
}
|
||||
|
||||
func getSubnetDetails(c *gin.Context) {
|
||||
subnetID := c.Param("id")
|
||||
subnet := &db.Subnet{ID: subnetID}.Get()
|
||||
}
|
Loading…
Reference in New Issue