diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 054d3857..384a9f0f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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"] - } - ] - } \ No newline at end of file + "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" + ] + } + ] +} \ No newline at end of file diff --git a/cmd/api/.air.toml b/cmd/api/.air.toml index bc1bee6c..5bb96e4d 100644 --- a/cmd/api/.air.toml +++ b/cmd/api/.air.toml @@ -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 diff --git a/cmd/web/.air.toml b/cmd/web/.air.toml index 41efeecd..c28005d0 100644 --- a/cmd/web/.air.toml +++ b/cmd/web/.air.toml @@ -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 diff --git a/go.mod b/go.mod index da0adc1e..d610628c 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index a4f9bea6..ea42ee1a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/web/components/layout.go b/internal/web/components/layout.go index e9cb98c4..ed1e75c4 100644 --- a/internal/web/components/layout.go +++ b/internal/web/components/layout.go @@ -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, diff --git a/internal/web/controllers/operators/show.go b/internal/web/controllers/operators/show.go index 8413c3aa..ccfe2c31 100644 --- a/internal/web/controllers/operators/show.go +++ b/internal/web/controllers/operators/show.go @@ -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( @@ -163,7 +165,6 @@ func (l *ShowOperatorControllerImpl) Get() error { htmx.Text("System Account"), ), htmx.Form( - forms.FormControlLabel( forms.FormControlLabelProps{}, forms.FormControlLabelText( diff --git a/internal/web/controllers/operators/sysaccount/update.go b/internal/web/controllers/operators/sysaccount/update.go index 38ed048d..d1a1bf5d 100644 --- a/internal/web/controllers/operators/sysaccount/update.go +++ b/internal/web/controllers/operators/sysaccount/update.go @@ -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" @@ -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), + ) + })..., + ), ), ), )