diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-13 19:38:22 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-13 19:38:22 +0100 |
commit | 0dc71813354407fad8fa1db113d75cad78dfc12f (patch) | |
tree | b34b739c2035808f08b8d92dac5ff1a40977b6ea /apps/files_external/js/public_key.js | |
parent | 2e7d50b7233dd812a0cca8bdc433fbfa41b8b31e (diff) | |
parent | 442f5269ef229afa09cbe1e06b2a73bb9656e8c4 (diff) | |
download | nextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.tar.gz nextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.zip |
Merge pull request #18441 from owncloud/ext-backends.advanced
Migrate advanced external storage backends to new registration API [part 3]
Diffstat (limited to 'apps/files_external/js/public_key.js')
-rw-r--r-- | apps/files_external/js/public_key.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/files_external/js/public_key.js b/apps/files_external/js/public_key.js new file mode 100644 index 00000000000..a8546067452 --- /dev/null +++ b/apps/files_external/js/public_key.js @@ -0,0 +1,46 @@ +$(document).ready(function() { + + OCA.External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme) { + if (scheme === 'publickey') { + var config = $tr.find('.configuration'); + if ($(config).find('[name="public_key_generate"]').length === 0) { + setupTableRow($tr, config); + } + } + }); + + $('#externalStorage').on('click', '[name="public_key_generate"]', function(event) { + event.preventDefault(); + var tr = $(this).parent().parent(); + generateKeys(tr); + }); + + function setupTableRow(tr, config) { + $(config).append($(document.createElement('input')) + .addClass('button auth-param') + .attr('type', 'button') + .attr('value', t('files_external', 'Generate keys')) + .attr('name', 'public_key_generate') + ); + // If there's no private key, build one + if (0 === $(config).find('[data-parameter="private_key"]').val().length) { + generateKeys(tr); + } + } + + function generateKeys(tr) { + var config = $(tr).find('.configuration'); + + $.post(OC.filePath('files_external', 'ajax', 'public_key.php'), {}, function(result) { + if (result && result.status === 'success') { + $(config).find('[data-parameter="public_key"]').val(result.data.public_key); + $(config).find('[data-parameter="private_key"]').val(result.data.private_key); + OCA.External.Settings.mountConfig.saveStorageConfig(tr, function() { + // Nothing to do + }); + } else { + OC.dialogs.alert(result.data.message, t('files_external', 'Error generating key pair') ); + } + }); + } +}); |