templates.go 752 B

12345678910111213141516171819202122232425262728293031323334
  1. package volume_server_ui
  2. import (
  3. _ "embed"
  4. "fmt"
  5. "github.com/chrislusf/seaweedfs/weed/util"
  6. "html/template"
  7. "strconv"
  8. "strings"
  9. )
  10. func percentFrom(total uint64, part_of uint64) string {
  11. return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100)
  12. }
  13. func join(data []int64) string {
  14. var ret []string
  15. for _, d := range data {
  16. ret = append(ret, strconv.Itoa(int(d)))
  17. }
  18. return strings.Join(ret, ",")
  19. }
  20. var funcMap = template.FuncMap{
  21. "join": join,
  22. "bytesToHumanReadable": util.BytesToHumanReadable,
  23. "percentFrom": percentFrom,
  24. "isNotEmpty": util.IsNotEmpty,
  25. }
  26. //go:embed volume.html
  27. var volumeHtml string
  28. var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(volumeHtml))