Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
|
|
"pageswiki/internal/store"
|
|
)
|
|
|
|
func (s *Server) handleTaskScheduleAPI(w http.ResponseWriter, r *http.Request, actor string) {
|
|
if r.Method != "GET" {
|
|
w.WriteHeader(405)
|
|
return
|
|
}
|
|
month := r.URL.Query().Get("month")
|
|
if month == "" {
|
|
month = time.Now().In(s.getLocation(s.domainUUIDForRequest(r))).Format("2006-01")
|
|
}
|
|
items, partial, err := s.store.TaskSchedule(r.Context(), s.domainUUIDForRequest(r), actor, month, r.URL.Query().Get("project"))
|
|
if err != nil {
|
|
taskError(w, err)
|
|
return
|
|
}
|
|
writeEventJSON(w, 200, map[string]any{"items": items, "partial": partial, "month": month})
|
|
}
|
|
func (s *Server) handleTaskSchedulePage(w http.ResponseWriter, r *http.Request, actor string) {
|
|
month := time.Now().In(s.getLocation(s.domainUUIDForRequest(r))).Format("2006-01")
|
|
suffix := strings.TrimPrefix(r.URL.Path, "/v/plan/tasks/schedule")
|
|
if suffix != "" {
|
|
parts := strings.Split(strings.TrimPrefix(suffix, "/"), "/")
|
|
if len(parts) != 2 {
|
|
http.NotFound(w, r)
|
|
return
|
|
}
|
|
month = parts[0] + "-" + parts[1]
|
|
v, e := time.Parse("2006-01", month)
|
|
if e != nil || v.Year() < 1 || v.Format("2006-01") != month {
|
|
http.NotFound(w, r)
|
|
return
|
|
}
|
|
}
|
|
if _, _, err := s.store.ListTasks(r.Context(), s.domainUUIDForRequest(r), actor, store.TaskQuery{Kind: "task", View: "all", Today: month + "-01", Limit: 1}); err != nil {
|
|
taskError(w, err)
|
|
return
|
|
}
|
|
s.renderWithContext(w, r, "task_schedule.gohtml", map[string]any{"Title": "Task schedule", "TaskMonth": month, "TaskTimezone": s.getTimezoneName(s.domainUUIDForRequest(r)), "Path": r.URL.Path})
|
|
}
|