From f4b4e5c864b0d3ff70c2bb134227310689c0cc99 Mon Sep 17 00:00:00 2001 From: Luis Eduardo Date: Tue, 4 Feb 2025 03:03:20 +0000 Subject: [PATCH] Replace all htmx client side handling --- internal/view/middleware/inject_reqctx.go | 4 +- internal/view/web/auth/create_first_user.go | 11 +- internal/view/web/auth/login.go | 11 +- internal/view/web/auth/logout.go | 10 +- .../web/dashboard/backups/create_backup.go | 15 +- .../web/dashboard/backups/delete_backup.go | 9 +- .../web/dashboard/backups/duplicate_backup.go | 9 +- .../view/web/dashboard/backups/edit_backup.go | 13 +- internal/view/web/dashboard/backups/index.go | 2 +- .../web/dashboard/backups/list_backups.go | 9 +- .../view/web/dashboard/backups/manual_run.go | 7 +- .../dashboard/databases/create_database.go | 11 +- .../dashboard/databases/delete_database.go | 9 +- .../web/dashboard/databases/edit_database.go | 13 +- .../view/web/dashboard/databases/index.go | 2 +- .../web/dashboard/databases/list_databases.go | 9 +- .../web/dashboard/databases/test_database.go | 16 +- .../destinations/create_destination.go | 11 +- .../destinations/delete_destination.go | 9 +- .../destinations/edit_destination.go | 13 +- .../view/web/dashboard/destinations/index.go | 2 +- .../destinations/list_destinations.go | 9 +- .../destinations/test_destination.go | 16 +- .../view/web/dashboard/executions/index.go | 2 +- .../dashboard/executions/list_executions.go | 9 +- .../dashboard/executions/restore_execution.go | 15 +- .../executions/soft_delete_execution.go | 9 +- internal/view/web/dashboard/health_button.go | 6 +- .../dashboard/profile/close_all_sessions.go | 2 +- .../view/web/dashboard/profile/update_user.go | 11 +- .../view/web/dashboard/restorations/index.go | 2 +- .../restorations/list_restorations.go | 9 +- .../web/dashboard/webhooks/create_webhook.go | 17 +- .../web/dashboard/webhooks/delete_webhook.go | 9 +- .../dashboard/webhooks/duplicate_webhook.go | 9 +- .../web/dashboard/webhooks/edit_webhook.go | 23 +- internal/view/web/dashboard/webhooks/index.go | 2 +- .../web/dashboard/webhooks/list_webhooks.go | 9 +- .../web/dashboard/webhooks/run_webhook.go | 7 +- .../dashboard/webhooks/webhook_executions.go | 11 +- internal/view/web/htmx/client.go | 267 ------------------ internal/view/web/{htmx => htmxs}/respond.go | 2 +- internal/view/web/{htmx => htmxs}/server.go | 2 +- internal/view/web/layout/dashboard.go | 2 +- internal/view/web/layout/dashboard_aside.go | 2 +- internal/view/web/layout/dashboard_header.go | 2 +- 46 files changed, 205 insertions(+), 444 deletions(-) delete mode 100644 internal/view/web/htmx/client.go rename internal/view/web/{htmx => htmxs}/respond.go (99%) rename internal/view/web/{htmx => htmxs}/server.go (99%) diff --git a/internal/view/middleware/inject_reqctx.go b/internal/view/middleware/inject_reqctx.go index d4a8f7e..614b716 100644 --- a/internal/view/middleware/inject_reqctx.go +++ b/internal/view/middleware/inject_reqctx.go @@ -6,14 +6,14 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/logger" "github.com/eduardolat/pgbackweb/internal/view/reqctx" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" ) func (m *Middleware) InjectReqctx(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { reqCtx := reqctx.Ctx{ - IsHTMXBoosted: htmx.ServerIsBoosted(c), + IsHTMXBoosted: htmxs.ServerIsBoosted(c), } found, user, err := m.servs.AuthService.GetUserFromSessionCookie(c) diff --git a/internal/view/web/auth/create_first_user.go b/internal/view/web/auth/create_first_user.go index 8951125..488abfe 100644 --- a/internal/view/web/auth/create_first_user.go +++ b/internal/view/web/auth/create_first_user.go @@ -8,10 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -118,10 +119,10 @@ func (h *handlers) createFirstUserHandler(c echo.Context) error { PasswordConfirmation string `form:"password_confirmation" validate:"required,eqfield=Password"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.UsersService.CreateUser(ctx, dbgen.UsersServiceCreateUserParams{ @@ -130,10 +131,10 @@ func (h *handlers) createFirstUserHandler(c echo.Context) error { Password: formData.Password, }) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondAlertWithRedirect( + return htmxs.RespondAlertWithRedirect( c, "User created successfully", "/auth/login", ) } diff --git a/internal/view/web/auth/login.go b/internal/view/web/auth/login.go index 1a10a70..f855c40 100644 --- a/internal/view/web/auth/login.go +++ b/internal/view/web/auth/login.go @@ -7,10 +7,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -87,10 +88,10 @@ func (h *handlers) loginHandler(c echo.Context) error { Password string `form:"password" validate:"required,max=50"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } session, err := h.servs.AuthService.Login( @@ -103,9 +104,9 @@ func (h *handlers) loginHandler(c echo.Context) error { "ua": c.Request().UserAgent(), "err": err, }) - return htmx.RespondToastError(c, "Login failed") + return htmxs.RespondToastError(c, "Login failed") } h.servs.AuthService.SetSessionCookie(c, session.DecryptedToken) - return htmx.RespondRedirect(c, "/dashboard") + return htmxs.RespondRedirect(c, "/dashboard") } diff --git a/internal/view/web/auth/logout.go b/internal/view/web/auth/logout.go index 06a455f..8120b8c 100644 --- a/internal/view/web/auth/logout.go +++ b/internal/view/web/auth/logout.go @@ -2,7 +2,7 @@ package auth import ( "github.com/eduardolat/pgbackweb/internal/view/reqctx" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" ) @@ -11,11 +11,11 @@ func (h *handlers) logoutHandler(c echo.Context) error { reqCtx := reqctx.GetCtx(c) if err := h.servs.AuthService.DeleteSession(ctx, reqCtx.SessionID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } h.servs.AuthService.ClearSessionCookie(c) - return htmx.RespondRedirect(c, "/auth/login") + return htmxs.RespondRedirect(c, "/auth/login") } func (h *handlers) logoutAllSessionsHandler(c echo.Context) error { @@ -24,9 +24,9 @@ func (h *handlers) logoutAllSessionsHandler(c echo.Context) error { err := h.servs.AuthService.DeleteAllUserSessions(ctx, reqCtx.User.ID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } h.servs.AuthService.ClearSessionCookie(c) - return htmx.RespondRedirect(c, "/auth/login") + return htmxs.RespondRedirect(c, "/auth/login") } diff --git a/internal/view/web/dashboard/backups/create_backup.go b/internal/view/web/dashboard/backups/create_backup.go index 9144eb1..519d9e5 100644 --- a/internal/view/web/dashboard/backups/create_backup.go +++ b/internal/view/web/dashboard/backups/create_backup.go @@ -9,11 +9,12 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" alpine "github.com/nodxdev/nodxgo-alpine" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -38,10 +39,10 @@ func (h *handlers) createBackupHandler(c echo.Context) error { OptNoComments string `form:"opt_no_comments" validate:"required,oneof=true false"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.BackupsService.CreateBackup( @@ -66,10 +67,10 @@ func (h *handlers) createBackupHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRedirect(c, "/dashboard/backups") + return htmxs.RespondRedirect(c, "/dashboard/backups") } func (h *handlers) createBackupFormHandler(c echo.Context) error { @@ -77,12 +78,12 @@ func (h *handlers) createBackupFormHandler(c echo.Context) error { databases, err := h.servs.DatabasesService.GetAllDatabases(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/backups/delete_backup.go b/internal/view/web/dashboard/backups/delete_backup.go index e18db38..0b141fc 100644 --- a/internal/view/web/dashboard/backups/delete_backup.go +++ b/internal/view/web/dashboard/backups/delete_backup.go @@ -2,10 +2,11 @@ package backups import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,14 +15,14 @@ func (h *handlers) deleteBackupHandler(c echo.Context) error { backupID, err := uuid.Parse(c.Param("backupID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err = h.servs.BackupsService.DeleteBackup(ctx, backupID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func deleteBackupButton(backupID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/backups/duplicate_backup.go b/internal/view/web/dashboard/backups/duplicate_backup.go index 35321a6..f874860 100644 --- a/internal/view/web/dashboard/backups/duplicate_backup.go +++ b/internal/view/web/dashboard/backups/duplicate_backup.go @@ -2,10 +2,11 @@ package backups import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,14 +15,14 @@ func (h *handlers) duplicateBackupHandler(c echo.Context) error { backupID, err := uuid.Parse(c.Param("backupID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if _, err = h.servs.BackupsService.DuplicateBackup(ctx, backupID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func duplicateBackupButton(backupID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/backups/edit_backup.go b/internal/view/web/dashboard/backups/edit_backup.go index 4b4cf43..065c604 100644 --- a/internal/view/web/dashboard/backups/edit_backup.go +++ b/internal/view/web/dashboard/backups/edit_backup.go @@ -8,10 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/staticdata" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -20,7 +21,7 @@ func (h *handlers) editBackupHandler(c echo.Context) error { backupID, err := uuid.Parse(c.Param("backupID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } var formData struct { @@ -38,10 +39,10 @@ func (h *handlers) editBackupHandler(c echo.Context) error { OptNoComments string `form:"opt_no_comments" validate:"required,oneof=true false"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err = h.servs.BackupsService.UpdateBackup( @@ -62,10 +63,10 @@ func (h *handlers) editBackupHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondAlertWithRefresh(c, "Backup updated") + return htmxs.RespondAlertWithRefresh(c, "Backup updated") } func editBackupButton(backup dbgen.BackupsServicePaginateBackupsRow) nodx.Node { diff --git a/internal/view/web/dashboard/backups/index.go b/internal/view/web/dashboard/backups/index.go index e7873ba..2aa9f41 100644 --- a/internal/view/web/dashboard/backups/index.go +++ b/internal/view/web/dashboard/backups/index.go @@ -6,10 +6,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) func (h *handlers) indexPageHandler(c echo.Context) error { diff --git a/internal/view/web/dashboard/backups/list_backups.go b/internal/view/web/dashboard/backups/list_backups.go index 59a557b..67d3e21 100644 --- a/internal/view/web/dashboard/backups/list_backups.go +++ b/internal/view/web/dashboard/backups/list_backups.go @@ -11,9 +11,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -24,10 +25,10 @@ func (h *handlers) listBackupsHandler(c echo.Context) error { Page int `query:"page" validate:"required,min=1"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, backups, err := h.servs.BackupsService.PaginateBackups( @@ -37,7 +38,7 @@ func (h *handlers) listBackupsHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/backups/manual_run.go b/internal/view/web/dashboard/backups/manual_run.go index fa38ae6..9a703ec 100644 --- a/internal/view/web/dashboard/backups/manual_run.go +++ b/internal/view/web/dashboard/backups/manual_run.go @@ -4,24 +4,25 @@ import ( "context" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) func (h *handlers) manualRunHandler(c echo.Context) error { backupID, err := uuid.Parse(c.Param("backupID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } go func() { _ = h.servs.ExecutionsService.RunExecution(context.Background(), backupID) }() - return htmx.RespondToastSuccess(c, "Backup started, check the backup executions for more details") + return htmxs.RespondToastSuccess(c, "Backup started, check the backup executions for more details") } func manualRunbutton(backupID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/databases/create_database.go b/internal/view/web/dashboard/databases/create_database.go index 5216e0b..fce1aed 100644 --- a/internal/view/web/dashboard/databases/create_database.go +++ b/internal/view/web/dashboard/databases/create_database.go @@ -6,9 +6,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -23,10 +24,10 @@ func (h *handlers) createDatabaseHandler(c echo.Context) error { var formData createDatabaseDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.DatabasesService.CreateDatabase( @@ -37,10 +38,10 @@ func (h *handlers) createDatabaseHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRedirect(c, "/dashboard/databases") + return htmxs.RespondRedirect(c, "/dashboard/databases") } func createDatabaseButton() nodx.Node { diff --git a/internal/view/web/dashboard/databases/delete_database.go b/internal/view/web/dashboard/databases/delete_database.go index 32db1c8..89dcd8f 100644 --- a/internal/view/web/dashboard/databases/delete_database.go +++ b/internal/view/web/dashboard/databases/delete_database.go @@ -2,10 +2,11 @@ package databases import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,14 +15,14 @@ func (h *handlers) deleteDatabaseHandler(c echo.Context) error { databaseID, err := uuid.Parse(c.Param("databaseID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err = h.servs.DatabasesService.DeleteDatabase(ctx, databaseID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func deleteDatabaseButton(databaseID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/databases/edit_database.go b/internal/view/web/dashboard/databases/edit_database.go index 05518d0..6af73f4 100644 --- a/internal/view/web/dashboard/databases/edit_database.go +++ b/internal/view/web/dashboard/databases/edit_database.go @@ -6,10 +6,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -18,15 +19,15 @@ func (h *handlers) editDatabaseHandler(c echo.Context) error { databaseID, err := uuid.Parse(c.Param("databaseID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } var formData createDatabaseDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err = h.servs.DatabasesService.UpdateDatabase( @@ -38,10 +39,10 @@ func (h *handlers) editDatabaseHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondAlertWithRefresh(c, "Database updated") + return htmxs.RespondAlertWithRefresh(c, "Database updated") } func editDatabaseButton( diff --git a/internal/view/web/dashboard/databases/index.go b/internal/view/web/dashboard/databases/index.go index b202fbc..6e440f9 100644 --- a/internal/view/web/dashboard/databases/index.go +++ b/internal/view/web/dashboard/databases/index.go @@ -6,10 +6,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) func (h *handlers) indexPageHandler(c echo.Context) error { diff --git a/internal/view/web/dashboard/databases/list_databases.go b/internal/view/web/dashboard/databases/list_databases.go index c5775cf..ee00894 100644 --- a/internal/view/web/dashboard/databases/list_databases.go +++ b/internal/view/web/dashboard/databases/list_databases.go @@ -11,9 +11,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -24,10 +25,10 @@ func (h *handlers) listDatabasesHandler(c echo.Context) error { Page int `query:"page" validate:"required,min=1"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, databases, err := h.servs.DatabasesService.PaginateDatabases( @@ -37,7 +38,7 @@ func (h *handlers) listDatabasesHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/databases/test_database.go b/internal/view/web/dashboard/databases/test_database.go index 24cf87e..c779a19 100644 --- a/internal/view/web/dashboard/databases/test_database.go +++ b/internal/view/web/dashboard/databases/test_database.go @@ -2,7 +2,7 @@ package databases import ( "github.com/eduardolat/pgbackweb/internal/validate" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" ) @@ -12,33 +12,33 @@ func (h *handlers) testDatabaseHandler(c echo.Context) error { var formData createDatabaseDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err := h.servs.DatabasesService.TestDatabase( ctx, formData.Version, formData.ConnectionString, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondToastSuccess(c, "Connection successful") + return htmxs.RespondToastSuccess(c, "Connection successful") } func (h *handlers) testExistingDatabaseHandler(c echo.Context) error { ctx := c.Request().Context() databaseID, err := uuid.Parse(c.Param("databaseID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err = h.servs.DatabasesService.TestDatabaseAndStoreResult(ctx, databaseID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondToastSuccess(c, "Connection successful") + return htmxs.RespondToastSuccess(c, "Connection successful") } diff --git a/internal/view/web/dashboard/destinations/create_destination.go b/internal/view/web/dashboard/destinations/create_destination.go index 0f5594c..af07b71 100644 --- a/internal/view/web/dashboard/destinations/create_destination.go +++ b/internal/view/web/dashboard/destinations/create_destination.go @@ -4,9 +4,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -24,10 +25,10 @@ func (h *handlers) createDestinationHandler(c echo.Context) error { var formData createDestinationDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.DestinationsService.CreateDestination( @@ -41,10 +42,10 @@ func (h *handlers) createDestinationHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRedirect(c, "/dashboard/destinations") + return htmxs.RespondRedirect(c, "/dashboard/destinations") } func createDestinationButton() nodx.Node { diff --git a/internal/view/web/dashboard/destinations/delete_destination.go b/internal/view/web/dashboard/destinations/delete_destination.go index 81a1fd5..674d01c 100644 --- a/internal/view/web/dashboard/destinations/delete_destination.go +++ b/internal/view/web/dashboard/destinations/delete_destination.go @@ -2,10 +2,11 @@ package destinations import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,15 +15,15 @@ func (h *handlers) deleteDestinationHandler(c echo.Context) error { destinationID, err := uuid.Parse(c.Param("destinationID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err = h.servs.DestinationsService.DeleteDestination(ctx, destinationID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func deleteDestinationButton(destinationID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/destinations/edit_destination.go b/internal/view/web/dashboard/destinations/edit_destination.go index c4170eb..c123910 100644 --- a/internal/view/web/dashboard/destinations/edit_destination.go +++ b/internal/view/web/dashboard/destinations/edit_destination.go @@ -6,10 +6,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -18,15 +19,15 @@ func (h *handlers) editDestinationHandler(c echo.Context) error { destinationID, err := uuid.Parse(c.Param("destinationID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } var formData createDestinationDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err = h.servs.DestinationsService.UpdateDestination( @@ -41,10 +42,10 @@ func (h *handlers) editDestinationHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondAlertWithRefresh(c, "Destination updated") + return htmxs.RespondAlertWithRefresh(c, "Destination updated") } func editDestinationButton( diff --git a/internal/view/web/dashboard/destinations/index.go b/internal/view/web/dashboard/destinations/index.go index cd15c10..8355c61 100644 --- a/internal/view/web/dashboard/destinations/index.go +++ b/internal/view/web/dashboard/destinations/index.go @@ -6,10 +6,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) func (h *handlers) indexPageHandler(c echo.Context) error { diff --git a/internal/view/web/dashboard/destinations/list_destinations.go b/internal/view/web/dashboard/destinations/list_destinations.go index bad3770..728d3c7 100644 --- a/internal/view/web/dashboard/destinations/list_destinations.go +++ b/internal/view/web/dashboard/destinations/list_destinations.go @@ -11,9 +11,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -24,10 +25,10 @@ func (h *handlers) listDestinationsHandler(c echo.Context) error { Page int `query:"page" validate:"required,min=1"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, destinations, err := h.servs.DestinationsService.PaginateDestinations( @@ -37,7 +38,7 @@ func (h *handlers) listDestinationsHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/destinations/test_destination.go b/internal/view/web/dashboard/destinations/test_destination.go index 6687d24..db21584 100644 --- a/internal/view/web/dashboard/destinations/test_destination.go +++ b/internal/view/web/dashboard/destinations/test_destination.go @@ -2,7 +2,7 @@ package destinations import ( "github.com/eduardolat/pgbackweb/internal/validate" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" ) @@ -10,10 +10,10 @@ import ( func (h *handlers) testDestinationHandler(c echo.Context) error { var formData createDestinationDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err := h.servs.DestinationsService.TestDestination( @@ -21,23 +21,23 @@ func (h *handlers) testDestinationHandler(c echo.Context) error { formData.BucketName, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondToastSuccess(c, "Connection successful") + return htmxs.RespondToastSuccess(c, "Connection successful") } func (h *handlers) testExistingDestinationHandler(c echo.Context) error { ctx := c.Request().Context() destinationID, err := uuid.Parse(c.Param("destinationID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err = h.servs.DestinationsService.TestDestinationAndStoreResult(ctx, destinationID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondToastSuccess(c, "Connection successful") + return htmxs.RespondToastSuccess(c, "Connection successful") } diff --git a/internal/view/web/dashboard/executions/index.go b/internal/view/web/dashboard/executions/index.go index 765efb9..5c57b5c 100644 --- a/internal/view/web/dashboard/executions/index.go +++ b/internal/view/web/dashboard/executions/index.go @@ -8,11 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) type execsQueryData struct { diff --git a/internal/view/web/dashboard/executions/list_executions.go b/internal/view/web/dashboard/executions/list_executions.go index 373d366..659823f 100644 --- a/internal/view/web/dashboard/executions/list_executions.go +++ b/internal/view/web/dashboard/executions/list_executions.go @@ -12,10 +12,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) type listExecsQueryData struct { @@ -30,10 +31,10 @@ func (h *handlers) listExecutionsHandler(c echo.Context) error { var queryData listExecsQueryData if err := c.Bind(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, executions, err := h.servs.ExecutionsService.PaginateExecutions( @@ -52,7 +53,7 @@ func (h *handlers) listExecutionsHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/executions/restore_execution.go b/internal/view/web/dashboard/executions/restore_execution.go index 5a7c82f..7560dd7 100644 --- a/internal/view/web/dashboard/executions/restore_execution.go +++ b/internal/view/web/dashboard/executions/restore_execution.go @@ -9,11 +9,12 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" alpine "github.com/nodxdev/nodxgo-alpine" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -26,20 +27,20 @@ func (h *handlers) restoreExecutionHandler(c echo.Context) error { ConnString string `form:"conn_string" validate:"omitempty"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if formData.DatabaseID == uuid.Nil && formData.ConnString == "" { - return htmx.RespondToastError( + return htmxs.RespondToastError( c, "Database or connection string is required", ) } if formData.DatabaseID != uuid.Nil && formData.ConnString != "" { - return htmx.RespondToastError( + return htmxs.RespondToastError( c, "Database and connection string cannot be both set", ) } @@ -56,7 +57,7 @@ func (h *handlers) restoreExecutionHandler(c echo.Context) error { ctx, execution.DatabasePgVersion, formData.ConnString, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } } @@ -73,7 +74,7 @@ func (h *handlers) restoreExecutionHandler(c echo.Context) error { ) }() - return htmx.RespondToastSuccess( + return htmxs.RespondToastSuccess( c, "Process started, check the restorations page for more details", ) } diff --git a/internal/view/web/dashboard/executions/soft_delete_execution.go b/internal/view/web/dashboard/executions/soft_delete_execution.go index b309197..ea62763 100644 --- a/internal/view/web/dashboard/executions/soft_delete_execution.go +++ b/internal/view/web/dashboard/executions/soft_delete_execution.go @@ -2,10 +2,11 @@ package executions import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,15 +15,15 @@ func (h *handlers) deleteExecutionHandler(c echo.Context) error { executionID, err := uuid.Parse(c.Param("executionID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } err = h.servs.ExecutionsService.SoftDeleteExecution(ctx, executionID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func deleteExecutionButton(executionID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/health_button.go b/internal/view/web/dashboard/health_button.go index 4989c5b..b24b573 100644 --- a/internal/view/web/dashboard/health_button.go +++ b/internal/view/web/dashboard/health_button.go @@ -8,7 +8,7 @@ import ( "github.com/eduardolat/pgbackweb/internal/service" "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" ) @@ -19,11 +19,11 @@ func healthButtonHandler(servs *service.Service) echo.HandlerFunc { databasesQty, err := servs.DatabasesService.GetDatabasesQty(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } destinationsQty, err := servs.DestinationsService.GetDestinationsQty(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx(c, http.StatusOK, healthButton( diff --git a/internal/view/web/dashboard/profile/close_all_sessions.go b/internal/view/web/dashboard/profile/close_all_sessions.go index 2b168ec..ad3cfe9 100644 --- a/internal/view/web/dashboard/profile/close_all_sessions.go +++ b/internal/view/web/dashboard/profile/close_all_sessions.go @@ -4,8 +4,8 @@ import ( "github.com/eduardolat/pgbackweb/internal/database/dbgen" "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) diff --git a/internal/view/web/dashboard/profile/update_user.go b/internal/view/web/dashboard/profile/update_user.go index a862c4f..61d9ce4 100644 --- a/internal/view/web/dashboard/profile/update_user.go +++ b/internal/view/web/dashboard/profile/update_user.go @@ -7,9 +7,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -24,10 +25,10 @@ func (h *handlers) updateUserHandler(c echo.Context) error { PasswordConfirmation string `form:"password_confirmation" validate:"omitempty,eqfield=Password"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.UsersService.UpdateUser(ctx, dbgen.UsersServiceUpdateUserParams{ @@ -37,10 +38,10 @@ func (h *handlers) updateUserHandler(c echo.Context) error { Password: sql.NullString{String: formData.Password, Valid: formData.Password != ""}, }) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondToastSuccess(c, "Profile updated") + return htmxs.RespondToastSuccess(c, "Profile updated") } func updateUserForm(user dbgen.User) nodx.Node { diff --git a/internal/view/web/dashboard/restorations/index.go b/internal/view/web/dashboard/restorations/index.go index bc9641c..587843d 100644 --- a/internal/view/web/dashboard/restorations/index.go +++ b/internal/view/web/dashboard/restorations/index.go @@ -8,11 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) type resQueryData struct { diff --git a/internal/view/web/dashboard/restorations/list_restorations.go b/internal/view/web/dashboard/restorations/list_restorations.go index 4e8a7f4..0c46bb6 100644 --- a/internal/view/web/dashboard/restorations/list_restorations.go +++ b/internal/view/web/dashboard/restorations/list_restorations.go @@ -12,10 +12,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) type listResQueryData struct { @@ -29,10 +30,10 @@ func (h *handlers) listRestorationsHandler(c echo.Context) error { var queryData listResQueryData if err := c.Bind(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, restorations, err := h.servs.RestorationsService.PaginateRestorations( @@ -48,7 +49,7 @@ func (h *handlers) listRestorationsHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/webhooks/create_webhook.go b/internal/view/web/dashboard/webhooks/create_webhook.go index 79434f5..56b7cb8 100644 --- a/internal/view/web/dashboard/webhooks/create_webhook.go +++ b/internal/view/web/dashboard/webhooks/create_webhook.go @@ -8,10 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -31,10 +32,10 @@ func (h *handlers) createWebhookHandler(c echo.Context) error { var formData createWebhookDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err := h.servs.WebhooksService.CreateWebhook( @@ -50,10 +51,10 @@ func (h *handlers) createWebhookHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRedirect(c, "/dashboard/webhooks") + return htmxs.RespondRedirect(c, "/dashboard/webhooks") } func (h *handlers) createWebhookFormHandler(c echo.Context) error { @@ -61,17 +62,17 @@ func (h *handlers) createWebhookFormHandler(c echo.Context) error { databases, err := h.servs.DatabasesService.GetAllDatabases(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } backups, err := h.servs.BackupsService.GetAllBackups(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx(c, http.StatusOK, createWebhookForm( diff --git a/internal/view/web/dashboard/webhooks/delete_webhook.go b/internal/view/web/dashboard/webhooks/delete_webhook.go index 7cccb56..662559d 100644 --- a/internal/view/web/dashboard/webhooks/delete_webhook.go +++ b/internal/view/web/dashboard/webhooks/delete_webhook.go @@ -2,10 +2,11 @@ package webhooks import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,14 +15,14 @@ func (h *handlers) deleteWebhookHandler(c echo.Context) error { webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err = h.servs.WebhooksService.DeleteWebhook(ctx, webhookID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func deleteWebhookButton(webhookID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/webhooks/duplicate_webhook.go b/internal/view/web/dashboard/webhooks/duplicate_webhook.go index e51150c..7dcb318 100644 --- a/internal/view/web/dashboard/webhooks/duplicate_webhook.go +++ b/internal/view/web/dashboard/webhooks/duplicate_webhook.go @@ -2,10 +2,11 @@ package webhooks import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -14,14 +15,14 @@ func (h *handlers) duplicateWebhookHandler(c echo.Context) error { webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if _, err = h.servs.WebhooksService.DuplicateWebhook(ctx, webhookID); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondRefresh(c) + return htmxs.RespondRefresh(c) } func duplicateWebhookButton(webhookID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/webhooks/edit_webhook.go b/internal/view/web/dashboard/webhooks/edit_webhook.go index 64a9515..9c6ef14 100644 --- a/internal/view/web/dashboard/webhooks/edit_webhook.go +++ b/internal/view/web/dashboard/webhooks/edit_webhook.go @@ -8,10 +8,11 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -30,15 +31,15 @@ func (h *handlers) editWebhookHandler(c echo.Context) error { ctx := c.Request().Context() webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } var formData editWebhookDTO if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } _, err = h.servs.WebhooksService.UpdateWebhook( @@ -55,37 +56,37 @@ func (h *handlers) editWebhookHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } - return htmx.RespondAlertWithRefresh(c, "Webhook updated") + return htmxs.RespondAlertWithRefresh(c, "Webhook updated") } func (h *handlers) editWebhookFormHandler(c echo.Context) error { ctx := c.Request().Context() webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } webhook, err := h.servs.WebhooksService.GetWebhook(ctx, webhookID) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } databases, err := h.servs.DatabasesService.GetAllDatabases(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } backups, err := h.servs.BackupsService.GetAllBackups(ctx) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx(c, http.StatusOK, editWebhookForm( diff --git a/internal/view/web/dashboard/webhooks/index.go b/internal/view/web/dashboard/webhooks/index.go index df59ace..06c5005 100644 --- a/internal/view/web/dashboard/webhooks/index.go +++ b/internal/view/web/dashboard/webhooks/index.go @@ -6,10 +6,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/echoutil" "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" "github.com/eduardolat/pgbackweb/internal/view/web/layout" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) func (h *handlers) indexPageHandler(c echo.Context) error { diff --git a/internal/view/web/dashboard/webhooks/list_webhooks.go b/internal/view/web/dashboard/webhooks/list_webhooks.go index 6fd1b43..bac4a25 100644 --- a/internal/view/web/dashboard/webhooks/list_webhooks.go +++ b/internal/view/web/dashboard/webhooks/list_webhooks.go @@ -12,9 +12,10 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) func (h *handlers) listWebhooksHandler(c echo.Context) error { @@ -24,10 +25,10 @@ func (h *handlers) listWebhooksHandler(c echo.Context) error { Page int `query:"page" validate:"required,min=1"` } if err := c.Bind(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&formData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, whooks, err := h.servs.WebhooksService.PaginateWebhooks( @@ -37,7 +38,7 @@ func (h *handlers) listWebhooksHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/dashboard/webhooks/run_webhook.go b/internal/view/web/dashboard/webhooks/run_webhook.go index e1862ff..c656e88 100644 --- a/internal/view/web/dashboard/webhooks/run_webhook.go +++ b/internal/view/web/dashboard/webhooks/run_webhook.go @@ -5,17 +5,18 @@ import ( "github.com/eduardolat/pgbackweb/internal/logger" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) func (h *handlers) runWebhookHandler(c echo.Context) error { webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } go func() { @@ -37,7 +38,7 @@ func (h *handlers) runWebhookHandler(c echo.Context) error { } }() - return htmx.RespondToastSuccess(c, "Running webhook, check the webhook executions for more details") + return htmxs.RespondToastSuccess(c, "Running webhook, check the webhook executions for more details") } func runWebhookButton(webhookID uuid.UUID) nodx.Node { diff --git a/internal/view/web/dashboard/webhooks/webhook_executions.go b/internal/view/web/dashboard/webhooks/webhook_executions.go index 2404eb9..51e2c05 100644 --- a/internal/view/web/dashboard/webhooks/webhook_executions.go +++ b/internal/view/web/dashboard/webhooks/webhook_executions.go @@ -13,11 +13,12 @@ import ( "github.com/eduardolat/pgbackweb/internal/util/timeutil" "github.com/eduardolat/pgbackweb/internal/validate" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" + "github.com/eduardolat/pgbackweb/internal/view/web/htmxs" "github.com/google/uuid" "github.com/labstack/echo/v4" nodx "github.com/nodxdev/nodxgo" alpine "github.com/nodxdev/nodxgo-alpine" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) @@ -25,17 +26,17 @@ func (h *handlers) paginateWebhookExecutionsHandler(c echo.Context) error { ctx := c.Request().Context() webhookID, err := uuid.Parse(c.Param("webhookID")) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } var queryData struct { Page int `query:"page" validate:"required,min=1"` } if err := c.Bind(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } if err := validate.Struct(&queryData); err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } pagination, execs, err := h.servs.WebhooksService.PaginateWebhookExecutions( @@ -46,7 +47,7 @@ func (h *handlers) paginateWebhookExecutionsHandler(c echo.Context) error { }, ) if err != nil { - return htmx.RespondToastError(c, err.Error()) + return htmxs.RespondToastError(c, err.Error()) } return echoutil.RenderNodx( diff --git a/internal/view/web/htmx/client.go b/internal/view/web/htmx/client.go deleted file mode 100644 index ebb0254..0000000 --- a/internal/view/web/htmx/client.go +++ /dev/null @@ -1,267 +0,0 @@ -package htmx - -import nodx "github.com/nodxdev/nodxgo" - -// HxGet returns a NodX node with the hx-get -// attribute set to the given path. -// -// https://htmx.org/attributes/hx-get/ -func HxGet(path string) nodx.Node { - return nodx.Attr("hx-get", path) -} - -// HxPost returns a NodX node with the hx-post -// attribute set to the given path. -// -// https://htmx.org/attributes/hx-post/ -func HxPost(path string) nodx.Node { - return nodx.Attr("hx-post", path) -} - -// HxPut returns a NodX node with the hx-put -// attribute set to the given path. -// -// https://htmx.org/attributes/hx-put/ -func HxPut(path string) nodx.Node { - return nodx.Attr("hx-put", path) -} - -// HxPatch returns a NodX node with the hx-patch -// attribute set to the given path. -// -// https://htmx.org/attributes/hx-patch/ -func HxPatch(path string) nodx.Node { - return nodx.Attr("hx-patch", path) -} - -// HxDelete returns a NodX node with the hx-delete -// attribute set to the given path. -// -// https://htmx.org/attributes/hx-delete/ -func HxDelete(path string) nodx.Node { - return nodx.Attr("hx-delete", path) -} - -// HxTrigger returns a NodX node with the hx-trigger -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-trigger/ -func HxTrigger(value string) nodx.Node { - return nodx.Attr("hx-trigger", value) -} - -// HxTarget returns a NodX node with the hx-target -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-target/ -func HxTarget(value string) nodx.Node { - return nodx.Attr("hx-target", value) -} - -// HxSwap returns a NodX node with the hx-swap -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-swap/ -func HxSwap(value string) nodx.Node { - return nodx.Attr("hx-swap", value) -} - -// HxIndicator returns a NodX node with the hx-indicator -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-indicator/ -func HxIndicator(value string) nodx.Node { - return nodx.Attr("hx-indicator", value) -} - -// HxConfirm returns a NodX node with the hx-confirm -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-confirm/ -func HxConfirm(value string) nodx.Node { - return nodx.Attr("hx-confirm", value) -} - -// HxBoost returns a NodX node with the hx-boost -// attribute set to the given value. -// -// See https://htmx.org/attributes/hx-boost/ -func HxBoost(value string) nodx.Node { - return nodx.Attr("hx-boost", value) -} - -// HxOn returns a NodX node with the hx-on:name="value" -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-on/ -func HxOn(name string, value string) nodx.Node { - return nodx.Attr("hx-on:"+name, value) -} - -// HxPushURL returns a NodX node with the hx-push-url -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-push-url/ -func HxPushURL(value string) nodx.Node { - return nodx.Attr("hx-push-url", value) -} - -// HxSelect returns a NodX node with the hx-select -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-select/ -func HxSelect(value string) nodx.Node { - return nodx.Attr("hx-select", value) -} - -// HxSelectOOB returns a NodX node with the hx-select-oob -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-select-oob/ -func HxSelectOOB(value string) nodx.Node { - return nodx.Attr("hx-select-oob", value) -} - -// HxSwapOOB returns a NodX node with the hx-swap-oob -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-swap-oob/ -func HxSwapOOB(value string) nodx.Node { - return nodx.Attr("hx-swap-oob", value) -} - -// HxVals returns a NodX node with the hx-vals -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-vals/ -func HxVals(value string) nodx.Node { - return nodx.Attr("hx-vals", value) -} - -// HxDisable returns a NodX node with the hx-disable -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-disable/ -func HxDisable(value string) nodx.Node { - return nodx.Attr("hx-disable", value) -} - -// HxDisabledELT returns a NodX node with the hx-disabled-elt -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-disabled-elt/ -func HxDisabledELT(value string) nodx.Node { - return nodx.Attr("hx-disabled-elt", value) -} - -// HxDisinherit returns a NodX node with the hx-disinherit -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-disinherit/ -func HxDisinherit(value string) nodx.Node { - return nodx.Attr("hx-disinherit", value) -} - -// HxEncoding returns a NodX node with the hx-encoding -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-encoding/ -func HxEncoding(value string) nodx.Node { - return nodx.Attr("hx-encoding", value) -} - -// HxExt returns a NodX node with the hx-ext -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-ext/ -func HxExt(value string) nodx.Node { - return nodx.Attr("hx-ext", value) -} - -// HxHeaders returns a NodX node with the hx-headers -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-headers/ -func HxHeaders(value string) nodx.Node { - return nodx.Attr("hx-headers", value) -} - -// HxHistory returns a NodX node with the hx-history -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-history/ -func HxHistory(value string) nodx.Node { - return nodx.Attr("hx-history", value) -} - -// HxHistoryElt returns a NodX node with the hx-history-elt -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-history-elt/ -func HxHistoryElt(value string) nodx.Node { - return nodx.Attr("hx-history-elt", value) -} - -// HxInclude returns a NodX node with the hx-include -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-include/ -func HxInclude(value string) nodx.Node { - return nodx.Attr("hx-include", value) -} - -// HxParams returns a NodX node with the hx-params -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-params/ -func HxParams(value string) nodx.Node { - return nodx.Attr("hx-params", value) -} - -// HxPreserve returns a NodX node with the hx-preserve -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-preserve/ -func HxPreserve(value string) nodx.Node { - return nodx.Attr("hx-preserve", value) -} - -// HxPrompt returns a NodX node with the hx-prompt -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-prompt/ -func HxPrompt(value string) nodx.Node { - return nodx.Attr("hx-prompt", value) -} - -// HxReplaceURL returns a NodX node with the hx-replace-url -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-replace-url/ -func HxReplaceURL(value string) nodx.Node { - return nodx.Attr("hx-replace-url", value) -} - -// HxRequest returns a NodX node with the hx-request -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-request/ -func HxRequest(value string) nodx.Node { - return nodx.Attr("hx-request", value) -} - -// HxSync returns a NodX node with the hx-sync -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-sync/ -func HxSync(value string) nodx.Node { - return nodx.Attr("hx-sync", value) -} - -// HxValidate returns a NodX node with the hx-validate -// attribute set to the given value. -// -// https://htmx.org/attributes/hx-validate/ -func HxValidate(value string) nodx.Node { - return nodx.Attr("hx-validate", value) -} diff --git a/internal/view/web/htmx/respond.go b/internal/view/web/htmxs/respond.go similarity index 99% rename from internal/view/web/htmx/respond.go rename to internal/view/web/htmxs/respond.go index c6618af..f825028 100644 --- a/internal/view/web/htmx/respond.go +++ b/internal/view/web/htmxs/respond.go @@ -1,4 +1,4 @@ -package htmx +package htmxs import ( "fmt" diff --git a/internal/view/web/htmx/server.go b/internal/view/web/htmxs/server.go similarity index 99% rename from internal/view/web/htmx/server.go rename to internal/view/web/htmxs/server.go index 65c656d..ae4036d 100644 --- a/internal/view/web/htmx/server.go +++ b/internal/view/web/htmxs/server.go @@ -1,4 +1,4 @@ -package htmx +package htmxs import ( "github.com/labstack/echo/v4" diff --git a/internal/view/web/layout/dashboard.go b/internal/view/web/layout/dashboard.go index f15de96..5817b56 100644 --- a/internal/view/web/layout/dashboard.go +++ b/internal/view/web/layout/dashboard.go @@ -3,8 +3,8 @@ package layout import ( "github.com/eduardolat/pgbackweb/internal/view/reqctx" "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" ) type DashboardParams struct { diff --git a/internal/view/web/layout/dashboard_aside.go b/internal/view/web/layout/dashboard_aside.go index 8d3820c..9b308db 100644 --- a/internal/view/web/layout/dashboard_aside.go +++ b/internal/view/web/layout/dashboard_aside.go @@ -3,9 +3,9 @@ package layout import ( "fmt" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" nodx "github.com/nodxdev/nodxgo" alpine "github.com/nodxdev/nodxgo-alpine" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" ) diff --git a/internal/view/web/layout/dashboard_header.go b/internal/view/web/layout/dashboard_header.go index 57055bd..7c8cca2 100644 --- a/internal/view/web/layout/dashboard_header.go +++ b/internal/view/web/layout/dashboard_header.go @@ -2,8 +2,8 @@ package layout import ( "github.com/eduardolat/pgbackweb/internal/view/web/component" - "github.com/eduardolat/pgbackweb/internal/view/web/htmx" nodx "github.com/nodxdev/nodxgo" + htmx "github.com/nodxdev/nodxgo-htmx" lucide "github.com/nodxdev/nodxgo-lucide" )