summaryrefslogtreecommitdiffstats
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
parentebf3953908a8dfdb754a5031d69326c6b83cf609 (diff)
downloadnextcloud-server-4a450c9d0d72103954286caca58652336e05b632.tar.gz
nextcloud-server-4a450c9d0d72103954286caca58652336e05b632.zip
improved admin settings
-rw-r--r--apps/encryption/css/settings-admin.css23
-rw-r--r--apps/encryption/js/settings-admin.js68
-rw-r--r--apps/encryption/templates/settings-admin.php62
3 files changed, 90 insertions, 63 deletions
diff --git a/apps/encryption/css/settings-admin.css b/apps/encryption/css/settings-admin.css
new file mode 100644
index 00000000000..47360e6bcf6
--- /dev/null
+++ b/apps/encryption/css/settings-admin.css
@@ -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;
+}
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
diff --git a/apps/encryption/templates/settings-admin.php b/apps/encryption/templates/settings-admin.php
index 59bc4a8ce3d..fe7b0de1837 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');
?>
<form id="ocDefaultEncryptionModule" class="sub-section">
<?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 else: ?>
<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>
<br/>
<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.")) ?>
</em>
<br/>
- <input type="password" name="encryptionRecoveryPassword" id="encryptionRecoveryPassword"/>
- <label for="recoveryPassword"><?php p($l->t("Recovery key password")); ?></label>
- <br/>
- <input type="password" name="encryptionRecoveryPassword" id="repeatEncryptionRecoveryPassword"/>
- <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat Recovery key password")); ?></label>
- <br/>
- <input
- type='radio'
- id='adminEnableRecovery'
- name='adminEnableRecovery'
- value='1'
- <?php echo($_["recoveryEnabled"] === '1' ? 'checked="checked"' : ''); ?> />
- <label for="adminEnableRecovery"><?php p($l->t("Enable recovery key")); ?></label>
- <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>
+ <input type="password"
+ name="encryptionRecoveryPassword"
+ id="encryptionRecoveryPassword"
+ placeholder="<?php p($l->t("Recovery key password")); ?>"/>
+ <input type="password"
+ name="encryptionRecoveryPassword"
+ id="repeatEncryptionRecoveryPassword"
+ placeholder="<?php p($l->t("Repeat recovery key password")); ?>"/>
+ <input type="button"
+ name="enableRecoveryKey"
+ id="enableRecoveryKey"
+ status="<?php p($_["recoveryEnabled"]) ?>"
+ value="<?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>"/>
</p>
<br/><br/>
- <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>>
- <strong><?php p($l->t("Change recovery key password:")); ?></strong>
+ <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>>
+ <?php p($l->t("Change recovery key password:")); ?>
<span class="msg"></span>
- <br/><br/>
+ <br/>
<input
type="password"
name="changeRecoveryPassword"
- id="oldEncryptionRecoveryPassword" />
- <label for="oldEncryptionRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label>
- <br/>
- <br/>
+ id="oldEncryptionRecoveryPassword"
+ placeholder="<?php p($l->t("Old recovery key password")); ?>"/>
+ <br />
<input
type="password"
name="changeRecoveryPassword"
- id="newEncryptionRecoveryPassword" />
- <label for="newEncryptionRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label>
- <br/>
+ id="newEncryptionRecoveryPassword"
+ placeholder="<?php p($l->t("New recovery key password")); ?>"/>
<input
type="password"
name="changeRecoveryPassword"
- id="repeatedNewEncryptionRecoveryPassword" />
- <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat New Recovery key password")); ?></label>
- <br/>
+ id="repeatedNewEncryptionRecoveryPassword"
+ placeholder="<?php p($l->t("Repeat new recovery key password")); ?>"/>
+
<button
type="button"
name="submitChangeRecoveryKey">