From 326c22c8f3123d889dfc3a302fd0bef47c246c06 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Fri, 11 Apr 2025 14:06:46 +0500 Subject: [PATCH] show both containers by default --- .../websiteFunctions/websiteFunctions.js | 51 ++++++++----------- .../websiteFunctions/DockerSiteHome.html | 30 +++++------ 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index eb34f1e20..0dab2d6ab 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -17321,13 +17321,6 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { $scope.conatinerview = true; $('#cyberpanelLoading').hide(); - // Add filter for object length - app.filter('objLength', function() { - return function(obj) { - return obj ? Object.keys(obj).length : 0; - }; - }); - // Format bytes to human readable function formatBytes(bytes, decimals = 2) { if (bytes === 0) return '0 Bytes'; @@ -17400,36 +17393,34 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { if (response.data.status === 1) { var containerInfo = response.data.data[1]; - // Basic Information - $scope.cid = containerInfo.id; - $scope.status = containerInfo.status; - $scope.created = new Date(containerInfo.created); - $scope.uptime = containerInfo.uptime; - $scope.cName = containerInfo.name; + // Find the container in the list and update its information + for (var i = 0; i < $scope.ContainerList.length; i++) { + if ($scope.ContainerList[i].id === containerid) { + // Basic Information + $scope.ContainerList[i].status = containerInfo.status; + $scope.ContainerList[i].created = new Date(containerInfo.created); + $scope.ContainerList[i].uptime = containerInfo.uptime; - // Resource Usage - var memoryBytes = containerInfo.memory_usage; - $scope.memoryUsage = formatBytes(memoryBytes); - $scope.memoryUsagePercent = (memoryBytes / (1024 * 1024 * 1024)) * 100; // Assuming 1GB limit - $scope.cpuUsagePercent = (containerInfo.cpu_usage / 10000000000) * 100; // Normalize to percentage + // Resource Usage + var memoryBytes = containerInfo.memory_usage; + $scope.ContainerList[i].memoryUsage = formatBytes(memoryBytes); + $scope.ContainerList[i].memoryUsagePercent = (memoryBytes / (1024 * 1024 * 1024)) * 100; // Assuming 1GB limit + $scope.ContainerList[i].cpuUsagePercent = (containerInfo.cpu_usage / 10000000000) * 100; // Normalize to percentage - // Network & Ports - $scope.ports = containerInfo.ports; + // Network & Ports + $scope.ContainerList[i].ports = containerInfo.ports; - // Volumes - $scope.volumes = containerInfo.volumes; + // Volumes + $scope.ContainerList[i].volumes = containerInfo.volumes; - // Environment Variables - $scope.environment = containerInfo.environment; + // Environment Variables + $scope.ContainerList[i].environment = containerInfo.environment; + break; + } + } // Get container logs $scope.getcontainerlog(containerid); - - new PNotify({ - title: 'Success!', - text: 'Container information loaded successfully.', - type: 'success' - }); } else { new PNotify({ title: 'Operation Failed!', diff --git a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html index 13e9e4b3e..06de474ca 100644 --- a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html +++ b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html @@ -342,11 +342,11 @@
- {$ memoryUsage $} + {$ web.memoryUsage $}
@@ -354,11 +354,11 @@
- {$ cpuUsagePercent | number:1 $}% + {$ web.cpuUsagePercent | number:1 $}%
@@ -368,7 +368,7 @@

Network & Ports

-
+
@@ -378,7 +378,7 @@ - +
{$ containerPort $} @@ -390,14 +390,14 @@
-
+

No ports exposed

Volumes

-
+
@@ -408,7 +408,7 @@ - + @@ -417,14 +417,14 @@
{$ volume.Source $} {$ volume.Destination $} {$ volume.Mode $}
-
+

No volumes mounted

Environment Variables

-
+
@@ -434,7 +434,7 @@ - +
{$ env.split('=')[0] $} {$ env.split('=')[1] $} @@ -445,7 +445,7 @@
-
+

No environment variables set