aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/incoming/web/handlers/group.go
diff options
context:
space:
mode:
Diffstat (limited to 'forged/internal/incoming/web/handlers/group.go')
-rw-r--r--forged/internal/incoming/web/handlers/group.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/forged/internal/incoming/web/handlers/group.go b/forged/internal/incoming/web/handlers/group.go
index e56a3b5..3551ab1 100644
--- a/forged/internal/incoming/web/handlers/group.go
+++ b/forged/internal/incoming/web/handlers/group.go
@@ -1,9 +1,10 @@
package handlers
import (
+ "log"
"net/http"
- "strings"
+ "go.lindenii.runxiyu.org/forge/forged/internal/database/queries"
"go.lindenii.runxiyu.org/forge/forged/internal/incoming/web/templates"
wtypes "go.lindenii.runxiyu.org/forge/forged/internal/incoming/web/types"
)
@@ -20,9 +21,36 @@ func NewGroupHTTP(r templates.Renderer) *GroupHTTP {
func (h *GroupHTTP) Index(w http.ResponseWriter, r *http.Request, _ wtypes.Vars) {
base := wtypes.Base(r)
- _ = h.r.Render(w, "group/index.html", struct {
- GroupPath string
+ p, err := base.Queries.GetGroupIDDescByPath(r.Context(), base.URLSegments)
+ if err != nil {
+ log.Println("failed to get group ID by path", "error", err)
+ http.Error(w, "Internal Server Error", http.StatusInternalServerError)
+ return
+ }
+ subgroups, err := base.Queries.GetSubgroups(r.Context(), &p.ID)
+ if err != nil {
+ log.Println("failed to get subgroups", "error", err)
+ http.Error(w, "Internal Server Error", http.StatusInternalServerError)
+ // TODO
+ }
+ repos, err := base.Queries.GetReposInGroup(r.Context(), p.ID)
+ if err != nil {
+ log.Println("failed to get repos in group", "error", err)
+ http.Error(w, "Internal Server Error", http.StatusInternalServerError)
+ // TODO
+ }
+ err = h.r.Render(w, "group", struct {
+ BaseData *wtypes.BaseData
+ Subgroups []queries.GetSubgroupsRow
+ Repos []queries.GetReposInGroupRow
+ Description string
}{
- GroupPath: "/" + strings.Join(base.GroupPath, "/") + "/",
+ BaseData: base,
+ Subgroups: subgroups,
+ Repos: repos,
+ Description: p.Description,
})
+ if err != nil {
+ log.Println("failed to render index page", "error", err)
+ }
}