mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2025-12-24 07:12:57 +00:00
Added exporting view for a tagging profile
This commit is contained in:
@@ -64,6 +64,9 @@
|
||||
<span>Activate Profile</span>
|
||||
{/if}
|
||||
</MenuItem>
|
||||
<MenuItem icon="file-export" href="/settings/maintenance/{profileId}/export">
|
||||
Export Profile
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
61
src/routes/settings/maintenance/[id]/export/+page.svelte
Normal file
61
src/routes/settings/maintenance/[id]/export/+page.svelte
Normal file
@@ -0,0 +1,61 @@
|
||||
<script>
|
||||
import {page} from "$app/stores";
|
||||
import {goto} from "$app/navigation";
|
||||
import {maintenanceProfilesStore} from "$stores/maintenance-profiles-store.js";
|
||||
import Menu from "$components/ui/menu/Menu.svelte";
|
||||
import MenuItem from "$components/ui/menu/MenuItem.svelte";
|
||||
import FormContainer from "$components/ui/forms/FormContainer.svelte";
|
||||
import {compressToEncodedURIComponent} from "lz-string";
|
||||
|
||||
const profileId = $page.params.id;
|
||||
|
||||
/**
|
||||
* @type {import('$lib/extension/entities/MaintenanceProfile.js').default|undefined}
|
||||
*/
|
||||
const profile = $maintenanceProfilesStore.find(profile => profile.id === profileId);
|
||||
|
||||
/** @type {string} */
|
||||
let exportedProfile = '';
|
||||
/** @type {string} */
|
||||
let compressedProfile = '';
|
||||
|
||||
if (!profile) {
|
||||
goto('/settings/maintenance/');
|
||||
} else {
|
||||
exportedProfile = JSON.stringify({
|
||||
v: 1,
|
||||
id: profileId,
|
||||
name: profile?.settings.name,
|
||||
tags: profile.settings.tags,
|
||||
}, null, 2);
|
||||
|
||||
compressedProfile = compressToEncodedURIComponent(exportedProfile);
|
||||
}
|
||||
|
||||
let isCompressedProfileShown = true;
|
||||
</script>
|
||||
|
||||
<Menu>
|
||||
<MenuItem href="/settings/maintenance/{profileId}" icon="arrow-left">
|
||||
Back
|
||||
</MenuItem>
|
||||
<hr>
|
||||
<MenuItem on:click={() => isCompressedProfileShown = !isCompressedProfileShown}>
|
||||
Export Format:
|
||||
{#if isCompressedProfileShown}
|
||||
Base64-Encoded
|
||||
{:else}
|
||||
Raw JSON
|
||||
{/if}
|
||||
</MenuItem>
|
||||
<hr>
|
||||
</Menu>
|
||||
<FormContainer>
|
||||
<textarea readonly rows="6">{isCompressedProfileShown ? compressedProfile : exportedProfile}</textarea>
|
||||
</FormContainer>
|
||||
|
||||
<style lang="scss">
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user