- html/template sistem: layout, dashboard, column, task-card, task-detail - Dark tema CSS, responsive grid (5→3→2→1 kolona) - HTMX: klik→detalj panel, move dugmad, auto-refresh active kolone - /report/:id za prikaz izveštaja - Slide-in animacija za detalj panel - 16 server testova, 83 ukupno — svi prolaze - T08 premešten u done/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
2.4 KiB
Go
103 lines
2.4 KiB
Go
package server
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
"strings"
|
|
|
|
"github.com/dal/kaos/internal/supervisor"
|
|
"github.com/dal/kaos/web"
|
|
)
|
|
|
|
// columnData holds data for rendering a single kanban column.
|
|
type columnData struct {
|
|
Name string
|
|
Label string
|
|
Icon string
|
|
Count int
|
|
Tasks []supervisor.Task
|
|
}
|
|
|
|
// dashboardData holds data for the full dashboard page.
|
|
type dashboardData struct {
|
|
Columns []columnData
|
|
}
|
|
|
|
// taskDetailData holds data for the task detail panel.
|
|
type taskDetailData struct {
|
|
Task supervisor.Task
|
|
Content string
|
|
HasReport bool
|
|
}
|
|
|
|
// statusIcons maps folder names to emoji icons.
|
|
var statusIcons = map[string]string{
|
|
"backlog": "📦",
|
|
"ready": "📋",
|
|
"active": "🔄",
|
|
"review": "👀",
|
|
"done": "✅",
|
|
}
|
|
|
|
// columnOrder defines the display order of columns.
|
|
var columnOrder = []string{"backlog", "ready", "active", "review", "done"}
|
|
|
|
// templateFuncs provides custom functions for templates.
|
|
var templateFuncs = template.FuncMap{
|
|
"joinDeps": func(deps []string) string {
|
|
return strings.Join(deps, ", ")
|
|
},
|
|
}
|
|
|
|
// templates holds the parsed template set.
|
|
var templates *template.Template
|
|
|
|
func init() {
|
|
templates = template.Must(
|
|
template.New("").Funcs(templateFuncs).ParseFS(
|
|
web.TemplatesFS,
|
|
"templates/layout.html",
|
|
"templates/dashboard.html",
|
|
"templates/partials/column.html",
|
|
"templates/partials/task-card.html",
|
|
"templates/partials/task-detail.html",
|
|
),
|
|
)
|
|
}
|
|
|
|
// renderDashboard generates the full dashboard HTML page.
|
|
func renderDashboard(columns map[string][]supervisor.Task) string {
|
|
data := dashboardData{}
|
|
for _, col := range columnOrder {
|
|
tasks := columns[col]
|
|
data.Columns = append(data.Columns, columnData{
|
|
Name: col,
|
|
Label: strings.ToUpper(col),
|
|
Icon: statusIcons[col],
|
|
Count: len(tasks),
|
|
Tasks: tasks,
|
|
})
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
if err := templates.ExecuteTemplate(&buf, "layout.html", data); err != nil {
|
|
return "Greška pri renderovanju: " + err.Error()
|
|
}
|
|
return buf.String()
|
|
}
|
|
|
|
// renderTaskDetail generates HTML fragment for task detail panel.
|
|
func renderTaskDetail(t supervisor.Task, content string, hasReport bool) string {
|
|
data := taskDetailData{
|
|
Task: t,
|
|
Content: content,
|
|
HasReport: hasReport,
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
if err := templates.ExecuteTemplate(&buf, "task-detail", data); err != nil {
|
|
return "Greška pri renderovanju: " + err.Error()
|
|
}
|
|
return buf.String()
|
|
}
|