Files
Redflag/aggregator-server/internal/api/handlers/settings.go
Fimeg a7fad61de2 Update installer system for update approval functionality
Major milestone: Update installation system now works
- Implemented unified installer interface with factory pattern
- Created APT, DNF, and Docker installers
- Integrated installer into agent command processing loop
- Update approval button now actually installs packages

Documentation updates:
- Updated claude.md with Session 7 implementation log
- Created clean, professional README.md for GitHub
- Added screenshots section with 4 dashboard views
- Preserved detailed development history in backup files

Repository ready for GitHub alpha release with working installer functionality.
2025-10-16 09:06:12 -04:00

67 lines
1.6 KiB
Go

package handlers
import (
"net/http"
"github.com/aggregator-project/aggregator-server/internal/services"
"github.com/gin-gonic/gin"
)
type SettingsHandler struct {
timezoneService *services.TimezoneService
}
func NewSettingsHandler(timezoneService *services.TimezoneService) *SettingsHandler {
return &SettingsHandler{
timezoneService: timezoneService,
}
}
// GetTimezones returns available timezone options
func (h *SettingsHandler) GetTimezones(c *gin.Context) {
timezones := h.timezoneService.GetAvailableTimezones()
c.JSON(http.StatusOK, gin.H{"timezones": timezones})
}
// GetTimezone returns the current timezone configuration
func (h *SettingsHandler) GetTimezone(c *gin.Context) {
// TODO: Get from user settings when implemented
// For now, return the server timezone
c.JSON(http.StatusOK, gin.H{
"timezone": "UTC",
"label": "UTC (Coordinated Universal Time)",
})
}
// UpdateTimezone updates the timezone configuration
func (h *SettingsHandler) UpdateTimezone(c *gin.Context) {
var req struct {
Timezone string `json:"timezone" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// TODO: Save to user settings when implemented
// For now, just validate it's a valid timezone
timezones := h.timezoneService.GetAvailableTimezones()
valid := false
for _, tz := range timezones {
if tz.Value == req.Timezone {
valid = true
break
}
}
if !valid {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid timezone"})
return
}
c.JSON(http.StatusOK, gin.H{
"message": "timezone updated",
"timezone": req.Timezone,
})
}