update adv upload

This commit is contained in:
thanawat saiyota 2026-06-16 11:23:33 +07:00
parent bd239cf71b
commit cd88d5aed9

View file

@ -43,18 +43,21 @@
// Each country can target a different SFTP host (configured on the backend
// via ADV_SFTP_COUNTRY_CONFIG). The selected country is sent with the upload.
// NOTE: only Thailand is enabled for now — other countries need their SFTP
// config (host/password/remote_dir) set on the backend before being added.
// To enable a country later, uncomment it here AND add it to ADV_SFTP_COUNTRY_CONFIG.
const COUNTRIES = [
{ value: 'tha', label: 'Thailand (tha)' },
{ value: 'mys', label: 'Malaysia (mys)' },
{ value: 'aus', label: 'Australia (aus)' },
{ value: 'sgp', label: 'Singapore (sgp)' },
{ value: 'hkg', label: 'Hong Kong (hkg)' },
{ value: 'gbr', label: 'United Kingdom (gbr)' },
{ value: 'uae_dubai', label: 'UAE Dubai (uae_dubai)' },
{ value: 'ltu', label: 'Lithuania (ltu)' },
{ value: 'rou', label: 'Romania (rou)' },
{ value: 'lva', label: 'Latvia (lva)' },
{ value: 'est', label: 'Estonia (est)' }
{ value: 'tha', label: 'Thailand (tha)' }
// { value: 'mys', label: 'Malaysia (mys)' },
// { value: 'aus', label: 'Australia (aus)' },
// { value: 'sgp', label: 'Singapore (sgp)' },
// { value: 'hkg', label: 'Hong Kong (hkg)' },
// { value: 'gbr', label: 'United Kingdom (gbr)' },
// { value: 'uae_dubai', label: 'UAE Dubai (uae_dubai)' },
// { value: 'ltu', label: 'Lithuania (ltu)' },
// { value: 'rou', label: 'Romania (rou)' },
// { value: 'lva', label: 'Latvia (lva)' },
// { value: 'est', label: 'Estonia (est)' }
];
let selectedCountry = $state('tha');
@ -91,6 +94,26 @@
let isAdbConnected = $derived(Boolean(AdbInstance.instance));
let pushingToMachine = $state(false);
let pushProgress = $state({ current: 0, total: 0, name: '', percent: 0 });
let connecting = $state(false);
async function connectMachine() {
if (AdbInstance.instance) {
addNotification('INFO:Machine already connected');
return;
}
connecting = true;
try {
await adb.connnectViaWebUSB(false);
addNotification(
AdbInstance.instance ? 'INFO:Machine connected' : 'WARN:No machine selected'
);
} catch (error) {
console.error('[Adv] connect error:', error);
addNotification(`ERR:Connect failed: ${error instanceof Error ? error.message : 'unknown'}`);
} finally {
connecting = false;
}
}
let generatingManifest = $state(false);
@ -372,8 +395,8 @@
uploading = false;
const successCount = files.filter((f) => f.status === 'success').length;
const errorCount = files.filter((f) => f.status === 'error').length;
const successCount = pendingFiles.filter((f) => f.status === 'success').length;
const errorCount = pendingFiles.filter((f) => f.status === 'error').length;
if (errorCount === 0) {
addNotification(`INFO:Uploaded ${successCount} adv video(s) successfully`);
@ -572,6 +595,18 @@
{isAdbConnected ? 'Machine connected' : 'Machine offline'}
</Badge>
{#if !isAdbConnected}
<Button variant="outline" onclick={connectMachine} disabled={connecting}>
{#if connecting}
<Spinner class="mr-2 h-4 w-4" />
Connecting...
{:else}
<MonitorPlay class="mr-2 h-4 w-4" />
Connect Machine
{/if}
</Button>
{/if}
{#if files.length > 0}
<Button
variant="outline"