This commit is contained in:
Azalea
2025-03-21 18:30:18 -04:00
parent bfdcdc30d6
commit 8578f6e048
4 changed files with 90 additions and 25 deletions

View File

@@ -40,16 +40,19 @@
srcEl.pull()
.then(() => dstEl.push(srcExportedData))
.then(() => confirm = {
title: "Done!",
message: `Transfer completed successfully! Your data on ${dst.dns} is overwritten with your data from ${src.dns}.`
title: t('trans.confirm.done.title'),
message: t('trans.confirm.done.msg', { src: src.dns, dst: dst.dns })
})
.catch(e => error = e)
.finally(() => loading = false)
}
function startTransfer() {
if (!(srcTested && dstTested)) return alert("Please test both servers first!")
if (loading) return alert("Transfer already in progress!")
if (!(srcTested && dstTested)) return confirm = {
title: t('trans.confirm.untested.title'),
message: t('trans.confirm.untested.msg')
}
if (loading) return alert(t('trans.alert.in-progress'))
console.log("Starting transfer...")
loading = true
@@ -57,8 +60,8 @@
// Ask user to make sure to backup their data
confirm = {
title: "Confirm transfer",
message: "It seems like you haven't backed up your destination data. Are you sure you want to proceed? (This will overwrite your destination server's data)",
title: t('trans.confirm.unbackuped.title'),
message: t('trans.confirm.unbackuped.msg'),
dangerous: true,
confirm: actuallyStartTransfer,
cancel: () => { loading = false }
@@ -72,7 +75,7 @@
<main class="content">
<div class="outer-title-options">
<h2>🏳️‍⚧️ AquaTrans™ Data Transfer?</h2>
<h2>{t('trans.title')}</h2>
<nav>
{#each tabs as tabName, i}
<div transition:slide={{axis: 'x'}} class:active={tab === i}
@@ -85,10 +88,7 @@
</div>
<div class="prompt">
<p>👋 Welcome to the AquaTrans™ server data transfer tool!</p>
<p>You can use this to export data from any server, and input data into any server using the connection credentials (card number, server address, and keychip id).</p>
<p>This tool will simulate a game client and pull your data from the source server, and push your data to the destination server.</p>
<p>Please fill out the info below to get started!</p>
{@html t("trans.prompt-html")}
</div>
<TransferServer bind:src={src} bind:gameInfo={gameInfo} on:change={onChange}

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import StatusOverlays from "../../components/StatusOverlays.svelte";
import { t } from "../../libs/i18n";
import { TRANSFER } from "../../libs/sdk";
import { download, selectJsonFile } from "../../libs/ui";
import InputTextShort from "./InputTextShort.svelte";
@@ -16,7 +17,7 @@
// Preliminiary checks
if (!src.dns || !src.keychip || !src.card || !gameInfo.game || !gameInfo.version) {
error = "Please fill out all fields"
error = t('trans.error.empty')
return
}
@@ -34,7 +35,7 @@
export function pull(): Promise<string> {
return new Promise<string>((resolve, reject) => {
if (loading || !tested) return reject("Please test connection first")
if (loading || !tested) return reject(t('trans.error.untested'))
if (exportedData) return resolve(exportedData)
console.log("Exporting data...")
error = ""
@@ -74,7 +75,7 @@
return TRANSFER.push({...src, ...gameInfo}, data).then(() => {
console.log("Data imported successfully")
messages = ["Data imported successfully"]
messages = [t('trans.success.import')]
}).catch(err => error = err.message).finally(() => loading = false)
}
</script>
@@ -82,7 +83,7 @@
<StatusOverlays {loading} />
<div class="server source" class:src={isSrc} class:hasError={error} class:tested={tested}>
<h3>{isSrc ? "Source" : "Target"} Server</h3>
<h3>{t(`trans.${isSrc ? "source" : "target"}.title`)}</h3>
{#if error}
<blockquote class="error-msg">{error}</blockquote>
@@ -90,21 +91,21 @@
<!-- First input line -->
<div class="inputs">
<InputTextShort desc="Server Address" placeholder="e.g. http://aquadx.hydev.org"
<InputTextShort desc={t('trans.field.addr')} placeholder="e.g. http://aquadx.hydev.org"
bind:value={src.dns} on:change validate={v => /^https?:\/\/[a-z0-9.-]+(:\d+)?$/i.test(v)} disabled={tested} />
<InputTextShort desc="Keychip ID" placeholder="e.g. A0299792458"
<InputTextShort desc={t('trans.field.keychip')} placeholder="e.g. A0299792458"
bind:value={src.keychip} on:change validate={v => /^([A-Z0-9]{11}|[A-Z0-9]{4}-[A-Z0-9]{11})$/.test(v)} disabled={tested} />
</div>
<!-- Second input line -->
<div class="inputs">
<div class="game-version">
<InputTextShort desc="Game" placeholder="e.g. SDHD"
<InputTextShort desc={t('trans.field.game')} placeholder="e.g. SDHD"
bind:value={gameInfo.game} on:change disabled={tested} />
<InputTextShort desc="Version" placeholder="e.g. 2.30"
<InputTextShort desc={t('trans.field.version')} placeholder="e.g. 2.30"
bind:value={gameInfo.version} on:change disabled={tested} />
</div>
<InputTextShort desc="Card Number" placeholder="e.g. 27182818284590452353"
<InputTextShort desc={t('trans.field.card')} placeholder="e.g. 27182818284590452353"
bind:value={src.card} on:change disabled={tested} />
</div>
@@ -120,10 +121,10 @@
<!-- Buttons -->
<div class="inputs buttons">
{#if !tested}
<button class="flex-1" on:click={testConnection} disabled={loading}>Test Connection</button>
<button class="flex-1" on:click={testConnection} disabled={loading}>{t('trans.btn.test')}</button>
{:else}
<button class="flex-1" on:click={pull}>Export Data</button>
<button class="flex-1" on:click={pushBtn}>Import Data</button>
<button class="flex-1" on:click={pull}>{t('trans.btn.export')}</button>
<button class="flex-1" on:click={pushBtn}>{t('trans.btn.import')}</button>
{/if}
</div>
</div>