1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-24 07:12:57 +00:00

Added import logic, moved logic to the profile class

This commit is contained in:
2024-07-07 17:18:26 +04:00
parent 8d8d7cc7e4
commit 81c66134a1
2 changed files with 83 additions and 15 deletions

View File

@@ -5,7 +5,6 @@
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;
@@ -22,14 +21,8 @@
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);
exportedProfile = profile.toJSON();
compressedProfile = profile.toCompressedJSON();
}
let isCompressedProfileShown = true;
@@ -40,19 +33,21 @@
Back
</MenuItem>
<hr>
</Menu>
<FormContainer>
<textarea readonly rows="6">{isCompressedProfileShown ? compressedProfile : exportedProfile}</textarea>
</FormContainer>
<Menu>
<hr>
<MenuItem on:click={() => isCompressedProfileShown = !isCompressedProfileShown}>
Export Format:
Switch 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 {