Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dadav committed Jul 11, 2024
1 parent c575e68 commit 46d6e53
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
18 changes: 18 additions & 0 deletions internal/v3/ui/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ body {
align-items: center;
justify-content: center;
}

.search {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}

input {
width: 100%;
padding: 5px;
}

table {
width: 100%;
font-size: 2rem;
text-align: center;
}
15 changes: 2 additions & 13 deletions internal/v3/ui/handlers/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/dadav/gorge/internal/log"
"github.com/dadav/gorge/internal/v3/backend"
"github.com/dadav/gorge/internal/v3/ui"
gen "github.com/dadav/gorge/pkg/gen/v3/openapi"
"github.com/go-chi/chi/v5"
)

Expand Down Expand Up @@ -43,19 +42,9 @@ func (g *GorgeService) SearchHandler(w http.ResponseWriter, r *http.Request) {
return
}

matching := []*gen.Module{}

for _, module := range modules {
if strings.Contains(module.Name, query) {
matching = append(matching, module)
}
}

if len(matching) > 0 {
for _, foo := range matching {
ui.ModuleToTableRow(foo.Name, foo.Owner.Username, foo.CurrentRelease.Version).Render(context.Background(), w)
if strings.Contains(module.Name, query) || strings.Contains(module.Owner.Username, query) || strings.Contains(module.CurrentRelease.Version, query) {
ui.ModuleToTableRow(module.Name, module.Owner.Username, module.CurrentRelease.Version).Render(context.Background(), w)
}
} else {
log.Log.Info("Nothing found")
}
}
8 changes: 4 additions & 4 deletions internal/v3/ui/index.templ
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import "github.com/dadav/gorge/internal/v3/ui/components"
templ body() {
<div class="main">
<div class="search">
<img src="/assets/logo.png" width="300"/>
<img id="logo" src="/assets/logo.png" width="300"/>
<br/>
<input
class="form-control"
type="search"
name="search"
placeholder="..."
placeholder="Name, author, version..."
hx-get="/search"
hx-params="*"
hx-trigger="input changed delay:500ms, search"
hx-trigger="input changed delay:500ms, search, load"
hx-target="#search-results"
hx-indicator=".htmx-indicator"
/>
<table class="table">
<thead>
Expand Down
2 changes: 1 addition & 1 deletion internal/v3/ui/index_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46d6e53

Please sign in to comment.