statuf on load fixed?

This commit is contained in:
Holger Sielaff
2025-09-04 10:15:41 +02:00
parent c5e7e3739f
commit d10938d2d2
3 changed files with 19 additions and 10 deletions

View File

@@ -282,12 +282,9 @@
$.get("{% url 'frontend:current_container_details' %}", {'ids': id}, function (container) {
container = container[0]
if (container.is_low) {
$('[data-crow="' + id + '"]').addClass(
'status-low'
).attr(
'title',
'Low Warning: Disk: ' + container.disk_percent + '%, Memory: ' + container.mem_percent + '%'
);
$('[data-crow="' + id + '"]')
.addClass('status-low')
.attr('title', 'Low Warning: Disk: ' + container.disk_percent + '%, Memory: ' + container.mem_percent + '%');
}
let lxc_status = $('.lxc_status_' + id);
let lease_status = $('.lease_status_' + id);

View File

@@ -107,7 +107,11 @@ def dashboard(request):
class ContainerStatus:
low_limit = 80
def __init__(self, **kwargs):
def __init__(self, dev_container:DevContainer):
self._devcontainer = dev_container
self.vmid = dev_container.lxc.vmid
self.lxc_status = dev_container.lxc.synced_status
kwargs = dev_container.statuscache or {}
self.cpus = kwargs.get('cpus', 0)
self.cpu = kwargs.get('cpu', 0)
self.maxmem = kwargs.get('maxmem', 256)
@@ -117,9 +121,7 @@ class ContainerStatus:
self.maxswap = kwargs.get('maxswap', 0)
self.swap = kwargs.get('swap', 0)
self.status = kwargs.get('status')
self.vmid = kwargs.get('vmid')
self.lease_status = kwargs.get('lease_status', 'waiting')
self.lxc_status = kwargs.get('lxc_status', 'stopped')
def __hash__(self):
return int(self.vmid)
@@ -171,7 +173,7 @@ def container_details(request):
with Proxmox() as pm:
for id in ids:
container = DevContainer.objects.get(internal_id=id)
ret.append(ContainerStatus(**(container.statuscache or {})).to_json)
ret.append(ContainerStatus(container).to_json)
return HttpResponse(json.dumps(ret), content_type='application/json')