seaweedfs/weed/server/volume_server_ui/templates.go

35 lines
752 B
Go
Raw Normal View History

2021-04-23 05:21:11 +08:00
package volume_server_ui
2015-03-20 01:39:22 +08:00
import (
_ "embed"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/util"
2015-03-20 01:39:22 +08:00
"html/template"
2015-03-23 03:50:04 +08:00
"strconv"
"strings"
2015-03-20 01:39:22 +08:00
)
func percentFrom(total uint64, part_of uint64) string {
return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100)
}
2015-03-23 03:50:04 +08:00
func join(data []int64) string {
var ret []string
for _, d := range data {
ret = append(ret, strconv.Itoa(int(d)))
}
return strings.Join(ret, ",")
}
var funcMap = template.FuncMap{
2020-05-29 10:00:07 +08:00
"join": join,
"bytesToHumanReadable": util.BytesToHumanReadable,
"percentFrom": percentFrom,
"isNotEmpty": util.IsNotEmpty,
2015-03-23 03:50:04 +08:00
}
//go:embed volume.html
var volumeHtml string
2019-06-05 12:52:37 +08:00
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(volumeHtml))