From e406bb2d0401b483e7a3118bb3c472a643b48757 Mon Sep 17 00:00:00 2001 From: zebrapurring <> Date: Fri, 28 Jun 2024 16:44:08 +0200 Subject: [PATCH 1/4] Fix VSCode debug configuration --- .vscode/launch.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d3753958..8c6ce98a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,6 +25,7 @@ "HBOX_STORAGE_DATA": "${workspaceRoot}/backend/.data", "HBOX_STORAGE_SQLITE_URL": "${workspaceRoot}/backend/.data/homebox.db?_fk=1" }, + "console": "integratedTerminal", }, { "name": "Launch Frontend", @@ -38,10 +39,11 @@ "cwd": "${workspaceFolder}/frontend", "serverReadyAction": { "action": "debugWithChrome", - "pattern": "Local: http://localhost:([0-9]+)", + "pattern": "Local: +http://localhost:([0-9]+)", "uriFormat": "http://localhost:%s", "webRoot": "${workspaceFolder}/frontend" - } + }, + "console": "integratedTerminal", } ] } \ No newline at end of file From e929c38e3763a16505dc5b4eff46cb9e5f30b67a Mon Sep 17 00:00:00 2001 From: zebrapurring <> Date: Fri, 28 Jun 2024 16:44:52 +0200 Subject: [PATCH 2/4] Ignore Go debug binary --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f2596031..51a835a4 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,7 @@ dist .pnpm-store backend/app/api/app -backend/app/api/__debug_bin +backend/app/api/__debug_bin* dist/ # Nuxt Publish Dir From e79905b608c23fe9a7b840486373f8187f012575 Mon Sep 17 00:00:00 2001 From: zebrapurring <> Date: Fri, 28 Jun 2024 16:45:43 +0200 Subject: [PATCH 3/4] Implement filtering feature to negate selected labels --- backend/app/api/handlers/v1/v1_ctrl_items.go | 1 + backend/internal/data/repo/repo_items.go | 14 +++++++++++--- frontend/lib/api/classes/items.ts | 1 + frontend/pages/items.vue | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index 2619f4d1..7bcd6131 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -57,6 +57,7 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc { Search: params.Get("q"), LocationIDs: queryUUIDList(params, "locations"), LabelIDs: queryUUIDList(params, "labels"), + NegateLabels: queryBool(params.Get("negateLabels")), ParentItemIDs: queryUUIDList(params, "parentIds"), IncludeArchived: queryBool(params.Get("includeArchived")), Fields: filterFieldItems(params["fields"]), diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go index e88a18ff..c714e229 100644 --- a/backend/internal/data/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -36,6 +36,7 @@ type ( AssetID AssetID `json:"assetId"` LocationIDs []uuid.UUID `json:"locationIds"` LabelIDs []uuid.UUID `json:"labelIds"` + NegateLabels bool `json:"negateLabels"` ParentItemIDs []uuid.UUID `json:"parentIds"` SortBy string `json:"sortBy"` IncludeArchived bool `json:"includeArchived"` @@ -365,10 +366,17 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite if len(q.LabelIDs) > 0 { labelPredicates := make([]predicate.Item, 0, len(q.LabelIDs)) for _, l := range q.LabelIDs { - labelPredicates = append(labelPredicates, item.HasLabelWith(label.ID(l))) + if !q.NegateLabels { + labelPredicates = append(labelPredicates, item.HasLabelWith(label.ID(l))) + } else { + labelPredicates = append(labelPredicates, item.Not(item.HasLabelWith(label.ID(l)))) + } + } + if !q.NegateLabels { + andPredicates = append(andPredicates, item.Or(labelPredicates...)) + } else { + andPredicates = append(andPredicates, item.And(labelPredicates...)) } - - andPredicates = append(andPredicates, item.Or(labelPredicates...)) } if len(q.LocationIDs) > 0 { diff --git a/frontend/lib/api/classes/items.ts b/frontend/lib/api/classes/items.ts index a5d3f2e9..22fbda2d 100644 --- a/frontend/lib/api/classes/items.ts +++ b/frontend/lib/api/classes/items.ts @@ -23,6 +23,7 @@ export type ItemsQuery = { pageSize?: number; locations?: string[]; labels?: string[]; + negateLabels?: boolean; parentIds?: string[]; q?: string; fields?: string[]; diff --git a/frontend/pages/items.vue b/frontend/pages/items.vue index cb207b15..2213975b 100644 --- a/frontend/pages/items.vue +++ b/frontend/pages/items.vue @@ -39,6 +39,7 @@ const advanced = useRouteQuery("advanced", false); const includeArchived = useRouteQuery("archived", false); const fieldSelector = useRouteQuery("fieldSelector", false); + const negateLabels = useRouteQuery("negateLabels", false); const totalPages = computed(() => Math.ceil(total.value / pageSize.value)); const hasNext = computed(() => page.value * pageSize.value < total.value); @@ -162,6 +163,12 @@ } }); + watch(negateLabels, (newV, oldV) => { + if (newV !== oldV) { + search(); + } + }); + async function fetchValues(field: string): Promise { if (fieldValuesCache.value[field]) { return fieldValuesCache.value[field]; @@ -193,6 +200,7 @@ page: page.value, pageSize: pageSize.value, includeArchived: includeArchived.value ? "true" : "false", + negateLabels: negateLabels.value ? "true" : "false", }, }); } @@ -219,6 +227,7 @@ q: query.value || "", locations: locIDs.value, labels: labIDs.value, + negateLabels: negateLabels.value, includeArchived: includeArchived.value, page: page.value, pageSize: pageSize.value, @@ -268,6 +277,7 @@ advanced: "true", archived: includeArchived.value ? "true" : "false", fieldSelector: fieldSelector.value ? "true" : "false", + negateLabels: negateLabels.value ? "true" : "false", pageSize: pageSize.value, page: page.value, q: query.value, @@ -359,6 +369,10 @@ Field Selector +
Reset Search From 9ed618d45e57267074e3d23a2cbf90565cd9054d Mon Sep 17 00:00:00 2001 From: zebrapurring <> Date: Fri, 28 Jun 2024 17:22:01 +0200 Subject: [PATCH 4/4] Fix quoting for GitHub Action --- .github/workflows/docker-publish-rootless.yaml | 2 +- .github/workflows/docker-publish.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish-rootless.yaml b/.github/workflows/docker-publish-rootless.yaml index f5322894..247243d8 100644 --- a/.github/workflows/docker-publish-rootless.yaml +++ b/.github/workflows/docker-publish-rootless.yaml @@ -89,7 +89,7 @@ jobs: build-args: | VERSION=${{ github.ref_name }} COMMIT=$(git rev-parse HEAD) - BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') - name: Attest uses: actions/attest-build-provenance@v1 diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 9458d39c..ed507260 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -86,7 +86,7 @@ jobs: build-args: | VERSION=${{ github.ref_name }} COMMIT=$(git rev-parse HEAD) - BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') - name: Attest uses: actions/attest-build-provenance@v1