adapt ui to new assets

This commit is contained in:
Mikaël Cluseau
2026-05-08 15:01:44 +02:00
parent 7a6310c93e
commit b0e84f6aa8
12 changed files with 97 additions and 41 deletions
+17 -4
View File
@@ -262,14 +262,17 @@ func wsDownloadSet(req *restful.Request, resp *restful.Response) {
for _, item := range set.Items {
names := make([]string, 0)
section := ""
switch item.Kind {
case "cluster":
section = "Cluster"
for _, c := range cfg.Clusters {
if globMatch(item.Name, c.Name) {
names = append(names, c.Name)
}
}
case "host":
section = "Host"
for _, h := range cfg.Hosts {
if globMatch(item.Name, h.Name) {
names = append(names, h.Name)
@@ -278,12 +281,22 @@ func wsDownloadSet(req *restful.Request, resp *restful.Response) {
}
for _, name := range names {
fmt.Fprintf(buf, "<h2>%s %s</h2>", strings.Title(item.Kind), name)
fmt.Fprintf(buf, "<p class=\"download-links\">\n")
buf.WriteString("<p>")
fmt.Fprintf(buf, "<strong>%s %s:</strong>", section, name)
buf.WriteString(" <span class=\"download-links\">")
for _, asset := range item.Assets {
fmt.Fprintf(buf, " <a href=\"/public/download-set/%s/%s/%s?set=%s\" download>%s</a>\n", item.Kind, name, asset, setStr, asset)
for _, v := range hostAssetVariants(asset) {
url := fmt.Sprintf("/public/download-set/%s/%s/%s", item.Kind, name, v.url)
if strings.Contains(url, "?") {
url += "&"
} else {
url += "?"
}
url += "set=" + setStr
fmt.Fprintf(buf, " <a href=\"%s\" download>%s</a>\n", url, v.name)
}
}
fmt.Fprintf(buf, `</p>`)
buf.WriteString("</span></p>\n")
}
}