-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): Adding filter by tags in the ui
Signed-off-by: Vincent Boutour <[email protected]>
- Loading branch information
Showing
6 changed files
with
72 additions
and
41 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
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,52 @@ | ||
package crud | ||
|
||
import ( | ||
"net/http" | ||
|
||
absto "github.com/ViBiOh/absto/pkg/model" | ||
"github.com/ViBiOh/fibr/pkg/provider" | ||
"github.com/ViBiOh/fibr/pkg/thumbnail" | ||
"github.com/ViBiOh/httputils/v4/pkg/renderer" | ||
"github.com/ViBiOh/httputils/v4/pkg/tracer" | ||
) | ||
|
||
func (a App) search(r *http.Request, request provider.Request, item absto.Item, files []absto.Item) (renderer.Page, error) { | ||
ctx, end := tracer.StartSpan(r.Context(), a.tracer, "search") | ||
defer end() | ||
|
||
metadatas, err := a.metadataApp.GetAllMetadataFor(ctx, files...) | ||
if err != nil { | ||
listLogger(item.Pathname).Error("list metadatas: %s", err) | ||
} | ||
|
||
items := make([]provider.RenderItem, len(files)) | ||
var hasMap bool | ||
|
||
renderWithThumbnail := request.Display == provider.GridDisplay | ||
|
||
for i, item := range files { | ||
renderItem := provider.StorageToRender(item, request) | ||
|
||
metadata := metadatas[item.ID] | ||
renderItem.Tags = metadata.Tags | ||
|
||
if renderWithThumbnail && a.thumbnailApp.CanHaveThumbnail(item) && a.thumbnailApp.HasThumbnail(ctx, item, thumbnail.SmallSize) { | ||
renderItem.HasThumbnail = true | ||
} | ||
|
||
items[i] = renderItem | ||
|
||
if !hasMap && metadata.Geocode.Longitude != 0 && metadata.Geocode.Latitude != 0 { | ||
hasMap = true | ||
} | ||
} | ||
|
||
return renderer.NewPage("search", http.StatusOK, map[string]any{ | ||
"Paths": getPathParts(request), | ||
"Files": items, | ||
"Cover": a.getCover(ctx, request, files), | ||
"Search": r.URL.Query(), | ||
"Request": request, | ||
"HasMap": hasMap, | ||
}), nil | ||
} |
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