Add UI console and spare forecast naming

This commit is contained in:
2026-02-06 00:01:52 +03:00
parent 5af1462645
commit ee46a093d3
21 changed files with 1573 additions and 207 deletions

View File

@@ -20,6 +20,7 @@ type ticketHandlers struct {
func RegisterTicketRoutes(mux *http.ServeMux, deps TicketDependencies) {
h := ticketHandlers{deps: deps}
mux.HandleFunc("/tickets", h.handleTickets)
mux.HandleFunc("/connectors/tickets/sync", h.handleTicketSync)
}
@@ -139,6 +140,34 @@ func (h ticketHandlers) handleTicketSync(w http.ResponseWriter, r *http.Request)
})
}
func (h ticketHandlers) handleTickets(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
if h.deps.Tickets == nil {
writeError(w, http.StatusInternalServerError, "tickets unavailable")
return
}
limit := 200
if raw := r.URL.Query().Get("limit"); raw != "" {
parsed, err := parseIntParam(raw)
if err != nil || parsed <= 0 {
writeError(w, http.StatusBadRequest, "limit must be a positive integer")
return
}
limit = parsed
}
items, err := h.deps.Tickets.ListAll(r.Context(), limit)
if err != nil {
writeError(w, http.StatusInternalServerError, "list tickets failed")
return
}
writeJSON(w, http.StatusOK, map[string]any{"items": items})
}
func parseRFC3339(value *string) (*time.Time, error) {
if value == nil || *value == "" {
return nil, nil