diff --git a/app/docker/views/containers/edit/containerController.js b/app/docker/views/containers/edit/containerController.js index 95affc028..ffef2445e 100644 --- a/app/docker/views/containers/edit/containerController.js +++ b/app/docker/views/containers/edit/containerController.js @@ -96,6 +96,7 @@ angular.module('portainer.docker').controller('ContainerController', [ }); } + $scope.container.Config.Env = _.sortBy($scope.container.Config.Env, _.toLower); const inSwarm = $scope.container.Config.Labels['com.docker.swarm.service.id']; const autoRemove = $scope.container.HostConfig.AutoRemove; const admin = Authentication.isAdmin(); diff --git a/app/docker/views/images/edit/imageController.js b/app/docker/views/images/edit/imageController.js index f30f8673c..597cdb7a0 100644 --- a/app/docker/views/images/edit/imageController.js +++ b/app/docker/views/images/edit/imageController.js @@ -154,6 +154,7 @@ angular.module('portainer.docker').controller('ImageController', [ .then(function success(data) { $scope.image = data.image; $scope.history = data.history; + $scope.image.Env = _.sortBy($scope.image.Env, _.toLower); }) .catch(function error(err) { Notifications.error('Failure', err, 'Unable to retrieve image details'); diff --git a/app/docker/views/services/edit/includes/environmentvariables.html b/app/docker/views/services/edit/includes/environmentvariables.html index 32e4d425f..795c8d77a 100644 --- a/app/docker/views/services/edit/includes/environmentvariables.html +++ b/app/docker/views/services/edit/includes/environmentvariables.html @@ -19,7 +19,7 @@ - +
name @@ -39,7 +39,7 @@ disable-authorization="DockerServiceUpdate" /> - diff --git a/app/docker/views/services/edit/serviceController.js b/app/docker/views/services/edit/serviceController.js index 6a44c4d00..b0a4932a6 100644 --- a/app/docker/views/services/edit/serviceController.js +++ b/app/docker/views/services/edit/serviceController.js @@ -115,8 +115,9 @@ angular.module('portainer.docker').controller('ServiceController', [ service.EnvironmentVariables.push({ key: '', value: '', originalValue: '' }); updateServiceArray(service, 'EnvironmentVariables', service.EnvironmentVariables); }; - $scope.removeEnvironmentVariable = function removeEnvironmentVariable(service, index) { - var removedElement = service.EnvironmentVariables.splice(index, 1); + $scope.removeEnvironmentVariable = function removeEnvironmentVariable(service, item) { + const index = service.EnvironmentVariables.indexOf(item); + const removedElement = service.EnvironmentVariables.splice(index, 1); if (removedElement !== null) { updateServiceArray(service, 'EnvironmentVariables', service.EnvironmentVariables); } diff --git a/app/kubernetes/helpers/application/index.js b/app/kubernetes/helpers/application/index.js index daf993719..b66a49019 100644 --- a/app/kubernetes/helpers/application/index.js +++ b/app/kubernetes/helpers/application/index.js @@ -130,6 +130,7 @@ class KubernetesApplicationHelper { res.Name = item.name; res.Value = item.value; res.IsNew = false; + res.NameIndex = item.name; return res; }); return _.without(envVariables, undefined); diff --git a/app/kubernetes/models/application/formValues.js b/app/kubernetes/models/application/formValues.js index 12d6151c3..53cb670c2 100644 --- a/app/kubernetes/models/application/formValues.js +++ b/app/kubernetes/models/application/formValues.js @@ -79,6 +79,7 @@ const _KubernetesApplicationEnvironmentVariableFormValue = Object.freeze({ IsSecret: false, NeedsDeletion: false, IsNew: true, + NameIndex: '', // keep the original name for sorting }); export class KubernetesApplicationEnvironmentVariableFormValue { diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index 627aaf510..0b5a931fb 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -142,7 +142,7 @@
-
+
name @@ -191,10 +191,10 @@
- -
diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index a0b3a32c1..46ece0ced 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -165,15 +165,19 @@ class KubernetesCreateApplicationController { this.formValues.EnvironmentVariables.push(new KubernetesApplicationEnvironmentVariableFormValue()); } - restoreEnvironmentVariable(index) { - this.formValues.EnvironmentVariables[index].NeedsDeletion = false; + restoreEnvironmentVariable(item) { + item.NeedsDeletion = false; } - removeEnvironmentVariable(index) { - if (this.state.isEdit && !this.formValues.EnvironmentVariables[index].IsNew) { - this.formValues.EnvironmentVariables[index].NeedsDeletion = true; - } else { - this.formValues.EnvironmentVariables.splice(index, 1); + removeEnvironmentVariable(item) { + const index = this.formValues.EnvironmentVariables.indexOf(item); + if (index !== -1) { + const envVar = this.formValues.EnvironmentVariables[index]; + if (!envVar.IsNew) { + envVar.NeedsDeletion = true; + } else { + this.formValues.EnvironmentVariables.splice(index, 1); + } } this.onChangeEnvironmentName(); } diff --git a/app/kubernetes/views/applications/edit/application.html b/app/kubernetes/views/applications/edit/application.html index 950843f4c..e314147ea 100644 --- a/app/kubernetes/views/applications/edit/application.html +++ b/app/kubernetes/views/applications/edit/application.html @@ -406,7 +406,7 @@ Configuration - + {{ container.Name }}