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