summaryrefslogtreecommitdiffstats
path: root/apps/encryption/js
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-05-07 12:55:49 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-05-08 11:41:38 +0200
commit4a450c9d0d72103954286caca58652336e05b632 (patch)
treee8ecbe395f7d291aa7e82c0687a920c19c9a3789 /apps/encryption/js
parentebf3953908a8dfdb754a5031d69326c6b83cf609 (diff)
downloadnextcloud-server-4a450c9d0d72103954286caca58652336e05b632.tar.gz
nextcloud-server-4a450c9d0d72103954286caca58652336e05b632.zip
improved admin settings
Diffstat (limited to 'apps/encryption/js')
-rw-r--r--apps/encryption/js/settings-admin.js68
1 files changed, 41 insertions, 27 deletions
diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js
index fdc53c52152..39923718c21 100644
--- a/apps/encryption/js/settings-admin.js
+++ b/apps/encryption/js/settings-admin.js
@@ -8,37 +8,51 @@
*/
$(document).ready(function () {
+
+ $('input:button[name="enableRecoveryKey"]').click(function () {
- $('input:radio[name="adminEnableRecovery"]').change(
- function () {
- var recoveryStatus = $(this).val();
- var oldStatus = (1 + parseInt(recoveryStatus)) % 2;
- var recoveryPassword = $('#encryptionRecoveryPassword').val();
- var confirmPassword = $('#repeatEncryptionRecoveryPassword').val();
- OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
- $.post(
- OC.generateUrl('/apps/encryption/ajax/adminRecovery'),
- {
- adminEnableRecovery: recoveryStatus,
- recoveryPassword: recoveryPassword,
- confirmPassword: confirmPassword
+ var recoveryStatus = $(this).attr('status');
+ var newRecoveryStatus = (1 + parseInt(recoveryStatus)) % 2;
+ var buttonValue = $(this).attr('value');
+
+ var recoveryPassword = $('#encryptionRecoveryPassword').val();
+ var confirmPassword = $('#repeatEncryptionRecoveryPassword').val();
+ OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
+ $.post(
+ OC.generateUrl('/apps/encryption/ajax/adminRecovery'),
+ {
+ adminEnableRecovery: newRecoveryStatus,
+ recoveryPassword: recoveryPassword,
+ confirmPassword: confirmPassword
+ }
+ ).done(function (data) {
+ OC.msg.finishedSuccess('#encryptionSetRecoveryKey .msg', data.data.message);
+
+ if (newRecoveryStatus === 0) {
+ $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
+ $('input:button[name="enableRecoveryKey"]').attr('value', 'Enable recovery key');
+ $('input:button[name="enableRecoveryKey"]').attr('status', '0');
+ } else {
+ $('input:password[name="changeRecoveryPassword"]').val("");
+ $('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
+ $('input:button[name="enableRecoveryKey"]').attr('value', 'Disable recovery key');
+ $('input:button[name="enableRecoveryKey"]').attr('status', '1');
}
- ).done(function (data) {
- OC.msg.finishedSuccess('#encryptionSetRecoveryKey .msg', data.data.message);
+ })
+ .fail(function (jqXHR) {
+ $('input:button[name="enableRecoveryKey"]').attr('value', buttonValue);
+ $('input:button[name="enableRecoveryKey"]').attr('status', recoveryStatus);
+ OC.msg.finishedError('#encryptionSetRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message);
+ });
+
- if (recoveryStatus === "0") {
- $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
- } else {
- $('input:password[name="changeRecoveryPassword"]').val("");
- $('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
- }
- })
- .fail(function (jqXHR) {
- $('input:radio[name="adminEnableRecovery"][value="' + oldStatus.toString() + '"]').attr("checked", "true");
- OC.msg.finishedError('#encryptionSetRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message);
- });
+ });
+
+ $("#repeatEncryptionRecoveryPassword").keyup(function (event) {
+ if (event.keyCode == 13) {
+ $("#enableRecoveryKey").click();
}
- );
+ });
// change recovery password