From a1b056737afe666a854bb48a6085533847a50b39 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 18 Oct 2025 19:32:11 +0200 Subject: [PATCH] feat(ui): add system backend metadata and deletion in index (#6546) Signed-off-by: Ettore Di Giacinto --- core/http/routes/ui_api.go | 26 ++++ core/http/views/index.html | 247 +++++++++++++++++++++++++++++++------ 2 files changed, 235 insertions(+), 38 deletions(-) diff --git a/core/http/routes/ui_api.go b/core/http/routes/ui_api.go index 87dcb44c0..1fb016825 100644 --- a/core/http/routes/ui_api.go +++ b/core/http/routes/ui_api.go @@ -620,6 +620,32 @@ func RegisterUIAPIRoutes(app *fiber.App, cl *config.ModelConfigLoader, appConfig return c.JSON(response) }) + // System Backend Deletion API (for installed backends on index page) + app.Post("/api/backends/system/delete/:name", func(c *fiber.Ctx) error { + backendName := strings.Clone(c.Params("name")) + // URL decode the backend name + backendName, err := url.QueryUnescape(backendName) + if err != nil { + return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ + "error": "invalid backend name", + }) + } + log.Debug().Msgf("API request to delete system backend: %+v\n", backendName) + + // Use the gallery package to delete the backend + if err := gallery.DeleteBackendFromSystem(appConfig.SystemState, backendName); err != nil { + log.Error().Err(err).Msgf("Failed to delete backend: %s", backendName) + return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ + "error": err.Error(), + }) + } + + return c.JSON(fiber.Map{ + "success": true, + "message": "Backend deleted successfully", + }) + }) + // P2P APIs app.Get("/api/p2p/workers", func(c *fiber.Ctx) error { nodes := p2p.GetAvailableNodes(p2p.NetworkID(appConfig.P2PNetworkID, p2p.WorkerID)) diff --git a/core/http/views/index.html b/core/http/views/index.html index 995421866..b92c6f2e9 100644 --- a/core/http/views/index.html +++ b/core/http/views/index.html @@ -3,10 +3,35 @@ {{template "views/partials/head" .}} -
+
{{template "views/partials/navbar" .}} + +
+ +
+
@@ -62,7 +87,7 @@ {{ if eq (len .ModelsConfig) 0 }} -
+
@@ -83,12 +108,12 @@
{{ if ne (len .Models) 0 }} -
+

Detected Model Files

These models were found but don't have configuration files yet

{{ range .Models }} -
+
@@ -126,7 +151,7 @@ {{ range .ModelsConfig }} {{ $backendCfg := . }} {{ $cfg:= index $galleryConfig .Name}} -
+
@@ -232,7 +257,7 @@ {{ range .Models }} -
+
@@ -265,55 +290,201 @@ {{ end }}
-
-
+ +
+

Installed Backends

- {{len .InstalledBackends}} backend{{if gt (len .InstalledBackends) 1}}s{{end}} ready to use + {{len .InstalledBackends}} backend{{if gt (len .InstalledBackends) 1}}s{{end}} ready to use

-
-
- - {{ if ne (len .InstalledBackends) 0 }} - - {{ else }} -
-
-
- -
-

No backends installed yet

-

Get started by installing backends from the gallery or check our documentation for guidance

-
-
- {{ end }} - - - {{ range .InstalledBackends }} -
-
-
-
- + {{ if eq (len .InstalledBackends) 0 }} + +
+
+
+
+
-
-

{{.Name}}

+

No backends installed yet

+

Backends power your AI models. Install them from the backend gallery to get started

+ +
+ {{ else }} + +
+ {{ range .InstalledBackends }} +
+ +
+
+
+ +
+
+

{{.Name}}

+ +
+ {{ if .IsSystem }} + + System + + {{ else }} + + User Installed + + {{ end }} + + {{ if .IsMeta }} + + Meta + + {{ end }} +
+
+
+
+ + +
+
+ {{ if and .Metadata .Metadata.Alias }} +
+ +
+ Alias: + {{.Metadata.Alias}} +
+
+ {{ end }} + + {{ if and .Metadata .Metadata.InstalledAt }} +
+ +
+ Installed: + {{.Metadata.InstalledAt}} +
+
+ {{ end }} + + {{ if and .Metadata .Metadata.MetaBackendFor }} +
+ +
+ Meta backend for: + {{.Metadata.MetaBackendFor}} +
+
+ {{ end }} + + {{ if and .Metadata .Metadata.GalleryURL }} + + {{ end }} + +
+ +
+ Path: + {{.RunFile}} +
+
+
+ + + {{ if not .IsSystem }} +
+ +
+ {{ end }} +
+
+ {{end}} +
+ {{ end }}
- {{end}} -
{{template "views/partials/footer" .}}
- \ No newline at end of file +