From a0abab5bf0471b4326a3eae2c6bfed4e3a6359ba Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Mon, 9 Apr 2018 10:49:10 +0000 Subject: [PATCH] Add book lists to dashboard --- lib/user.go | 13 ++++++++++++- templates/book.html | 4 ++-- templates/dashboard.html | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/user.go b/lib/user.go index 2f8fde2..c37e7ef 100644 --- a/lib/user.go +++ b/lib/user.go @@ -58,13 +58,24 @@ func dashboardHandler(h handler) { return } - var data statusData + lists, err := h.db.GetListsByUser(h.sess.User) + if err != nil { + log.Error("Error loading user ", h.sess.User, " lists: ", err) + } + + var data dashboardData data.S = GetStatus(h) data.S.Title = "Dashboard -- " + data.S.Title data.S.Dasboard = true + data.Lists = lists h.load("dashboard", data) } +type dashboardData struct { + S Status + Lists []database.BookList +} + func settingsHandler(h handler) { if h.sess.User == "" { notFound(h) diff --git a/templates/book.html b/templates/book.html index 7d0e7ed..4bc77ba 100644 --- a/templates/book.html +++ b/templates/book.html @@ -80,9 +80,9 @@ function delBook(){

Book in lists:

-
diff --git a/templates/dashboard.html b/templates/dashboard.html index 751fb90..d5fb3a9 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -2,6 +2,7 @@

Dashboard

+
+
+ +{{if .Lists}} +
+

My book lists

+
+
+ +
+
+{{end}} {{template "footer.html"}}