more api call

This commit is contained in:
shoopea
2025-12-28 19:27:10 +01:00
parent c8715679f8
commit fd1c14831f
3 changed files with 61 additions and 4 deletions

View File

@@ -62,12 +62,17 @@ func (a *AdminConfig) Run() {
r.GET("/config/:app", ApiConfigApp)
r.GET("/app/list", ApiAppList)
r.GET("/app/list/schedule/:schedule", ApiListSchedule)
r.GET("/app/add/:app", ApiAppAdd)
r.GET("/app/del/:app", ApiAppDel)
r.GET("/app/activate/:app", ApiAppActivate)
r.GET("/app/deactivate/:app", ApiAppDeactivate)
r.GET("/app/:app/source/list", ApiAppSourceList)
r.GET("/app/:app/source/add/:src", ApiAppSourceAdd)
r.GET("/app/:app/source/del/:src", ApiAppSourceDel)
srv := &http.Server{
Addr: a.Addr,
Handler: r,

52
api.go
View File

@@ -192,6 +192,34 @@ func ApiAppList(c *gin.Context) {
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
}
func ApiListSchedule(c *gin.Context) {
name := c.Param("schedule")
list := make([]string, 0)
CfgLock()
defer CfgUnlock()
for _, app := range cfg.Apps {
for _, sched := range app.Schedule {
if sched == name && !slices.Contains(list, app.Name) {
list = append(list, app.Name)
}
}
}
slices.Sort(list)
b, err := json.Marshal(list)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": err,
})
return
}
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
}
func ApiAppAdd(c *gin.Context) {
name := c.Param("app")
found := false
@@ -334,3 +362,27 @@ func ApiAppDeactivate(c *gin.Context) {
"message": "done",
})
}
// FIXME
func ApiAppSourceList(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": "not implemented",
})
}
// FIXME
func ApiAppSourceAdd(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": "not implemented",
})
}
// FIXME
func ApiAppSourceDel(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": "not implemented",
})
}

View File

@@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "ee94b07"
var githash = "c871567"
var branch = "master"
var buildstamp = "2025-12-28_15:41:47"
var commits = "123"
var version = "ee94b07-b123 - 2025-12-28_15:41:47"
var buildstamp = "2025-12-28_18:26:51"
var commits = "124"
var version = "c871567-b124 - 2025-12-28_18:26:51"