diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/grils/grils.go | 33 | ||||
-rw-r--r-- | modules/lists/lists.go | 63 |
2 files changed, 90 insertions, 6 deletions
diff --git a/modules/grils/grils.go b/modules/grils/grils.go new file mode 100644 index 0000000..6ce7c5e --- /dev/null +++ b/modules/grils/grils.go | |||
@@ -0,0 +1,33 @@ | |||
1 | package grils | ||
2 | |||
3 | import ( | ||
4 | "fagott.pw/charakterin" | ||
5 | "fagott.pw/grilist/grilist" | ||
6 | ) | ||
7 | |||
8 | type GrilsModule struct { | ||
9 | g *grilist.Grilist | ||
10 | Test []int | ||
11 | } | ||
12 | |||
13 | func (m *GrilsModule) Name() string { | ||
14 | return "Grils" | ||
15 | } | ||
16 | |||
17 | func (m *GrilsModule) Init(g *grilist.Grilist) { | ||
18 | m.g = g | ||
19 | m.Test = append(m.Test, len(m.Test) + 1) | ||
20 | } | ||
21 | |||
22 | func (m *GrilsModule) Interface() interface{} { | ||
23 | m.Test = append(m.Test, len(m.Test) + 1) | ||
24 | return m | ||
25 | } | ||
26 | |||
27 | func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) grilist.DashboardCategory { | ||
28 | return grilist.DashboardCategory{} | ||
29 | } | ||
30 | |||
31 | func New() *GrilsModule { | ||
32 | return &GrilsModule{} | ||
33 | } | ||
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 | ||
3 | import ( | 3 | import ( |
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 | ||
8 | type ListsModule struct { | 11 | type ListsModule struct { |
9 | g *grilist.Grilist | 12 | g *grilist.Grilist |
13 | grils *grils.GrilsModule | ||
10 | } | 14 | } |
11 | 15 | ||
12 | func (d *ListsModule) Name() string { | 16 | type List struct { |
13 | return "ListsModule" | 17 | ID int |
18 | Name string | ||
19 | Description string | ||
20 | Owner *charakterin.User | ||
14 | } | 21 | } |
15 | 22 | ||
16 | func (d *ListsModule) Init(g *grilist.Grilist) { | 23 | func (m *ListsModule) Name() string { |
17 | d.g = g | 24 | return "Lists" |
18 | } | 25 | } |
19 | 26 | ||
20 | func (d *ListsModule) ProvideDashboardData(user *charakterin.User) grilist.DashboardCategory { | 27 | func (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 | |||
42 | func (m *ListsModule) Interface() interface{} { | ||
43 | return m | ||
44 | } | ||
45 | |||
46 | func (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 | ||
24 | func New() *ListsModule { | 75 | func New() *ListsModule { |