Urlaubsmodus implementiert - Globale Checkbox zum Deaktivieren des Schedulers
This commit is contained in:
@ -327,3 +327,55 @@ func (h *PCHandler) GetRecentLogsByPCID(c *gin.Context) {
|
||||
Logs: logs,
|
||||
})
|
||||
}
|
||||
|
||||
// GetVacationMode gibt den aktuellen Urlaubsmodus-Status zurück
|
||||
func (h *PCHandler) GetVacationMode(c *gin.Context) {
|
||||
enabled, err := h.db.IsVacationModeEnabled()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"success": false,
|
||||
"message": "Fehler beim Laden des Urlaubsmodus: " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"vacation_mode": enabled,
|
||||
})
|
||||
}
|
||||
|
||||
// SetVacationMode setzt den Urlaubsmodus
|
||||
func (h *PCHandler) SetVacationMode(c *gin.Context) {
|
||||
var req struct {
|
||||
VacationMode bool `json:"vacation_mode" binding:"required"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"success": false,
|
||||
"message": "Ungültige Anfrage: " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
value := "false"
|
||||
if req.VacationMode {
|
||||
value = "true"
|
||||
}
|
||||
|
||||
err := h.db.SetSetting("vacation_mode", value)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"success": false,
|
||||
"message": "Fehler beim Speichern des Urlaubsmodus: " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "Urlaubsmodus erfolgreich aktualisiert",
|
||||
"vacation_mode": req.VacationMode,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user