aboutsummaryrefslogtreecommitdiff
path: root/dashboard.go
blob: 0ca38efb57e957eb3ecc7627a22117bd38d37e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main

import (
	"fagott.pw/grilist/grilist"
	"github.com/julienschmidt/httprouter"
	"net/http"
)

func viewDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	user, _ := app.Charakterin.GetUserFromRequest(r)

	var categories []grilist.DashboardCategory

	for _, module := range app.Modules {
		for _, category := range module.ProvideDashboardData(user) {
			if len(category.Cards) > 0 {
				categories = append(categories, category)
			}
		}
	}

	data := make(map[string]interface{})
	data["categories"] = categories
	data["user"] = user
	app.Renderer.RenderPage("dashboard", w, data)
}