✨ RoadSign Sideload now built-in web ui
This commit is contained in:
29
pkg/sideload/processes.go
Normal file
29
pkg/sideload/processes.go
Normal file
@ -0,0 +1,29 @@
|
||||
package sideload
|
||||
|
||||
import (
|
||||
"code.smartsheep.studio/goatworks/roadsign/pkg/sign"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func getProcesses(c *fiber.Ctx) error {
|
||||
processes := lo.FlatMap(sign.App.Sites, func(item *sign.SiteConfig, idx int) []*sign.ProcessInstance {
|
||||
return item.Processes
|
||||
})
|
||||
|
||||
return c.JSON(processes)
|
||||
}
|
||||
|
||||
func getProcessLog(c *fiber.Ctx) error {
|
||||
processes := lo.FlatMap(sign.App.Sites, func(item *sign.SiteConfig, idx int) []*sign.ProcessInstance {
|
||||
return item.Processes
|
||||
})
|
||||
|
||||
if target, ok := lo.Find(processes, func(item *sign.ProcessInstance) bool {
|
||||
return item.ID == c.Params("id")
|
||||
}); !ok {
|
||||
return fiber.NewError(fiber.StatusNotFound)
|
||||
} else {
|
||||
return c.SendString(target.GetLogs())
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package sideload
|
||||
|
||||
import (
|
||||
"code.smartsheep.studio/goatworks/roadsign/pkg/sideload/view"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@ -39,12 +42,21 @@ func InitSideload() *fiber.App {
|
||||
},
|
||||
}))
|
||||
|
||||
app.Use("/", filesystem.New(filesystem.Config{
|
||||
Root: http.FS(view.FS),
|
||||
PathPrefix: "dist",
|
||||
Index: "index.html",
|
||||
NotFoundFile: "index.html",
|
||||
}))
|
||||
|
||||
cgi := app.Group("/cgi").Name("CGI")
|
||||
{
|
||||
cgi.All("/connectivity", responseConnectivity)
|
||||
cgi.Get("/statistics", getStatistics)
|
||||
cgi.Get("/sites", getSites)
|
||||
cgi.Get("/sites/cfg/:id", getSiteConfig)
|
||||
cgi.Get("/processes", getProcesses)
|
||||
cgi.Get("/processes/logs/:id", getProcessLog)
|
||||
}
|
||||
|
||||
webhooks := app.Group("/webhooks").Name("WebHooks")
|
||||
|
2
pkg/sideload/view/.dockerignore
Normal file
2
pkg/sideload/view/.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
/dist
|
||||
/node_modules
|
@ -92,7 +92,7 @@ const submitting = ref(false)
|
||||
const publishing = ref(false)
|
||||
const editing = ref(false)
|
||||
|
||||
const config = ref<string | null>(null)
|
||||
const config = ref<string | undefined>(undefined)
|
||||
|
||||
async function editConfig() {
|
||||
const resp = await fetch(`/cgi/sites/cfg/${props.id}`)
|
||||
@ -101,6 +101,8 @@ async function editConfig() {
|
||||
}
|
||||
|
||||
async function syncConfig() {
|
||||
if (config.value == null) return
|
||||
|
||||
let content
|
||||
try {
|
||||
content = yaml.load(config.value)
|
||||
|
@ -21,7 +21,7 @@ import SitesTableExpand from "@/components/data/sites-table-expand.vue"
|
||||
import SitesTableAction from "@/components/data/sites-table-action.vue"
|
||||
import SitesTableAdd from "@/components/data/sites-table-add.vue"
|
||||
|
||||
const columns = [
|
||||
const columns: any[] = [
|
||||
{
|
||||
type: "expand",
|
||||
renderExpand(row: any) {
|
||||
|
Reference in New Issue
Block a user