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 "Container ID" %}: {$ web.id $}
+
Container ID: {$ web.id $}
Status: + + {$ web.status $} + +
+| Variable | +Value | +
|---|---|
{$ env.split('=')[0] $} |
+
+ {$ env.split('=')[1] $}
+ [hidden]
+ {$ env.split('=')[1] $}
+ |
+
No environment variables set
+{$ web.n8nVersion || 'Unknown' $}
-| Date | Version | Action | -
|---|---|---|
| {$ version.date | date:'medium' $} | {$ version.version $} | @@ -701,18 +795,18 @@ - -
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 -