seaweedfs/weed/server/volume_server_ui/templates.go

35 lines
752 B
Go
Raw Normal View History

2021-04-22 21:21:11 +00:00
package volume_server_ui
2015-03-19 17:39:22 +00:00
import (
_ "embed"
"fmt"
2020-05-29 02:00:07 +00:00
"github.com/chrislusf/seaweedfs/weed/util"
2015-03-19 17:39:22 +00:00
"html/template"
2015-03-22 19:50:04 +00:00
"strconv"
"strings"
2015-03-19 17:39:22 +00:00
)
func percentFrom(total uint64, part_of uint64) string {
return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100)
}
2015-03-22 19:50:04 +00: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 02:00:07 +00:00
"join": join,
"bytesToHumanReadable": util.BytesToHumanReadable,
"percentFrom": percentFrom,
"isNotEmpty": util.IsNotEmpty,
2015-03-22 19:50:04 +00:00
}
//go:embed volume.html
var volumeHtml string
2019-06-05 04:52:37 +00:00
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(volumeHtml))