fix format of internal node URLs in master UI templates

This commit is contained in:
Chris Lu
2026-02-22 13:47:29 -08:00
parent 07f284c391
commit b5f3094619
2 changed files with 113 additions and 108 deletions

View File

@@ -1,9 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>SeaweedFS {{ .Version }}</title> <title>SeaweedFS {{ .Version }}</title>
<link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css"> <link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css">
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="page-header"> <div class="page-header">
@@ -33,14 +35,14 @@
{{ with .RaftServer }} {{ with .RaftServer }}
<tr> <tr>
<th>Leader</th> <th>Leader</th>
<td><a href="http://{{ .Leader }}">{{ .Leader }}</a></td> <td><a href="{{ url .Leader }}">{{ .Leader }}</a></td>
</tr> </tr>
<tr> <tr>
<th>Other Masters</th> <th>Other Masters</th>
<td class="col-sm-5"> <td class="col-sm-5">
<ul class="list-unstyled"> <ul class="list-unstyled">
{{ range $k, $p := .GetConfiguration.Configuration.Servers }} {{ range $k, $p := .GetConfiguration.Configuration.Servers }}
<li><a href="http://{{ $p.ID }}/ui/index.html">{{ $p.ID }}</a></li> <li><a href="{{ url $p.ID }}/ui/index.html">{{ $p.ID }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
</td> </td>
@@ -99,9 +101,9 @@
<tr> <tr>
<td><code>{{ $dc.Id }}</code></td> <td><code>{{ $dc.Id }}</code></td>
<td>{{ $rack.Id }}</td> <td>{{ $rack.Id }}</td>
<td><a href="http://{{ $dn.Url }}/ui/index.html">{{ $dn.Url }}</a> <td><a href="{{ url $dn.Url }}/ui/index.html">{{ $dn.Url }}</a>
{{ if ne $dn.PublicUrl $dn.Url }} {{ if ne $dn.PublicUrl $dn.Url }}
/ <a href="http://{{ $dn.PublicUrl }}/ui/index.html">{{ $dn.PublicUrl }}</a> / <a href="{{ url $dn.PublicUrl }}/ui/index.html">{{ $dn.PublicUrl }}</a>
{{ end }} {{ end }}
</td> </td>
<td>{{ $dn.Volumes }}</td> <td>{{ $dn.Volumes }}</td>
@@ -118,4 +120,5 @@
</div> </div>
</body> </body>
</html> </html>

View File

@@ -4,6 +4,8 @@ import (
_ "embed" _ "embed"
"html/template" "html/template"
"strings" "strings"
"github.com/seaweedfs/seaweedfs/weed/pb"
) )
//go:embed master.html //go:embed master.html
@@ -16,7 +18,7 @@ var templateFunctions = template.FuncMap{
"url": func(input string) string { "url": func(input string) string {
if !strings.HasPrefix(input, "http://") && !strings.HasPrefix(input, "https://") { if !strings.HasPrefix(input, "http://") && !strings.HasPrefix(input, "https://") {
return "http://" + input return "http://" + pb.ServerAddress(input).ToHttpAddress()
} }
return input return input
@@ -25,4 +27,4 @@ var templateFunctions = template.FuncMap{
var StatusTpl = template.Must(template.New("status").Funcs(templateFunctions).Parse(masterHtml)) var StatusTpl = template.Must(template.New("status").Funcs(templateFunctions).Parse(masterHtml))
var StatusNewRaftTpl = template.Must(template.New("status").Parse(masterNewRaftHtml)) var StatusNewRaftTpl = template.Must(template.New("status").Funcs(templateFunctions).Parse(masterNewRaftHtml))