Skip to content

Commit

Permalink
wip: oob update messages
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed May 30, 2024
1 parent dbd2bcf commit aa40453
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 43 deletions.
45 changes: 30 additions & 15 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Web Server",
"type": "shell",
"command": "air",
"args": ["-c", "${workspaceFolder}/cmd/web/.air.toml"]
"version": "2.0.0",
"options": {
"env": {}
},
"tasks": [
{
"label": "Start Web Server",
"type": "shell",
"command": "air",
"options": {
"cwd": "${workspaceFolder}"
},
{
"label": "Start API Server",
"type": "shell",
"command": "air",
"args": ["-c", "${workspaceFolder}/cmd/api/.air.toml"]
}
]
}
"args": [
"-c",
"${workspaceFolder}/cmd/web/.air.toml"
]
},
{
"label": "Start API Server",
"type": "shell",
"command": "air",
"options": {
"cwd": "${workspaceFolder}"
},
"args": [
"-c",
"${workspaceFolder}/cmd/api/.air.toml"
]
}
]
}
2 changes: 1 addition & 1 deletion cmd/api/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = "."
tmp_dir = "tmp"

[build]
cmd = "go build -o ./tmp/api cmd/api/main.go"
cmd = "export $(grep -v '^#' .env | xargs); go build -o ./tmp/api cmd/api/main.go"
bin = "./tmp/api"
full_bin = "dlv exec ./tmp/api --listen=127.0.0.1:2345 --headless=true --api-version=2 --accept-multiclient --continue --log -- "
delay = 1000 # ms
Expand Down
2 changes: 1 addition & 1 deletion cmd/web/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = "."
tmp_dir = "tmp"

[build]
cmd = "go build -o ./tmp/web cmd/web/main.go"
cmd = "export $(grep -v '^#' .env | xargs); go build -o ./tmp/web cmd/web/main.go"
bin = "./tmp/web"
full_bin = "dlv exec ./tmp/web --listen=127.0.0.1:2345 --headless=true --api-version=2 --accept-multiclient --continue --log -- "
delay = 1000 # ms
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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.3.1
github.com/zeiss/fiber-htmx v1.3.4
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1232,8 +1232,8 @@ github.com/zeiss/fiber-authz v1.0.24 h1:rNaBl56GGsn5CJmcsCCTEvC+tqRD57utGvl7tagO
github.com/zeiss/fiber-authz v1.0.24/go.mod h1:q3yxf4CcCkIrXPaBc+n+TW7XsZLpNi7YhF28r55pYCY=
github.com/zeiss/fiber-goth v1.2.1 h1:mXjQx5ekV6jfe3Gi0apyTGh2IoQ8zRw2oY1o8iy+CmQ=
github.com/zeiss/fiber-goth v1.2.1/go.mod h1:AVhqrCUdrqRdtu+N0mkq/JI2rZd01Ss46LKbdXZ3bsA=
github.com/zeiss/fiber-htmx v1.3.1 h1:5LciDpsgfr9ouhZJMQJtwSNMzA8d5aQbG4MgdeCgdLQ=
github.com/zeiss/fiber-htmx v1.3.1/go.mod h1:YVUFnm3TG/2zJ83pV1nq9J0wgibeh8G7Digii7bhshE=
github.com/zeiss/fiber-htmx v1.3.4 h1:INGXQe11YI0gbhQACsyTvYcsxOy3cdKb8WaWpstoZB4=
github.com/zeiss/fiber-htmx v1.3.4/go.mod h1:HM23oBjoxuJmMh8KnPMzFfPO8GWNbefBNpgXKxXxXdw=
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
15 changes: 15 additions & 0 deletions internal/web/components/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ func Layout(p LayoutProps, children ...htmx.Node) htmx.Node {
drawers.DrawerContentProps{
ID: "drawer",
},
htmx.Div(
htmx.ID("alerts"),
// toasts.ToastEnd(
// toasts.ToastProps{},
// toasts.ToastAlertInfo(
// htmx.Text("Info"),
// ),
// toasts.ToastAlertError(
// htmx.Text("Error"),
// ),
// toasts.ToastAlertSuccess(
// htmx.Text("Success"),
// ),
// ),
),
htmx.Div(
htmx.ClassNames{
"overflow-auto": true,
Expand Down
5 changes: 3 additions & 2 deletions internal/web/controllers/operators/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func (l *ShowOperatorControllerImpl) Get() error {
return htmx.RenderComp(
l.Ctx(),
components.Page(
components.PageProps{},
components.PageProps{
Boost: true,
},
components.Layout(
components.LayoutProps{},
cards.CardBordered(
Expand Down Expand Up @@ -163,7 +165,6 @@ func (l *ShowOperatorControllerImpl) Get() error {
htmx.Text("System Account"),
),
htmx.Form(

forms.FormControlLabel(
forms.FormControlLabelProps{},
forms.FormControlLabelText(
Expand Down
65 changes: 44 additions & 21 deletions internal/web/controllers/operators/sysaccount/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/nats-io/nkeys"
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/forms"
"github.com/zeiss/fiber-htmx/components/icons"
"github.com/zeiss/fiber-htmx/components/toasts"
"github.com/zeiss/typhoon/internal/api/models"
"github.com/zeiss/typhoon/internal/utils"
"github.com/zeiss/typhoon/internal/web/ports"
Expand Down Expand Up @@ -113,28 +115,49 @@ func (l *UpdateSystemAccountControllerImpl) Put() error {

return htmx.RenderComp(
l.Ctx(),
forms.SelectBordered(
forms.SelectProps{},
htmx.HxPut(fmt.Sprintf("/operators/%s/system-account", op.ID)),
htmx.HxTarget("this"),
forms.Option(
forms.OptionProps{
Selected: true,
Disabled: true,
},
htmx.Text("Select account"),
htmx.Fragment(
htmx.Div(
htmx.ID("alerts"),
htmx.HxSwapOob("true"),
toasts.ToastEnd(
toasts.ToastProps{},
// toasts.ToastAlertInfo(
// htmx.Text("Info"),
// ),
// toasts.ToastAlertError(
// htmx.Text("Error"),
// ),
toasts.ToastAlertSuccess(
icons.CheckCircleOutline(
icons.IconProps{},
),
htmx.Span(htmx.Text("Success")),
),
),
),
htmx.Name("system_account_id"),
htmx.Group(
htmx.ForEach(accs, func(account *models.Account) htmx.Node {
return forms.Option(
forms.OptionProps{
Value: account.ID.String(),
Selected: op.SystemAdminAccountID != nil && account.ID == utils.UUIDPtr(op.SystemAdminAccountID),
},
htmx.Text(account.Name),
)
})...,
forms.SelectBordered(
forms.SelectProps{},
htmx.HxPut(fmt.Sprintf("/operators/%s/system-account", op.ID)),
htmx.HxTarget("this"),
forms.Option(
forms.OptionProps{
Selected: true,
Disabled: true,
},
htmx.Text("Select account"),
),
htmx.Name("system_account_id"),
htmx.Group(
htmx.ForEach(accs, func(account *models.Account) htmx.Node {
return forms.Option(
forms.OptionProps{
Value: account.ID.String(),
Selected: op.SystemAdminAccountID != nil && account.ID == utils.UUIDPtr(op.SystemAdminAccountID),
},
htmx.Text(account.Name),
)
})...,
),
),
),
)
Expand Down

0 comments on commit aa40453

Please sign in to comment.