fix(env): get edited environment info [EE-5129] (#8603)

Co-authored-by: testa113 <testa113>
pull/8572/head
Ali 2023-03-07 14:44:19 +13:00 committed by GitHub
parent 37484566eb
commit 7dca784ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import { isEdgeEnvironment } from '@/react/portainer/environments/utils';
import { commandsTabs } from '@/react/edge/components/EdgeScriptForm/scripts'; import { commandsTabs } from '@/react/edge/components/EdgeScriptForm/scripts';
import { confirmDisassociate } from '@/react/portainer/environments/ItemView/ConfirmDisassociateModel'; import { confirmDisassociate } from '@/react/portainer/environments/ItemView/ConfirmDisassociateModel';
import { buildConfirmButton } from '@@/modals/utils'; import { buildConfirmButton } from '@@/modals/utils';
import { getInfo } from '@/docker/services/system.service';
angular.module('portainer.app').controller('EndpointController', EndpointController); angular.module('portainer.app').controller('EndpointController', EndpointController);
@ -24,7 +25,6 @@ function EndpointController(
clipboard, clipboard,
EndpointService, EndpointService,
GroupService, GroupService,
StateManager,
Notifications, Notifications,
Authentication, Authentication,
@ -272,8 +272,17 @@ function EndpointController(
try { try {
const [endpoint, groups, settings] = await Promise.all([EndpointService.endpoint($transition$.params().id), GroupService.groups(), SettingsService.settings()]); const [endpoint, groups, settings] = await Promise.all([EndpointService.endpoint($transition$.params().id), GroupService.groups(), SettingsService.settings()]);
const applicationState = StateManager.getState(); // Check if the environment is docker standalone, to decide whether to show the GPU insights box
$scope.isDockerStandaloneEnv = applicationState.endpoint.mode.provider === 'DOCKER_STANDALONE'; 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) { if (endpoint.URL.indexOf('unix://') === 0 || endpoint.URL.indexOf('npipe://') === 0) {
$scope.endpointType = 'local'; $scope.endpointType = 'local';