From 7dca784ec668ede3f94ce5ccab7cf9f52ce3e112 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Tue, 7 Mar 2023 14:44:19 +1300 Subject: [PATCH] fix(env): get edited environment info [EE-5129] (#8603) Co-authored-by: testa113 --- .../views/endpoints/edit/endpointController.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/portainer/views/endpoints/edit/endpointController.js b/app/portainer/views/endpoints/edit/endpointController.js index 26d678de5..46cc87627 100644 --- a/app/portainer/views/endpoints/edit/endpointController.js +++ b/app/portainer/views/endpoints/edit/endpointController.js @@ -11,6 +11,7 @@ import { isEdgeEnvironment } from '@/react/portainer/environments/utils'; import { commandsTabs } from '@/react/edge/components/EdgeScriptForm/scripts'; import { confirmDisassociate } from '@/react/portainer/environments/ItemView/ConfirmDisassociateModel'; import { buildConfirmButton } from '@@/modals/utils'; +import { getInfo } from '@/docker/services/system.service'; angular.module('portainer.app').controller('EndpointController', EndpointController); @@ -24,7 +25,6 @@ function EndpointController( clipboard, EndpointService, GroupService, - StateManager, Notifications, Authentication, @@ -272,8 +272,17 @@ function EndpointController( try { const [endpoint, groups, settings] = await Promise.all([EndpointService.endpoint($transition$.params().id), GroupService.groups(), SettingsService.settings()]); - const applicationState = StateManager.getState(); - $scope.isDockerStandaloneEnv = applicationState.endpoint.mode.provider === 'DOCKER_STANDALONE'; + // Check if the environment is docker standalone, to decide whether to show the GPU insights box + const isDockerEnvironment = endpoint.Type === PortainerEndpointTypes.DockerEnvironment; + if (isDockerEnvironment) { + try { + const dockerInfo = await getInfo(endpoint.Id); + const isDockerSwarmEnv = dockerInfo.Swarm && dockerInfo.Swarm.NodeID; + $scope.isDockerStandaloneEnv = !isDockerSwarmEnv; + } catch (err) { + // $scope.isDockerStandaloneEnv is only used to show the "GPU insights box", so fail quietly on error + } + } if (endpoint.URL.indexOf('unix://') === 0 || endpoint.URL.indexOf('npipe://') === 0) { $scope.endpointType = 'local';