fix(templates): set var to default value if no value selected (#2323)
* fix(templates): set preset to true iff var type is preset * * fix(templates): add env var value when changing typepull/2472/head
parent
5fa4403d20
commit
acce5e0023
|
@ -41,6 +41,7 @@ angular.module('portainer.app').component('templateForm', {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addEnvVarValue = function(env) {
|
this.addEnvVarValue = function(env) {
|
||||||
|
env.select = env.select || [];
|
||||||
env.select.push({ name: '', value: '' });
|
env.select.push({ name: '', value: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,11 +50,7 @@ angular.module('portainer.app').component('templateForm', {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.changeEnvVarType = function(env) {
|
this.changeEnvVarType = function(env) {
|
||||||
if (env.type === 1) {
|
env.preset = env.type === 1;
|
||||||
env.preset = true;
|
|
||||||
} else if (env.type === 2) {
|
|
||||||
env.preset = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
bindings: {
|
bindings: {
|
||||||
|
|
|
@ -125,13 +125,18 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
|
||||||
|
|
||||||
function createStackFromTemplate(template, userId, accessControlData) {
|
function createStackFromTemplate(template, userId, accessControlData) {
|
||||||
var stackName = $scope.formValues.name;
|
var stackName = $scope.formValues.name;
|
||||||
|
var env =_.filter(
|
||||||
for (var i = 0; i < template.Env.length; i++) {
|
_.map(template.Env, function transformEnvVar(envvar) {
|
||||||
var envvar = template.Env[i];
|
return {
|
||||||
if (envvar.preset) {
|
name: envvar.name,
|
||||||
envvar.value = envvar.default;
|
value:
|
||||||
}
|
envvar.preset || !envvar.value ? envvar.default : envvar.value
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
function removeUndefinedVars(envvar) {
|
||||||
|
return envvar.value && envvar.name;
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var repositoryOptions = {
|
var repositoryOptions = {
|
||||||
RepositoryURL: template.Repository.url,
|
RepositoryURL: template.Repository.url,
|
||||||
|
@ -139,7 +144,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
|
||||||
};
|
};
|
||||||
|
|
||||||
var endpointId = EndpointProvider.endpointID();
|
var endpointId = EndpointProvider.endpointID();
|
||||||
StackService.createSwarmStackFromGitRepository(stackName, repositoryOptions, template.Env, endpointId)
|
StackService.createSwarmStackFromGitRepository(stackName, repositoryOptions, env, endpointId)
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
return ResourceControlService.applyResourceControl('stack', stackName, userId, accessControlData, []);
|
return ResourceControlService.applyResourceControl('stack', stackName, userId, accessControlData, []);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue