2020-11-05 06:29:58 +00:00
|
|
|
<script>
|
2020-11-06 08:24:41 +00:00
|
|
|
import { mdiCloudAlert, mdiContentSave, mdiDownload, mdiFile, mdiGoogleDrive, mdiLoading, mdiUpload } from '@mdi/js';
|
2021-03-30 22:18:52 +01:00
|
|
|
import { t } from 'svelte-i18n';
|
2021-10-13 23:40:46 +01:00
|
|
|
|
2020-11-05 06:29:58 +00:00
|
|
|
import Button from './Button.svelte';
|
|
|
|
import Icon from './Icon.svelte';
|
|
|
|
|
|
|
|
export let remoteTime;
|
|
|
|
export let localTime;
|
2021-10-13 23:40:46 +01:00
|
|
|
export let remoteSize;
|
|
|
|
export let localSize;
|
2020-11-05 10:27:12 +00:00
|
|
|
export let downloadBackup = () => {};
|
2020-11-06 08:24:41 +00:00
|
|
|
export let useRemote = () => {};
|
|
|
|
export let useLocal = () => {};
|
|
|
|
|
2021-10-13 23:40:46 +01:00
|
|
|
const numberFormat = Intl.NumberFormat('en', {
|
|
|
|
maximumFractionDigits: 1,
|
|
|
|
minimumFractionDigits: 0,
|
|
|
|
});
|
|
|
|
|
2020-11-06 08:24:41 +00:00
|
|
|
let loading = false;
|
|
|
|
|
|
|
|
function useLocalData() {
|
|
|
|
loading = true;
|
|
|
|
useLocal();
|
|
|
|
}
|
|
|
|
|
|
|
|
function useRemoteData() {
|
|
|
|
loading = true;
|
|
|
|
useRemote();
|
|
|
|
}
|
2020-11-05 06:29:58 +00:00
|
|
|
|
|
|
|
const remoteFormatted = remoteTime.format('dddd, MMMM D, YYYY h:mm A');
|
|
|
|
const localFormatted = localTime.format('dddd, MMMM D, YYYY h:mm A');
|
|
|
|
const remoteNewer = remoteTime.isAfter(localTime);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="flex">
|
|
|
|
<Icon path={mdiCloudAlert} color="white" size={2} />
|
|
|
|
<p class="flex-1 text-white text-lg md:text-xl font-bold ml-4">
|
2021-03-30 22:18:52 +01:00
|
|
|
{$t('sync.message')}
|
2020-11-05 06:29:58 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="mt-4 p-4 bg-item rounded-xl text-white">
|
|
|
|
<p class="font-bold">
|
|
|
|
<Icon path={mdiGoogleDrive} className="mr-2" />
|
2021-03-30 22:18:52 +01:00
|
|
|
{$t('sync.googleDriveData')} -
|
2021-10-13 23:40:46 +01:00
|
|
|
<span class={remoteNewer ? 'text-green-400' : 'text-red-400'}>
|
|
|
|
{remoteNewer ? $t('sync.newer') : $t('sync.older')}
|
|
|
|
</span>
|
|
|
|
<span>- {numberFormat.format(remoteSize)} KB</span>
|
2020-11-05 06:29:58 +00:00
|
|
|
</p>
|
2021-03-30 22:18:52 +01:00
|
|
|
<p class="text-gray-400 mt-1">{$t('sync.lastModified')}: {remoteFormatted}</p>
|
2022-07-12 22:32:41 +01:00
|
|
|
{#if remoteSize / localSize < 0.3}
|
|
|
|
<p class="text-red-400 font-bold mt-1">{$t('sync.smallSizeWarning')}</p>
|
|
|
|
{/if}
|
2020-11-06 08:24:41 +00:00
|
|
|
<Button disabled={loading} className="mt-2 w-full" on:click={useRemoteData}>
|
2021-03-30 22:18:52 +01:00
|
|
|
<Icon path={loading ? mdiLoading : mdiDownload} spin={loading} className="mr-1" />{$t('sync.useGoogleDriveData')}
|
2020-11-05 06:29:58 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
2021-03-30 22:18:52 +01:00
|
|
|
<p class="mt-2 text-white text-center">{$t('sync.or')}</p>
|
2020-11-05 06:29:58 +00:00
|
|
|
<div class="mt-2 p-4 bg-item rounded-xl text-white">
|
|
|
|
<p class="font-bold">
|
|
|
|
<Icon path={mdiFile} className="mr-2" />
|
2021-03-30 22:18:52 +01:00
|
|
|
{$t('sync.localData')} -
|
2021-10-13 23:40:46 +01:00
|
|
|
<span class={remoteNewer ? 'text-red-400' : 'text-green-400'}>
|
|
|
|
{remoteNewer ? $t('sync.older') : $t('sync.newer')}
|
|
|
|
</span>
|
|
|
|
<span>- {numberFormat.format(localSize)} KB</span>
|
2020-11-05 06:29:58 +00:00
|
|
|
</p>
|
2021-03-30 22:18:52 +01:00
|
|
|
<p class="text-gray-400 mt-1">{$t('sync.lastModified')}: {localFormatted}</p>
|
2022-07-12 22:32:41 +01:00
|
|
|
{#if localSize / remoteSize < 0.3}
|
|
|
|
<p class="text-red-400 font-bold mt-1">{$t('sync.smallSizeWarning')}</p>
|
|
|
|
{/if}
|
2020-11-06 08:24:41 +00:00
|
|
|
<Button disabled={loading} className="mt-2 w-full" on:click={useLocalData}>
|
2021-03-30 22:18:52 +01:00
|
|
|
<Icon path={loading ? mdiLoading : mdiUpload} spin={loading} className="mr-1" />{$t('sync.useLocalData')}
|
2020-11-05 06:29:58 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<div class="flex mt-6 justify-end">
|
2020-11-05 10:27:12 +00:00
|
|
|
<Button className="w-full md:w-auto" on:click={downloadBackup}>
|
2021-03-30 22:18:52 +01:00
|
|
|
<Icon path={mdiContentSave} className="mr-1" />{$t('sync.download')}
|
2020-11-05 06:29:58 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|