mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-23 21:19:31 -06:00
Add manual run button for backups in dashboard
This commit is contained in:
@@ -76,6 +76,7 @@ func listBackups(
|
||||
lucide.List(),
|
||||
),
|
||||
),
|
||||
manualRunbutton(backup.ID),
|
||||
editBackupButton(backup),
|
||||
deleteBackupButton(backup.ID),
|
||||
),
|
||||
|
||||
38
internal/view/web/dashboard/backups/manual_run.go
Normal file
38
internal/view/web/dashboard/backups/manual_run.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package backups
|
||||
|
||||
import (
|
||||
lucide "github.com/eduardolat/gomponents-lucide"
|
||||
"github.com/eduardolat/pgbackweb/internal/view/web/htmx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/maragudk/gomponents"
|
||||
"github.com/maragudk/gomponents/html"
|
||||
)
|
||||
|
||||
func (h *handlers) manualRunHandler(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
|
||||
backupID, err := uuid.Parse(c.Param("backupID"))
|
||||
if err != nil {
|
||||
return htmx.RespondToastError(c, err.Error())
|
||||
}
|
||||
|
||||
if err := h.servs.ExecutionsService.RunExecution(ctx, backupID); err != nil {
|
||||
return htmx.RespondToastError(c, err.Error())
|
||||
}
|
||||
|
||||
return htmx.RespondToastSuccess(c, "Backup run successfully, check the backup executions for more details")
|
||||
}
|
||||
|
||||
func manualRunbutton(backupID uuid.UUID) gomponents.Node {
|
||||
return html.Div(
|
||||
html.Class("inline-block tooltip tooltip-right"),
|
||||
html.Data("tip", "Run backup now"),
|
||||
html.Button(
|
||||
htmx.HxPost("/dashboard/backups/"+backupID.String()+"/run"),
|
||||
htmx.HxDisabledELT("this"),
|
||||
html.Class("btn btn-sm btn-ghost btn-square"),
|
||||
lucide.Zap(),
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -25,4 +25,5 @@ func MountRouter(
|
||||
parent.POST("", h.createBackupHandler)
|
||||
parent.DELETE("/:backupID", h.deleteBackupHandler)
|
||||
parent.POST("/:backupID/edit", h.editBackupHandler)
|
||||
parent.POST("/:backupID/run", h.manualRunHandler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user