From a6a02eaca73b564fecb5995952c8c27a9c9b6b62 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 10 Feb 2020 20:17:58 +0000 Subject: [PATCH] Privacy: Give progress indication for export and erasure. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a progress indicator for "Download Personal Data" and "Erase Personal Data" row actions, which can take a while with a lot of data. Props garrett-eclipse, allendav, dominic_ks, xkon, karmatosed, birgire. Fixes #44264. git-svn-id: https://develop.svn.wordpress.org/trunk@47246 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/privacy-tools.js | 20 ++++++++++++++++++- ...rivacy-data-export-requests-list-table.php | 4 ++-- ...ivacy-data-removal-requests-list-table.php | 4 ++-- ...acySendRequestConfirmationNotification.php | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js index 90b3a49233..f31e2d6d55 100644 --- a/src/js/_enqueues/admin/privacy-tools.js +++ b/src/js/_enqueues/admin/privacy-tools.js @@ -59,6 +59,7 @@ jQuery( document ).ready( function( $ ) { var $this = $( this ), $action = $this.parents( '.export-personal-data' ), $requestRow = $this.parents( 'tr' ), + $progress = $requestRow.find( '.export-progress' ); requestID = $action.data( 'request-id' ), nonce = $action.data( 'nonce' ), exportersCount = $action.data( 'exporters-count' ), @@ -69,6 +70,7 @@ jQuery( document ).ready( function( $ ) { $action.blur(); clearResultsAfterRow( $requestRow ); + setExportProgress( 0 ); function onExportDoneSuccess( zipUrl ) { var summaryMessage = strings.emailSent; @@ -77,7 +79,7 @@ jQuery( document ).ready( function( $ ) { appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] ); $this.hide(); - + if ( 'undefined' !== typeof zipUrl ) { window.location = zipUrl; } else if ( ! sendAsEmail ) { @@ -92,6 +94,12 @@ jQuery( document ).ready( function( $ ) { } } + function setExportProgress( exporterIndex ) { + var progress = ( exportersCount > 0 ? exporterIndex / exportersCount : 0 ); + var progressString = Math.round( progress * 100 ).toString() + '%'; + $progress.html( progressString ); + } + function doNextExport( exporterIndex, pageIndex ) { $.ajax( { @@ -120,6 +128,7 @@ jQuery( document ).ready( function( $ ) { setTimeout( doNextExport( exporterIndex, pageIndex + 1 ) ); } else { if ( exporterIndex < exportersCount ) { + setExportProgress( exporterIndex ); setTimeout( doNextExport( exporterIndex + 1, 1 ) ); } else { onExportDoneSuccess( responseData.url ); @@ -141,6 +150,7 @@ jQuery( document ).ready( function( $ ) { var $this = $( this ), $action = $this.parents( '.remove-personal-data' ), $requestRow = $this.parents( 'tr' ), + $progress = $requestRow.find( '.erasure-progress' ); requestID = $action.data( 'request-id' ), nonce = $action.data( 'nonce' ), erasersCount = $action.data( 'erasers-count' ), @@ -152,6 +162,7 @@ jQuery( document ).ready( function( $ ) { $action.blur(); clearResultsAfterRow( $requestRow ); + setErasureProgress( 0 ); function onErasureDoneSuccess() { var summaryMessage = strings.noDataFound; @@ -183,6 +194,12 @@ jQuery( document ).ready( function( $ ) { appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] ); } + function setErasureProgress( eraserIndex ) { + var progress = ( erasersCount > 0 ? eraserIndex / erasersCount : 0 ); + var progressString = Math.round( progress * 100 ).toString() + '%'; + $progress.html( progressString ); + } + function doNextErasure( eraserIndex, pageIndex ) { $.ajax({ url: window.ajaxurl, @@ -214,6 +231,7 @@ jQuery( document ).ready( function( $ ) { setTimeout( doNextErasure( eraserIndex, pageIndex + 1 ) ); } else { if ( eraserIndex < erasersCount ) { + setErasureProgress( eraserIndex ); setTimeout( doNextErasure( eraserIndex + 1, 1 ) ); } else { onErasureDoneSuccess(); diff --git a/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php b/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php index 880af8cd04..3898f8ef05 100644 --- a/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php +++ b/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php @@ -57,7 +57,7 @@ class WP_Privacy_Data_Export_Requests_List_Table extends WP_Privacy_Requests_Tab '">'; $download_data_markup .= '' . - '' . + '' . '' . ''; @@ -100,7 +100,7 @@ class WP_Privacy_Data_Export_Requests_List_Table extends WP_Privacy_Requests_Tab ?> - + '; $remove_data_markup .= '' . - '' . + '' . '' . ''; @@ -106,7 +106,7 @@ class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Ta ?> - +