Skip to content

Commit 14846d8

Browse files
feat: add per-config JSON export button to dashboard
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 8a571b0 commit 14846d8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/routes/dashboard/+page.svelte

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,34 @@
381381
}
382382
}
383383
384+
async function exportConfig(slug: string) {
385+
try {
386+
const response = await fetch(`/api/configs/${slug}`);
387+
const data = await response.json();
388+
const config = data.config;
389+
const exported = {
390+
name: config.name,
391+
description: config.description || '',
392+
base_preset: config.base_preset,
393+
packages: config.packages || [],
394+
custom_script: config.custom_script || '',
395+
dotfiles_repo: config.dotfiles_repo || '',
396+
snapshot: config.snapshot || null,
397+
visibility: config.visibility || 'unlisted',
398+
alias: config.alias || null
399+
};
400+
const blob = new Blob([JSON.stringify(exported, null, 2)], { type: 'application/json' });
401+
const url = URL.createObjectURL(blob);
402+
const a = document.createElement('a');
403+
a.href = url;
404+
a.download = `${slug}.json`;
405+
a.click();
406+
URL.revokeObjectURL(url);
407+
} catch (e) {
408+
alert('Failed to export configuration');
409+
}
410+
}
411+
384412
function copyToClipboard(text: string, configId: string) {
385413
navigator.clipboard.writeText(text);
386414
copiedId = configId;
@@ -556,6 +584,7 @@
556584
<Button variant="secondary" onclick={() => editConfig(config.slug)}>Edit</Button>
557585
<Button variant="secondary" onclick={() => duplicateConfig(config.slug)}>Duplicate</Button>
558586
<Button variant="secondary" onclick={() => shareConfig(config)}>Share</Button>
587+
<Button variant="secondary" onclick={() => exportConfig(config.slug)}>Export</Button>
559588
<Button variant="danger" onclick={() => deleteConfig(config.slug)}>Delete</Button>
560589
</div>
561590
</div>

0 commit comments

Comments
 (0)