From cd75b776f021f2ede241f36ade4763050671c058 Mon Sep 17 00:00:00 2001 From: Dragoon Dorise Date: Sun, 14 Jan 2024 01:16:27 +0100 Subject: [PATCH] cloudSync checkHealth --- src/renderer/components | 2 +- src/renderer/pages/CloudSyncConfigPage.jsx | 133 +++++++++++++-------- 2 files changed, 81 insertions(+), 54 deletions(-) diff --git a/src/renderer/components b/src/renderer/components index 84ad6ad..c45eee3 160000 --- a/src/renderer/components +++ b/src/renderer/components @@ -1 +1 @@ -Subproject commit 84ad6add382da7e5ca1be29b3804d1a8439d0947 +Subproject commit c45eee3be62b79a29a27f8a028331a3608b3dbaa diff --git a/src/renderer/pages/CloudSyncConfigPage.jsx b/src/renderer/pages/CloudSyncConfigPage.jsx index 1079eff..7c726bd 100644 --- a/src/renderer/pages/CloudSyncConfigPage.jsx +++ b/src/renderer/pages/CloudSyncConfigPage.jsx @@ -142,6 +142,78 @@ function CloudSyncPageConfig() { }); }; + const checkHealth = () => { + const modalData = { + active: true, + header: Testing CloudSync, + body:

Please wait a few minutes while we test your configuration.

, + css: 'emumodal--sm', + }; + setStatePage({ + ...statePage, + modal: modalData, + }); + ipcChannel.sendMessage('emudeck', [`cloudSyncHealth|||cloudSyncHealth`]); + + ipcChannel.once('cloudSyncHealth', (message) => { + const { stdout } = message; + let modalData; + if (stdout.includes('true')) { + modalData = { + active: true, + header: Success!, + body:

Everything seems to be in order.

, + css: 'emumodal--sm', + }; + } else if (stdout.includes('nobinary')) { + modalData = { + active: true, + header: Missing CloudSync binary, + body:

Please try reinstalling CloudSync.

, + css: 'emumodal--sm', + }; + } else if (stdout.includes('noconfig')) { + modalData = { + active: true, + header: ( + CloudSync failure - No config file + ), + body:

Please try reinstalling CloudSync

, + css: 'emumodal--sm', + }; + } else if (stdout.includes('noprovider')) { + modalData = { + active: true, + header: ( + + CloudSync failure - No cloud provider found + + ), + body:

Please try reinstalling CloudSync

, + css: 'emumodal--sm', + }; + } else if (stdout.includes('upload')) { + modalData = { + active: true, + header: CloudSync failure, + body:

{stdout}

, + css: 'emumodal--sm', + }; + } else if (stdout.includes('download')) { + modalData = { + active: true, + header: CloudSync failure, + body:

{stdout}

, + css: 'emumodal--sm', + }; + } + setStatePage({ + ...statePage, + modal: modalData, + }); + }); + }; + const installRclone = () => { // OLD TOKEN upload, not needed for now // if ( @@ -191,6 +263,7 @@ function CloudSyncPageConfig() { console.log({ stdout }); let modalData; if (stdout.includes('true')) { + checkHealth(); modalData = { active: true, header: CloudSync Configured, @@ -239,6 +312,11 @@ function CloudSyncPageConfig() { cloudSyncStatus: true, }); } else { + checkHealth(); + let warningChrome; + if (system !== 'win32') { + warningChrome = `Make sure you have Google Chrome installed, Firefox won't work. Once you have CloudSync installed you can remove Chrome`; + } modalData = { active: true, header: Error Installing CloudSync, @@ -260,10 +338,6 @@ function CloudSyncPageConfig() { cloudSyncStatus: false, }); } - let warningChrome; - if (system !== 'win32') { - warningChrome = `Make sure you have Google Chrome installed, Firefox won't work. Once you have CloudSync installed you can remove Chrome`; - } setStatePage({ ...statePage, disableButton: false, modal: modalData }); }); @@ -299,58 +373,10 @@ function CloudSyncPageConfig() { }); }; - const createDesktopIcon = () => { - setStatePage({ - ...statePage, - disableButton: true, - }); - - if (system === 'win32') { - ipcChannel.sendMessage('emudeck', [ - `rclone_install|||rclone_install ${cloudSync}`, - ]); - ipcChannel.once('rclone_install', (message) => { - // No versioning found, what to do? - const modalData = { - active: true, - header: CloudSave Configured, - css: 'emumodal--xs', - body: ( -

- All Done, your game states and saved games will be synced to $ - {cloudSync} in the background every 5 minutes -

- ), - }; - setStatePage({ - ...statePage, - disableButton: false, - modal: modalData, - }); - }); - } else { - ipcChannel.sendMessage('emudeck', [ - `createDesktop|||createDesktopShortcut "$HOME/Desktop/SaveBackup.desktop" "EmuDeck SaveBackup" ". $HOME/.config/EmuDeck/backend/functions/all.sh && rclone_setup" true`, - ]); - - ipcChannel.once('createDesktop', (message) => { - // No versioning found, what to do? - setStatePage({ - ...statePage, - disableButton: false, - }); - }); - - ipcChannel.sendMessage('bash-nolog', [ - `zenity --info --width=400 --text="Go to your Desktop and open the new EmuDeck SaveBackup icon.`, - ]); - } - }; - useEffect(() => { if (cloudSync !== '' || cloudSync !== undefined) { ipcChannel.sendMessage('emudeck', [ - `save-setting|||setSetting rclone_provider ${cloudSync}`, + `save-setting|||setSetting rclone_provider ${cloudSync} && setSetting cloud_sync_provider ${cloudSync} `, ]); localStorage.setItem('settings_emudeck', json); } @@ -393,6 +419,7 @@ function CloudSyncPageConfig() { onClick={cloudSyncSet} onClickInstall={installRclone} onClickUninstall={uninstallRclone} + onClickCheckHealth={checkHealth} disableButton={disableButton} showLoginButton={showLoginButton} />