]> source.dussan.org Git - nextcloud-server.git/commitdiff
improved visual feedback if user enabled recovery key
authorBjoern Schiessle <schiessle@owncloud.com>
Tue, 7 Oct 2014 10:52:01 +0000 (12:52 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Tue, 7 Oct 2014 10:52:01 +0000 (12:52 +0200)
apps/files_encryption/ajax/userrecovery.php
apps/files_encryption/js/settings-personal.js
apps/files_encryption/templates/settings-personal.php

index 0f3b973d69ab8be1938a0fcff07833f957b22b35..a5b89fa723394d1c82934e5efa56cefd3859c5b9 100644 (file)
@@ -13,6 +13,8 @@ use OCA\Encryption;
 \OCP\JSON::checkAppEnabled('files_encryption');
 \OCP\JSON::callCheck();
 
+$l = \OC::$server->getL10N('files_encryption');
+
 if (
        isset($_POST['userEnableRecovery'])
        && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])
@@ -38,4 +40,8 @@ if (
 }
 
 // Return success or failure
-($return) ? \OCP\JSON::success() : \OCP\JSON::error();
+if ($return) {
+       \OCP\JSON::success(array('data' => array('message' => $l->t('File recovery settings updated'))));
+} else {
+       \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update file recovery'))));
+}
index f857c2c9f053a54133774a7e2410c3c6c730fb94..b798ba7e4e16727f405f875b9419cd51d4a0c106 100644 (file)
@@ -26,36 +26,27 @@ $(document).ready(function(){
        // Trigger ajax on recoveryAdmin status change
        $( 'input:radio[name="userEnableRecovery"]' ).change(
                function() {
-                       
-                       // Hide feedback messages in case they're already visible
-                       $('#recoveryEnabledSuccess').hide();
-                       $('#recoveryEnabledError').hide();
-                       
                        var recoveryStatus = $( this ).val();
-                       
+                       OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...');
                        $.post(
                                OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
                                , { userEnableRecovery: recoveryStatus }
                                ,  function( data ) {
-                                       if ( data.status == "success" ) {
-                                               $('#recoveryEnabledSuccess').show();
-                                       } else {
-                                               $('#recoveryEnabledError').show();
-                                       }
+                                       OC.msg.finishedAction('#userEnableRecovery .msg', data);
                                }
                        );
                        // Ensure page is not reloaded on form submit
                        return false;
                }
        );
-       
+
        $("#encryptAll").click(
                function(){
-                       
+
                        // Hide feedback messages in case they're already visible
                        $('#encryptAllSuccess').hide();
                        $('#encryptAllError').hide();
-                       
+
                        var userPassword = $( '#userPassword' ).val();
                        var encryptAll = $( '#encryptAll' ).val();
 
@@ -73,7 +64,7 @@ $(document).ready(function(){
                        // Ensure page is not reloaded on form submit
                        return false;
                }
-               
+
        );
 
        // update private key password
index a1221240422efa0657082f8a1ac4505496cd07ab..ce8cf6aec281c079b1593fb8fdd84dd957cb1511 100644 (file)
@@ -39,8 +39,9 @@
 \r
        <?php elseif ( $_["recoveryEnabled"] && $_["privateKeySet"] &&  $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL ): ?>\r
                <br />\r
-               <p>\r
+               <p id="userEnableRecovery">\r
                        <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label>\r
+                       <span class="msg"></span>\r
                        <br />\r
                        <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?></em>\r
                        <br />\r
@@ -60,8 +61,6 @@
                        value='0'\r
                        <?php echo ( $_["recoveryEnabledForUser"] === false ? 'checked="checked"' : '' ); ?> />\r
                        <label for="userDisableRecovery"><?php p( $l->t( "Disabled" ) ); ?></label>\r
-                       <div id="recoveryEnabledSuccess"><?php p( $l->t( 'File recovery settings updated' ) ); ?></div>\r
-                       <div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>\r
                </p>\r
        <?php endif; ?>\r
 </form>\r