aboutsummaryrefslogtreecommitdiff
path: root/modules/lists
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-21 22:29:10 (UTC)
committerjan <jan@ruken.pw>2015-12-21 22:29:10 (UTC)
commit4254929eea29a42896fd57185d6f52fdc3efdca4 (patch)
tree9e8dc1f456ef20c4308d193be5db4114e976577a /modules/lists
parentc3e905c2698f6eb44e291eeb6b180b13755b7705 (diff)
dashboard. FUCKING DASHBOARD!
Diffstat (limited to 'modules/lists')
-rw-r--r--modules/lists/lists.go63
1 files changed, 57 insertions, 6 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index f8f13bb..4e0036a 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -2,23 +2,74 @@ package lists
2 2
3import ( 3import (
4 "fagott.pw/charakterin" 4 "fagott.pw/charakterin"
5 "fagott.pw/grilist/frontend"
5 "fagott.pw/grilist/grilist" 6 "fagott.pw/grilist/grilist"
7 "fagott.pw/grilist/modules/grils"
8 "log"
6) 9)
7 10
8type ListsModule struct { 11type ListsModule struct {
9 g *grilist.Grilist 12 g *grilist.Grilist
13 grils *grils.GrilsModule
10} 14}
11 15
12func (d *ListsModule) Name() string { 16type List struct {
13 return "ListsModule" 17 ID int
18 Name string
19 Description string
20 Owner *charakterin.User
14} 21}
15 22
16func (d *ListsModule) Init(g *grilist.Grilist) { 23func (m *ListsModule) Name() string {
17 d.g = g 24 return "Lists"
18} 25}
19 26
20func (d *ListsModule) ProvideDashboardData(user *charakterin.User) grilist.DashboardCategory { 27func (m *ListsModule) Init(g *grilist.Grilist) {
21 return grilist.DashboardCategory{} 28 m.g = g
29
30 gm, ok := g.Modules["Grils"]
31 if !ok {
32 log.Fatal("lists: grils module not found")
33 }
34
35 grilsModule, ok := gm.Interface().(*grils.GrilsModule)
36 if !ok {
37 log.Fatal("lists: error with grils module")
38 }
39 m.grils = grilsModule
40}
41
42func (m *ListsModule) Interface() interface{} {
43 return m
44}
45
46func (m *ListsModule) ProvideDashboardData(user *charakterin.User) grilist.DashboardCategory {
47 data := grilist.DashboardCategory{
48 Title: "Meine Listen",
49 }
50
51 rows, err := m.g.DB.Query(`SELECT id, name, description FROM grilist.lists WHERE user_id = $1`, user.ID)
52 if err != nil {
53 return data
54 }
55
56 defer rows.Close()
57 for rows.Next() {
58 card := frontend.Card{}
59 view := frontend.Action{
60 Name: "anguckieren",
61 }
62 var id int
63 if err := rows.Scan(&id, &card.Title, &card.Description); err != nil {
64 log.Println("error scanning row",err)
65 continue
66 }
67
68 card.Actions = []frontend.Action{view}
69 data.Cards = append(data.Cards, card)
70 }
71
72 return data
22} 73}
23 74
24func New() *ListsModule { 75func New() *ListsModule {