From 13e6adfc8c6142bc131c47ff06f8d8426a1cce4d Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sat, 12 Apr 2025 03:11:48 +0500 Subject: [PATCH] fix issue with design on n8n page --- plogical/DockerSites.py | 27 +- .../websiteFunctions/DockerContainers.js | 73 +++- .../websiteFunctions/DockerSiteHome.html | 356 ++++++++---------- 3 files changed, 240 insertions(+), 216 deletions(-) diff --git a/plogical/DockerSites.py b/plogical/DockerSites.py index f54888442..37038bc54 100644 --- a/plogical/DockerSites.py +++ b/plogical/DockerSites.py @@ -672,25 +672,32 @@ services: FilerValue = self.DockerAppName - # Define the label to filter containers - label_filter = {'name': FilerValue} - - - # List containers matching the label filter - containers = client.containers.list(filters=label_filter) - + # First try to find the containers by name pattern + containers = [] + + # List all containers + all_containers = client.containers.list(all=True) + + # Filter containers that match our app name pattern (both exact and related containers like DB) + for container in all_containers: + if FilerValue in container.name: + containers.append(container) + json_data = "[" checker = 0 for container in containers: - + # Get environment variables + environment = container.attrs.get('Config', {}).get('Env', []) + dic = { 'id': container.short_id, 'name': container.name, 'status': container.status, - 'volumes': container.attrs['HostConfig']['Binds'] if 'HostConfig' in container.attrs else [], + 'volumes': container.attrs['HostConfig']['Binds'] if 'HostConfig' in container.attrs and 'Binds' in container.attrs['HostConfig'] else [], 'logs_50': container.logs(tail=50).decode('utf-8'), - 'ports': container.attrs['HostConfig']['PortBindings'] if 'HostConfig' in container.attrs else {} + 'ports': container.attrs['HostConfig']['PortBindings'] if 'HostConfig' in container.attrs and 'PortBindings' in container.attrs['HostConfig'] else {}, + 'environment': environment } if checker == 0: diff --git a/websiteFunctions/static/websiteFunctions/DockerContainers.js b/websiteFunctions/static/websiteFunctions/DockerContainers.js index 29c5d57aa..e75fb19ad 100644 --- a/websiteFunctions/static/websiteFunctions/DockerContainers.js +++ b/websiteFunctions/static/websiteFunctions/DockerContainers.js @@ -1161,8 +1161,77 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { // Helper function to handle container actions $scope.handleAction = function(action, container) { - $scope.selectedContainer = container; - $scope.cAction(action); + $scope.cyberpanelLoading = false; + $('#cyberpanelLoading').show(); + + var url = "/docker/"; + switch(action) { + case 'start': + url += "startContainer"; + break; + case 'stop': + url += "stopContainer"; + break; + case 'restart': + url += "restartContainer"; + break; + default: + console.error("Unknown action:", action); + $('#cyberpanelLoading').hide(); + return; + } + + var data = { + 'name': $('#sitename').html(), + 'container_id': container.id + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then( + function(response) { + $scope.cyberpanelLoading = true; + $('#cyberpanelLoading').hide(); + + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Container ' + action + ' successful.', + type: 'success' + }); + + // Update container status after action + container.status = action === 'stop' ? 'stopped' : 'running'; + + // Refresh container info after short delay to allow Docker to update + setTimeout(function() { + $scope.Lunchcontainer(container.id); + }, 1000); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message || 'An unknown error occurred.', + type: 'error' + }); + } + }, + function(error) { + $scope.cyberpanelLoading = true; + $('#cyberpanelLoading').hide(); + + new PNotify({ + title: 'Operation Failed!', + text: 'Connection disrupted or server error occurred.', + type: 'error' + }); + + console.error("Error during container action:", error); + } + ); }; // Keep your existing functions diff --git a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html index f12bdb56f..34846703a 100644 --- a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html +++ b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html @@ -475,6 +475,100 @@
+ +
+
+

+ {% trans "Database Container: " %} {$ web.name $} +
+ + + + +
+

+

+ {% trans "Container ID" %}: {$ web.id $} +

+
+ +
+
+

+ {% trans "Database Container Information" %} + +

+ +
+
+
+

Basic Information

+
+

Container ID: {$ web.id $}

+

Status: + + {$ web.status $} + +

+
+
+
+ +
+
+

Environment Variables

+
+
+ + + + + + + + + + + + + +
VariableValue
{$ env.split('=')[0] $} + {$ env.split('=')[1] $} + [hidden] + {$ env.split('=')[1] $} +
+
+
+
+

No environment variables set

+
+
+
+
+
+ +
+

+ {% trans "Logs" %} + + + +

+
+ +
+
+
+
+
@@ -638,10 +732,10 @@
-
+
-
-
+
+

Version Management

@@ -652,13 +746,13 @@

{$ web.n8nVersion || 'Unknown' $}

-
+
-
-
+
+
@@ -672,28 +766,28 @@ -
-
- + + +
You are running the latest version. -
-
- + + +
Version History
-
- - - +
+
+ + - - - + + + @@ -701,18 +795,18 @@ - - - -
Date Version Action
{$ version.date | date:'medium' $} {$ version.version $}
-
-
- + + + + + + + -
-
+
+

Credential Management

{$ web.insecureCredentials.length $}

Insecure Credentials

-
- -
+
+ +
- - + + - - - + + + - - -
Name Type Usage Security Actions
{$ credential.name $} @@ -780,11 +874,11 @@ -
-
+ + + + +
-
- + + +

No credentials found or container is not running

@@ -998,7 +1092,7 @@ Generate -
+
@@ -1006,10 +1100,10 @@ -
-
- - + + + +
Test Webhook
@@ -1092,14 +1186,14 @@

- {% trans "Logs" %} + {% trans "Logs" %}

-
+
-
+
@@ -1114,7 +1208,7 @@
Current Domain Settings
-
+
@@ -1132,7 +1226,7 @@ Disabled

-
+
-
-
+
+ +
@@ -1652,152 +1746,6 @@ - -