Skip to content

Commit

Permalink
Add sort
Browse files Browse the repository at this point in the history
  • Loading branch information
noqqe committed Feb 26, 2023
1 parent 6be5cf5 commit 5e627d3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.20

WORKDIR /go/src/app
COPY . /go/src/app

RUN go get -v ./...
RUN go build -ldflags "-X github.com/noqqe/serra/src/serra.Version=`git describe --tags`" -v serra.go

# Run radsportsalat
EXPOSE 8080
CMD [ "./serra", "web" ]
3 changes: 2 additions & 1 deletion src/serra/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var webCmd = &cobra.Command{
type Query struct {
Name string `form:"name"`
Set string `form:"set"`
Sort string `form:"sort"`
}

func startWeb() error {
Expand All @@ -45,7 +46,7 @@ func landingPage(c *gin.Context) {

var query Query
if c.ShouldBind(&query) == nil {
cards := Cards("", query.Set, "", query.Name, "", "")
cards := Cards("", query.Set, query.Sort, query.Name, "", "")
sets := Sets("release")
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"title": "Serraaaa",
Expand Down
23 changes: 21 additions & 2 deletions templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<!-- Left side -->
<div class="level-left">

<div class="level-item">
<div class="field">
<label class="label">Set</label>
Expand All @@ -60,6 +61,21 @@
</div>
</div>

<div class="level-item">
<div class="field">
<label class="label">Sort</label>
<div class="control">
<div class="select is-primary">
<select name="sort" id="sort" form="searchform">
<option value="name" selected>Name</option>
<option value="value">Value</option>
<option value="number">Collector Number</option>
</select>
</div>
</div>
</div>
</div>

<!-- Right side -->
<div class="level-right">
<form action="/" id="searchform">
Expand Down Expand Up @@ -125,8 +141,11 @@
(RegExp(paramName + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]
);
}
var selectedVal = getParam("set");
document.getElementById("set").value = selectedVal;
var selectedSetVal = getParam("set");
document.getElementById("set").value = selectedSetVal;

var selectedSortVal = getParam("sort");
document.getElementById("sort").value = selectedSortVal;
</script>

</html>

0 comments on commit 5e627d3

Please sign in to comment.