From 93cf5ed8206c2d66d8d71a81af37ba1e8a025b50 Mon Sep 17 00:00:00 2001 From: broisnees Date: Wed, 18 Nov 2026 06:48:05 +0000 Subject: [PATCH] Redesign scheduled backups: one-line header, row per schedule, compact dialog --- src/lib/components/ScheduledBackups.svelte | 404 +++++++++++---------- 1 file changed, 218 insertions(+), 186 deletions(-) diff --git a/src/lib/components/ScheduledBackups.svelte b/src/lib/components/ScheduledBackups.svelte index 3fad0ce7..a8f07e27 100644 --- a/src/lib/components/ScheduledBackups.svelte +++ b/src/lib/components/ScheduledBackups.svelte @@ -1,13 +1,15 @@ -{#snippet message(/** @type {string} */ title, /** @type {string} */ body)} +{#snippet message(/** @type {string} */ title, /** @type {string} */ body, /** @type {import('svelte').Snippet | undefined} */ action = undefined)}

{title}

-

{body}

+

{body}

+ {#if action}
{@render action()}
{/if}
{/snippet} +{#snippet getPro()} + +{/snippet} + +{#snippet addButton()} + +{/snippet} + {#if !$isSignedIn} - {@render message('Sign in for scheduled backups', 'Scheduled backups come with Stroke Pro on your account.')} + {@render message('Sign in for scheduled backups', 'They come with Stroke Pro on your account.')} {:else if !$hasPro || overview?.pro === false} -
- -

Scheduled backups are part of Stroke Pro

-

Back up up to 10 databases on a schedule, to Stroke Cloud or your own S3 bucket.

- -
+ {@render message('Scheduled backups are a Pro feature', 'Up to 10 databases, to Stroke Cloud or your own S3.', getPro)} {:else if !connection} - {@render message('Save this connection first', 'Scheduled backups run on saved connections, so Stroke can open them again later.')} + {@render message('Save this connection first', 'Schedules run on saved connections.')} {:else if !supported} - {@render message('Not available for this database', 'Scheduled backups support PostgreSQL, MySQL, SQLite, Cloudflare D1, Turso/libSQL, DuckDB and SQL Server.')} + {@render message('Not available for this database', 'PostgreSQL, MySQL, SQLite, D1, Turso, DuckDB and SQL Server.')} {:else}
-
-
-
-

Scheduled backups

-

- Stroke runs them while it's open on a computer with this connection. A run missed while it was closed happens the next time it opens. -

- {#if overview} -

- {overview.jobs.length} of {overview.max_jobs} schedules · {formatBytes(overview.used_bytes)} of {formatBytes(overview.quota_bytes)} on Stroke Cloud -

- {/if} -
- + {@render addButton()}
{#if $backupLoadError && !overview}

{$backupLoadError}

{/if} -
-

This database

- {#if !overview} -
- {:else if jobs.length === 0 && !formOpen} -

No schedule yet.

- {/if} - {#each jobs as job (job.id)} - {@const last = job.runs[0]} -
- {#if job.destination === 'stroke'}{:else}{/if} -
-

- {describeCron(job.cron)} - {#if !job.enabled}Paused{/if} -

-

- {job.destination === 'stroke' ? `Stroke Cloud, keeps ${job.keep}` : `S3 bucket ${job.s3_bucket}`} - {#if $runningJobId === job.id} · Running now - {:else if last} · Last {last.status === 'failed' ? 'failed' : last.status === 'running' ? 'started' : 'ran'} {when(last.started_at)} - {/if} - {#if job.enabled && job.next_run_at} · Next {when(job.next_run_at)}{/if} -

- {#if last?.status === 'failed' && last.error} -

{last.error}

- {/if} -
-
- {#if $runningJobId === job.id} - - {:else} - - {/if} - - - {#if confirmDelete === job.id} - - - {:else} - - {/if} -
-
- {/each} - - {#if overview && !formOpen} -
- - {#if atLimit}

You have {overview.max_jobs} schedules, the most Pro allows. Delete one to add another.

{/if} -
- {/if} -
- - {#if formOpen} -
-
-
- - -
- {#if preset === 'daily' || preset === 'weekly'} -
- - -
- {/if} - {#if preset === 'weekly'} -
- - ({ value: String(i), label: d }))} /> -
- {/if} - {#if preset === 'custom'} -
- - -
- {/if} -
-

{describeCron(cron)}, {timezone} time. At most once an hour.

- -
- Save to - {#each [{ v: 'stroke', icon: Cloud, title: 'Stroke Cloud', body: 'Stored for you, 5 GB per account. Download from stroke.click.' }, { v: 's3', icon: HardDrive, title: 'My S3 bucket', body: 'AWS S3, Cloudflare R2, MinIO, Backblaze B2 or any S3-compatible storage.' }] as opt (opt.v)} - - {/each} -
- - {#if destination === 'stroke'} -
- - ({ value: String(n), label: `${n} backups` }))} /> -
- {:else} -
-
- - -
-
- - -
-
- - -
-
- - + {#if !overview} +
+ {:else if jobs.length === 0} +
+ +

No schedule for this database yet.

+ {@render addButton()} +
+ {:else} +
    + {#each jobs as job (job.id)} + {@const last = job.runs[0]} + {@const running = $runningJobId === job.id} +
  • + + {#if job.destination === 'stroke'}{:else}{/if} + +
    +

    + {describeCron(job.cron)} + {#if !job.enabled}Paused{/if} +

    +

    + {job.destination === 'stroke' ? `Stroke Cloud · keeps ${job.keep}` : job.s3_bucket} +

    -
    - - + -
    - - +
    + {#if confirmDelete === job.id} + + + {:else} + + + + + {/if}
    -

    The keys stay in this computer's keychain. stroke.click only sees the bucket name.

    -
    - {/if} - - {#if formError}{/if} -
    - - -
    - +
  • + {/each} +
{/if} {#if otherJobs.length}
-

Other databases

+

Other databases

    {#each otherJobs as job (job.id)} -
  • +
  • {job.label} - {describeCron(job.cron)}{job.enabled ? '' : ' · Paused'} + {describeCron(job.cron)}{job.enabled ? '' : ' · Paused'}
  • {/each}
@@ -380,3 +332,83 @@
{/if} + + + + + {editing ? 'Edit schedule' : 'New schedule'} + {connection?.name || driver} + + +
+
+ Repeat + + {#if preset === 'daily' || preset === 'weekly'} +
+ {#if preset === 'weekly'} + ({ value: String(i), label: d }))} bind:value={weekday} ariaLabel="Day" class="min-w-0 flex-1" /> + {/if} + +
+ {:else if preset === 'custom'} + + {/if} +

+ {nextRun.error ?? `Next ${when(nextRun.at ?? 0)}`} +

+
+ +
+ Save to +
+ {#each [{ v: /** @type {const} */ ('stroke'), icon: Cloud, title: 'Stroke Cloud', sub: '5 GB included' }, { v: /** @type {const} */ ('s3'), icon: HardDrive, title: 'S3 bucket', sub: 'R2, MinIO, B2, AWS' }] as opt (opt.v)} + + {/each} +
+
+ + {#if destination === 'stroke'} +
+ Keep + ({ value: n, label: n }))} bind:value={keep} ariaLabel="Backups to keep" /> +
+ {:else} +
+ + + + + + +

Keys stay in this computer's keychain.

+
+ {/if} + + {#if formError}{/if} + + + + + +
+
+