Skip to content

Commit

Permalink
wip: skg controller
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed May 24, 2024
1 parent 118735d commit 831155b
Show file tree
Hide file tree
Showing 13 changed files with 652 additions and 235 deletions.
1 change: 1 addition & 0 deletions cmd/web/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.R
app.Post("/operators/new", handlers.CreateOperator())
app.Get("/operators/:id", handlers.ShowOperator())
app.Delete("/operators/:id", handlers.DeleteOperator())
app.Get("/operators/:id/skgs/new", handlers.NewOperatorSkg())

// Accounts handler
app.Get("/accounts", handlers.ListAccounts())
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/xdg-go/scram v1.0.2
github.com/zeiss/fiber-authz v1.0.24
github.com/zeiss/fiber-goth v1.2.1
github.com/zeiss/fiber-htmx v1.2.8-0.20240523133310-14e7c0153f18
github.com/zeiss/fiber-htmx v1.2.8-0.20240524085744-979772bbbf4e
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff
go.opencensus.io v0.24.0
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -304,7 +304,7 @@ require (
github.com/ultraware/whitespace v0.1.1 // indirect
github.com/uudashr/gocognit v1.1.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.53.0 // indirect
github.com/valyala/fasthttp v1.54.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.53.0 h1:lW/+SUkOxCx2vlIu0iaImv4JLrVRnbbkpCoaawvA4zc=
github.com/valyala/fasthttp v1.53.0/go.mod h1:6dt4/8olwq9QARP/TDuPmWyWcl4byhpvTJ4AAtcz+QM=
github.com/valyala/fasthttp v1.54.0 h1:cCL+ZZR3z3HPLMVfEYVUMtJqVaui0+gu7Lx63unHwS0=
github.com/valyala/fasthttp v1.54.0/go.mod h1:6dt4/8olwq9QARP/TDuPmWyWcl4byhpvTJ4AAtcz+QM=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/wamuir/go-xslt v0.1.5 h1:FmO1SD7PpoJtHOfnXcb6R/+NANYHX8+mz0UogNJuPnk=
Expand Down Expand Up @@ -1231,6 +1233,10 @@ github.com/zeiss/fiber-htmx v1.2.8-0.20240523131348-b10bcfa66aa0 h1:uqQKZzsPQuw9
github.com/zeiss/fiber-htmx v1.2.8-0.20240523131348-b10bcfa66aa0/go.mod h1:aZjZpybS/yfTU53EHmmPPlpHIhj+9ETLWMl1z9VqUhc=
github.com/zeiss/fiber-htmx v1.2.8-0.20240523133310-14e7c0153f18 h1:v9wHldvYG/xUSpEYxmmaRPZu0zmDDVwiy4IP7U8mCgE=
github.com/zeiss/fiber-htmx v1.2.8-0.20240523133310-14e7c0153f18/go.mod h1:aZjZpybS/yfTU53EHmmPPlpHIhj+9ETLWMl1z9VqUhc=
github.com/zeiss/fiber-htmx v1.2.8-0.20240524074557-e189850f9c3e h1:Cka6lWU8bos+QmsEhS5gLxVnF7U7ScMzf5mmOrvQioc=
github.com/zeiss/fiber-htmx v1.2.8-0.20240524074557-e189850f9c3e/go.mod h1:aZjZpybS/yfTU53EHmmPPlpHIhj+9ETLWMl1z9VqUhc=
github.com/zeiss/fiber-htmx v1.2.8-0.20240524085744-979772bbbf4e h1:D6G727nQlNm5hR2Gm5iZziWC7RvLm/yz6iOgV9iMr84=
github.com/zeiss/fiber-htmx v1.2.8-0.20240524085744-979772bbbf4e/go.mod h1:aZjZpybS/yfTU53EHmmPPlpHIhj+9ETLWMl1z9VqUhc=
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff h1:IguG+jnCnFyAzZ8Fp+6v2lJNvUFPfu8Q2UUgSFw4doU=
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff/go.mod h1:HvitS/QkqgqhV/bNWxPKn0NjByjTaEACZnNgHKZEuio=
gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo=
Expand Down
11 changes: 11 additions & 0 deletions internal/web/adapters/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/zeiss/typhoon/internal/web/controllers/login"
"github.com/zeiss/typhoon/internal/web/controllers/me"
"github.com/zeiss/typhoon/internal/web/controllers/operators"
oskgs "github.com/zeiss/typhoon/internal/web/controllers/operators/skgs"
"github.com/zeiss/typhoon/internal/web/controllers/users"
"github.com/zeiss/typhoon/internal/web/ports"
"github.com/zeiss/typhoon/pkg/resolvers"
Expand Down Expand Up @@ -88,3 +89,13 @@ func (h *handlers) CreateAccount() fiber.Handler {
func (h *handlers) ShowAccount() fiber.Handler {
return htmx.NewHxControllerHandler(accounts.NewShowAccountController(h.db))
}

// NewOperatorSkg ...
func (h *handlers) NewOperatorSkg() fiber.Handler {
return htmx.NewHxControllerHandler(oskgs.NewSkgsController(h.db))
}

// CreateOperatorSkg ...
func (h *handlers) CreateOperatorSkg() fiber.Handler {
return htmx.NewHxControllerHandler(oskgs.NewCreateSkgsController(h.db))
}
127 changes: 127 additions & 0 deletions internal/web/components/accounts/accounts-table.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package accounts

import (
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/buttons"
"github.com/zeiss/fiber-htmx/components/forms"
"github.com/zeiss/fiber-htmx/components/links"
"github.com/zeiss/fiber-htmx/components/tables"
"github.com/zeiss/typhoon/internal/api/models"
)

// AccountsTableProps ...
type AccountsTableProps struct {
Accounts []*models.Account
Offset int
Limit int
Total int
}

// AccountsTable ...
func AccountsTable(props AccountsTableProps, children ...htmx.Node) htmx.Node {
return htmx.Div(
htmx.ClassNames{
"bg-base-100": true,
"m-4": true,
},
tables.Table(
tables.TableProps{
ID: "accounts-tables",
Toolbar: tables.TableToolbar(
tables.TableToolbarProps{
ClassNames: htmx.ClassNames{
"flex": true,
"items-center": true,
"justify-between": true,
"px-5": true,
"pt-5": true,
},
},
htmx.Div(
htmx.ClassNames{
"inline-flex": true,
"items-center": true,
"gap-3": true,
},
forms.TextInputBordered(
forms.TextInputProps{
ClassNames: htmx.ClassNames{
"input-sm": true,
},
Placeholder: "Search ...",
},
),
),
htmx.A(
htmx.Href("/accounts/new"),
buttons.Outline(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-sm": true,
},
},
htmx.Text("Create Account"),
),
),
),
},
[]tables.ColumnDef[*models.Account]{
{
ID: "id",
AccessorKey: "id",
Header: func(p tables.TableProps) htmx.Node {
return htmx.Th(htmx.Text("ID"))
},
Cell: func(p tables.TableProps, row *models.Account) htmx.Node {
return htmx.Td(
htmx.Text(row.ID.String()),
)
},
},
{
ID: "name",
AccessorKey: "name",
Header: func(p tables.TableProps) htmx.Node {
return htmx.Th(htmx.Text("Name"))
},
Cell: func(p tables.TableProps, row *models.Account) htmx.Node {
return htmx.Td(
links.Link(
links.LinkProps{
Href: "/accounts/" + row.ID.String(),
},
htmx.Text(row.Name),
),
)
},
},
{
Header: func(p tables.TableProps) htmx.Node {
return nil
},
Cell: func(p tables.TableProps, row *models.Account) htmx.Node {
return htmx.Td(
buttons.Button(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-square": true,
},
},
),
)
},
},
},
props.Accounts,
// Pagination: ProfileListTablePaginationComponent(
// ProfileListTablePaginationProps{
// Limit: props.Limit,
// Offset: props.Offset,
// Total: props.Total,
// Target: "profiles-tables",
// Team: props.Team,
// },
// ),
),
)
}
127 changes: 0 additions & 127 deletions internal/web/components/accounts/tables.go

This file was deleted.

Loading

0 comments on commit 831155b

Please sign in to comment.