update app list
This commit is contained in:
4
admin.go
4
admin.go
@@ -62,7 +62,9 @@ func (a *AdminConfig) Run() {
|
|||||||
r.GET("/config/:app", ApiConfigApp)
|
r.GET("/config/:app", ApiConfigApp)
|
||||||
|
|
||||||
r.GET("/app/list", ApiAppList)
|
r.GET("/app/list", ApiAppList)
|
||||||
r.GET("/app/list/schedule/:schedule", ApiListSchedule)
|
r.GET("/app/list/schedule/:schedule", ApiAppListSchedule)
|
||||||
|
r.GET("/app/list/active", ApiAppListActive)
|
||||||
|
r.GET("/app/list/inactive", ApiAppListInactive)
|
||||||
r.GET("/app/add/:app", ApiAppAdd)
|
r.GET("/app/add/:app", ApiAppAdd)
|
||||||
r.GET("/app/del/:app", ApiAppDel)
|
r.GET("/app/del/:app", ApiAppDel)
|
||||||
|
|
||||||
|
|||||||
117
api.go
117
api.go
@@ -124,53 +124,22 @@ func ApiRunApp(c *gin.Context) {
|
|||||||
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting")
|
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting")
|
||||||
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done")
|
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done")
|
||||||
|
|
||||||
name := c.Param("app")
|
if app, ok := cfg.apps[c.Param("app")]; ok {
|
||||||
found := false
|
if err := app.RunStandaloneTime(time.Now()); err != nil {
|
||||||
active := false
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
var (
|
"message": "error",
|
||||||
app *App
|
"error": fmt.Sprint(err),
|
||||||
err error
|
})
|
||||||
)
|
} else {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
for _, a := range cfg.Apps {
|
"message": "done",
|
||||||
if a.Name == name {
|
})
|
||||||
found = true
|
|
||||||
active = a.Active
|
|
||||||
app, err = cfg.NewApp(a.Name, a.Sources, a.Destinations, a.Schedule, a.Before, a.After)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"message": "error",
|
|
||||||
"error": fmt.Sprint(err),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"message": "error",
|
|
||||||
"error": "no app found",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !active {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"message": "error",
|
|
||||||
"error": "app not active",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.RunStandaloneTime(time.Now()); err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"message": "error",
|
|
||||||
"error": fmt.Sprint(err),
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"message": "done",
|
"message": "error",
|
||||||
|
"app": c.Param("app"),
|
||||||
|
"error": "no active app found",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +231,7 @@ func ApiAppList(c *gin.Context) {
|
|||||||
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApiListSchedule(c *gin.Context) {
|
func ApiAppListSchedule(c *gin.Context) {
|
||||||
log.WithFields(log.Fields{"schedule": c.Param("schedule")}).Debugf("starting")
|
log.WithFields(log.Fields{"schedule": c.Param("schedule")}).Debugf("starting")
|
||||||
log.WithFields(log.Fields{"schedule": c.Param("schedule")}).Debugf("done")
|
log.WithFields(log.Fields{"schedule": c.Param("schedule")}).Debugf("done")
|
||||||
|
|
||||||
@@ -293,6 +262,62 @@ func ApiListSchedule(c *gin.Context) {
|
|||||||
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ApiAppListActive(c *gin.Context) {
|
||||||
|
log.WithFields(log.Fields{}).Debugf("starting")
|
||||||
|
log.WithFields(log.Fields{}).Debugf("done")
|
||||||
|
|
||||||
|
list := make([]string, 0)
|
||||||
|
|
||||||
|
CfgLock()
|
||||||
|
defer CfgUnlock()
|
||||||
|
|
||||||
|
for _, app := range cfg.Apps {
|
||||||
|
if app.Active {
|
||||||
|
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": fmt.Sprint(err),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ApiAppListInactive(c *gin.Context) {
|
||||||
|
log.WithFields(log.Fields{}).Debugf("starting")
|
||||||
|
log.WithFields(log.Fields{}).Debugf("done")
|
||||||
|
|
||||||
|
list := make([]string, 0)
|
||||||
|
|
||||||
|
CfgLock()
|
||||||
|
defer CfgUnlock()
|
||||||
|
|
||||||
|
for _, app := range cfg.Apps {
|
||||||
|
if !app.Active {
|
||||||
|
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": fmt.Sprint(err),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "}))
|
||||||
|
}
|
||||||
|
|
||||||
func ApiAppAdd(c *gin.Context) {
|
func ApiAppAdd(c *gin.Context) {
|
||||||
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting")
|
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting")
|
||||||
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done")
|
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||||
package main
|
package main
|
||||||
var githash = "b1a5084"
|
var githash = "551651b"
|
||||||
var branch = "master"
|
var branch = "master"
|
||||||
var buildstamp = "2026-01-10_10:51:23"
|
var buildstamp = "2026-01-10_11:02:11"
|
||||||
var commits = "132"
|
var commits = "133"
|
||||||
var version = "b1a5084-b132 - 2026-01-10_10:51:23"
|
var version = "551651b-b133 - 2026-01-10_11:02:11"
|
||||||
|
|||||||
Reference in New Issue
Block a user