diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 285b897..2a2754a 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -35,6 +35,6 @@
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node",
"features": {
- "golang": "1.19"
+ "golang": "1.20"
}
}
diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml
index 5adc0ab..ece397f 100644
--- a/.github/workflows/publish.yaml
+++ b/.github/workflows/publish.yaml
@@ -4,9 +4,6 @@ on:
push:
branches:
- main
- release:
- types:
- - published
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
@@ -29,28 +26,4 @@ jobs:
secrets:
GH_TOKEN: ${{ secrets.CR_PAT }}
- publish-tag:
- name: "Publish Tag"
- if: github.event_name == 'release'
- uses: hay-kot/homebox/.github/workflows/partial-publish.yaml@main
- with:
- release: true
- tag: ${{ github.event.release.tag_name }}
- secrets:
- GH_TOKEN: ${{ secrets.CR_PAT }}
- deploy-docs:
- name: Deploy docs
- needs:
- - publish-tag
- runs-on: ubuntu-latest
- steps:
- - name: Checkout main
- uses: actions/checkout@v3
-
- - name: Deploy docs
- uses: mhausenblas/mkdocs-deploy-gh-pages@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- CONFIG_FILE: docs/mkdocs.yml
- EXTRA_PACKAGES: build-base
diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml
index f36d6df..3705c61 100644
--- a/.github/workflows/tag.yaml
+++ b/.github/workflows/tag.yaml
@@ -17,8 +17,8 @@ jobs:
name: "Frontend and End-to-End Tests"
uses: hay-kot/homebox/.github/workflows/partial-frontend.yaml@main
-
goreleaser:
+ name: goreleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -49,3 +49,29 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ publish-tag:
+ name: "Publish Tag"
+ uses: hay-kot/homebox/.github/workflows/partial-publish.yaml@main
+ with:
+ release: true
+ tag: ${{ github.ref_name }}
+ secrets:
+ GH_TOKEN: ${{ secrets.CR_PAT }}
+
+ deploy-docs:
+ name: Deploy docs
+ needs:
+ - publish-tag
+ - goreleaser
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout main
+ uses: actions/checkout@v3
+
+ - name: Deploy docs
+ uses: mhausenblas/mkdocs-deploy-gh-pages@master
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ CONFIG_FILE: docs/mkdocs.yml
+ EXTRA_PACKAGES: build-base
\ No newline at end of file
diff --git a/backend/app/api/app.go b/backend/app/api/app.go
index 0f44297..16c0ea9 100644
--- a/backend/app/api/app.go
+++ b/backend/app/api/app.go
@@ -8,7 +8,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/config"
"github.com/hay-kot/homebox/backend/pkgs/mailer"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/server"
)
type app struct {
diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.go
index bf14a9d..801eca8 100644
--- a/backend/app/api/handlers/v1/controller.go
+++ b/backend/app/api/handlers/v1/controller.go
@@ -5,8 +5,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
)
type Results[T any] struct {
diff --git a/backend/app/api/handlers/v1/v1_ctrl_actions.go b/backend/app/api/handlers/v1/v1_ctrl_actions.go
index 10c9f2e..3b31c85 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_actions.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_actions.go
@@ -7,8 +7,8 @@ import (
"github.com/google/uuid"
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
diff --git a/backend/app/api/handlers/v1/v1_ctrl_assets.go b/backend/app/api/handlers/v1/v1_ctrl_assets.go
index 117ebe4..ce531ea 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_assets.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_assets.go
@@ -9,8 +9,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
diff --git a/backend/app/api/handlers/v1/v1_ctrl_auth.go b/backend/app/api/handlers/v1/v1_ctrl_auth.go
index 936f38e..14e864c 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_auth.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_auth.go
@@ -8,8 +8,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
diff --git a/backend/app/api/handlers/v1/v1_ctrl_group.go b/backend/app/api/handlers/v1/v1_ctrl_group.go
index bd9ff4c..8b1624d 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_group.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_group.go
@@ -7,7 +7,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
type (
diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go
index d38c037..c6cd328 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_items.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_items.go
@@ -12,8 +12,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
@@ -58,6 +58,7 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
LabelIDs: queryUUIDList(params, "labels"),
IncludeArchived: queryBool(params.Get("includeArchived")),
Fields: filterFieldItems(params["fields"]),
+ OrderBy: params.Get("orderBy"),
}
if strings.HasPrefix(v.Search, "#") {
@@ -261,7 +262,9 @@ func (ctrl *V1Controller) HandleItemsExport() errchain.HandlerFunc {
w.Header().Set("Content-Type", "text/tsv")
w.Header().Set("Content-Disposition", "attachment;filename=homebox-items.tsv")
+
writer := csv.NewWriter(w)
+ writer.Comma = '\t'
return writer.WriteAll(csvData)
}
}
diff --git a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
index 9745538..8da8eb4 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
@@ -8,8 +8,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/data/ent/attachment"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
diff --git a/backend/app/api/handlers/v1/v1_ctrl_labels.go b/backend/app/api/handlers/v1/v1_ctrl_labels.go
index e21036d..dae23db 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_labels.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_labels.go
@@ -7,7 +7,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
// HandleLabelsGetAll godoc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_locations.go b/backend/app/api/handlers/v1/v1_ctrl_locations.go
index c9ffa57..1b053d3 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_locations.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_locations.go
@@ -7,7 +7,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
// HandleLocationTreeQuery
diff --git a/backend/app/api/handlers/v1/v1_ctrl_maint_entry.go b/backend/app/api/handlers/v1/v1_ctrl_maint_entry.go
index eeed717..5a65a4b 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_maint_entry.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_maint_entry.go
@@ -7,7 +7,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
// HandleMaintenanceGetLog godoc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_notifiers.go b/backend/app/api/handlers/v1/v1_ctrl_notifiers.go
index da561c4..3c64dc7 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_notifiers.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_notifiers.go
@@ -8,7 +8,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
// HandleGetUserNotifiers godoc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_qrcode.go b/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
index 1f06e2f..a4352df 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
@@ -7,7 +7,7 @@ import (
"net/http"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
diff --git a/backend/app/api/handlers/v1/v1_ctrl_reporting.go b/backend/app/api/handlers/v1/v1_ctrl_reporting.go
index 030a1ff..40f0d22 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_reporting.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_reporting.go
@@ -4,7 +4,7 @@ import (
"net/http"
"github.com/hay-kot/homebox/backend/internal/core/services"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
// HandleBillOfMaterialsExport godoc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_statistics.go b/backend/app/api/handlers/v1/v1_ctrl_statistics.go
index 55a8dcb..2a91a8e 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_statistics.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_statistics.go
@@ -8,8 +8,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
"github.com/hay-kot/homebox/backend/internal/web/adapters"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
)
// HandleGroupGet godoc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_user.go b/backend/app/api/handlers/v1/v1_ctrl_user.go
index cc57305..8708d24 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_user.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_user.go
@@ -8,8 +8,8 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
)
diff --git a/backend/app/api/main.go b/backend/app/api/main.go
index d966a48..befc0de 100644
--- a/backend/app/api/main.go
+++ b/backend/app/api/main.go
@@ -13,15 +13,14 @@ import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
- "github.com/hay-kot/homebox/backend/app/api/static/docs"
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/ent"
"github.com/hay-kot/homebox/backend/internal/data/migrations"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/config"
"github.com/hay-kot/homebox/backend/internal/web/mid"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
@@ -39,7 +38,6 @@ var (
// @version 1.0
// @description Track, Manage, and Organize your Things.
// @contact.name Don't
-// @license.name MIT
// @BasePath /api
// @securityDefinitions.apikey Bearer
// @in header
@@ -53,8 +51,6 @@ func main() {
panic(err)
}
- docs.SwaggerInfo.Host = cfg.Swagger.Host
-
if err := run(cfg); err != nil {
panic(err)
}
diff --git a/backend/app/api/middleware.go b/backend/app/api/middleware.go
index 3617c09..fb6b9cf 100644
--- a/backend/app/api/middleware.go
+++ b/backend/app/api/middleware.go
@@ -9,7 +9,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
)
type tokenHasKey struct {
diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go
index e36ee02..affc79f 100644
--- a/backend/app/api/routes.go
+++ b/backend/app/api/routes.go
@@ -3,7 +3,6 @@ package main
import (
"embed"
"errors"
- "fmt"
"io"
"mime"
"net/http"
@@ -16,7 +15,7 @@ import (
_ "github.com/hay-kot/homebox/backend/app/api/static/docs"
"github.com/hay-kot/homebox/backend/internal/data/ent/authroles"
"github.com/hay-kot/homebox/backend/internal/data/repo"
- "github.com/hay-kot/safeserve/errchain"
+ "github.com/hay-kot/httpkit/errchain"
httpSwagger "github.com/swaggo/http-swagger" // http-swagger middleware
)
@@ -41,7 +40,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
registerMimes()
r.Get("/swagger/*", httpSwagger.Handler(
- httpSwagger.URL(fmt.Sprintf("%s://%s/swagger/doc.json", a.conf.Swagger.Scheme, a.conf.Swagger.Host)),
+ httpSwagger.URL("/swagger/doc.json"),
))
// =========================================================================
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index b927d87..7c7da2d 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -13,9 +13,6 @@ const docTemplate = `{
"contact": {
"name": "Don't"
},
- "license": {
- "name": "MIT"
- },
"version": "{{.Version}}"
},
"host": "{{.Host}}",
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index d5e71d2..818dfe6 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -6,9 +6,6 @@
"contact": {
"name": "Don't"
},
- "license": {
- "name": "MIT"
- },
"version": "1.0"
},
"basePath": "/api",
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index ccdb538..cc6c467 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -702,8 +702,6 @@ info:
contact:
name: Don't
description: Track, Manage, and Organize your Things.
- license:
- name: MIT
title: Homebox API
version: "1.0"
paths:
diff --git a/backend/go.mod b/backend/go.mod
index bae9413..6d4a4f4 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -9,20 +9,20 @@ require (
github.com/containrrr/shoutrrr v0.7.1
github.com/go-chi/chi/v5 v5.0.8
github.com/go-playground/validator/v10 v10.12.0
- github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a
+ github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479
github.com/google/uuid v1.3.0
github.com/gorilla/schema v1.2.0
- github.com/hay-kot/safeserve v0.0.1
+ github.com/hay-kot/httpkit v0.0.3
github.com/mattn/go-sqlite3 v1.14.16
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.29.0
github.com/stretchr/testify v1.8.2
github.com/swaggo/http-swagger v1.3.4
- github.com/swaggo/swag v1.8.11
+ github.com/swaggo/swag v1.8.12
github.com/yeqown/go-qrcode/v2 v2.2.1
github.com/yeqown/go-qrcode/writer/standard v1.2.1
golang.org/x/crypto v0.7.0
- modernc.org/sqlite v1.21.0
+ modernc.org/sqlite v1.21.1
)
require (
@@ -56,11 +56,11 @@ require (
github.com/yeqown/reedsolomon v1.0.0 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect
- golang.org/x/mod v0.8.0 // indirect
+ golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
- golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 // indirect
+ golang.org/x/tools v0.7.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index 5544f85..8eb5695 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -302,8 +302,8 @@ github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6A
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
-github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a h1:/5o1ejt5M0fNAN2lU1NBLtPzUSZru689EWJq01ptr+E=
-github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
+github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479 h1:KaCpc4e48emF9hYmMB9INyfpGJHAZxEAS9EqWFkpTig=
+github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
@@ -441,8 +441,8 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn
github.com/hashicorp/memberlist v0.3.1/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
github.com/hashicorp/serf v0.9.8/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
-github.com/hay-kot/safeserve v0.0.1 h1:9u8Ooyk8NNkqgxrqkLMWtMqauWEl/VZVtEUTLbHuAU8=
-github.com/hay-kot/safeserve v0.0.1/go.mod h1:RUvwyfQTmbNgm5sHt+tQOqtdcpWadXWMhLty74Vedzw=
+github.com/hay-kot/httpkit v0.0.3 h1:QYq01J5Jrn+ie0s1ptavNSEyydkOHqsrw4RLp+2LeJQ=
+github.com/hay-kot/httpkit v0.0.3/go.mod h1:1s/OJwWRyH6tBtTw76jTp6kwBYvjswziXaokPQH7eKQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -503,7 +503,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -529,7 +528,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
-github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
@@ -602,10 +600,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
-github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
-github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -629,8 +625,8 @@ github.com/swaggo/files v1.0.0 h1:1gGXVIeUFCS/dta17rnP0iOpr6CXFwKD7EO5ID233e4=
github.com/swaggo/files v1.0.0/go.mod h1:N59U6URJLyU1PQgFqPM7wXLMhJx7QAolnvfQkqO13kc=
github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64a5ww=
github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ=
-github.com/swaggo/swag v1.8.11 h1:Fp1dNNtDvbCf+8kvehZbHQnlF6AxHGjmw6H/xAMrZfY=
-github.com/swaggo/swag v1.8.11/go.mod h1:2GXgpNI9iy5OdsYWu8zXfRAGnOAPxYxTWTyM0XOTYZQ=
+github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
+github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/yeqown/go-qrcode/v2 v2.2.1 h1:Jc1Q916fwC05R8C7mpWDbrT9tyLPaLLKDABoC5XBCe8=
github.com/yeqown/go-qrcode/v2 v2.2.1/go.mod h1:2Qsk2APUCPne0TsRo40DIkI5MYnbzYKCnKGEFWrxd24=
@@ -720,8 +716,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
-golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
-golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
+golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -998,8 +994,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
-golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 h1:8985/C5IvACpd9DDXckSnjSBLKDgbxXiyODgi94zOPM=
-golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
+golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1267,8 +1263,8 @@ modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
-modernc.org/sqlite v1.21.0 h1:4aP4MdUf15i3R3M2mx6Q90WHKz3nZLoz96zlB6tNdow=
-modernc.org/sqlite v1.21.0/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI=
+modernc.org/sqlite v1.21.1 h1:GyDFqNnESLOhwwDRaHGdp2jKLDzpyT/rNLglX3ZkMSU=
+modernc.org/sqlite v1.21.1/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI=
modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
modernc.org/tcl v1.15.1 h1:mOQwiEK4p7HruMZcwKTZPw/aqtGM4aY00uzWhlKKYws=
diff --git a/backend/internal/core/services/reporting/.testdata/import.csv b/backend/internal/core/services/reporting/.testdata/import.csv
deleted file mode 100644
index 08bd9c8..0000000
--- a/backend/internal/core/services/reporting/.testdata/import.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-Import Ref,Location,Labels,Quantity,Name,Description,Insured,Serial Number,Mode Number,Manufacturer,Notes,Purchase From,Purchased Price,Purchased Time,Lifetime Warranty,Warranty Expires,Warranty Details,Sold To,Sold Price,Sold Time,Sold Notes
-A,Garage,IOT;Home Assistant; Z-Wave,1,Zooz Universal Relay ZEN17,Description 1,TRUE,,ZEN17,Zooz,,Amazon,39.95,10/13/2021,,10/13/2021,,,,10/13/2021,
-B,Living Room,IOT;Home Assistant; Z-Wave,1,Zooz Motion Sensor,Description 2,FALSE,,ZSE18,Zooz,,Amazon,29.95,10/15/2021,,10/15/2021,,,,10/15/2021,
-C,Office,IOT;Home Assistant; Z-Wave,1,Zooz 110v Power Switch,Description 3,TRUE,,ZEN15,Zooz,,Amazon,39.95,10/13/2021,,10/13/2021,,,,10/13/2021,
-D,Downstairs,IOT;Home Assistant; Z-Wave,1,Ecolink Z-Wave PIR Motion Sensor,Description 4,FALSE,,PIRZWAVE2.5-ECO,Ecolink,,Amazon,35.58,10/21/2020,,10/21/2020,,,,10/21/2020,
-E,Entry,IOT;Home Assistant; Z-Wave,1,Yale Security Touchscreen Deadbolt,Description 5,TRUE,,YRD226ZW2619,Yale,,Amazon,120.39,10/14/2020,,10/14/2020,,,,10/14/2020,
-F,Kitchen,IOT;Home Assistant; Z-Wave,1,Smart Rocker Light Dimmer,Description 6,FALSE,,39351,Honeywell,,Amazon,65.98,09/30/2020,,09/30/2020,,,,09/30/2020,
\ No newline at end of file
diff --git a/backend/internal/core/services/reporting/.testdata/import.tsv b/backend/internal/core/services/reporting/.testdata/import.tsv
deleted file mode 100644
index 503c777..0000000
--- a/backend/internal/core/services/reporting/.testdata/import.tsv
+++ /dev/null
@@ -1,7 +0,0 @@
-Import Ref Location Labels Quantity Name Description Insured Serial Number Mode Number Manufacturer Notes Purchase From Purchased Price Purchased Time Lifetime Warranty Warranty Expires Warranty Details Sold To Sold Price Sold Time Sold Notes
-A Garage IOT;Home Assistant; Z-Wave 1 Zooz Universal Relay ZEN17 Description 1 TRUE ZEN17 Zooz Amazon 39.95 10/13/2021 10/13/2021 10/13/2021
-B Living Room IOT;Home Assistant; Z-Wave 1 Zooz Motion Sensor Description 2 FALSE ZSE18 Zooz Amazon 29.95 10/15/2021 10/15/2021 10/15/2021
-C Office IOT;Home Assistant; Z-Wave 1 Zooz 110v Power Switch Description 3 TRUE ZEN15 Zooz Amazon 39.95 10/13/2021 10/13/2021 10/13/2021
-D Downstairs IOT;Home Assistant; Z-Wave 1 Ecolink Z-Wave PIR Motion Sensor Description 4 FALSE PIRZWAVE2.5-ECO Ecolink Amazon 35.58 10/21/2020 10/21/2020 10/21/2020
-E Entry IOT;Home Assistant; Z-Wave 1 Yale Security Touchscreen Deadbolt Description 5 TRUE YRD226ZW2619 Yale Amazon 120.39 10/14/2020 10/14/2020 10/14/2020
-F Kitchen IOT;Home Assistant; Z-Wave 1 Smart Rocker Light Dimmer Description 6 FALSE 39351 Honeywell Amazon 65.98 09/30/2020 09/30/2020 09/30/2020
\ No newline at end of file
diff --git a/backend/internal/core/services/reporting/io_row.go b/backend/internal/core/services/reporting/io_row.go
index faa5d25..f097c83 100644
--- a/backend/internal/core/services/reporting/io_row.go
+++ b/backend/internal/core/services/reporting/io_row.go
@@ -83,3 +83,13 @@ func parseLocationString(s string) LocationString {
func (csf LocationString) String() string {
return strings.Join(csf, " / ")
}
+
+func fromPathSlice(s []repo.LocationPath) LocationString {
+ v := make(LocationString, len(s))
+
+ for i := range s {
+ v[i] = s[i].Name
+ }
+
+ return v
+}
diff --git a/backend/internal/core/services/reporting/io_sheet.go b/backend/internal/core/services/reporting/io_sheet.go
index 88d1d36..6fb0c9d 100644
--- a/backend/internal/core/services/reporting/io_sheet.go
+++ b/backend/internal/core/services/reporting/io_sheet.go
@@ -1,6 +1,7 @@
package reporting
import (
+ "context"
"fmt"
"io"
"reflect"
@@ -8,6 +9,7 @@ import (
"strconv"
"strings"
+ "github.com/google/uuid"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/data/types"
"github.com/rs/zerolog/log"
@@ -151,7 +153,7 @@ func (s *IOSheet) Read(data io.Reader) error {
}
// Write writes the sheet to a writer.
-func (s *IOSheet) ReadItems(items []repo.ItemOut) {
+func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, GID uuid.UUID, repos *repo.AllRepos) error {
s.Rows = make([]ExportTSVRow, len(items))
extraHeaders := map[string]struct{}{}
@@ -160,7 +162,15 @@ func (s *IOSheet) ReadItems(items []repo.ItemOut) {
item := items[i]
// TODO: Support fetching nested locations
- locString := LocationString{item.Location.Name}
+ locId := item.Location.ID
+
+ locPaths, err := repos.Locations.PathForLoc(context.Background(), GID, locId)
+ if err != nil {
+ log.Error().Err(err).Msg("could not get location path")
+ return err
+ }
+
+ locString := fromPathSlice(locPaths)
labelString := make([]string, len(item.Labels))
@@ -238,6 +248,8 @@ func (s *IOSheet) ReadItems(items []repo.ItemOut) {
for _, h := range customHeaders {
s.headers = append(s.headers, "HB.field."+h)
}
+
+ return nil
}
// Writes the current sheet to a writer in TSV format.
diff --git a/backend/internal/core/services/reporting/io_sheet_test.go b/backend/internal/core/services/reporting/io_sheet_test.go
index 9d7f9a0..845a791 100644
--- a/backend/internal/core/services/reporting/io_sheet_test.go
+++ b/backend/internal/core/services/reporting/io_sheet_test.go
@@ -20,12 +20,6 @@ var (
//go:embed .testdata/import/types.csv
customTypesImportCSV []byte
-
- //go:embed .testdata/import.csv
- CSVData_Comma []byte
-
- //go:embed .testdata/import.tsv
- CSVData_Tab []byte
)
func TestSheet_Read(t *testing.T) {
@@ -189,7 +183,7 @@ func Test_determineSeparator(t *testing.T) {
{
name: "comma",
args: args{
- data: CSVData_Comma,
+ data: []byte("a,b,c"),
},
want: ',',
wantErr: false,
@@ -197,7 +191,7 @@ func Test_determineSeparator(t *testing.T) {
{
name: "tab",
args: args{
- data: CSVData_Tab,
+ data: []byte("a\tb\tc"),
},
want: '\t',
wantErr: false,
diff --git a/backend/internal/core/services/service_items.go b/backend/internal/core/services/service_items.go
index c1a37d5..3ea79e2 100644
--- a/backend/internal/core/services/service_items.go
+++ b/backend/internal/core/services/service_items.go
@@ -337,7 +337,10 @@ func (svc *ItemService) ExportTSV(ctx context.Context, GID uuid.UUID) ([][]strin
sheet := reporting.IOSheet{}
- sheet.ReadItems(items)
+ err = sheet.ReadItems(ctx, items, GID, svc.repo)
+ if err != nil {
+ return nil, err
+ }
return sheet.TSV()
}
diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go
index 103c3e9..3e263cc 100644
--- a/backend/internal/data/repo/repo_items.go
+++ b/backend/internal/data/repo/repo_items.go
@@ -29,13 +29,14 @@ type (
ItemQuery struct {
Page int
PageSize int
- Search string `json:"search"`
- AssetID AssetID `json:"assetId"`
- LocationIDs []uuid.UUID `json:"locationIds"`
- LabelIDs []uuid.UUID `json:"labelIds"`
- SortBy string `json:"sortBy"`
- IncludeArchived bool `json:"includeArchived"`
- Fields []FieldQuery
+ Search string `json:"search"`
+ AssetID AssetID `json:"assetId"`
+ LocationIDs []uuid.UUID `json:"locationIds"`
+ LabelIDs []uuid.UUID `json:"labelIds"`
+ SortBy string `json:"sortBy"`
+ IncludeArchived bool `json:"includeArchived"`
+ Fields []FieldQuery `json:"fields"`
+ OrderBy string `json:"orderBy"`
}
ItemField struct {
@@ -326,6 +327,7 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
item.NameContainsFold(q.Search),
item.DescriptionContainsFold(q.Search),
item.NotesContainsFold(q.Search),
+ item.ManufacturerContainsFold(q.Search),
),
)
}
@@ -385,7 +387,17 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
return PaginationResult[ItemSummary]{}, err
}
- qb = qb.Order(ent.Asc(item.FieldName)).
+ // Order
+ switch q.OrderBy {
+ case "createdAt":
+ qb = qb.Order(ent.Desc(item.FieldCreatedAt))
+ case "updatedAt":
+ qb = qb.Order(ent.Desc(item.FieldUpdatedAt))
+ default: // "name"
+ qb = qb.Order(ent.Asc(item.FieldName))
+ }
+
+ qb = qb.
WithLabel().
WithLocation()
diff --git a/backend/internal/data/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.go
index e65a983..28e3968 100644
--- a/backend/internal/data/repo/repo_locations.go
+++ b/backend/internal/data/repo/repo_locations.go
@@ -249,6 +249,56 @@ type TreeQuery struct {
WithItems bool `json:"withItems" schema:"withItems"`
}
+type LocationPath struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name"`
+}
+
+func (lr *LocationRepository) PathForLoc(ctx context.Context, GID, locID uuid.UUID) ([]LocationPath, error) {
+ query := `WITH RECURSIVE location_path AS (
+ SELECT id, name, location_children
+ FROM locations
+ WHERE id = ? -- Replace ? with the ID of the item's location
+ AND group_locations = ? -- Replace ? with the ID of the group
+
+ UNION ALL
+
+ SELECT loc.id, loc.name, loc.location_children
+ FROM locations loc
+ JOIN location_path lp ON loc.id = lp.location_children
+ )
+
+ SELECT id, name
+ FROM location_path`
+
+ rows, err := lr.db.Sql().QueryContext(ctx, query, locID, GID)
+ if err != nil {
+ return nil, err
+ }
+
+ var locations []LocationPath
+
+ for rows.Next() {
+ var location LocationPath
+ if err := rows.Scan(&location.ID, &location.Name); err != nil {
+ return nil, err
+ }
+ locations = append(locations, location)
+ }
+
+ if err := rows.Err(); err != nil {
+ return nil, err
+ }
+
+ // Reverse the order of the locations so that the root is last
+ for i := len(locations)/2 - 1; i >= 0; i-- {
+ opp := len(locations) - 1 - i
+ locations[i], locations[opp] = locations[opp], locations[i]
+ }
+
+ return locations, nil
+}
+
func (lr *LocationRepository) Tree(ctx context.Context, GID uuid.UUID, tq TreeQuery) ([]TreeItem, error) {
query := `
WITH recursive location_tree(id, NAME, parent_id, level, node_type) AS
diff --git a/backend/internal/data/repo/repo_locations_test.go b/backend/internal/data/repo/repo_locations_test.go
index 644828d..8840b51 100644
--- a/backend/internal/data/repo/repo_locations_test.go
+++ b/backend/internal/data/repo/repo_locations_test.go
@@ -146,6 +146,34 @@ func TestItemRepository_TreeQuery(t *testing.T) {
}
}
+func TestLocationRepository_PathForLoc(t *testing.T) {
+ locs := useLocations(t, 3)
+
+ // Set relations 3 -> 2 -> 1
+ for i := 0; i < 2; i++ {
+ _, err := tRepos.Locations.UpdateByGroup(context.Background(), tGroup.ID, locs[i].ID, LocationUpdate{
+ ID: locs[i].ID,
+ ParentID: locs[i+1].ID,
+ Name: locs[i].Name,
+ Description: locs[i].Description,
+ })
+ assert.NoError(t, err)
+ }
+
+ last := locs[0]
+
+ path, err := tRepos.Locations.PathForLoc(context.Background(), tGroup.ID, last.ID)
+
+ assert.NoError(t, err)
+ assert.Equal(t, 3, len(path))
+
+ // Check path and order
+ for i, loc := range path {
+ assert.Equal(t, locs[2-i].ID, loc.ID)
+ assert.Equal(t, locs[2-i].Name, loc.Name)
+ }
+}
+
func TestConvertLocationsToTree(t *testing.T) {
uuid1, uuid2, uuid3, uuid4 := uuid.New(), uuid.New(), uuid.New(), uuid.New()
diff --git a/backend/internal/data/types/date.go b/backend/internal/data/types/date.go
index 1b8b182..1c4b5fa 100644
--- a/backend/internal/data/types/date.go
+++ b/backend/internal/data/types/date.go
@@ -41,6 +41,7 @@ func DateFromString(s string) Date {
try := [...]string{
"2006-01-02",
"01/02/2006",
+ "2006/01/02",
time.RFC3339,
}
diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.go
index c1655c2..6ece6c5 100644
--- a/backend/internal/sys/config/conf.go
+++ b/backend/internal/sys/config/conf.go
@@ -15,15 +15,14 @@ const (
)
type Config struct {
- Mode string `yaml:"mode" conf:"default:development"` // development or production
- Web WebConfig `yaml:"web"`
- Storage Storage `yaml:"storage"`
- Log LoggerConf `yaml:"logger"`
- Mailer MailerConf `yaml:"mailer"`
- Swagger SwaggerConf `yaml:"swagger"`
- Demo bool `yaml:"demo"`
- Debug DebugConf `yaml:"debug"`
- Options Options `yaml:"options"`
+ Mode string `yaml:"mode" conf:"default:development"` // development or production
+ Web WebConfig `yaml:"web"`
+ Storage Storage `yaml:"storage"`
+ Log LoggerConf `yaml:"logger"`
+ Mailer MailerConf `yaml:"mailer"`
+ Demo bool `yaml:"demo"`
+ Debug DebugConf `yaml:"debug"`
+ Options Options `yaml:"options"`
}
type Options struct {
@@ -36,11 +35,6 @@ type DebugConf struct {
Port string `yaml:"port" conf:"default:4000"`
}
-type SwaggerConf struct {
- Host string `yaml:"host" conf:"default:localhost:7745"`
- Scheme string `yaml:"scheme" conf:"default:http"`
-}
-
type WebConfig struct {
Port string `yaml:"port" conf:"default:7745"`
Host string `yaml:"host"`
diff --git a/backend/internal/web/adapters/actions.go b/backend/internal/web/adapters/actions.go
index db9a410..3905723 100644
--- a/backend/internal/web/adapters/actions.go
+++ b/backend/internal/web/adapters/actions.go
@@ -3,8 +3,8 @@ package adapters
import (
"net/http"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
)
// Action is a function that adapts a function to the server.Handler interface.
diff --git a/backend/internal/web/adapters/command.go b/backend/internal/web/adapters/command.go
index 3d7eb06..d3d099b 100644
--- a/backend/internal/web/adapters/command.go
+++ b/backend/internal/web/adapters/command.go
@@ -4,8 +4,8 @@ import (
"net/http"
"github.com/google/uuid"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
)
type CommandFunc[T any] func(*http.Request) (T, error)
diff --git a/backend/internal/web/adapters/decoders.go b/backend/internal/web/adapters/decoders.go
index ef4bf6c..ad5b82b 100644
--- a/backend/internal/web/adapters/decoders.go
+++ b/backend/internal/web/adapters/decoders.go
@@ -9,7 +9,7 @@ import (
"github.com/google/uuid"
"github.com/gorilla/schema"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/server"
)
var queryDecoder = schema.NewDecoder()
diff --git a/backend/internal/web/adapters/query.go b/backend/internal/web/adapters/query.go
index 8f669f0..b044475 100644
--- a/backend/internal/web/adapters/query.go
+++ b/backend/internal/web/adapters/query.go
@@ -3,8 +3,8 @@ package adapters
import (
"net/http"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
)
// Query is a server.Handler that decodes a query from the request and calls the provided function.
diff --git a/backend/internal/web/mid/errors.go b/backend/internal/web/mid/errors.go
index 269387c..318d323 100644
--- a/backend/internal/web/mid/errors.go
+++ b/backend/internal/web/mid/errors.go
@@ -6,8 +6,8 @@ import (
"github.com/go-chi/chi/v5/middleware"
"github.com/hay-kot/homebox/backend/internal/data/ent"
"github.com/hay-kot/homebox/backend/internal/sys/validate"
- "github.com/hay-kot/safeserve/errchain"
- "github.com/hay-kot/safeserve/server"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog"
)
diff --git a/docs/docs/api/openapi-2.0.json b/docs/docs/api/openapi-2.0.json
index d5e71d2..818dfe6 100644
--- a/docs/docs/api/openapi-2.0.json
+++ b/docs/docs/api/openapi-2.0.json
@@ -6,9 +6,6 @@
"contact": {
"name": "Don't"
},
- "license": {
- "name": "MIT"
- },
"version": "1.0"
},
"basePath": "/api",
diff --git a/docs/docs/import-csv.md b/docs/docs/import-csv.md
index 5dffc38..8d5586f 100644
--- a/docs/docs/import-csv.md
+++ b/docs/docs/import-csv.md
@@ -64,12 +64,12 @@ Below are the supported columns. They are case sensitive, can be in any ordered
| HB.notes | String (1000) | General notes about the product |
| HB.purchase_from | String | Name of the place the item was purchased from |
| HB.purchase_price | Float64 | |
-| HB.purchase_at | Date | Date the item was purchased |
+| HB.purchase_time | Date | Date the item was purchased |
| HB.lifetime_warranty | Boolean | true or false - case insensitive |
| HB.warranty_expires | Date | Date in the format |
| HB.warranty_details | String | Details about the warranty |
| HB.sold_to | String | Name of the person the item was sold to |
-| HB.sold_at | Date | Date the item was sold |
+| HB.sold_time | Date | Date the item was sold |
| HB.sold_price | Float64 | |
| HB.sold_notes | String (1000) | |
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 68bfe4a..a66000e 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1 +1 @@
-mkdocs-material==9.1.4
\ No newline at end of file
+mkdocs-material==9.1.5
\ No newline at end of file
diff --git a/frontend/components/Base/Card.vue b/frontend/components/Base/Card.vue
index 88fef80..d89c1c0 100644
--- a/frontend/components/Base/Card.vue
+++ b/frontend/components/Base/Card.vue
@@ -23,10 +23,10 @@
diff --git a/frontend/components/Item/View/Table.vue b/frontend/components/Item/View/Table.vue
index b9b7196..f6c3cf1 100644
--- a/frontend/components/Item/View/Table.vue
+++ b/frontend/components/Item/View/Table.vue
@@ -79,7 +79,7 @@
};
const props = defineProps();
- const sortByProperty = ref("name");
+ const sortByProperty = ref("");
const headers = computed(() => {
return [
@@ -136,6 +136,10 @@
}
function itemSort(a: ItemSummary, b: ItemSummary) {
+ if (!sortByProperty.value) {
+ return 0;
+ }
+
const aLower = extractSortable(a, sortByProperty.value);
const bLower = extractSortable(b, sortByProperty.value);
diff --git a/frontend/layouts/default.vue b/frontend/layouts/default.vue
index 393b4ee..8941b28 100644
--- a/frontend/layouts/default.vue
+++ b/frontend/layouts/default.vue
@@ -16,16 +16,16 @@
diff --git a/frontend/lib/api/classes/items.ts b/frontend/lib/api/classes/items.ts
index 29403a2..b7cc17d 100644
--- a/frontend/lib/api/classes/items.ts
+++ b/frontend/lib/api/classes/items.ts
@@ -15,6 +15,7 @@ import { AttachmentTypes, PaginationResult } from "../types/non-generated";
import { Requests } from "~~/lib/requests";
export type ItemsQuery = {
+ orderBy?: string;
includeArchived?: boolean;
page?: number;
pageSize?: number;
diff --git a/frontend/pages/home/table.ts b/frontend/pages/home/table.ts
index 127ecbb..7c38d6a 100644
--- a/frontend/pages/home/table.ts
+++ b/frontend/pages/home/table.ts
@@ -5,6 +5,7 @@ export function itemsTable(api: UserClient) {
const { data } = await api.items.getAll({
page: 1,
pageSize: 5,
+ orderBy: "createdAt",
});
return data.items;
});
diff --git a/frontend/pages/profile.vue b/frontend/pages/profile.vue
index 8e848b7..5788d74 100644
--- a/frontend/pages/profile.vue
+++ b/frontend/pages/profile.vue
@@ -473,11 +473,10 @@
Delete Account
Delete your account and all its associated data.
-
-
- Delete Account
-
+
+ Delete Account
+