feat: sd frontend integration

This commit is contained in:
Timothy J. Baek 2024-02-21 18:36:40 -08:00
parent 733e963c44
commit cc50cc10e6
7 changed files with 218 additions and 29 deletions

View file

@ -2,14 +2,17 @@
import toast from 'svelte-french-toast';
import { createEventDispatcher, onMount } from 'svelte';
import { user } from '$lib/stores';
import { config, user } from '$lib/stores';
import {
getAUTOMATIC1111Url,
getDefaultDiffusionModel,
getDiffusionModels,
getImageGenerationEnabledStatus,
toggleImageGenerationEnabledStatus,
updateAUTOMATIC1111Url,
updateDefaultDiffusionModel
} from '$lib/apis/images';
import { getBackendConfig } from '$lib/apis';
const dispatch = createEventDispatcher();
export let saveSettings: Function;
@ -42,11 +45,13 @@
};
const toggleImageGeneration = async () => {
enableImageGeneration = !enableImageGeneration;
enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token);
config.set(await getBackendConfig(localStorage.token));
};
onMount(async () => {
if ($user.role === 'admin') {
enableImageGeneration = await getImageGenerationEnabledStatus(localStorage.token);
AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
if (AUTOMATIC1111_BASE_URL) {