fix(endpoints): show edge script when unassociated [EE-2842] (#6730)

pull/6750/head
Chaim Lev-Ari 3 years ago committed by GitHub
parent 287107e8da
commit 13faa75a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,7 @@ angular.module('portainer.app').factory('Endpoints', [
},
get: { method: 'GET', params: { id: '@id' } },
update: { method: 'PUT', params: { id: '@id' } },
deassociate: { method: 'DELETE', params: { id: '@id', action: 'association' } },
disassociate: { method: 'DELETE', params: { id: '@id', action: 'association' } },
updateAccess: { method: 'PUT', params: { id: '@id', action: 'access' } },
remove: { method: 'DELETE', params: { id: '@id' } },
snapshots: { method: 'POST', params: { action: 'snapshot' } },

@ -40,8 +40,8 @@ angular.module('portainer.app').factory('EndpointService', [
return Endpoints.updateAccess({ id: id }, { UserAccessPolicies: userAccessPolicies, TeamAccessPolicies: teamAccessPolicies }).$promise;
};
service.deassociateEndpoint = function (endpointID) {
return Endpoints.deassociate({ id: endpointID }).$promise;
service.disassociateEndpoint = function (endpointID) {
return Endpoints.disassociate({ id: endpointID }).$promise;
};
service.updateEndpoint = function (id, payload) {

@ -115,17 +115,17 @@ export function confirmDetachment(message: string, callback: ConfirmCallback) {
});
}
export function confirmDeassociate(callback: ConfirmCallback) {
export function confirmDisassociate(callback: ConfirmCallback) {
const message =
'<p>De-associating this Edge environment will mark it as non associated and will clear the registered Edge ID.</p>' +
'<p>Disassociating this Edge environment will mark it as non associated and will clear the registered Edge ID.</p>' +
'<p>Any agent started with the Edge key associated to this environment will be able to re-associate with this environment.</p>' +
'<p>You can re-use the Edge ID and Edge key that you used to deploy the existing Edge agent to associate a new Edge device to this environment.</p>';
confirm({
title: 'About de-associating',
title: 'About disassociating',
message: sanitize(message),
buttons: {
confirm: {
label: 'De-associate',
label: 'Disassociate',
className: 'btn-primary',
},
},

@ -4,7 +4,7 @@ import bootbox from 'bootbox';
import {
cancelRegistryRepositoryAction,
confirmAsync,
confirmDeassociate,
confirmDisassociate,
confirmDeletion,
confirmDetachment,
confirmDeletionAsync,
@ -46,7 +46,7 @@ export function ModalServiceAngular() {
cancelRegistryRepositoryAction,
confirmDeletion,
confirmDetachment,
confirmDeassociate,
confirmDisassociate,
confirmUpdate,
confirmRedeploy,
confirmDeletionAsync,

@ -10,7 +10,8 @@
</rd-header>
<div class="row">
<information-panel ng-if="state.edgeEndpoint && endpoint.EdgeID && endpoint.LastCheckInDate" title-text="Edge information">
<div ng-if="state.edgeEndpoint">
<information-panel ng-if="state.edgeAssociated" title-text="Edge information">
<span class="small text-muted">
<p>
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
@ -27,18 +28,18 @@
type="button"
class="btn btn-primary btn-sm"
ng-disabled="state.actionInProgress"
ng-click="onDeassociateEndpoint()"
ng-click="onDisassociateEndpoint()"
button-spinner="state.actionInProgress"
analytics-on
analytics-event="edge-endpoint-deassociate"
analytics-event="edge-endpoint-disassociate"
analytics-category="edge"
>
<span ng-hide="state.actionInProgress">De-associate</span>
<span ng-hide="state.actionInProgress">Disassociate</span>
</button>
</p>
</span>
</information-panel>
<information-panel ng-if="state.edgeEndpoint && !endpoint.LastCheckInDate" title-text="Deploy an agent">
<information-panel ng-if="!state.edgeAssociated" title-text="Deploy an agent">
<span class="small text-muted">
<p>
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
@ -53,7 +54,6 @@
<label class="btn btn-primary" ng-model="state.platformType" uib-btn-radio="'windows'"><i class="fab fa-windows" style="margin-right: 2px"></i> Windows</label>
</div>
</div>
<div class="form-group">
<por-switch-field
label="'Allow self-signed certs'"
@ -62,7 +62,6 @@
on-change="(onToggleAllowSelfSignedCerts)"
></por-switch-field>
</div>
<div class="form-group clearfix" ng-if="!isKubernetesDeploymentTabSelected()">
<label for="env_vars" class="col-sm-3 col-lg-2 control-label text-left" style="padding-left: 0; padding-top: 5px">
Environment variables
@ -75,7 +74,6 @@
<input type="text" class="form-control" id="env_vars" ng-model="formValues.EnvVarSource" placeholder="foo=bar,myvar" />
</div>
</div>
<div style="margin-top: 10px">
<uib-tabset active="state.deploymentTab">
<uib-tab index="'kubernetes'" heading="Kubernetes" ng-if="state.platformType === 'linux'">
@ -116,7 +114,8 @@
</div>
</span>
</information-panel>
<information-panel ng-if="state.kubernetesEndpoint && (!state.edgeEndpoint || (state.edgeEndpoint && endpoint.EdgeID))" title-text="Kubernetes features configuration">
</div>
<information-panel ng-if="state.kubernetesEndpoint && (!state.edgeEndpoint || state.edgeAssociated)" title-text="Kubernetes features configuration">
<span class="small text-muted">
<i class="fa fa-tools blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
You should configure the features available in this Kubernetes environment in the

@ -47,6 +47,7 @@ function EndpointController(
kubernetesEndpoint: false,
agentEndpoint: false,
edgeEndpoint: false,
edgeAssociated: false,
allowCreate: Authentication.isAdmin(),
availableEdgeAgentCheckinOptions: [
{ key: 'Use default interval', value: 0 },
@ -139,24 +140,24 @@ function EndpointController(
}
}
$scope.onDeassociateEndpoint = async function () {
ModalService.confirmDeassociate((confirmed) => {
$scope.onDisassociateEndpoint = async function () {
ModalService.confirmDisassociate((confirmed) => {
if (confirmed) {
deassociateEndpoint();
disassociateEndpoint();
}
});
};
async function deassociateEndpoint() {
async function disassociateEndpoint() {
var endpoint = $scope.endpoint;
try {
$scope.state.actionInProgress = true;
await EndpointService.deassociateEndpoint(endpoint.Id);
Notifications.success('Environment de-associated', $scope.endpoint.Name);
await EndpointService.disassociateEndpoint(endpoint.Id);
Notifications.success('Environment disassociated', $scope.endpoint.Name);
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Unable to de-associate environment');
Notifications.error('Failure', err, 'Unable to disassociate environment');
} finally {
$scope.state.actionInProgress = false;
}
@ -280,6 +281,8 @@ function EndpointController(
if (endpoint.Type === PortainerEndpointTypes.EdgeAgentOnDockerEnvironment || endpoint.Type === PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment) {
$scope.edgeKeyDetails = decodeEdgeKey(endpoint.EdgeKey);
$scope.state.edgeAssociated = !!endpoint.EdgeID;
endpoint.EdgeID = endpoint.EdgeID || uuidv4();
$scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`;
@ -291,8 +294,7 @@ function EndpointController(
configureState();
const disconnectedEdge = $scope.state.edgeEndpoint && !endpoint.EdgeID;
if (EndpointHelper.isDockerEndpoint(endpoint) && !disconnectedEdge) {
if (EndpointHelper.isDockerEndpoint(endpoint) && $scope.state.edgeAssociated) {
$scope.state.showAMTInfo = settings && settings.openAMTConfiguration && settings.openAMTConfiguration.enabled;
}
} catch (err) {

Loading…
Cancel
Save