Scripting

/app/controller/cmenu/scripting.go (665 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package cmenu

import (
"net/url"

"github.com/samber/lo"

"{{{ .Package }}}/app/lib/menu"
"{{{ .Package }}}/app/lib/scripting"
"{{{ .Package }}}/app/util"
)

func scriptingMenu(s *scripting.Service, logger util.Logger) *menu.Item {
scripts := s.ListScripts(logger)
ret := make(menu.Items, 0, len(scripts))
lo.ForEach(scripts, func(x string, _ int) {
ret = append(ret, &menu.Item{Key: x, Title: x, Icon: "file-code", Route: "/admin/scripting/" + url.QueryEscape(x)})
})
desc := "script files managed by this system"
return &menu.Item{Key: "scripting", Title: "Scripts", Description: desc, Icon: "file-code", Route: "/admin/scripting", Children: ret}
}