summaryrefslogtreecommitdiff
path: root/internal/handlers/elements.go
blob: 65a1c2d0fb6ff099d5f027bd4a10c61ed728dd59 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package handlers

import (
	"html/template"
	"net/http"
)

func (h *Handlers) ServeShowForm(w http.ResponseWriter, r *http.Request) {
	tmpl, err := template.ParseGlob("components/*.html")
	if err != nil {
		abortWithError(w, err.Error())
		return
	}
	tmpl.ExecuteTemplate(w, "actionform", nil)
}

func (h *Handlers) ServeHideForm(w http.ResponseWriter, r *http.Request) {
	tmpl, err := template.ParseGlob("components/*.html")
	if err != nil {
		abortWithError(w, err.Error())
		return
	}
	tmpl.ExecuteTemplate(w, "showformbtn", nil)
}

func (h *Handlers) ShowRecommended(w http.ResponseWriter, r *http.Request) {
	var username string
	// TODO: getusername
	// TODO: get recommendations for user
	acts, err := h.fetchRecommendations(username, 5)
	if err != nil {
		abortWithError(w, err.Error())
		return
	}
	h.log.Debug("got actions", "acts#", len(acts))
	tmpl, err := template.ParseGlob("components/*.html")
	if err != nil {
		abortWithError(w, err.Error())
		return
	}
	tmpl.ExecuteTemplate(w, "showformbtn", nil)
}

func (h *Handlers) HideRecommended(w http.ResponseWriter, r *http.Request) {
	tmpl, err := template.ParseGlob("components/*.html")
	if err != nil {
		abortWithError(w, err.Error())
		return
	}
	tmpl.ExecuteTemplate(w, "showformbtn", nil)
}