mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-26 06:29:03 -06:00
Refactor htmxserver references to respondhtmx in dashboard handlers
This commit is contained in:
@@ -8,8 +8,8 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/layout"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -119,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.UsersService.CreateUser(ctx, dbgen.UsersServiceCreateUserParams{
|
||||
@@ -131,10 +131,10 @@ func (h *handlers) createFirstUserHandler(c echo.Context) error {
|
||||
Password: formData.Password,
|
||||
})
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondAlertWithRedirect(
|
||||
return respondhtmx.AlertWithRedirect(
|
||||
c, "User created successfully", "/auth/login",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/layout"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -88,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
session, err := h.servs.AuthService.Login(
|
||||
@@ -104,9 +104,9 @@ func (h *handlers) loginHandler(c echo.Context) error {
|
||||
"ua": c.Request().UserAgent(),
|
||||
"err": err,
|
||||
})
|
||||
return htmxserver.RespondToastError(c, "Login failed")
|
||||
return respondhtmx.ToastError(c, "Login failed")
|
||||
}
|
||||
|
||||
h.servs.AuthService.SetSessionCookie(c, session.DecryptedToken)
|
||||
return htmxserver.RespondRedirect(c, "/dashboard")
|
||||
return respondhtmx.Redirect(c, "/dashboard")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package auth
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/reqctx"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
h.servs.AuthService.ClearSessionCookie(c)
|
||||
return htmxserver.RespondRedirect(c, "/auth/login")
|
||||
return respondhtmx.Redirect(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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
h.servs.AuthService.ClearSessionCookie(c)
|
||||
return htmxserver.RespondRedirect(c, "/auth/login")
|
||||
return respondhtmx.Redirect(c, "/auth/login")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -39,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.BackupsService.CreateBackup(
|
||||
@@ -67,10 +67,10 @@ func (h *handlers) createBackupHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRedirect(c, "/dashboard/backups")
|
||||
return respondhtmx.Redirect(c, "/dashboard/backups")
|
||||
}
|
||||
|
||||
func (h *handlers) createBackupFormHandler(c echo.Context) error {
|
||||
@@ -78,12 +78,12 @@ func (h *handlers) createBackupFormHandler(c echo.Context) error {
|
||||
|
||||
databases, err := h.servs.DatabasesService.GetAllDatabases(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -2,7 +2,7 @@ package backups
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ func (h *handlers) deleteBackupHandler(c echo.Context) error {
|
||||
|
||||
backupID, err := uuid.Parse(c.Param("backupID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if err = h.servs.BackupsService.DeleteBackup(ctx, backupID); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func deleteBackupButton(backupID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -2,7 +2,7 @@ package backups
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ func (h *handlers) duplicateBackupHandler(c echo.Context) error {
|
||||
|
||||
backupID, err := uuid.Parse(c.Param("backupID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if _, err = h.servs.BackupsService.DuplicateBackup(ctx, backupID); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func duplicateBackupButton(backupID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -8,7 +8,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -21,7 +21,7 @@ func (h *handlers) editBackupHandler(c echo.Context) error {
|
||||
|
||||
backupID, err := uuid.Parse(c.Param("backupID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
var formData struct {
|
||||
@@ -39,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err = h.servs.BackupsService.UpdateBackup(
|
||||
@@ -63,10 +63,10 @@ func (h *handlers) editBackupHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondAlertWithRefresh(c, "Backup updated")
|
||||
return respondhtmx.AlertWithRefresh(c, "Backup updated")
|
||||
}
|
||||
|
||||
func editBackupButton(backup dbgen.BackupsServicePaginateBackupsRow) nodx.Node {
|
||||
|
||||
@@ -11,7 +11,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, backups, err := h.servs.BackupsService.PaginateBackups(
|
||||
@@ -38,7 +38,7 @@ func (h *handlers) listBackupsHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ import (
|
||||
func (h *handlers) manualRunHandler(c echo.Context) error {
|
||||
backupID, err := uuid.Parse(c.Param("backupID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
go func() {
|
||||
_ = h.servs.ExecutionsService.RunExecution(context.Background(), backupID)
|
||||
}()
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Backup started, check the backup executions for more details")
|
||||
return respondhtmx.ToastSuccess(c, "Backup started, check the backup executions for more details")
|
||||
}
|
||||
|
||||
func manualRunbutton(backupID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -6,7 +6,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -24,10 +24,10 @@ func (h *handlers) createDatabaseHandler(c echo.Context) error {
|
||||
|
||||
var formData createDatabaseDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.DatabasesService.CreateDatabase(
|
||||
@@ -38,10 +38,10 @@ func (h *handlers) createDatabaseHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRedirect(c, "/dashboard/databases")
|
||||
return respondhtmx.Redirect(c, "/dashboard/databases")
|
||||
}
|
||||
|
||||
func createDatabaseButton() nodx.Node {
|
||||
|
||||
@@ -2,7 +2,7 @@ package databases
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ func (h *handlers) deleteDatabaseHandler(c echo.Context) error {
|
||||
|
||||
databaseID, err := uuid.Parse(c.Param("databaseID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if err = h.servs.DatabasesService.DeleteDatabase(ctx, databaseID); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func deleteDatabaseButton(databaseID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -6,7 +6,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -19,15 +19,15 @@ func (h *handlers) editDatabaseHandler(c echo.Context) error {
|
||||
|
||||
databaseID, err := uuid.Parse(c.Param("databaseID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
var formData createDatabaseDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err = h.servs.DatabasesService.UpdateDatabase(
|
||||
@@ -39,10 +39,10 @@ func (h *handlers) editDatabaseHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondAlertWithRefresh(c, "Database updated")
|
||||
return respondhtmx.AlertWithRefresh(c, "Database updated")
|
||||
}
|
||||
|
||||
func editDatabaseButton(
|
||||
|
||||
@@ -11,7 +11,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, databases, err := h.servs.DatabasesService.PaginateDatabases(
|
||||
@@ -38,7 +38,7 @@ func (h *handlers) listDatabasesHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -2,7 +2,7 @@ package databases
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/validate"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
err := h.servs.DatabasesService.TestDatabase(
|
||||
ctx, formData.Version, formData.ConnectionString,
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Connection successful")
|
||||
return respondhtmx.ToastSuccess(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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
err = h.servs.DatabasesService.TestDatabaseAndStoreResult(ctx, databaseID)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Connection successful")
|
||||
return respondhtmx.ToastSuccess(c, "Connection successful")
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,10 +25,10 @@ func (h *handlers) createDestinationHandler(c echo.Context) error {
|
||||
|
||||
var formData createDestinationDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.DestinationsService.CreateDestination(
|
||||
@@ -42,10 +42,10 @@ func (h *handlers) createDestinationHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRedirect(c, "/dashboard/destinations")
|
||||
return respondhtmx.Redirect(c, "/dashboard/destinations")
|
||||
}
|
||||
|
||||
func createDestinationButton() nodx.Node {
|
||||
|
||||
@@ -2,7 +2,7 @@ package destinations
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,15 +15,15 @@ func (h *handlers) deleteDestinationHandler(c echo.Context) error {
|
||||
|
||||
destinationID, err := uuid.Parse(c.Param("destinationID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
err = h.servs.DestinationsService.DeleteDestination(ctx, destinationID)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func deleteDestinationButton(destinationID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -6,7 +6,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -19,15 +19,15 @@ func (h *handlers) editDestinationHandler(c echo.Context) error {
|
||||
|
||||
destinationID, err := uuid.Parse(c.Param("destinationID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
var formData createDestinationDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err = h.servs.DestinationsService.UpdateDestination(
|
||||
@@ -42,10 +42,10 @@ func (h *handlers) editDestinationHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondAlertWithRefresh(c, "Destination updated")
|
||||
return respondhtmx.AlertWithRefresh(c, "Destination updated")
|
||||
}
|
||||
|
||||
func editDestinationButton(
|
||||
|
||||
@@ -11,7 +11,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, destinations, err := h.servs.DestinationsService.PaginateDestinations(
|
||||
@@ -38,7 +38,7 @@ func (h *handlers) listDestinationsHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -2,7 +2,7 @@ package destinations
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/validate"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Connection successful")
|
||||
return respondhtmx.ToastSuccess(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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
err = h.servs.DestinationsService.TestDestinationAndStoreResult(ctx, destinationID)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Connection successful")
|
||||
return respondhtmx.ToastSuccess(c, "Connection successful")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -31,10 +31,10 @@ func (h *handlers) listExecutionsHandler(c echo.Context) error {
|
||||
|
||||
var queryData listExecsQueryData
|
||||
if err := c.Bind(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, executions, err := h.servs.ExecutionsService.PaginateExecutions(
|
||||
@@ -53,7 +53,7 @@ func (h *handlers) listExecutionsHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -9,7 +9,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -27,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if formData.DatabaseID == uuid.Nil && formData.ConnString == "" {
|
||||
return htmxserver.RespondToastError(
|
||||
return respondhtmx.ToastError(
|
||||
c, "Database or connection string is required",
|
||||
)
|
||||
}
|
||||
|
||||
if formData.DatabaseID != uuid.Nil && formData.ConnString != "" {
|
||||
return htmxserver.RespondToastError(
|
||||
return respondhtmx.ToastError(
|
||||
c, "Database and connection string cannot be both set",
|
||||
)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (h *handlers) restoreExecutionHandler(c echo.Context) error {
|
||||
ctx, execution.DatabasePgVersion, formData.ConnString,
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (h *handlers) restoreExecutionHandler(c echo.Context) error {
|
||||
)
|
||||
}()
|
||||
|
||||
return htmxserver.RespondToastSuccess(
|
||||
return respondhtmx.ToastSuccess(
|
||||
c, "Process started, check the restorations page for more details",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package executions
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,15 +15,15 @@ func (h *handlers) deleteExecutionHandler(c echo.Context) error {
|
||||
|
||||
executionID, err := uuid.Parse(c.Param("executionID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
err = h.servs.ExecutionsService.SoftDeleteExecution(ctx, executionID)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func deleteExecutionButton(executionID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
destinationsQty, err := servs.DestinationsService.GetDestinationsQty(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(c, http.StatusOK, healthButton(
|
||||
|
||||
@@ -7,7 +7,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.UsersService.UpdateUser(ctx, dbgen.UsersServiceUpdateUserParams{
|
||||
@@ -38,10 +38,10 @@ func (h *handlers) updateUserHandler(c echo.Context) error {
|
||||
Password: sql.NullString{String: formData.Password, Valid: formData.Password != ""},
|
||||
})
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Profile updated")
|
||||
return respondhtmx.ToastSuccess(c, "Profile updated")
|
||||
}
|
||||
|
||||
func updateUserForm(user dbgen.User) nodx.Node {
|
||||
|
||||
@@ -12,7 +12,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -30,10 +30,10 @@ func (h *handlers) listRestorationsHandler(c echo.Context) error {
|
||||
|
||||
var queryData listResQueryData
|
||||
if err := c.Bind(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, restorations, err := h.servs.RestorationsService.PaginateRestorations(
|
||||
@@ -49,7 +49,7 @@ func (h *handlers) listRestorationsHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -8,7 +8,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -32,10 +32,10 @@ func (h *handlers) createWebhookHandler(c echo.Context) error {
|
||||
|
||||
var formData createWebhookDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err := h.servs.WebhooksService.CreateWebhook(
|
||||
@@ -51,10 +51,10 @@ func (h *handlers) createWebhookHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRedirect(c, "/dashboard/webhooks")
|
||||
return respondhtmx.Redirect(c, "/dashboard/webhooks")
|
||||
}
|
||||
|
||||
func (h *handlers) createWebhookFormHandler(c echo.Context) error {
|
||||
@@ -62,17 +62,17 @@ func (h *handlers) createWebhookFormHandler(c echo.Context) error {
|
||||
|
||||
databases, err := h.servs.DatabasesService.GetAllDatabases(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
backups, err := h.servs.BackupsService.GetAllBackups(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(c, http.StatusOK, createWebhookForm(
|
||||
|
||||
@@ -2,7 +2,7 @@ package webhooks
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ func (h *handlers) deleteWebhookHandler(c echo.Context) error {
|
||||
|
||||
webhookID, err := uuid.Parse(c.Param("webhookID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if err = h.servs.WebhooksService.DeleteWebhook(ctx, webhookID); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func deleteWebhookButton(webhookID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -2,7 +2,7 @@ package webhooks
|
||||
|
||||
import (
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -15,14 +15,14 @@ func (h *handlers) duplicateWebhookHandler(c echo.Context) error {
|
||||
|
||||
webhookID, err := uuid.Parse(c.Param("webhookID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if _, err = h.servs.WebhooksService.DuplicateWebhook(ctx, webhookID); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondRefresh(c)
|
||||
return respondhtmx.Refresh(c)
|
||||
}
|
||||
|
||||
func duplicateWebhookButton(webhookID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -8,7 +8,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -31,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
var formData editWebhookDTO
|
||||
if err := c.Bind(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
_, err = h.servs.WebhooksService.UpdateWebhook(
|
||||
@@ -56,37 +56,37 @@ func (h *handlers) editWebhookHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmxserver.RespondAlertWithRefresh(c, "Webhook updated")
|
||||
return respondhtmx.AlertWithRefresh(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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
webhook, err := h.servs.WebhooksService.GetWebhook(ctx, webhookID)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
databases, err := h.servs.DatabasesService.GetAllDatabases(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
destinations, err := h.servs.DestinationsService.GetAllDestinations(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
backups, err := h.servs.BackupsService.GetAllBackups(ctx)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(c, http.StatusOK, editWebhookForm(
|
||||
|
||||
@@ -12,7 +12,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
htmx "github.com/nodxdev/nodxgo-htmx"
|
||||
@@ -25,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&formData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, whooks, err := h.servs.WebhooksService.PaginateWebhooks(
|
||||
@@ -38,7 +38,7 @@ func (h *handlers) listWebhooksHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/logger"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/component"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
func (h *handlers) runWebhookHandler(c echo.Context) error {
|
||||
webhookID, err := uuid.Parse(c.Param("webhookID"))
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
go func() {
|
||||
@@ -38,7 +38,7 @@ func (h *handlers) runWebhookHandler(c echo.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
return htmxserver.RespondToastSuccess(c, "Running webhook, check the webhook executions for more details")
|
||||
return respondhtmx.ToastSuccess(c, "Running webhook, check the webhook executions for more details")
|
||||
}
|
||||
|
||||
func runWebhookButton(webhookID uuid.UUID) nodx.Node {
|
||||
|
||||
@@ -13,7 +13,7 @@ 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/htmxserver"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/respondhtmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
nodx "github.com/nodxdev/nodxgo"
|
||||
@@ -26,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 htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
var queryData struct {
|
||||
Page int `query:"page" validate:"required,min=1"`
|
||||
}
|
||||
if err := c.Bind(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
if err := validate.Struct(&queryData); err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
pagination, execs, err := h.servs.WebhooksService.PaginateWebhookExecutions(
|
||||
@@ -47,7 +47,7 @@ func (h *handlers) paginateWebhookExecutionsHandler(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return htmxserver.RespondToastError(c, err.Error())
|
||||
return respondhtmx.ToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return echoutil.RenderNodx(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package htmxserver
|
||||
package respondhtmx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -19,22 +19,22 @@ func setCustomTrigger(c echo.Context, key string, value string) {
|
||||
htmx.ServerSetTrigger(c.Response().Header(), s)
|
||||
}
|
||||
|
||||
// RespondAlert shows an alert.
|
||||
func RespondAlert(c echo.Context, message string) error {
|
||||
// Alert shows an alert.
|
||||
func Alert(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_alert", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondAlertWithRefresh shows an alert and refreshes the page using HTMX.
|
||||
func RespondAlertWithRefresh(c echo.Context, message string) error {
|
||||
// AlertWithRefresh shows an alert and refreshes the page using HTMX.
|
||||
func AlertWithRefresh(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_alert_with_refresh", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondAlertWithRedirect shows an alert and redirects the page using JS.
|
||||
func RespondAlertWithRedirect(c echo.Context, message, url string) error {
|
||||
// AlertWithRedirect shows an alert and redirects the page using JS.
|
||||
func AlertWithRedirect(c echo.Context, message, url string) error {
|
||||
msg := fmt.Sprintf("%s-::-::-%s", message, url)
|
||||
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
@@ -42,47 +42,47 @@ func RespondAlertWithRedirect(c echo.Context, message, url string) error {
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondToastSuccess reswaps the HTMX to none and shows an success message
|
||||
// ToastSuccess reswaps the HTMX to none and shows an success message
|
||||
// inside a toast.
|
||||
func RespondToastSuccess(c echo.Context, message string) error {
|
||||
func ToastSuccess(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_toast_success", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondToastError reswaps the HTMX to none and shows an error message inside
|
||||
// ToastError reswaps the HTMX to none and shows an error message inside
|
||||
// a toast.
|
||||
func RespondToastError(c echo.Context, message string) error {
|
||||
func ToastError(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_toast_error", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondToastSuccessInfinite reswaps the HTMX to none and shows an success
|
||||
// ToastSuccessInfinite reswaps the HTMX to none and shows an success
|
||||
// message inside an infinite toast.
|
||||
func RespondToastSuccessInfinite(c echo.Context, message string) error {
|
||||
func ToastSuccessInfinite(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_toast_success_infinite", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondToastErrorInfinite reswaps the HTMX to none and shows an error message
|
||||
// ToastErrorInfinite reswaps the HTMX to none and shows an error message
|
||||
// inside an infinite toast.
|
||||
func RespondToastErrorInfinite(c echo.Context, message string) error {
|
||||
func ToastErrorInfinite(c echo.Context, message string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
setCustomTrigger(c, "ctm_toast_error_infinite", message)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondRedirect redirects the user to the given URL using HTMX.
|
||||
func RespondRedirect(c echo.Context, url string) error {
|
||||
// Redirect redirects the user to the given URL using HTMX.
|
||||
func Redirect(c echo.Context, url string) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
htmx.ServerSetRedirect(c.Response().Header(), url)
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// RespondRefresh refreshes the page using HTMX.
|
||||
func RespondRefresh(c echo.Context) error {
|
||||
// Refresh refreshes the page using HTMX.
|
||||
func Refresh(c echo.Context) error {
|
||||
htmx.ServerSetReswap(c.Response().Header(), "none")
|
||||
htmx.ServerSetRefresh(c.Response().Header(), "true")
|
||||
return c.NoContent(http.StatusOK)
|
||||
Reference in New Issue
Block a user