mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
show RemoteVolumes/EcVolumes only if it is not empty
This commit is contained in:
parent
44a2538f67
commit
ed57a55eae
|
@ -25,6 +25,7 @@ var funcMap = template.FuncMap{
|
||||||
"join": join,
|
"join": join,
|
||||||
"bytesToHumanReadable": util.BytesToHumanReadable,
|
"bytesToHumanReadable": util.BytesToHumanReadable,
|
||||||
"percentFrom": percentFrom,
|
"percentFrom": percentFrom,
|
||||||
|
"isNotEmpty": util.IsNotEmpty,
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed volume.html
|
//go:embed volume.html
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ if isNotEmpty .RemoteVolumes }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>Remote Volumes</h2>
|
<h2>Remote Volumes</h2>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -162,7 +163,9 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if isNotEmpty .EcVolumes }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>Erasure Coding Shards</h2>
|
<h2>Erasure Coding Shards</h2>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -188,7 +191,7 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
40
weed/util/reflect.go
Normal file
40
weed/util/reflect.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
// IsNotEmpty returns true if the given value is not zero or empty.
|
||||||
|
func IsNotEmpty(given interface{}) bool {
|
||||||
|
return !IsEmpty(given)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsEmpty returns true if the given value has the zero value for its type.
|
||||||
|
func IsEmpty(given interface{}) bool {
|
||||||
|
g := reflect.ValueOf(given)
|
||||||
|
if !g.IsValid() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if g.Kind() == reflect.Ptr {
|
||||||
|
g = g.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basically adapted from text/template.isTrue
|
||||||
|
switch g.Kind() {
|
||||||
|
case reflect.Array, reflect.Slice, reflect.Map, reflect.String:
|
||||||
|
return g.Len() == 0
|
||||||
|
case reflect.Bool:
|
||||||
|
return !g.Bool()
|
||||||
|
case reflect.Complex64, reflect.Complex128:
|
||||||
|
return g.Complex() == 0
|
||||||
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
|
return g.Int() == 0
|
||||||
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||||
|
return g.Uint() == 0
|
||||||
|
case reflect.Float32, reflect.Float64:
|
||||||
|
return g.Float() == 0
|
||||||
|
case reflect.Struct:
|
||||||
|
return g.IsZero()
|
||||||
|
default:
|
||||||
|
return g.IsNil()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue