Autostart-Funktionalität implementiert: Crontab-Syntax, Scheduler und UI-Integration
This commit is contained in:
@@ -79,8 +79,13 @@ func (h *PCHandler) CreatePC(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Standardwert für Autostart-Cron setzen, falls nicht angegeben
|
||||
if req.AutostartCron == "" {
|
||||
req.AutostartCron = "30 7 * * Mon-Fri"
|
||||
}
|
||||
|
||||
// PC erstellen
|
||||
pc, err := h.db.CreatePC(req.Name, req.MAC, req.IP)
|
||||
pc, err := h.db.CreatePC(req.Name, req.MAC, req.IP, req.AutostartCron, req.AutostartEnabled)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, models.PCResponse{
|
||||
Success: false,
|
||||
@@ -126,8 +131,13 @@ func (h *PCHandler) UpdatePC(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Standardwert für Autostart-Cron setzen, falls nicht angegeben
|
||||
if req.AutostartCron == "" {
|
||||
req.AutostartCron = "30 7 * * Mon-Fri"
|
||||
}
|
||||
|
||||
// PC aktualisieren
|
||||
pc, err := h.db.UpdatePC(id, req.Name, req.MAC, req.IP)
|
||||
pc, err := h.db.UpdatePC(id, req.Name, req.MAC, req.IP, req.AutostartCron, req.AutostartEnabled)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, models.PCResponse{
|
||||
Success: false,
|
||||
@@ -231,11 +241,13 @@ func (h *PCHandler) GetPCStatus(c *gin.Context) {
|
||||
for _, pc := range pcs {
|
||||
online := h.pingService.IsOnline(pc.IP)
|
||||
statusList = append(statusList, models.PCStatus{
|
||||
ID: pc.ID,
|
||||
Name: pc.Name,
|
||||
MAC: pc.MAC,
|
||||
IP: pc.IP,
|
||||
Online: online,
|
||||
ID: pc.ID,
|
||||
Name: pc.Name,
|
||||
MAC: pc.MAC,
|
||||
IP: pc.IP,
|
||||
Online: online,
|
||||
AutostartCron: pc.AutostartCron,
|
||||
AutostartEnabled: pc.AutostartEnabled,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user