✨ RoadSign Sideload now built-in web ui
This commit is contained in:
parent
86b65cd21f
commit
14a7d936d2
@ -1,8 +1,14 @@
|
|||||||
# Building Backend
|
# Building Backend
|
||||||
FROM golang:alpine as roadsign-server
|
FROM golang:alpine as roadsign-server
|
||||||
|
|
||||||
|
RUN apk add nodejs npm
|
||||||
|
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
WORKDIR /source/pkg/sideload/view
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
WORKDIR /source
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/cmd/server/main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/cmd/server/main.go
|
||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
|
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
|
package sideload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.smartsheep.studio/goatworks/roadsign/pkg/sideload/view"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
|
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
|
||||||
"github.com/gofiber/fiber/v2"
|
"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 := app.Group("/cgi").Name("CGI")
|
||||||
{
|
{
|
||||||
cgi.All("/connectivity", responseConnectivity)
|
cgi.All("/connectivity", responseConnectivity)
|
||||||
cgi.Get("/statistics", getStatistics)
|
cgi.Get("/statistics", getStatistics)
|
||||||
cgi.Get("/sites", getSites)
|
cgi.Get("/sites", getSites)
|
||||||
cgi.Get("/sites/cfg/:id", getSiteConfig)
|
cgi.Get("/sites/cfg/:id", getSiteConfig)
|
||||||
|
cgi.Get("/processes", getProcesses)
|
||||||
|
cgi.Get("/processes/logs/:id", getProcessLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
webhooks := app.Group("/webhooks").Name("WebHooks")
|
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 publishing = ref(false)
|
||||||
const editing = ref(false)
|
const editing = ref(false)
|
||||||
|
|
||||||
const config = ref<string | null>(null)
|
const config = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
async function editConfig() {
|
async function editConfig() {
|
||||||
const resp = await fetch(`/cgi/sites/cfg/${props.id}`)
|
const resp = await fetch(`/cgi/sites/cfg/${props.id}`)
|
||||||
@ -101,6 +101,8 @@ async function editConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function syncConfig() {
|
async function syncConfig() {
|
||||||
|
if (config.value == null) return
|
||||||
|
|
||||||
let content
|
let content
|
||||||
try {
|
try {
|
||||||
content = yaml.load(config.value)
|
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 SitesTableAction from "@/components/data/sites-table-action.vue"
|
||||||
import SitesTableAdd from "@/components/data/sites-table-add.vue"
|
import SitesTableAdd from "@/components/data/sites-table-add.vue"
|
||||||
|
|
||||||
const columns = [
|
const columns: any[] = [
|
||||||
{
|
{
|
||||||
type: "expand",
|
type: "expand",
|
||||||
renderExpand(row: any) {
|
renderExpand(row: any) {
|
||||||
|
@ -32,7 +32,6 @@ type ProcessInstance struct {
|
|||||||
Logger strings.Builder `json:"-"`
|
Logger strings.Builder `json:"-"`
|
||||||
|
|
||||||
Status ProcessStatus `json:"status"`
|
Status ProcessStatus `json:"status"`
|
||||||
Logs string `json:"logs"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *ProcessInstance) BootProcess() error {
|
func (v *ProcessInstance) BootProcess() error {
|
||||||
@ -117,8 +116,7 @@ func (v *ProcessInstance) StopProcess() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *ProcessInstance) GetLogs() string {
|
func (v *ProcessInstance) GetLogs() string {
|
||||||
v.Logs = v.Logger.String()
|
return v.Logger.String()
|
||||||
return v.Logs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *RoadApp) PreheatProcesses(callbacks ...func(total int, success int)) {
|
func (v *RoadApp) PreheatProcesses(callbacks ...func(total int, success int)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user