fix: UI and backend fixes

- Add orange highlighting for recently booted containers (< 1 hour)
- Handle cpulimit causing JSON unmarshaling error with FlexInt type
- Improve PVE 9 compatibility in temporary helper script
- Fixes issues #251 and #256
This commit is contained in:
Pulse Monitor
2025-08-06 10:44:35 +00:00
parent de85b861be
commit 2ba5e91fcd
6 changed files with 35 additions and 3 deletions
@@ -112,7 +112,9 @@ export function GuestRow(props: GuestRowProps) {
</Show>
{/* Uptime */}
<td class="p-1 px-2 text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap">
<td class={`p-1 px-2 text-sm whitespace-nowrap ${
props.guest.uptime < 3600 ? 'text-orange-500' : 'text-gray-600 dark:text-gray-400'
}`}>
<Show when={isRunning()} fallback="-">
{formatUptime(props.guest.uptime)}
</Show>
+1 -1
View File
@@ -931,7 +931,7 @@ func (m *Monitor) pollContainers(ctx context.Context, instanceName string, clien
Status: ct.Status,
Type: "lxc",
CPU: safeFloat(ct.CPU), // Already in percentage
CPUs: ct.CPUs,
CPUs: int(ct.CPUs),
Memory: models.Memory{
Total: int64(ct.MaxMem),
Used: int64(ct.Mem),
+30 -1
View File
@@ -7,6 +7,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@@ -14,6 +15,34 @@ import (
"github.com/rs/zerolog/log"
)
// FlexInt handles JSON fields that can be either int or string
type FlexInt int
func (f *FlexInt) UnmarshalJSON(data []byte) error {
// Try to unmarshal as int first
var i int
if err := json.Unmarshal(data, &i); err == nil {
*f = FlexInt(i)
return nil
}
// If that fails, try as string
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
// Parse string to float first (handles "1.5" format from cpulimit)
floatVal, err := strconv.ParseFloat(s, 64)
if err != nil {
return err
}
// Convert to int
*f = FlexInt(int(floatVal))
return nil
}
// Client represents a Proxmox VE API client
type Client struct {
baseURL string
@@ -346,7 +375,7 @@ type Container struct {
Node string `json:"node"`
Status string `json:"status"`
CPU float64 `json:"cpu"`
CPUs int `json:"cpus"`
CPUs FlexInt `json:"cpus"`
Mem uint64 `json:"mem"`
MaxMem uint64 `json:"maxmem"`
Swap uint64 `json:"swap"`
Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Submodule
+1
Submodule tmp-proxmox added at a2866e1697