Add ability to browse data

This commit is contained in:
2025-03-24 12:26:31 +01:00
parent c459148d33
commit dbfbd6e164
9 changed files with 272 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
package main
import (
"fmt"
)
func createDeviceLink(deviceType, name string, qr *int) CreateDeviceLink {
return CreateDeviceLink{
Type: deviceType,
@@ -13,3 +17,31 @@ type CreateDeviceLink struct {
Name string
Qr *int
}
func formatMemorySize(size int) string {
const (
KB = 1024
MB = KB * 1024
GB = MB * 1024
)
switch {
case size >= GB:
return fmt.Sprintf("%.2f GB", float64(size)/GB)
case size >= MB:
return fmt.Sprintf("%.2f MB", float64(size)/MB)
case size >= KB:
return fmt.Sprintf("%.2f KB", float64(size)/KB)
default:
return fmt.Sprintf("%d B", size)
}
}
func formatType(t string) string {
switch t {
case "ram":
return "Random Access Memory"
default:
return t
}
}