forked from sysadminsmedia/homebox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement maintenance view (sysadminsmedia#235)
* implement backend to query maintenances * improve backend API for maintenances * add itemId and itemName (v1/maintenances) * fix remaining todo in backend (/v1/maintenances) * refactor: extract MaintenanceEditModal * first draft (to be cleaned) * revert dependency updates (not required) * translation + fix deletion * fix main menu css issues * fix main menu "create" button (css) * enhancement: make item name clickable * fix: add page title (+ translate existing ones) * fix: missing toast translation (when updating) * bug fix: missing group check in backend (for new endpoint) * backport from following PR (to avoid useless changes) * maintenances => maintenance
- Loading branch information
Showing
21 changed files
with
1,165 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package v1 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/google/uuid" | ||
"github.com/hay-kot/httpkit/errchain" | ||
"github.com/sysadminsmedia/homebox/backend/internal/core/services" | ||
"github.com/sysadminsmedia/homebox/backend/internal/data/repo" | ||
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters" | ||
) | ||
|
||
// HandleMaintenanceGetAll godoc | ||
// | ||
// @Summary Query All Maintenance | ||
// @Tags Maintenance | ||
// @Produce json | ||
// @Param filters query repo.MaintenanceFilters false "which maintenance to retrieve" | ||
// @Success 200 {array} repo.MaintenanceEntryWithDetails[] | ||
// @Router /v1/maintenance [GET] | ||
// @Security Bearer | ||
func (ctrl *V1Controller) HandleMaintenanceGetAll() errchain.HandlerFunc { | ||
fn := func(r *http.Request, filters repo.MaintenanceFilters) ([]repo.MaintenanceEntryWithDetails, error) { | ||
auth := services.NewContext(r.Context()) | ||
return ctrl.repo.MaintEntry.GetAllMaintenance(auth, auth.GID, filters) | ||
} | ||
|
||
return adapters.Query(fn, http.StatusOK) | ||
} | ||
|
||
// HandleMaintenanceEntryUpdate godoc | ||
// | ||
// @Summary Update Maintenance Entry | ||
// @Tags Maintenance | ||
// @Produce json | ||
// @Param payload body repo.MaintenanceEntryUpdate true "Entry Data" | ||
// @Success 200 {object} repo.MaintenanceEntry | ||
// @Router /v1/maintenance/{id} [PUT] | ||
// @Security Bearer | ||
func (ctrl *V1Controller) HandleMaintenanceEntryUpdate() errchain.HandlerFunc { | ||
fn := func(r *http.Request, entryID uuid.UUID, body repo.MaintenanceEntryUpdate) (repo.MaintenanceEntry, error) { | ||
auth := services.NewContext(r.Context()) | ||
return ctrl.repo.MaintEntry.Update(auth, entryID, body) | ||
} | ||
|
||
return adapters.ActionID("id", fn, http.StatusOK) | ||
} | ||
|
||
// HandleMaintenanceEntryDelete godoc | ||
// | ||
// @Summary Delete Maintenance Entry | ||
// @Tags Maintenance | ||
// @Produce json | ||
// @Success 204 | ||
// @Router /v1/maintenance/{id} [DELETE] | ||
// @Security Bearer | ||
func (ctrl *V1Controller) HandleMaintenanceEntryDelete() errchain.HandlerFunc { | ||
fn := func(r *http.Request, entryID uuid.UUID) (any, error) { | ||
auth := services.NewContext(r.Context()) | ||
err := ctrl.repo.MaintEntry.Delete(auth, entryID) | ||
return nil, err | ||
} | ||
|
||
return adapters.CommandID("id", fn, http.StatusNoContent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.