diff --git a/apps/encryption/css/settings-admin.css b/apps/encryption/css/settings-admin.css new file mode 100644 index 0000000000..47360e6bcf --- /dev/null +++ b/apps/encryption/css/settings-admin.css @@ -0,0 +1,23 @@ +/** + * @author Björn Schießle + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +#encryptionAPI input[type=password] { + width: 300px; +} diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js index fdc53c5215..39923718c2 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 diff --git a/apps/encryption/templates/settings-admin.php b/apps/encryption/templates/settings-admin.php index 59bc4a8ce3..fe7b0de183 100644 --- a/apps/encryption/templates/settings-admin.php +++ b/apps/encryption/templates/settings-admin.php @@ -3,13 +3,14 @@ /** @var OC_L10N $l */ script('encryption', 'settings-admin'); script('core', 'multiselect'); +style('encryption', 'settings-admin'); ?>
t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>

- t('Enable recovery key: ')); ?> + t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>
@@ -17,54 +18,43 @@ script('core', 'multiselect'); to encrypt files. It allows recovery of a user's files if the user forgets their password.")) ?>
- - -
- - -
- /> - -
- - /> - + "/> + "/> + " + value="t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>"/>



-

> - t("Change recovery key password:")); ?> +

> + t("Change recovery key password:")); ?> -

- - -

- -
+ id="oldEncryptionRecoveryPassword" + placeholder="t("Old recovery key password")); ?>"/> +
- -
+ id="newEncryptionRecoveryPassword" + placeholder="t("New recovery key password")); ?>"/> + "/> +