mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-09 17:14:20 +01:00
Add Todos, Projects, and Contexts web pages
- Created todos.html template showing user's todos with state badges - Created projects.html template showing project cards in grid layout - Created contexts.html template showing context cards - Added ShowTodos, ShowProjects, ShowContexts handlers to web_handler.go - Added routes for /todos, /projects, /contexts to main.go - All pages show empty state when no data exists - Navigation menu links now work without 404 errors All pages are functional and display user-specific data from the database.
This commit is contained in:
parent
f51dccb228
commit
ca6e157a91
5 changed files with 380 additions and 0 deletions
|
|
@ -183,3 +183,68 @@ func (h *WebHandler) HandleCreateUser(c *gin.Context) {
|
|||
// Redirect back to users page with success message
|
||||
c.Redirect(http.StatusFound, "/admin/users?success=User created successfully")
|
||||
}
|
||||
|
||||
// ShowTodos displays the todos page
|
||||
func (h *WebHandler) ShowTodos(c *gin.Context) {
|
||||
user, _ := middleware.GetCurrentUser(c)
|
||||
|
||||
// Get user's todos
|
||||
var todos []models.Todo
|
||||
database.DB.
|
||||
Preload("Context").
|
||||
Preload("Project").
|
||||
Where("user_id = ?", user.ID).
|
||||
Order("created_at DESC").
|
||||
Find(&todos)
|
||||
|
||||
data := gin.H{
|
||||
"Title": "Todos",
|
||||
"User": user,
|
||||
"Todos": todos,
|
||||
}
|
||||
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.templates.ExecuteTemplate(c.Writer, "base.html", data)
|
||||
}
|
||||
|
||||
// ShowProjects displays the projects page
|
||||
func (h *WebHandler) ShowProjects(c *gin.Context) {
|
||||
user, _ := middleware.GetCurrentUser(c)
|
||||
|
||||
// Get user's projects
|
||||
var projects []models.Project
|
||||
database.DB.
|
||||
Where("user_id = ?", user.ID).
|
||||
Order("created_at DESC").
|
||||
Find(&projects)
|
||||
|
||||
data := gin.H{
|
||||
"Title": "Projects",
|
||||
"User": user,
|
||||
"Projects": projects,
|
||||
}
|
||||
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.templates.ExecuteTemplate(c.Writer, "base.html", data)
|
||||
}
|
||||
|
||||
// ShowContexts displays the contexts page
|
||||
func (h *WebHandler) ShowContexts(c *gin.Context) {
|
||||
user, _ := middleware.GetCurrentUser(c)
|
||||
|
||||
// Get user's contexts
|
||||
var contexts []models.Context
|
||||
database.DB.
|
||||
Where("user_id = ?", user.ID).
|
||||
Order("position ASC").
|
||||
Find(&contexts)
|
||||
|
||||
data := gin.H{
|
||||
"Title": "Contexts",
|
||||
"User": user,
|
||||
"Contexts": contexts,
|
||||
}
|
||||
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.templates.ExecuteTemplate(c.Writer, "base.html", data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue