2021-04-22 21:21:11 +00:00
|
|
|
package volume_server_ui
|
2015-03-19 17:39:22 +00:00
|
|
|
|
|
|
|
import (
|
2021-07-05 10:09:44 +00:00
|
|
|
_ "embed"
|
2020-02-23 20:33:47 +00:00
|
|
|
"fmt"
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/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
|
|
|
)
|
|
|
|
|
2020-02-23 20:33:47 +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,
|
2021-07-06 07:20:18 +00:00
|
|
|
"isNotEmpty": util.IsNotEmpty,
|
2015-03-22 19:50:04 +00:00
|
|
|
}
|
|
|
|
|
2021-07-05 10:09:44 +00:00
|
|
|
//go:embed volume.html
|
|
|
|
var volumeHtml string
|
2019-06-05 04:52:37 +00:00
|
|
|
|
2021-07-05 10:09:44 +00:00
|
|
|
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(volumeHtml))
|