more api call
This commit is contained in:
5
admin.go
5
admin.go
@@ -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
52
api.go
@@ -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",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user