improved admin settings

This commit is contained in:
Bjoern Schiessle 2015-05-07 12:55:49 +02:00
parent ebf3953908
commit 4a450c9d0d
3 changed files with 92 additions and 65 deletions

View File

@ -0,0 +1,23 @@
/**
* @author Björn Schießle <schiessle@owncloud.com>
*
* @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 <http://www.gnu.org/licenses/>
*
*/
#encryptionAPI input[type=password] {
width: 300px;
}

View File

@ -8,37 +8,51 @@
*/ */
$(document).ready(function () { $(document).ready(function () {
$('input:button[name="enableRecoveryKey"]').click(function () {
$('input:radio[name="adminEnableRecovery"]').change( var recoveryStatus = $(this).attr('status');
function () { var newRecoveryStatus = (1 + parseInt(recoveryStatus)) % 2;
var recoveryStatus = $(this).val(); var buttonValue = $(this).attr('value');
var oldStatus = (1 + parseInt(recoveryStatus)) % 2;
var recoveryPassword = $('#encryptionRecoveryPassword').val(); var recoveryPassword = $('#encryptionRecoveryPassword').val();
var confirmPassword = $('#repeatEncryptionRecoveryPassword').val(); var confirmPassword = $('#repeatEncryptionRecoveryPassword').val();
OC.msg.startSaving('#encryptionSetRecoveryKey .msg'); OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
$.post( $.post(
OC.generateUrl('/apps/encryption/ajax/adminRecovery'), OC.generateUrl('/apps/encryption/ajax/adminRecovery'),
{ {
adminEnableRecovery: recoveryStatus, adminEnableRecovery: newRecoveryStatus,
recoveryPassword: recoveryPassword, recoveryPassword: recoveryPassword,
confirmPassword: confirmPassword 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(""); $("#repeatEncryptionRecoveryPassword").keyup(function (event) {
$('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden"); if (event.keyCode == 13) {
} $("#enableRecoveryKey").click();
})
.fail(function (jqXHR) {
$('input:radio[name="adminEnableRecovery"][value="' + oldStatus.toString() + '"]').attr("checked", "true");
OC.msg.finishedError('#encryptionSetRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message);
});
} }
); });
// change recovery password // change recovery password

View File

@ -3,13 +3,14 @@
/** @var OC_L10N $l */ /** @var OC_L10N $l */
script('encryption', 'settings-admin'); script('encryption', 'settings-admin');
script('core', 'multiselect'); script('core', 'multiselect');
style('encryption', 'settings-admin');
?> ?>
<form id="ocDefaultEncryptionModule" class="sub-section"> <form id="ocDefaultEncryptionModule" class="sub-section">
<?php if(!$_["initStatus"]): ?> <?php if(!$_["initStatus"]): ?>
<?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?> <?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>
<?php else: ?> <?php else: ?>
<p id="encryptionSetRecoveryKey"> <p id="encryptionSetRecoveryKey">
<?php p($l->t('Enable recovery key: ')); ?> <?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>
<span class="msg"></span> <span class="msg"></span>
<br/> <br/>
<em> <em>
@ -17,54 +18,43 @@ script('core', 'multiselect');
to encrypt files. It allows recovery of a user's files if the user forgets their password.")) ?> to encrypt files. It allows recovery of a user's files if the user forgets their password.")) ?>
</em> </em>
<br/> <br/>
<input type="password" name="encryptionRecoveryPassword" id="encryptionRecoveryPassword"/> <input type="password"
<label for="recoveryPassword"><?php p($l->t("Recovery key password")); ?></label> name="encryptionRecoveryPassword"
<br/> id="encryptionRecoveryPassword"
<input type="password" name="encryptionRecoveryPassword" id="repeatEncryptionRecoveryPassword"/> placeholder="<?php p($l->t("Recovery key password")); ?>"/>
<label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat Recovery key password")); ?></label> <input type="password"
<br/> name="encryptionRecoveryPassword"
<input id="repeatEncryptionRecoveryPassword"
type='radio' placeholder="<?php p($l->t("Repeat recovery key password")); ?>"/>
id='adminEnableRecovery' <input type="button"
name='adminEnableRecovery' name="enableRecoveryKey"
value='1' id="enableRecoveryKey"
<?php echo($_["recoveryEnabled"] === '1' ? 'checked="checked"' : ''); ?> /> status="<?php p($_["recoveryEnabled"]) ?>"
<label for="adminEnableRecovery"><?php p($l->t("Enable recovery key")); ?></label> value="<?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>"/>
<br/>
<input
type='radio'
id='adminDisableRecovery'
name='adminEnableRecovery'
value='0'
<?php echo($_["recoveryEnabled"] === '0' ? 'checked="checked"' : ''); ?> />
<label for="adminDisableRecovery"><?php p($l->t("Disable recovery key")); ?></label>
</p> </p>
<br/><br/> <br/><br/>
<p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>>
<strong><?php p($l->t("Change recovery key password:")); ?></strong> <?php p($l->t("Change recovery key password:")); ?>
<span class="msg"></span> <span class="msg"></span>
<br/><br/>
<input
type="password"
name="changeRecoveryPassword"
id="oldEncryptionRecoveryPassword" />
<label for="oldEncryptionRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label>
<br/>
<br/> <br/>
<input <input
type="password" type="password"
name="changeRecoveryPassword" name="changeRecoveryPassword"
id="newEncryptionRecoveryPassword" /> id="oldEncryptionRecoveryPassword"
<label for="newEncryptionRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label> placeholder="<?php p($l->t("Old recovery key password")); ?>"/>
<br/> <br />
<input <input
type="password" type="password"
name="changeRecoveryPassword" name="changeRecoveryPassword"
id="repeatedNewEncryptionRecoveryPassword" /> id="newEncryptionRecoveryPassword"
<label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat New Recovery key password")); ?></label> placeholder="<?php p($l->t("New recovery key password")); ?>"/>
<br/> <input
type="password"
name="changeRecoveryPassword"
id="repeatedNewEncryptionRecoveryPassword"
placeholder="<?php p($l->t("Repeat new recovery key password")); ?>"/>
<button <button
type="button" type="button"
name="submitChangeRecoveryKey"> name="submitChangeRecoveryKey">