Fix UI and icon display (#101)

This commit is contained in:
andig 2020-05-05 16:54:31 +02:00 • committed by GitHub
parent b7c9069030
commit 4c3f8a0c73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 30 deletions

View file

@ -85,12 +85,13 @@ func NewSocketHub() *SocketHub {
func (h *SocketHub) encode(v core.Param) ([]byte, error) {
var s string
switch val := v.Val.(type) {
case string:
case time.Duration:
// must be before stringer to convert to seconds instead of string
s = fmt.Sprintf("{\"%s\": %d}", v.Key, int64(val.Seconds()))
case fmt.Stringer, string:
s = fmt.Sprintf("{\"%s\": \"%s\"}", v.Key, val)
case float64:
s = fmt.Sprintf("{\"%s\": %.3f}", v.Key, val)
case time.Duration:
s = fmt.Sprintf("{\"%s\": %d}", v.Key, int64(val.Seconds()))
default:
s = fmt.Sprintf("{\"%s\": %v}", v.Key, val)
}