working commit of passphrase disabling

This commit is contained in:
John Mitchell 2015-07-27 15:18:52 -04:00
parent 2d79402a9c
commit f080339b9a
3 changed files with 52 additions and 3 deletions

View File

@ -142,6 +142,8 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $r
defaultUrl = GetBasePath('credentials'),
url;
$scope.keyEntered = false;
generator.inject(form, { mode: 'add', related: false, scope: $scope });
generator.reset();
@ -213,6 +215,15 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $r
OwnerChange({ scope: $scope });
}
$scope.$watch("ssh_key_data", function(val) {
if (val === "" || val === null || val === undefined) {
$scope.keyEntered = false;
$scope.ssh_key_unlock_ask = false;
$scope.ssh_key_unlock = "";
} else {
$scope.keyEntered = true;
}
});
// Handle Kind change
$scope.kindChange = function () {
@ -357,6 +368,15 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $
reset: false
});
OwnerChange({ scope: $scope });
$scope.$watch("ssh_key_data", function(val) {
if (val === "" || val === null || val === undefined) {
$scope.keyEntered = false;
$scope.ssh_key_unlock_ask = false;
$scope.ssh_key_unlock = "";
} else {
$scope.keyEntered = true;
}
});
Wait('stop');
});

View File

@ -275,6 +275,7 @@ export default
ngShow: "kind.value == 'ssh' || kind.value == 'scm'",
addRequired: false,
editRequired: false,
ngDisabled: "keyEntered === false",
ask: true,
hasShowInputButton: true,
askShow: "kind.value == 'ssh'", // Only allow ask for machine credentials

View File

@ -896,7 +896,19 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += buildId(field, fld + "_show_input_button", this.form);
html += "aw-tool-tip='Toggle the display of plaintext.' aw-tip-placement='top' ";
html += "ng-click='" + fld + "_field.toggleInput(\"#" + this.form.name + "_" + fld + "\")'";
html += (field.ask) ? " ng-disabled='" + fld + "_ask'" : "";
if (field.ngDisabled || field.ask) {
var disabled = "";
if (field.ngDisabled) {
disabled += field.ngDisabled;
}
if (field.ngDisabled && field.ask) {
disabled += " || ";
}
if (field.ask) {
disabled += fld + "_ask";
}
html += "ng-disabled='" + disabled + "'";
}
html += ">\n" + field.showInputInnerHTML;
html += "\n</button>\n";
html += "</span>\n";
@ -931,12 +943,25 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += (field.awPassMatch) ? "awpassmatch='" + field.associated + "' " : "";
html += (field.capitalize) ? "capitalize " : "";
html += (field.awSurveyQuestion) ? "aw-survey-question" : "";
html += (field.ask) ? "ng-disabled='" + fld + "_ask' " : "";
if (field.ngDisabled || field.ask) {
var disabled = "";
if (field.ngDisabled) {
disabled += field.ngDisabled;
}
if (field.ngDisabled && field.ask) {
disabled += " || ";
}
if (field.ask) {
disabled += fld + "_ask";
}
html += "ng-disabled='" + disabled + "'";
}
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
html += (field.awRequiredWhen) ? "data-awrequired-init='" + field.awRequiredWhen.init + "' aw-required-when='" +
field.awRequiredWhen.variable + "' " : "";
html += (field.awValidUrl) ? "aw-valid-url " : "";
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled='" + field.associated + "_ask' " : "";
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled='" + field.associated + "_foo' " : "";
html += ">\n";
}
@ -960,6 +985,9 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "<input type=\"checkbox\" ng-model=\"" +
fld + "_ask\" ng-change=\"ask('" + fld + "','" + field.associated + "')\" ";
html += "id=\"" + this.form.name + "_" + fld + "_ask_chbox\" ";
if (field.ngDisabled) {
html += "ng-disabled='" + field.ngDisabled + "'";
}
html += "> Ask at runtime?</label>";
}