From a03fc1a74542ade9b79e95c7a2e49b513652dbdd Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 20 Jan 2019 18:04:09 +0100 Subject: [PATCH] Integrated personnal data navigator --- assets/js/components/account/export/worker.js | 46 +++++++++++++++---- ...personnal-data-export-navigator-builder.sh | 1 + builder | 8 ++++ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/assets/js/components/account/export/worker.js b/assets/js/components/account/export/worker.js index d19225e6..0745f5f4 100644 --- a/assets/js/components/account/export/worker.js +++ b/assets/js/components/account/export/worker.js @@ -25,18 +25,51 @@ ComunicWeb.components.account.export.worker = { ComunicWeb.components.account.export.ui.updateMessage("Got text data"); ComunicWeb.components.account.export.ui.updateProgress(10); - //Parse data - ComunicWeb.components.account.export.worker.parse(result); + //Get explorer + ComunicWeb.components.account.export.worker.getExplorer(result); }); }, /** - * Parse account text data into ZIP file + * Second step for export : Get and open personnal data explorer * - * @param {Object} data Text data about the account + * @param {Object} data Text data about the account (data not modified at this stage) */ - parse: function(data){ + getExplorer: function(data){ + + ComunicWeb.components.account.export.ui.updateMessage("Getting data explorer"); + ComunicWeb.components.account.export.ui.updateProgress(15); + + JSZipUtils.getBinaryContent(ComunicWeb.__config.assetsURL+"zip/personnal-data-export-navigator.zip", function(err, file){ + + if(err != null){ + ComunicWeb.debug.logMessage("Could not get personnal data export navigator!"); + ComunicWeb.components.account.export.ui.exportFatalError(e); + return; + } + + JSZip.loadAsync(file).then(function(zip){ + + //Ready to parse data + ComunicWeb.components.account.export.worker.parse(data, zip); + + }).catch(function(){ + ComunicWeb.debug.logMessage("Could not parse personnal data export navigator!"); + ComunicWeb.components.account.export.ui.exportFatalError(e); + return; + }); + + }); + }, + + /** + * Parse account text data into ZIP file + * + * @param {Object} data Text data about the account + * @param {ZIP} zip The ZIP object to fill + */ + parse: function(data, zip){ //Get UI shorcut var ui = ComunicWeb.components.account.export.ui; @@ -77,9 +110,6 @@ ComunicWeb.components.account.export.worker = { //Determine the list of files to download var files_list = this._generate_files_list(data); - //Create zip file - var zip = new JSZip(); - //Add raw json file zip.file("source.json", JSON.stringify(data)); diff --git a/assets/zip/personnal-data-export-navigator-builder.sh b/assets/zip/personnal-data-export-navigator-builder.sh index 31d58b45..a3e64bde 100755 --- a/assets/zip/personnal-data-export-navigator-builder.sh +++ b/assets/zip/personnal-data-export-navigator-builder.sh @@ -1,6 +1,7 @@ #!/bin/bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +rm -f personnal-data-export-navigator.zip cd personnal-data-export-navigator; zip -r personnal-data-export-navigator.zip assets Export.html mv personnal-data-export-navigator.zip ../ diff --git a/builder b/builder index 2ed545b2..c03af7bc 100755 --- a/builder +++ b/builder @@ -177,6 +177,7 @@ if(file_exists(OUTPUT_DIRECTORY)) mkdir(OUTPUT_DIRECTORY, 0777, true); mkdir($path_release_assets, 0777, true); mkdir($path_release_assets."/css", 0777, true); +mkdir($path_release_assets."/zip", 0777, true); @@ -237,6 +238,13 @@ rcopy($path_debug_assets."css/dark_theme.css", $path_release_assets."css/dark_th //Copy pacman rcopy($path_debug_assets."3rdparty/pacman", $path_release_assets."3rdparty/pacman"); + +//Build and copy personnal data navigator +notice("Build personnal data export navigator and add it to built files"); +exec($path_debug_assets."zip/personnal-data-export-navigator-builder.sh"); +rcopy($path_debug_assets."zip/personnal-data-export-navigator.zip", $path_release_assets."zip/personnal-data-export-navigator.zip"); + + //Begin to write root PHP File notice("Generate PHP root file"); $page_src = '