forked from zer.ooo/web
fixed all the little form popup logic and the loading of the key file, now to fix decrypting it and adding it to the embedded config
parent
21c8c34d7d
commit
e7eb852c66
@ -0,0 +1,76 @@
|
||||
$(function () {
|
||||
var keyLocation = $('#key-location');
|
||||
var keyLocationContainer = keyLocation.parent();
|
||||
var decryptKeyCheckbox = $('#decrypt-key');
|
||||
var decryptKeyCheckboxContainer = decryptKeyCheckbox.parent();
|
||||
var password = $('#password');
|
||||
var passwordContainer = password.parent();
|
||||
var embedConfiguration = $('#want-embedded');
|
||||
var embedConfigurationContainer = embedConfiguration.parent();
|
||||
|
||||
decryptKeyCheckbox.change(function() {
|
||||
if (this.checked) {
|
||||
passwordContainer.show();
|
||||
return;
|
||||
}
|
||||
|
||||
passwordContainer.hide();
|
||||
});
|
||||
|
||||
function handleKeyFile(element) {
|
||||
var keyFileContent = element.target.result;
|
||||
|
||||
console.log(keyFileContent);
|
||||
// TODO: Add keyfile to embedded server config using forge
|
||||
}
|
||||
|
||||
keyLocationContainer.on('show', function() {
|
||||
decryptKeyCheckboxContainer.show();
|
||||
});
|
||||
|
||||
keyLocationContainer.on('hide', function() {
|
||||
decryptKeyCheckboxContainer.hide();
|
||||
});
|
||||
|
||||
decryptKeyCheckboxContainer.on('show', function() {
|
||||
if (decryptKeyCheckbox.prop('checked') === true) {
|
||||
passwordContainer.show();
|
||||
}
|
||||
});
|
||||
|
||||
decryptKeyCheckboxContainer.on('hide', function() {
|
||||
passwordContainer.hide();
|
||||
passwordContainer.val('');
|
||||
});
|
||||
|
||||
function setFileSelectVisibility() {
|
||||
var selectedOption = $('#certificate option:selected');
|
||||
|
||||
if (selectedOption.data('hasPrivateKey') == '1') {
|
||||
keyLocationContainer.show();
|
||||
return;
|
||||
}
|
||||
|
||||
keyLocationContainer.hide();
|
||||
}
|
||||
|
||||
keyLocation.change(function () {
|
||||
var file = this.files[0];
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = handleKeyFile;
|
||||
|
||||
reader.readAsText(file);
|
||||
});
|
||||
|
||||
embedConfiguration.change(function () {
|
||||
if (this.checked) {
|
||||
setFileSelectVisibility();
|
||||
decryptKeyCheckboxContainer.show();
|
||||
return;
|
||||
}
|
||||
|
||||
decryptKeyCheckboxContainer.hide();
|
||||
keyLocationContainer.hide();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue