-
Notifications
You must be signed in to change notification settings - Fork 214
feat: add JSON export wizard with background export and progress tracking #2892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Divyansh2992
wants to merge
7
commits into
appwrite:main
from
Divyansh2992:feature/database-json-export
+685
−12
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4b9a1d9
feat: add JSON export wizard with background export and progress trac…
Divyansh2992 9e4e040
fix: address review comments (remove pnpm artifacts, fix pagination a…
Divyansh2992 ab9bd4f
fix: remove duplicate Submit.DatabaseExportJson tracking
Divyansh2992 aebc168
fixed issues
Divyansh2992 f103d09
feat: implement 5k row limit and full feature parity with CSV
Divyansh2992 098845a
feat: achieve exact visual and behavioral parity with CSV export
Divyansh2992 caa4b0c
modified jsonExportBox.svelte
Divyansh2992 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,4 +155,5 @@ dist | |
| .sentryclirc | ||
|
|
||
| # IDE specifics | ||
| .idea | ||
| .idea | ||
|
|
||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| <script lang="ts"> | ||
| import { Layout, Typography } from '@appwrite.io/pink-svelte'; | ||
| import { jsonExportStore, type JsonExportJob } from '$lib/stores/jsonExport'; | ||
| import { addNotification } from '$lib/stores/notifications'; | ||
|
|
||
| let isOpen = $state(true); | ||
|
|
||
| // Convert store Map to a plain array for safe iteration in Svelte 5 | ||
| let jobEntries = $state<[string, JsonExportJob][]>([]); | ||
| let jobCount = $state(0); | ||
|
|
||
| jsonExportStore.subscribe((map) => { | ||
| jobEntries = [...map.entries()]; | ||
| jobCount = map.size; | ||
| }); | ||
|
|
||
| let showBox = $derived(jobCount > 0); | ||
|
|
||
| function graphSize(status: string, fetched: number, total: number): number { | ||
| switch (status) { | ||
| case 'pending': | ||
| return 5; | ||
| case 'processing': | ||
| return total > 0 ? Math.max(10, Math.round((fetched / total) * 100)) : 30; | ||
| case 'completed': | ||
| case 'failed': | ||
| return 100; | ||
| default: | ||
| return 10; | ||
| } | ||
| } | ||
|
|
||
| function text(job: JsonExportJob): string { | ||
| switch (job.status) { | ||
| case 'completed': | ||
| return 'completed'; | ||
| case 'failed': | ||
| return 'failed'; | ||
| case 'processing': | ||
| return job.totalRows > 0 | ||
| ? `(${job.fetchedRows}/${job.totalRows} rows)` | ||
| : ''; | ||
| default: | ||
| return ''; | ||
| } | ||
| } | ||
|
|
||
| // Track completed exports to fire notifications | ||
| let notifiedJobs = new Set<string>(); | ||
|
|
||
| $effect(() => { | ||
| // Prune stale jobs | ||
| for (const key of notifiedJobs) { | ||
| if (!jobEntries.some(([k]) => k === key)) { | ||
| notifiedJobs.delete(key); | ||
| } | ||
| } | ||
|
|
||
| for (const [key, job] of jobEntries) { | ||
| if (notifiedJobs.has(key)) continue; | ||
|
|
||
| if (job.status === 'completed') { | ||
| notifiedJobs.add(key); | ||
| addNotification({ | ||
| type: 'success', | ||
| message: `Exported ${job.fetchedRows} rows as JSON`, | ||
| timeout: 10000 | ||
| }); | ||
| } else if (job.status === 'failed') { | ||
| notifiedJobs.add(key); | ||
| addNotification({ | ||
| type: 'error', | ||
| message: job.error || 'JSON export failed', | ||
| timeout: 10000 | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| {#if showBox} | ||
| <Layout.Stack direction="column" gap="l" alignItems="flex-end"> | ||
| <section class="upload-box"> | ||
| <header class="upload-box-header"> | ||
| <h4 class="upload-box-title"> | ||
| <Typography.Text variant="m-500"> | ||
| Exporting rows ({jobCount}) | ||
| </Typography.Text> | ||
| </h4> | ||
| <button | ||
| class="upload-box-button" | ||
| class:is-open={isOpen} | ||
| aria-label="toggle export box" | ||
| onclick={() => (isOpen = !isOpen)}> | ||
| <span class="icon-cheveron-up" aria-hidden="true"></span> | ||
| </button> | ||
| <button | ||
| class="upload-box-button" | ||
| aria-label="close export box" | ||
| onclick={() => jsonExportStore.clear()}> | ||
| <span class="icon-x" aria-hidden="true"></span> | ||
| </button> | ||
| </header> | ||
|
|
||
| <div class="upload-box-content-list"> | ||
| {#each jobEntries as [key, job] (key)} | ||
| <div class="upload-box-content" class:is-open={isOpen}> | ||
| <ul class="upload-box-list"> | ||
| <li class="upload-box-item"> | ||
| <section class="progress-bar u-width-full-line"> | ||
| <div | ||
| class="progress-bar-top-line u-flex u-gap-8 u-main-space-between"> | ||
| <Typography.Text> | ||
| Exporting <Typography.Text variant="m-600">{job.tableName}</Typography.Text> {text(job)} | ||
| </Typography.Text> | ||
| </div> | ||
| <div | ||
| class="progress-bar-container" | ||
| class:is-danger={job.status === 'failed'} | ||
| style="--graph-size:{graphSize( | ||
| job.status, | ||
| job.fetchedRows, | ||
| job.totalRows | ||
| )}%"> | ||
| </div> | ||
| </section> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| {/each} | ||
| </div> | ||
| </section> | ||
| </Layout.Stack> | ||
| {/if} | ||
|
|
||
| <style lang="scss"> | ||
| .upload-box { | ||
| display: flex; | ||
| max-height: 320px; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .upload-box-header { | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .upload-box-title { | ||
| font-size: 11px; | ||
| } | ||
|
|
||
| .upload-box-content-list { | ||
| overflow-y: auto; | ||
| } | ||
|
|
||
| .upload-box-content { | ||
| width: 304px; | ||
| } | ||
|
|
||
| .upload-box-button { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .progress-bar-container { | ||
| height: 4px; | ||
|
|
||
| &::before { | ||
| height: 4px; | ||
| background-color: var(--bgcolor-neutral-invert); | ||
| } | ||
|
|
||
| &.is-danger::before { | ||
| height: 4px; | ||
| background-color: var(--bgcolor-error); | ||
| } | ||
| } | ||
| </style> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.